use of edu.uci.ics.jung.visualization.renderers.VertexLabelAsShapeRenderer in project abstools by abstools.
the class JungObjectGraph method begin.
@Override
public void begin() {
graph = new DirectedSparseGraph<String, Integer>();
layout = new FRLayout<String, Integer>(graph);
layout.setSize(new Dimension(600, 600));
vv = new VisualizationViewer<String, Integer>(layout, new Dimension(600, 600));
vv.setBackground(Color.white);
startAnimator();
VertexLabelAsShapeRenderer<String, Integer> vlasr = new VertexLabelAsShapeRenderer<String, Integer>(vv.getRenderContext());
// vv.getRenderContext().setVertexShapeTransformer(arg0)
vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.getRenderContext().setVertexShapeTransformer(vlasr);
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame("Simple Graph View");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane = new JPanel();
pane.setLayout(new BorderLayout());
pane.add(vv, BorderLayout.CENTER);
frame.getContentPane().add(pane);
pane.setBorder(BorderFactory.createEmptyBorder(50, 50, 50, 50));
frame.pack();
frame.setVisible(true);
}
});
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
Aggregations