|
Hi,
I'm getting this exception
java.lang.NullPointerException at com.mindfusion.common.Helper.as(Unknown Source) at com.mindfusion.diagramming.jlayout.FlowchartLayout.arrange(Unknown Source) at com.mindfusion.diagramming.FlowchartLayout.arrange(Unknown Source) at com.mindfusion.diagramming.AbstractLayout.arrange(Unknown Source) at org.apache.jsp.index_jsp.onFlowchartLayout(index_jsp.java:149)
My source code, based on your JSP example is
diagram.setShapeBrush(new SolidBrush(new Color(255, 255, 255))); Factory factory = diagram.getFactory(); ShapeNode node0 = factory.createShapeNode(1, 1, 30, 20); node0.setText("0"); node0.setTextFormat(new TextFormat(Align.Center, Align.Far)); node0.setTransparent(false); ShapeNode node1 = factory.createShapeNode(1, 1, 30, 20); node1.setText("1"); node1.setTextFormat(new TextFormat(Align.Center, Align.Far)); node1.setTransparent(false); factory.createDiagramLink(node0, node1); ShapeNode node2 = factory.createShapeNode(1, 1, 30, 20); node2.setText("2"); node2.setTextFormat(new TextFormat(Align.Center, Align.Far)); node2.setTransparent(false); factory.createDiagramLink(node1, node2); ShapeNode node3 = factory.createShapeNode(1, 1, 30, 20); node3.setText("3"); node3.setTextFormat(new TextFormat(Align.Center, Align.Far)); node3.setTransparent(false); factory.createDiagramLink(node2, node3); for(int i=0;i<10;i++){ ShapeNode node4 = factory.createShapeNode(1, 1, 30, 20); node4.setText(String.valueOf(4+i)); node4.setTextFormat(new TextFormat(Align.Center, Align.Far)); node4.setTransparent(false); factory.createDiagramLink(node3, node4); } ShapeNode node5 = factory.createShapeNode(1, 1, 30, 20); node5.setText("14"); node5.setTextFormat(new TextFormat(Align.Center, Align.Far)); node5.setTransparent(false); DiagramNodeList nodes = diagram.getNodes(); int nodeCount = nodes.size(); for(int i=nodeCount-1;i>=(nodeCount-10);i--){ DiagramNode nodei = nodes.get(i-1); factory.createDiagramLink(nodei, node5); } for(int i=0;i<10;i++){ ShapeNode node6 = factory.createShapeNode(1, 1, 30, 20); node6.setText(String.valueOf(i+nodeCount)); node6.setTextFormat(new TextFormat(Align.Center, Align.Far)); node6.setTransparent(false); factory.createDiagramLink(node5, node6); } ShapeNode node7 = factory.createShapeNode(1, 1, 30, 20); node7.setText("25"); node7.setTextFormat(new TextFormat(Align.Center, Align.Far)); node7.setTransparent(false); nodeCount = nodes.size(); for(int i=nodeCount-1;i>=(nodeCount-10);i--){ DiagramNode nodei = nodes.get(i-1); factory.createDiagramLink(nodei, node7); } ShapeNode node8 = factory.createShapeNode(1, 1, 30, 20); // ERROR factory.createDiagramLink(node7, node8); // ERROR
FlowchartLayout fl = new FlowchartLayout(); fl.arrange(diagram);
Everyting works fine, until I added those lines marked with // ERROR
The same code without those lines has no problems. Also, other layouts like Tree, Orthogonal, Anneal works fine (including the lines)
Including one more node below node 14, and modifying links located in the iterator, to this new node, it also works.
Any help would be appreciated.
|