I will plot using JUNG (Java Universal Network / Graph Framework) with the following code:
g = new SparseMultigraph<BusStop, Travel>();
Layout<String, String> layout1 = new CircleLayout(g);
layout1.setSize(new Dimension(300,300));
VisualizationViewer vv = new VisualizationViewer(layout1);
vv.setPreferredSize(new Dimension(350,350));
Transformer<BusStop,Paint> vertexPaint = new Transformer<BusStop,Paint>() {
public Paint transform(BusStop b) {
return Color.GREEN;
}
};
Transformer<BusStop,Shape> vertexShape = new Transformer<BusStop,Shape>() {
public Shape transform(BusStop b) {
return new Rectangle(-20, -10, 40, 20);
}
};
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
vv.getRenderContext().setVertexShapeTransformer(vertexShape);
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
GraphViewerForm = new edu.uci.ics.jung.visualization.GraphZoomScrollPane(vv);
Now I want to add even more vertices and edges to the graph. How can i do this? What instructions should be followed to redraw the chart? Thank!
source
share