public SimpleGraphSpatialTest() {
setLayout(new BorderLayout());
Network g = TestGraphs.getOneComponentGraph();
Dimension viewPreferredSize = new Dimension(600, 600);
Dimension layoutPreferredSize = new Dimension(600, 600);
LayoutAlgorithm layoutAlgorithm = new FRLayoutAlgorithm();
ScalingControl scaler = new CrossoverScalingControl();
VisualizationModel model =
new BaseVisualizationModel(
g,
layoutAlgorithm,
new RandomLocationTransformer(600, 600, System.currentTimeMillis()),
layoutPreferredSize);
VisualizationViewer vv = new VisualizationViewer(model, viewPreferredSize);
final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();
vv.setGraphMouse(graphMouse);
vv.getRenderContext().setNodeLabelFunction(Object::toString);
vv.getRenderer().getNodeLabelRenderer().setPosition(Renderer.NodeLabel.Position.CNTR);
vv.addKeyListener(graphMouse.getModeKeyListener());
vv.setToolTipText("<html><center>Type 'p' for Pick mode<p>Type 't' for Transform mode");
vv.setForeground(Color.white);
vv.scaleToLayout(scaler);
this.add(vv);
}