public void actionPerformed(ActionEvent event) { JMenuItem source = (JMenuItem) (event.getSource()); for (GraphView v : gp.getGraphViewList()) { if (v.getMenuText().equals(source.getText())) { v.view(); repaint(); return; } } for (GraphDrawer d : gp.getGraphDrawerList()) { if (d.getMenuText().equals(source.getText())) { d.layout(); repaint(); return; } } for (GraphUtility u : gp.getGraphUtilityList()) { if (u.getMenuText().equals(source.getText())) { u.apply(); repaint(); return; } } for (GraphExperiment ge : gp.getGraphExperimentList()) { if (ge.getMenuText().equals(source.getText())) { ge.experiment(); repaint(); return; } } }
public void mouseClicked(MouseEvent e) { if (!(e.getSource().getClass().getName()).equalsIgnoreCase("VisualItem") && !UILib.isButtonPressed(e, button1)) { if (gv.getDisplay().getCursor().getType() == (Cursor.DEFAULT_CURSOR)) { // release all focus and neighbour highlight TupleSet ts = vis.getGroup(Visualization.FOCUS_ITEMS); if (gv.getRecStatus() == 2 && gv.fromIndirect && (ts.getTupleCount() == 0) && !gv.fromAll) gv.showDirectGraph(); ts.clear(); vis.removeGroup("depthEdge"); gv.releaseSearchFocus(); } } if (UILib.isButtonPressed(e, button1) && e.getClickCount() == 1) { if (gv.getDisplay().getCursor().getName().equals("zoom")) admin.toggleZoom(); else if (gv.getDisplay().getCursor().getName().equals("zoomout")) admin.toggleZoomOut(); else if (gv.getDisplay().getCursor().getName().equals("zoomin")) admin.toggleZoomIn(); else if (gv.getDisplay().getCursor().getName().equals("zoomout1")) admin.toggleZoomOut1(); else if (gv.getDisplay().getCursor().getName().equals("zoomin1")) admin.toggleZoomIn1(); else if (gv.getDisplay().getCursor().getName().equals("pan")) admin.togglePan(); } }
private void initMenu() { JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); // File Menu JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu); JMenuItem fileNewItem = new JMenuItem("New", KeyEvent.VK_N); fileNewItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)); fileMenu.add(fileNewItem); JMenuItem fileOpenItem = new JMenuItem("Open...", KeyEvent.VK_O); fileOpenItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); fileMenu.add(fileOpenItem); JMenuItem fileOpenAdjacencyItem = new JMenuItem("Open Adjacency File..."); fileMenu.add(fileOpenAdjacencyItem); JMenuItem fileOpenWeightedAdjacencyItem = new JMenuItem("Open Weighted Adjacency File..."); fileMenu.add(fileOpenWeightedAdjacencyItem); JMenuItem fileOpenXMLItem = new JMenuItem("Open XML File..."); fileMenu.add(fileOpenXMLItem); JMenuItem fileSaveItem = new JMenuItem("Save", KeyEvent.VK_S); fileSaveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); fileMenu.add(fileSaveItem); JMenuItem fileSaveAsItem = new JMenuItem("Save As..."); fileMenu.add(fileSaveAsItem); JMenuItem fileSaveSimpleItem = new JMenuItem("Save Simple Graph..."); fileMenu.add(fileSaveSimpleItem); JMenuItem fileSaveXMLItem = new JMenuItem("Save XML File..."); fileMenu.add(fileSaveXMLItem); JMenuItem filePNGItem = new JMenuItem("Export to png"); fileMenu.add(filePNGItem); JMenuItem fileExitItem = new JMenuItem("Exit", KeyEvent.VK_X); fileExitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK)); fileMenu.add(fileExitItem); fileExitItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { fileExit(); } }); fileNewItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { fileNew(); } }); fileOpenItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { fileOpen(); } }); fileOpenXMLItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { fileOpenXML(); } }); fileSaveItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { fileSave(); } }); fileSaveAsItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { fileSaveAs(); } }); fileSaveSimpleItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { fileSaveSimple(); } }); fileSaveXMLItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { fileSaveXML(); } }); filePNGItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { filePNG(); } }); // Edit Menu JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic(KeyEvent.VK_E); menuBar.add(editMenu); JMenuItem editNodesItem = new JMenuItem("Edit Selected Nodes...", KeyEvent.VK_N); editNodesItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.SHIFT_MASK)); editMenu.add(editNodesItem); JMenuItem editEdgesItem = new JMenuItem("Edit Selected Edges...", KeyEvent.VK_E); editEdgesItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.SHIFT_MASK)); editMenu.add(editEdgesItem); JMenuItem editEdgeTypesItem = new JMenuItem("Edit Edge Types..."); editMenu.add(editEdgeTypesItem); JMenuItem editNodeTypesItem = new JMenuItem("Edit Node Types..."); editMenu.add(editNodeTypesItem); JMenuItem editMoveGraphItem = new JMenuItem("Move Graph..."); editMenu.add(editMoveGraphItem); JMenuItem editAddEdgeBendItem = new JMenuItem("Add Edge Bend"); editMenu.add(editAddEdgeBendItem); JMenuItem editRemoveEdgeBendsItem = new JMenuItem("Remove Edge Bends"); editMenu.add(editRemoveEdgeBendsItem); JMenuItem editSelectAllItem = new JMenuItem("Select All", KeyEvent.VK_A); editSelectAllItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK)); editMenu.add(editSelectAllItem); editNodesItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { gp.editNodes(gp.getSelection().getNodes()); } }); editEdgesItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { gp.editEdges(gp.getSelection().getEdges()); } }); editEdgeTypesItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { gp.editEdgeTypes(); } }); editNodeTypesItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { gp.editNodeTypes(); } }); editMoveGraphItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { gp.moveGraph(); } }); editAddEdgeBendItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { gp.addEdgeBend(); } }); editRemoveEdgeBendsItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { gp.removeEdgeBends(); } }); editSelectAllItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { editSelectAll(); } }); // View Menu JMenu viewMenu = new JMenu("View"); viewMenu.setMnemonic(KeyEvent.VK_V); menuBar.add(viewMenu); for (GraphView v : gp.getGraphViewList()) { JMenuItem menuItem = new JMenuItem(v.getMenuText(), v.getMnemonicKey()); menuItem.setAccelerator(KeyStroke.getKeyStroke(v.getAcceleratorKey(), 0)); menuItem.addActionListener(this); viewMenu.add(menuItem); } // Experiment Menu JMenu experimentsMenu = new JMenu("Experiments"); experimentsMenu.setMnemonic(KeyEvent.VK_E); menuBar.add(experimentsMenu); for (GraphExperiment ge : gp.getGraphExperimentList()) { JMenuItem menuItem = new JMenuItem(ge.getMenuText(), ge.getMnemonicKey()); menuItem.setAccelerator(KeyStroke.getKeyStroke(ge.getAcceleratorKey(), 0)); menuItem.addActionListener(this); experimentsMenu.add(menuItem); } // Utilities Menu JMenu utilitiesMenu = new JMenu("Utilities"); utilitiesMenu.setMnemonic(KeyEvent.VK_U); menuBar.add(utilitiesMenu); for (GraphUtility u : gp.getGraphUtilityList()) { JMenuItem menuItem = new JMenuItem(u.getMenuText(), u.getMnemonicKey()); menuItem.setAccelerator(KeyStroke.getKeyStroke(u.getAcceleratorKey(), 0)); menuItem.addActionListener(this); utilitiesMenu.add(menuItem); } JMenu layoutMenu = new JMenu("Layout"); layoutMenu.setMnemonic(KeyEvent.VK_L); menuBar.add(layoutMenu); for (GraphDrawer d : gp.getGraphDrawerList()) { JMenuItem menuItem = new JMenuItem(d.getMenuText(), d.getMnemonicKey()); menuItem.setAccelerator(KeyStroke.getKeyStroke(d.getAcceleratorKey(), 0)); menuItem.addActionListener(this); layoutMenu.add(menuItem); } }