public MapViewer(String title) { super(title); setSize(800, 600); // setExtendedState(Frame.MAXIMIZED_BOTH); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); edgeCnt = 0; startMap(); Container cp = getContentPane(); cp.setLayout(new BorderLayout()); cp.setBackground(Color.lightGray); // vv.getModel().getRelaxer().setSleepTime(500); vv.setGraphMouse(new DefaultModalGraphMouse<Number, Number>()); vv.getRenderer() .getVertexLabelRenderer() .setPosition(edu.uci.ics.jung.visualization.renderers.Renderer.VertexLabel.Position.CNTR); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Number>()); vv.setForeground(Color.white); cp.add(vv, BorderLayout.CENTER); getContentPane().setFont(new Font("Serif", Font.PLAIN, 12)); setVisible(true); JMenuBar jb = new JMenuBar(); JMenu fileMenu = new JMenu("File"); jb.add(fileMenu); JMenuItem exitMenu = new JMenuItem("Exit"); fileMenu.add(exitMenu); exitMenu.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { MapViewer.this.dispose(); } }); JMenu helpMenu = new JMenu("Help"); jb.add(helpMenu); JMenuItem aboutItem = new JMenuItem("About"); helpMenu.add(aboutItem); aboutItem.addActionListener(new AboutActionListener()); this.setJMenuBar(jb); setLocationRelativeTo(null); }
/** * Sets a new Layout for the graph. * * @param layout The Layout instance to use for the new Graph Layout. */ public void setGraphLayout(Layout<V, E> layout) { super.setGraphLayout(layout); layout.initialize(); this.graph = (UndirectedSparseGraph<V, E>) this.getGraphLayout().getGraph(); }