From: Alex M. <am...@di...> - 2012-10-23 20:59:03
|
Thanks for the link. I am able to run the given JGraphXAdapter code successfully, but when I try to integrate it in my own code I get a blank screen. Maybe it's because of the cell location stuff. In that link somebody said "The most trickey for me was having to set-up the cell location and dimension, before applying layouts." I'm not sure what that means, but I have a feeling I am having the same problem. When I try to apply my own layout by modifying the JGraphXAdapter, I added the following code in the main() method: mxIGraphLayout layout = new mxFastOrganicLayout( graph ); // layout using morphing graph.getModel().beginUpdate(); try { layout.execute( graph.getDefaultParent() ); } finally { mxMorphing morph = new mxMorphing( graphComponent, 20, 1.2, 20 ); morph.addListener( mxEvent.DONE, new mxIEventListener() { @Override public void invoke( Object arg0, mxEventObject arg1 ) { graph.getModel().endUpdate(); // fitViewport(); } } ); morph.startAnimation(); } But I got this exception: Exception in thread "main" java.lang.NullPointerException at com.mxgraph.layout.mxGraphLayout.getVertexBounds(Unknown Source) at com.mxgraph.layout.mxFastOrganicLayout.execute(Unknown Source) at com.dii.fuzzy.gui.JGraphXAdapter.main(JGraphXAdapter.java:243) Then I tried this code instead to do the layout and got the exact same exception. mxFastOrganicLayout layout = new mxFastOrganicLayout( graph ); // set some properties layout.setForceConstant( 40 ); // the higher, the more separated layout.setDisableEdgeStyle( false ); // true transforms the edges and makes them direct lines // layout graph layout.execute( graph.getDefaultParent() ); Does anyone have an idea on how to avoid this exception when trying to layout the graph? Is it because I don't have the right cell location or dimensions like that person posted? Thanks, Alex |