public IvusFrame(World world) { OrbitView view = (world != null) ? new OrbitView(world) : new OrbitView(); view.setAxesOrientation(AxesOrientation.XRIGHT_YOUT_ZDOWN); ViewCanvas canvas = new ViewCanvas(view); canvas.setView(view); ModeManager mm = new ModeManager(); mm.add(canvas); OrbitViewMode ovm = new OrbitViewMode(mm); SelectDragMode sdm = new SelectDragMode(mm); JPopupMenu.setDefaultLightWeightPopupEnabled(false); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('F'); Action exitAction = new AbstractAction("Exit") { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent event) { System.exit(0); } }; JMenuItem exitItem = fileMenu.add(exitAction); exitItem.setMnemonic('x'); JMenu modeMenu = new JMenu("Mode"); modeMenu.setMnemonic('M'); JMenuItem ovmItem = new ModeMenuItem(ovm); modeMenu.add(ovmItem); JMenuItem sdmItem = new ModeMenuItem(sdm); modeMenu.add(sdmItem); JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(modeMenu); JToolBar toolBar = new JToolBar(SwingConstants.VERTICAL); toolBar.setRollover(true); JToggleButton ovmButton = new ModeToggleButton(ovm); toolBar.add(ovmButton); JToggleButton sdmButton = new ModeToggleButton(sdm); toolBar.add(sdmButton); ovm.setActive(true); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setSize(new Dimension(SIZE, SIZE)); this.add(canvas, BorderLayout.CENTER); this.add(toolBar, BorderLayout.WEST); this.setJMenuBar(menuBar); }
private void maybeShowPopup(MouseEvent e) { if (e.isPopupTrigger()) { _mnuAllFilteredSelectedOrder.setEnabled(_modeManager.getMode().isQueryBuilder()); _popUp.show(e.getComponent(), e.getX(), e.getY()); } }
/** * Constructs a simple frame with the specified world and orientation. * * @param world the world view. * @param ao the axes orientation. */ public RSFFrame(World world, AxesOrientation ao) { super(new PlotPanel()); if (world == null) world = new World(); if (ao == null) ao = AxesOrientation.XRIGHT_YOUT_ZDOWN; _world = world; _view = new OrbitView(_world); _view.setAxesOrientation(ao); _canvas = new ViewCanvas(); _canvas.setView(_view); _canvas.setBackground(Color.WHITE); _points = new ArrayList<PointGroup>(); _lines = new ArrayList<LineGroup>(); _d = null; _tpx = null; _tpy = null; _ipg = null; _etc = null; _coord = null; ModeManager mm = new ModeManager(); mm.add(_canvas); OrbitViewMode ovm = new OrbitViewMode(mm); SelectDragMode sdm = new SelectDragMode(mm); JPopupMenu.setDefaultLightWeightPopupEnabled(false); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('F'); Action exitAction = new AbstractAction("Exit") { public void actionPerformed(ActionEvent event) { System.exit(0); } }; Action cubeAction = new AbstractAction("Add Cube") { public void actionPerformed(ActionEvent event) { String filename = chooseFile("."); if (filename != null) addRSFCube(filename); } }; Action lineAction = new AbstractAction("Add Line") { public void actionPerformed(ActionEvent event) { String filename = chooseFile("."); if (filename != null) addRSFLine(filename); } }; Action pointAction = new AbstractAction("Add Points") { public void actionPerformed(ActionEvent event) { String filename = chooseFile("."); if (filename != null) addRSFPoint(filename); } }; Action loadViewAction = new AbstractAction("Load Viewpoint") { public void actionPerformed(ActionEvent event) { String filename = chooseFile("."); if (filename != null) loadView(filename); } }; Action saveViewAction = new AbstractAction("Save Viewpoint") { public void actionPerformed(ActionEvent event) { JFileChooser chooser = new JFileChooser(new File(".")); int returnVal = chooser.showSaveDialog(new JFrame()); String filename = null; if (returnVal == JFileChooser.APPROVE_OPTION) { filename = chooser.getSelectedFile().getPath(); saveView(filename); } } }; Action saveFrameAction = new AbstractAction("Save to PNG") { public void actionPerformed(ActionEvent event) { JFileChooser chooser = new JFileChooser(new File(".")); int returnVal = chooser.showSaveDialog(new JFrame()); String filename = null; if (returnVal == JFileChooser.APPROVE_OPTION) { filename = chooser.getSelectedFile().getPath(); saveFrametoPNG(filename); } } }; JMenuItem cubeItem = fileMenu.add(cubeAction); cubeItem.setMnemonic('C'); JMenuItem lineItem = fileMenu.add(lineAction); lineItem.setMnemonic('L'); JMenuItem pointItem = fileMenu.add(pointAction); pointItem.setMnemonic('P'); JMenuItem saveViewItem = fileMenu.add(saveViewAction); saveViewItem.setMnemonic('V'); JMenuItem loadViewItem = fileMenu.add(loadViewAction); loadViewItem.setMnemonic('I'); JMenuItem saveFrameItem = fileMenu.add(saveFrameAction); saveFrameItem.setMnemonic('S'); JMenuItem exitItem = fileMenu.add(exitAction); exitItem.setMnemonic('X'); JMenu colorMenu = new JMenu("Color"); Action jetAction = new AbstractAction("Jet") { public void actionPerformed(ActionEvent event) { _color = ColorList.JET; setColorMap(); } }; Action prismAction = new AbstractAction("Prism") { public void actionPerformed(ActionEvent event) { _color = ColorList.PRISM; setColorMap(); } }; Action grayAction = new AbstractAction("Gray") { public void actionPerformed(ActionEvent event) { _color = ColorList.GRAY; setColorMap(); } }; Action rwbAction = new AbstractAction("Red-White-Blue") { public void actionPerformed(ActionEvent event) { _color = ColorList.RWB; setColorMap(); } }; colorMenu.add(jetAction); colorMenu.add(prismAction); colorMenu.add(grayAction); colorMenu.add(rwbAction); JMenu clipMenu = new JMenu("% Clip"); Action clipUp = new AbstractAction("Set max pclip") { public void actionPerformed(ActionEvent event) { String value = JOptionPane.showInputDialog(new JFrame(), "Percentile Clip Max (0-100.0):", _pmax); try { _pmax = Float.parseFloat(value); if (_pmax > 100.0f) _pmax = 100.0f; if (_pmax < _pmin) _pmax = _pmin + 1.0f; System.out.printf("pclip: (%f,%f) \n", _pmin, _pmax); _ipg.setPercentiles(_pmin, _pmax); } catch (Exception e) { System.out.println(e); } } }; Action clipDown = new AbstractAction("Set min pclip") { public void actionPerformed(ActionEvent event) { String value = JOptionPane.showInputDialog( new JFrame(), String.format("Percentile Clip Min (0-%f):", _pmax), _pmin); try { _pmin = Float.parseFloat(value); if (_pmin < 0.0f) _pmin = 0.0f; if (_pmin > _pmax) _pmin = _pmax - 1.0f; System.out.printf("pclip: (%f,%f) \n", _pmin, _pmax); _ipg.setPercentiles(_pmin, _pmax); } catch (Exception e) { System.out.println(e); } } }; clipMenu.add(clipUp); clipMenu.add(clipDown); JMenu modeMenu = new JMenu("Mode"); modeMenu.setMnemonic('M'); JMenuItem ovmItem = new JMenuItem(ovm); modeMenu.add(ovmItem); JMenuItem sdmItem = new JMenuItem(sdm); modeMenu.add(sdmItem); JMenu tensorMenu = new JMenu("Tensor"); Action tenLoadAction = new AbstractAction("Load Tensors") { public void actionPerformed(ActionEvent event) { String filename = chooseFile("."); if (filename != null) loadTensors(filename); } }; Action tenCoordLoadAction = new AbstractAction("Load Tensor Coordinates") { public void actionPerformed(ActionEvent event) { String filename = chooseFile("."); if (filename != null) loadTensorCoords(filename); } }; Action showTenAction = new AbstractAction("Show Tensors at Coordinates") { public void actionPerformed(ActionEvent event) { String filename; int sel; if (_ipg == null) { sel = JOptionPane.showConfirmDialog( null, "An RSF Cube (Image) needs to be loaded. " + " Would you like to load one?", "Notice", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (sel == JOptionPane.OK_OPTION) { filename = chooseFile("."); if (filename != null) addRSFCube(filename); } else { JOptionPane.showConfirmDialog( null, "Cannot load tensors because an RFC cube was not loaded.", "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); return; } } if (_coord == null) { sel = JOptionPane.showConfirmDialog( null, "The tensors coordinates need to be loaded. " + " Would you like to load them?", "Notice", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (sel == JOptionPane.OK_OPTION) { filename = chooseFile("."); if (filename != null) loadCoord(filename); } else { JOptionPane.showConfirmDialog( null, "Error loading coordinates.", "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); return; } } if (_etc == null) { sel = JOptionPane.showConfirmDialog( null, "The tensors at coordinates need to be loaded. " + " Would you like to load them?", "Notice", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (sel == JOptionPane.OK_OPTION) { filename = chooseFile("."); if (filename != null) loadTensorCoords(filename); return; } else { JOptionPane.showConfirmDialog( null, "Cannot show tensors because the tensors at coordinates" + " were not loaded.", "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); return; } } /* if(_d == null) { sel = JOptionPane.showConfirmDialog(null, "The tensors need to be loaded. " + " Would you like to load them?", "Notice", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if(sel == JOptionPane.OK_OPTION) { filename = chooseFile("."); if (filename != null) loadTensors(filename); } else { JOptionPane.showConfirmDialog(null, "Cannot show tensors because the tensors were not loaded.", "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); return; } } if(_etg == null) { sel = JOptionPane.showConfirmDialog(null, "The tensor coordinates need to be loaded. " + " Would you like to load them?", "Notice", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if(sel == JOptionPane.OK_OPTION) { filename = chooseFile("."); if (filename != null) loadTensorCoords(filename); return; } else { JOptionPane.showConfirmDialog(null, "Cannot show tensors because the tensor coordinates" + " were not loaded.", "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); return; } } */ _world.addChild(_etg); } }; Action hideTenAction = new AbstractAction("Hide Tensors at Coordinates") { public void actionPerformed(ActionEvent event) { if (_etg != null) _world.removeChild(_etg); } }; Action showTenPanAction = new AbstractAction("Show Tensor Panels") { public void actionPerformed(ActionEvent event) { String filename; int sel; if (_ipg == null) { sel = JOptionPane.showConfirmDialog( null, "An RSF Cube (Image) needs to be loaded. " + " Would you like to load one?", "Notice", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (sel == JOptionPane.OK_OPTION) { filename = chooseFile("."); if (filename != null) addRSFCube(filename); } else { JOptionPane.showConfirmDialog( null, "Cannot load tensors because an RFC cube was not loaded.", "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); return; } } if (_d == null) { sel = JOptionPane.showConfirmDialog( null, "The tensors need to be loaded. " + " Would you like to load them?", "Notice", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (sel == JOptionPane.OK_OPTION) { filename = chooseFile("."); if (filename != null) loadTensors(filename); addRSFTensorEllipsoids(); } else { JOptionPane.showConfirmDialog( null, "Cannot show tensors because the tensors were not loaded.", "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); return; } } else if (_tpx == null || _tpy == null) { addRSFTensorEllipsoids(); } else { ImagePanel ipx = _ipg.getImagePanel(Axis.X); ImagePanel ipy = _ipg.getImagePanel(Axis.Y); ipx.getFrame().addChild(_tpx); ipy.getFrame().addChild(_tpy); } } }; Action hideTenPanAction = new AbstractAction("Hide Tensor Panels") { public void actionPerformed(ActionEvent event) { if (_tpx != null) { ImagePanel ipx = _ipg.getImagePanel(Axis.X); ipx.getFrame().removeChild(_tpx); } if (_tpy != null) { ImagePanel ipy = _ipg.getImagePanel(Axis.Y); ipy.getFrame().removeChild(_tpy); } } }; JMenuItem tensorItem0 = tensorMenu.add(tenLoadAction); tensorItem0.setMnemonic('L'); JMenuItem tensorItem2 = tensorMenu.add(tenCoordLoadAction); tensorItem2.setMnemonic('C'); JMenuItem tensorItem1 = tensorMenu.add(showTenPanAction); tensorItem1.setMnemonic('T'); JMenuItem tensorItem5 = tensorMenu.add(hideTenPanAction); tensorItem5.setMnemonic('R'); JMenuItem tensorItem4 = tensorMenu.add(showTenAction); tensorItem4.setMnemonic('S'); JMenuItem tensorItem3 = tensorMenu.add(hideTenAction); tensorItem3.setMnemonic('H'); JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(modeMenu); menuBar.add(tensorMenu); menuBar.add(colorMenu); menuBar.add(clipMenu); JToolBar toolBar = new JToolBar(SwingConstants.VERTICAL); toolBar.setRollover(true); JToggleButton ovmButton = new ModeToggleButton(ovm); toolBar.add(ovmButton); JToggleButton sdmButton = new ModeToggleButton(sdm); toolBar.add(sdmButton); _cb = new ColorBar(); _cb.setWidthMinimum(45); _cb.setFont(_cb.getFont().deriveFont(18.f)); // _ipg.addColorMapListener(_cb); ovm.setActive(true); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setSize(new Dimension(SIZE, SIZE)); this.add(_canvas, BorderLayout.CENTER); this.add(toolBar, BorderLayout.WEST); this.add(_cb, BorderLayout.EAST); this.setJMenuBar(menuBar); this.setVisible(true); }
public TableFramesModel getTableFramesModel() { return _modeManager.getTableFramesModel(); }
public void sessionEnding() { _modeManager.sessionEnding(); }
public ZoomPrintController getZoomPrintController() { return _modeManager.getZoomPrintController(); }
public Zoomer getZoomer() { return _modeManager.getZoomer(); }
private void createPopUp() { _popUp = new JPopupMenu(); // i18n[graph.saveGraph=Save graph] _mnuSaveGraph = new JMenuItem(s_stringMgr.getString("graph.saveGraph")); _mnuSaveGraph.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onSaveGraph(); } }); // i18n[graph.renameGraph=Rename graph] _mnuRenameGraph = new JMenuItem(s_stringMgr.getString("graph.renameGraph")); _mnuRenameGraph.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onRenameGraph(); } }); // i18n[graph.removeGraph=Remove graph] _mnuRemoveGraph = new JMenuItem(s_stringMgr.getString("graph.removeGraph")); _mnuRemoveGraph.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onRemoveGraph(); } }); // i18n[graph.refreshAllTables=Refresh all tables] _mnuRefreshAllTables = new JMenuItem(s_stringMgr.getString("graph.refreshAllTables")); _mnuRefreshAllTables.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onRefreshAllTables(); } }); // i18n[graph.scriptAllTables=Script all tables] _mnuScriptAllTables = new JMenuItem(s_stringMgr.getString("graph.scriptAllTables")); _mnuScriptAllTables.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onScriptAllTables(); } }); ///////////////////////////////////////////////////////// // Tablegroups // i18n[graph.scriptAllTables=Script all tables] _mnuSelectAllTables = new JMenuItem(s_stringMgr.getString("graph.selectAllTables")); _mnuSelectAllTables.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onSelectAllTables(); } }); // i18n[graph.scriptAllTables=Script all tables] _mnuSelectTablesByName = new JMenuItem(s_stringMgr.getString("graph.selectTablesByName")); _mnuSelectTablesByName.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onSelectTablesByName(); } }); ///////////////////////////////////////////////////////// // i18n[graph.showConstr=Show constraint names] _mnuShowConstraintNames = new JCheckBoxMenuItem(s_stringMgr.getString("graph.showConstr")); _mnuShowConstraintNames.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { _desktopPane.repaint(); } }); // i18n[graph.showQualifiedTableNames=Show qualified table names] _mnuShowQualifiedTableNames = new JCheckBoxMenuItem(s_stringMgr.getString("graph.showQualifiedTableNames")); _mnuShowQualifiedTableNames.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onShowQualifiedTableNames(); } }); ImageIcon toWInIcon = _graphPluginResources.getIcon(GraphPluginResources.IKeys.TO_WINDOW); _mnuToggleWindowTab = new JMenuItem(s_stringMgr.getString("graph.toggleWindowTab"), toWInIcon); _mnuToggleWindowTab.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onToggleWindowTab(); } }); _mnuAllTablesDbOrder = new JMenuItem(s_stringMgr.getString("graph.allTablesDbOrderRequested")); _mnuAllTablesDbOrder.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onAllTablesDbOrder(); } }); _mnuAllTablesByNameOrder = new JMenuItem(s_stringMgr.getString("graph.allTablesByNameOrderRequested")); _mnuAllTablesByNameOrder.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onAllTablesByNameOrder(); } }); _mnuAllTablesPkConstOrder = new JMenuItem(s_stringMgr.getString("graph.allTablesPkConstOrderRequested")); _mnuAllTablesPkConstOrder.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onAllTablesPkConstOrder(); } }); _mnuAllFilteredSelectedOrder = new JMenuItem(s_stringMgr.getString("graph.allTablesFilteredSelectedOrderRequested")); _mnuAllFilteredSelectedOrder.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onAllTablesFilteredSelectedOrder(); } }); _popUp.add(_mnuSaveGraph); _popUp.add(_mnuRenameGraph); _popUp.add(_mnuRemoveGraph); _popUp.add(new JSeparator()); _popUp.add(_mnuRefreshAllTables); _popUp.add(_mnuScriptAllTables); _popUp.add(new JSeparator()); ///////////////////////////////////////////////////////// // Tablegroups _popUp.add(_mnuSelectAllTables); _popUp.add(_mnuSelectTablesByName); _popUp.add(new JSeparator()); ///////////////////////////////////////////////////////// _popUp.add(_mnuAllTablesDbOrder); _popUp.add(_mnuAllTablesByNameOrder); _popUp.add(_mnuAllTablesPkConstOrder); _popUp.add(_mnuAllFilteredSelectedOrder); _popUp.add(new JSeparator()); _popUp.add(_mnuShowConstraintNames); _popUp.add(_mnuShowQualifiedTableNames); _popUp.add(new JSeparator()); _popUp.add(_mnuToggleWindowTab); _popUp.add(new JSeparator()); _popUp.add(_modeManager.getModeMenuItem()); _modeManager.addModeManagerListener( new ModeManagerListener() { @Override public void modeChanged(Mode newMode) { _popUp.setVisible(false); } }); _popUp.addPopupMenuListener( new PopupMenuListener() { @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { onPopupMenuWillBecomeInvisible(); } @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) {} @Override public void popupMenuCanceled(PopupMenuEvent e) {} }); }