Jeroen Van hove
unread,Aug 6, 2010, 1:11:36 AM8/6/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message as abuse
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to guess-discuss
Try looking at this code:
try{
jFrame = new JFrame();
jFrame.setTitle("testinss");
// 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
StorageFactory.useDBServer();
// then load the gdf/xml file
// you can skip this if you don't want to load
// any initial data
StorageFactory.loadFromFile("yourFile.gdf");
// we tell GUESS not to create the ui window
Guess.enableMainUI(false);
// 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".
//jFrame.getContentPane().add((Component)Guess.getFrame(),c);
// you'll want to show at this point because
// the next part depends on having a window the
// canvas showing and sized appropriately
//jFrame.show();
// finish setting up the environment
Guess.initRest(VisFactory.PICCOLO,false,false);
// now you can grab the interpreter if you want
PythonInterpreter pi =
(PythonInterpreter)Guess.getInterpreter();
// and start dumping commands to it
// e.g. pi.eval(".....");
// or pi.exec("....");
//pi.exec("gemLayout()");
// 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) {
e.printStackTrace();
}
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");