New graph

Skip to first unread message


Aug 5, 2010, 5:28:48 PM8/5/10
to guess-discuss
Dear all,

First of all, I just want to say that GUESS is a wonderful tool.

I'm a new Java user so my question is probably stupid but after a long
time of search I can't find any answer ...How create and initialize a
graph ?

I know that "Graph(FrameListener display,InterpreterAbstraction
interp) create a new graph." but I don't know how to define the

I have tried this but there is an error (Exception in thread "main"
java.lang.NoSuchFieldError: NOT_PARALLEL_EDGE)
InterpreterAbstraction interp = null ;
FrameListener display = null ;
Graph g = new Graph(display,interp);

A last question : when g is created, is this the right code if I want
to import a GDF file ? g.makeFromGDF("D:/Java/Workspace/test01/

Could you help me please ?Your help will be really appreciated.
Thanks a lot for your help.


PS: Sorry for my bad english.

Jeroen Van hove

Aug 6, 2010, 1:11:36 AM8/6/10
to guess-discuss
Try looking at this code:

jFrame = new JFrame();

// You probably don't need
// a gridbag, but I copied code out of the
// main UI system
jFrame.getContentPane().setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weighty = 1;
c.weightx = 1;
c.gridx = 0;
c.gridy = 0;

// don't forget to set the size or you'll have
// problems with PICCOLO
jFrame.setBounds(new Rectangle(100, 100, 800, 600));

// we're going to tell GUESS to use a SQL database

// then load the gdf/xml file
// you can skip this if you don't want to load
// any initial data

// we tell GUESS not to create the ui window

// start running, if you're not using PICCOLO you can get away
// with just calling the single init function (instead of
// initUI and then initRest) but PICCOLO has the feature of
// getting very confused with the bounds aren't set correctly.
// So if you're using touchgraph or prefuse you can do:
// Guess.init(VisFactory.PREFUSE,false,false);
// otherwise:

// we tell GUESS to use the PICCOLO interface
// we disable both interfaces (GUI and console)
Guess.initUI(VisFactory.PICCOLO,false, false);

// now we can set the Content pane for
// this frame to the "canvas".

// you'll want to show at this point because
// the next part depends on having a window the
// canvas showing and sized appropriately

// finish setting up the environment

// now you can grab the interpreter if you want
PythonInterpreter pi =

// and start dumping commands to it
// e.g. pi.eval(".....");
// or pi.exec("....");


// you may want/need to run some of these things in the swing
// thread to avoid race conditions
// e.g.
// try {
// javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
// public void run() {
// PythonInterpreter pi =
// (PythonInterpreter)Guess.getInterpreter();
// pi.exec("gemLayout()");
// }
// });
// } catch (Exception e) {
// }

} catch (Exception e) {


Off course you can adjust the interface as you want. Just take in mind
that you should first draw the interface an than insert the data.
Basically this code is the same as the example code Guess provides
except for the line StorageFactory.loadFromFile("yourFile.gdf");


Aug 6, 2010, 6:14:57 PM8/6/10
to guess-discuss
Hi !

Thanks a lot for your quick answer which allows me to make progress.
Now that I have something which run it will be more easy !
There a lot of possibilities and I have to discover them (like about
the problem of overlapping nodes).

Have a good week-end.

Jeroen Van hove

Aug 6, 2010, 7:09:15 PM8/6/10
to guess-discuss
You're Welcome

Reply all
Reply to author
0 new messages