List of usage examples for java.awt.event MouseMotionAdapter MouseMotionAdapter
MouseMotionAdapter
From source file:org.colombbus.tangara.CommandSelection.java
/** * This method initializes commandList//w w w . j a v a2 s . c o m * * @return javax.swing.JList */ private JList getCommandList() { if (commandList == null) { commandList = new JList(); } commandList.setSelectionBackground(selectedBackgroundColor); commandList.setSelectionForeground(selectedForegroundColor); commandList.setBackground(Color.white); commandList.setForeground(Color.gray); MouseListener[] mouseListeners = commandList.getMouseListeners(); for (MouseListener m : mouseListeners) { commandList.removeMouseListener(m); } MouseMotionListener[] motionListeners = commandList.getMouseMotionListeners(); for (MouseMotionListener m : motionListeners) { commandList.removeMouseMotionListener(m); } commandList.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { int index = commandList.locationToIndex(e.getPoint()); if (commandList.isSelectedIndex(index)) { commandList.removeSelectionInterval(index, index); selecting = false; } else { commandList.addSelectionInterval(index, index); selecting = true; } previousIndex = index; } @Override public void mouseReleased(MouseEvent e) { previousIndex = -1; } }); commandList.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent e) { int index = commandList.locationToIndex(e.getPoint()); if (index != previousIndex) { if (previousIndex > -1) { if (index > previousIndex) { if (selecting) { commandList.addSelectionInterval(previousIndex + 1, index); } else { commandList.removeSelectionInterval(previousIndex + 1, index); } } else { if (selecting) { commandList.addSelectionInterval(index, previousIndex - 1); } else { commandList.removeSelectionInterval(index, previousIndex - 1); } } } else { if (selecting) { commandList.addSelectionInterval(index, index); } else { commandList.removeSelectionInterval(index, index); } } commandList.ensureIndexIsVisible(index); previousIndex = index; } } }); return commandList; }
From source file:org.omegat.gui.scripting.ScriptingWindow.java
private void initWindowLayout() { // set default size and position frame.setBounds(50, 80, 1150, 650);/* w ww .j a v a 2s.c o m*/ StaticUIUtils.persistGeometry(frame, Preferences.SCRIPTWINDOW_GEOMETRY_PREFIX); frame.getContentPane().setLayout(new BorderLayout(0, 0)); m_scriptList = new JList<>(); JScrollPane scrollPaneList = new JScrollPane(m_scriptList); m_scriptList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { onListSelectionChanged(); } } }); m_scriptList.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { ListModel<ScriptItem> lm = m_scriptList.getModel(); int index = m_scriptList.locationToIndex(e.getPoint()); if (index > -1) { m_scriptList.setToolTipText(lm.getElementAt(index).getFile().getName()); } } }); m_txtResult = new JEditorPane(); JScrollPane scrollPaneResults = new JScrollPane(m_txtResult); //m_txtScriptEditor = new StandardScriptEditor(); m_txtScriptEditor = getScriptEditor(); m_txtScriptEditor.initLayout(this); JSplitPane splitPane1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, m_txtScriptEditor.getPanel(), scrollPaneResults); splitPane1.setOneTouchExpandable(true); splitPane1.setDividerLocation(430); Dimension minimumSize1 = new Dimension(100, 50); //scrollPaneEditor.setMinimumSize(minimumSize1); scrollPaneResults.setMinimumSize(minimumSize1); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPaneList, splitPane1); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(250); Dimension minimumSize = new Dimension(100, 50); scrollPaneList.setMinimumSize(minimumSize); scrollPaneResults.setMinimumSize(minimumSize); frame.getContentPane().add(splitPane, BorderLayout.CENTER); JPanel panelSouth = new JPanel(); FlowLayout fl_panelSouth = (FlowLayout) panelSouth.getLayout(); fl_panelSouth.setAlignment(FlowLayout.LEFT); frame.getContentPane().add(panelSouth, BorderLayout.SOUTH); setupRunButtons(panelSouth); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.setJMenuBar(createMenuBar()); }
From source file:edu.pdi2.visual.PDI.java
private void initGUI() { try {// w w w . ja v a2s . c o m setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(null); this.setTitle("Procesamiento Digital de Imagenes"); //$NON-NLS-1$ getContentPane().setBackground(new java.awt.Color(212, 208, 200)); this.setResizable(false); this.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent evt) { thisFocusGained(evt); } }); { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu1 = new JMenu(); jMenuBar1.add(jMenu1); jMenu1.setText("File"); //$NON-NLS-1$ { jMenuItem1 = new JMenuItem(); // jMenu1.add(jMenuItem1); jMenu1.add(getJMenuOpenImage()); jMenu1.add(getJSeparator1()); jMenu1.add(getJMenuItemExit()); jMenuItem1.setText("Open Image"); //$NON-NLS-1$ jMenuItem1.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent evt) { jMenuItem1MouseReleased(evt); } }); } } { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenuBar1.add(getJMenuView()); jMenu3.setText("Options"); //$NON-NLS-1$ jMenu3.setEnabled(false); { jMenuItem3 = new JMenuItem(); jMenu3.add(getJMenuItem2()); jMenu3.add(jMenuItem3); jMenuItem3.setText("False Color Image"); //$NON-NLS-1$ jMenuItem3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { menuFalseColorActionPerformed(evt); } }); } { jMenuItem4 = new JMenuItem(); jMenu3.add(jMenuItem4); jMenuItem4.setText("Mesh"); //$NON-NLS-1$ jMenuItem4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jMenuItem4ActionPerformed(evt); } }); } { jMenu4 = new JMenu(); jMenu3.add(jMenu4); jMenu3.add(getJMenuItem5()); jMenu3.add(getJGenerarSignature()); jMenu4.setText("Image"); //$NON-NLS-1$ { jmiCorrectedReflectance = new JMenuItem(); jMenu4.add(jmiCorrectedReflectance); jmiCorrectedReflectance.setText("Corrected Reflectance"); //$NON-NLS-1$ jmiCorrectedReflectance.setAccelerator(KeyStroke.getKeyStroke("ctrl pressed 1")); //$NON-NLS-1$ jmiCorrectedReflectance.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jmiCorrectedRadianceActionPerformed(evt); } }); } { jmiCorrectedRadiance = new JMenuItem(); jMenu4.add(jmiCorrectedRadiance); jmiCorrectedRadiance.setText("Corrected Radiance"); //$NON-NLS-1$ jmiCorrectedRadiance.setAccelerator(KeyStroke.getKeyStroke("ctrl pressed 2")); jmiCorrectedRadiance.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jmiCorrectedReflectanceActionPerformed(evt); } }); } } } } // First we create the instance of DisplayThumbnail with a 0.1 // scale. // dt.setBorder(BorderFactory.createTitledBorder("")); // We must register mouse motion listeners to it ! // Now we create the instance of DisplayJAI to show the region // corresponding to the viewport. // Set it size. { image = new JPanel(); getContentPane().add(image); image.setBounds(1, 10, 590, dHeight + 10); { dj = new DisplayJAIWithAnnotations(); image.add(dj); dj.setBounds(0, 0, dWidth, dHeight); dj.setPreferredSize(new Dimension(dWidth, dHeight)); dj.setMinimumSize(new Dimension(dWidth, dHeight)); dj.setMaximumSize(new Dimension(dWidth, dHeight)); dj.setBorder(BorderFactory.createTitledBorder("")); dj.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent evt) { djMousePressed(evt); } }); dj.addMouseMotionListener(new MouseMotionAdapter() { public void mouseMoved(MouseEvent evt) { djMouseMoved(evt); } public void mouseDragged(MouseEvent evt) { djMouseDragged(evt); } }); } getContentPane().add(getLatLon()); } pack(); this.setSize(604, 579); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.accada.hal.impl.sim.multi.GraphicSimulatorServer.java
/** * creates the layered pane if it does not already exists * // ww w .ja va2 s. co m * @return layered pane */ private JLayeredPane getJLayeredPane() { if (jLayeredPane == null) { jLayeredPane = new JLayeredPane(); jLayeredPane.setLayout(null); jLayeredPane.setOpaque(true); jLayeredPane.setBackground(Color.WHITE); //jLayeredPane.add(getReader(), new Integer(0)); // add readers createReaders(controller.getReaderIds()); // add context menu jLayeredPane.add(getContextMenu()); // add mouse listener jLayeredPane.addMouseListener(new MouseAdapter() { // context menu public void mouseReleased(MouseEvent e) { hideActiveContextMenuAndSelection(); if (e.getButton() == MouseEvent.BUTTON3) { Point posOnScreen = getJLayeredPane().getLocationOnScreen(); contextMenu.setLocation(posOnScreen.x + e.getX(), posOnScreen.y + e.getY()); contextMenu.setVisible(true); setActiveContextMenu(contextMenu); } else { contextMenu.setVisible(false); if (e.getButton() == MouseEvent.BUTTON1) { selection.select(tags); } } } // selection public void mousePressed(final MouseEvent e) { hideActiveContextMenuAndSelection(); if (e.getButton() == MouseEvent.BUTTON1) { selection.setBounds(0, 0, getProperty("WindowWidth"), getProperty("WindowHeight")); selection.setStartPoint(e.getPoint()); jLayeredPane.add(selection, new Integer(2)); } } }); // add drag listener jLayeredPane.addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { if (selection.isActive()) { selection.setCurrentPoint(e.getPoint()); } } }); } return jLayeredPane; }
From source file:org.pmedv.blackboard.components.BoardEditor.java
/** * Setup the listeners/* ww w . j ava 2s . c o m*/ */ private void initListeners() { addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent e) { handleMouseDragged(e); } @Override public void mouseMoved(MouseEvent e) { Point p = e.getPoint(); p = BoardUtil.mirrorTransform(p, zoomLayer, e); if (editorMode.equals(EditorMode.CHECK_CONNECTIONS)) { mouseOverLine = EditorUtils.findMouseOverLine(e, BoardEditor.this); } else { mouseOverPin = EditorUtils.findPin(e.getX(), e.getY(), BoardEditor.this); } win.getCustomLabel().setText("x : " + e.getX() + " y : " + e.getY()); if (mouseOverPin != null) { tooltipBuffer.delete(0, tooltipBuffer.length()); tooltipBuffer.append(mouseOverPin.getNum()); if (mouseOverPin.getName() != null) { tooltipBuffer.append(" " + mouseOverPin.getName()); } BoardEditor.this.setToolTipText(tooltipBuffer.toString()); ToolTipManager.sharedInstance() .mouseMoved(new MouseEvent(BoardEditor.this, 0, 0, 0, (int) p.getX(), (int) p.getY(), // X-Y of the mouse for the tool tip 0, false)); } else if (mouseOverLine != null) { tooltipBuffer.delete(0, tooltipBuffer.length()); tooltipBuffer.append("net : " + mouseOverLine.getNetIndex()); BoardEditor.this.setToolTipText(tooltipBuffer.toString()); ToolTipManager.sharedInstance() .mouseMoved(new MouseEvent(BoardEditor.this, 0, 0, 0, (int) p.getX(), (int) p.getY(), // X-Y of the mouse for the tool tip 0, false)); } else { BoardEditor.this.setToolTipText(null); } } }); addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { handleMousePressed(e); } @Override public void mouseReleased(MouseEvent e) { handleMouseReleased(e); } }); addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { Boolean invertMouse = (Boolean) Preferences.values .get("org.pmedv.blackboard.BoardDesignerPerspective.invertMouse"); if (invertMouse) { if (currentZoomIndex - e.getWheelRotation() < zoomLevels.length && currentZoomIndex - e.getWheelRotation() > 0) { currentZoomIndex -= e.getWheelRotation(); } } else { if (currentZoomIndex + e.getWheelRotation() < zoomLevels.length && currentZoomIndex + e.getWheelRotation() > 0) { currentZoomIndex += e.getWheelRotation(); } } JXLayer<?> layer = getZoomLayer(); TransformUI ui = (TransformUI) (Object) layer.getUI(); DefaultTransformModel model = (DefaultTransformModel) ui.getModel(); model.setScale(zoomLevels[currentZoomIndex]); ctx.getBean(ApplicationWindow.class).getZoomCombo().setSelectedItem(zoomLevels[currentZoomIndex]); } }); addMouseMotionListener(AppContext.getContext().getBean(AddTextCommand.class)); }
From source file:org.accada.reader.hal.impl.sim.GraphicSimulator.java
/** * creates the layered pane if it does not already exists * /* ww w. j a v a 2 s. co m*/ * @return layered pane */ private JLayeredPane getJLayeredPane() { if (jLayeredPane == null) { jLayeredPane = new JLayeredPane(); jLayeredPane.setLayout(null); jLayeredPane.setOpaque(true); jLayeredPane.setBackground(Color.WHITE); jLayeredPane.add(getReader(), new Integer(0)); // add antennas String[] antennaIds = null; try { antennaIds = controller.getReadPointNames(); } catch (HardwareException ignored) { } for (int i = 0; i < antennaIds.length; i++) { createNewAntenna(antennaIds[i]); } jLayeredPane.add(getContextMenu()); jLayeredPane.add(getMgmtSimMenu()); // add mouse listener jLayeredPane.addMouseListener(new MouseAdapter() { // context menu public void mouseReleased(MouseEvent e) { hideActiveContextMenuAndSelection(); if (e.getButton() == MouseEvent.BUTTON3) { Point posOnScreen = getJLayeredPane().getLocationOnScreen(); contextMenu.setLocation(posOnScreen.x + e.getX(), posOnScreen.y + e.getY()); contextMenu.setVisible(true); mgmtSimMenu.setVisible(false); setActiveContextMenu(contextMenu); } else { contextMenu.setVisible(false); mgmtSimMenu.setVisible(false); if (e.getButton() == MouseEvent.BUTTON1) { selection.select(tags); } } } // selection public void mousePressed(final MouseEvent e) { hideActiveContextMenuAndSelection(); if (e.getButton() == MouseEvent.BUTTON1) { selection.setBounds(0, 0, getProperty("WindowWidth"), getProperty("WindowHeight")); selection.setStartPoint(e.getPoint()); jLayeredPane.add(selection, new Integer(2)); } } }); // add drag listener jLayeredPane.addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { if (selection.isActive()) { selection.setCurrentPoint(e.getPoint()); } } }); } return jLayeredPane; }
From source file:org.accada.hal.impl.sim.GraphicSimulator.java
/** * creates the layered pane if it does not already exists * /*from w w w . j a v a 2 s . c o m*/ * @return layered pane */ private JLayeredPane getJLayeredPane() { if (jLayeredPane == null) { jLayeredPane = new JLayeredPane(); jLayeredPane.setLayout(null); jLayeredPane.setOpaque(true); jLayeredPane.setBackground(Color.WHITE); jLayeredPane.add(getReader(), new Integer(0)); // add antennas String[] antennaIds = null; antennaIds = controller.getReadPointNames(); for (int i = 0; i < antennaIds.length; i++) { createNewAntenna(antennaIds[i]); } jLayeredPane.add(getContextMenu()); jLayeredPane.add(getMgmtSimMenu()); // add mouse listener jLayeredPane.addMouseListener(new MouseAdapter() { // context menu public void mouseReleased(MouseEvent e) { hideActiveContextMenuAndSelection(); if (e.getButton() == MouseEvent.BUTTON3) { Point posOnScreen = getJLayeredPane().getLocationOnScreen(); contextMenu.setLocation(posOnScreen.x + e.getX(), posOnScreen.y + e.getY()); contextMenu.setVisible(true); mgmtSimMenu.setVisible(false); setActiveContextMenu(contextMenu); } else { contextMenu.setVisible(false); mgmtSimMenu.setVisible(false); if (e.getButton() == MouseEvent.BUTTON1) { selection.select(tags); } } } // selection public void mousePressed(final MouseEvent e) { hideActiveContextMenuAndSelection(); if (e.getButton() == MouseEvent.BUTTON1) { selection.setBounds(0, 0, getProperty("WindowWidth"), getProperty("WindowHeight")); selection.setStartPoint(e.getPoint()); jLayeredPane.add(selection, new Integer(2)); } } }); // add drag listener jLayeredPane.addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { if (selection.isActive()) { selection.setCurrentPoint(e.getPoint()); } } }); } return jLayeredPane; }
From source file:com.net2plan.gui.utils.topologyPane.TopologyPanel.java
/** * Default constructor./*from ww w . j a v a 2 s. c o m*/ * * @param callback Topology callback listening plugin events * @param defaultDesignDirectory Default location for design {@code .n2p} files (it may be null, then default is equal to {@code net2planFolder/workspace/data/networkTopologies}) * @param defaultDemandDirectory Default location for design {@code .n2p} files (it may be null, then default is equal to {@code net2planFolder/workspace/data/trafficMatrices}) * @param canvasType Canvas type (i.e. JUNG) * @param plugins List of plugins to be included (it may be null) */ public TopologyPanel(final IVisualizationCallback callback, File defaultDesignDirectory, File defaultDemandDirectory, Class<? extends ITopologyCanvas> canvasType, List<ITopologyCanvasPlugin> plugins) { File currentDir = SystemUtils.getCurrentDir(); this.callback = callback; this.defaultDesignDirectory = defaultDesignDirectory == null ? new File( currentDir + SystemUtils.getDirectorySeparator() + "workspace" + SystemUtils.getDirectorySeparator() + "data" + SystemUtils.getDirectorySeparator() + "networkTopologies") : defaultDesignDirectory; this.defaultDemandDirectory = defaultDemandDirectory == null ? new File( currentDir + SystemUtils.getDirectorySeparator() + "workspace" + SystemUtils.getDirectorySeparator() + "data" + SystemUtils.getDirectorySeparator() + "trafficMatrices") : defaultDemandDirectory; this.multilayerControlPanel = new MultiLayerControlPanel(callback); try { canvas = canvasType.getDeclaredConstructor(IVisualizationCallback.class, TopologyPanel.class) .newInstance(callback, this); } catch (Exception e) { throw new RuntimeException(e); } if (plugins != null) for (ITopologyCanvasPlugin plugin : plugins) addPlugin(plugin); setLayout(new BorderLayout()); JToolBar toolbar = new JToolBar(); toolbar.setRollover(true); toolbar.setFloatable(false); toolbar.setOpaque(false); toolbar.setBorderPainted(false); JPanel topPanel = new JPanel(new BorderLayout()); topPanel.add(toolbar, BorderLayout.NORTH); add(topPanel, BorderLayout.NORTH); JComponent canvasComponent = canvas.getCanvasComponent(); canvasPanel = new JPanel(new BorderLayout()); canvasComponent.setBorder(LineBorder.createBlackLineBorder()); JToolBar multiLayerToolbar = new JToolBar(JToolBar.VERTICAL); multiLayerToolbar.setRollover(true); multiLayerToolbar.setFloatable(false); multiLayerToolbar.setOpaque(false); canvasPanel.add(canvasComponent, BorderLayout.CENTER); canvasPanel.add(multiLayerToolbar, BorderLayout.WEST); add(canvasPanel, BorderLayout.CENTER); btn_load = new JButton(); btn_load.setToolTipText("Load a network design"); btn_loadDemand = new JButton(); btn_loadDemand.setToolTipText("Load a traffic demand set"); btn_save = new JButton(); btn_save.setToolTipText("Save current state to a file"); btn_zoomIn = new JButton(); btn_zoomIn.setToolTipText("Zoom in"); btn_zoomOut = new JButton(); btn_zoomOut.setToolTipText("Zoom out"); btn_zoomAll = new JButton(); btn_zoomAll.setToolTipText("Zoom all"); btn_takeSnapshot = new JButton(); btn_takeSnapshot.setToolTipText("Take a snapshot of the canvas"); btn_showNodeNames = new JToggleButton(); btn_showNodeNames.setToolTipText("Show/hide node names"); btn_showLinkIds = new JToggleButton(); btn_showLinkIds.setToolTipText( "Show/hide link utilization, measured as the ratio between the total traffic in the link (including that in protection segments) and total link capacity (including that reserved by protection segments)"); btn_showNonConnectedNodes = new JToggleButton(); btn_showNonConnectedNodes.setToolTipText("Show/hide non-connected nodes"); btn_increaseNodeSize = new JButton(); btn_increaseNodeSize.setToolTipText("Increase node size"); btn_decreaseNodeSize = new JButton(); btn_decreaseNodeSize.setToolTipText("Decrease node size"); btn_increaseFontSize = new JButton(); btn_increaseFontSize.setToolTipText("Increase font size"); btn_decreaseFontSize = new JButton(); btn_decreaseFontSize.setToolTipText("Decrease font size"); /* Multilayer buttons */ btn_increaseInterLayerDistance = new JButton(); btn_increaseInterLayerDistance .setToolTipText("Increase the distance between layers (when more than one layer is visible)"); btn_decreaseInterLayerDistance = new JButton(); btn_decreaseInterLayerDistance .setToolTipText("Decrease the distance between layers (when more than one layer is visible)"); btn_showLowerLayerInfo = new JToggleButton(); btn_showLowerLayerInfo .setToolTipText("Shows the links in lower layers that carry traffic of the picked element"); btn_showLowerLayerInfo.setSelected(getVisualizationState().isShowInCanvasLowerLayerPropagation()); btn_showUpperLayerInfo = new JToggleButton(); btn_showUpperLayerInfo.setToolTipText( "Shows the links in upper layers that carry traffic that appears in the picked element"); btn_showUpperLayerInfo.setSelected(getVisualizationState().isShowInCanvasUpperLayerPropagation()); btn_showThisLayerInfo = new JToggleButton(); btn_showThisLayerInfo.setToolTipText( "Shows the links in the same layer as the picked element, that carry traffic that appears in the picked element"); btn_showThisLayerInfo.setSelected(getVisualizationState().isShowInCanvasThisLayerPropagation()); btn_npChangeUndo = new JButton(); btn_npChangeUndo.setToolTipText( "Navigate back to the previous state of the network (last time the network design was changed)"); btn_npChangeRedo = new JButton(); btn_npChangeRedo.setToolTipText( "Navigate forward to the next state of the network (when network design was changed"); btn_osmMap = new JToggleButton(); btn_osmMap.setToolTipText( "Toggle between on/off the OSM support. An internet connection is required in order for this to work."); btn_tableControlWindow = new JButton(); btn_tableControlWindow.setToolTipText("Show the network topology control window."); // MultiLayer control window JPopupMenu multiLayerPopUp = new JPopupMenu(); multiLayerPopUp.add(multilayerControlPanel); JPopUpButton btn_multilayer = new JPopUpButton("", multiLayerPopUp); btn_reset = new JButton("Reset"); btn_reset.setToolTipText("Reset the user interface"); btn_reset.setMnemonic(KeyEvent.VK_R); btn_load.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/loadDesign.png"))); btn_loadDemand.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/loadDemand.png"))); btn_save.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/saveDesign.png"))); btn_showNodeNames .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNodeName.png"))); btn_showLinkIds .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLinkUtilization.png"))); btn_showNonConnectedNodes.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNonConnectedNodes.png"))); //btn_whatIfActivated.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNonConnectedNodes.png"))); btn_zoomIn.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomIn.png"))); btn_zoomOut.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomOut.png"))); btn_zoomAll.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomAll.png"))); btn_takeSnapshot.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/takeSnapshot.png"))); btn_increaseNodeSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseNode.png"))); btn_decreaseNodeSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseNode.png"))); btn_increaseFontSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseFont.png"))); btn_decreaseFontSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseFont.png"))); btn_increaseInterLayerDistance.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseLayerDistance.png"))); btn_decreaseInterLayerDistance.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseLayerDistance.png"))); btn_multilayer .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerControl.png"))); btn_showThisLayerInfo .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerPropagation.png"))); btn_showUpperLayerInfo.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerUpperPropagation.png"))); btn_showLowerLayerInfo.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerLowerPropagation.png"))); btn_tableControlWindow .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showControl.png"))); btn_osmMap.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showOSM.png"))); btn_npChangeUndo.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/undoButton.png"))); btn_npChangeRedo.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/redoButton.png"))); btn_load.addActionListener(this); btn_loadDemand.addActionListener(this); btn_save.addActionListener(this); btn_showNodeNames.addActionListener(this); btn_showLinkIds.addActionListener(this); btn_showNonConnectedNodes.addActionListener(this); btn_zoomIn.addActionListener(this); btn_zoomOut.addActionListener(this); btn_zoomAll.addActionListener(this); btn_takeSnapshot.addActionListener(this); btn_reset.addActionListener(this); btn_increaseInterLayerDistance.addActionListener(this); btn_decreaseInterLayerDistance.addActionListener(this); btn_showLowerLayerInfo.addActionListener(this); btn_showUpperLayerInfo.addActionListener(this); btn_showThisLayerInfo.addActionListener(this); btn_increaseNodeSize.addActionListener(this); btn_decreaseNodeSize.addActionListener(this); btn_increaseFontSize.addActionListener(this); btn_decreaseFontSize.addActionListener(this); btn_npChangeUndo.addActionListener(this); btn_npChangeRedo.addActionListener(this); btn_osmMap.addActionListener(this); btn_tableControlWindow.addActionListener(this); toolbar.add(btn_load); toolbar.add(btn_loadDemand); toolbar.add(btn_save); toolbar.add(new JToolBar.Separator()); toolbar.add(btn_zoomIn); toolbar.add(btn_zoomOut); toolbar.add(btn_zoomAll); toolbar.add(btn_takeSnapshot); toolbar.add(new JToolBar.Separator()); toolbar.add(btn_showNodeNames); toolbar.add(btn_showLinkIds); toolbar.add(btn_showNonConnectedNodes); toolbar.add(new JToolBar.Separator()); toolbar.add(btn_increaseNodeSize); toolbar.add(btn_decreaseNodeSize); toolbar.add(btn_increaseFontSize); toolbar.add(btn_decreaseFontSize); toolbar.add(new JToolBar.Separator()); toolbar.add(Box.createHorizontalGlue()); toolbar.add(btn_osmMap); toolbar.add(btn_tableControlWindow); toolbar.add(btn_reset); multiLayerToolbar.add(new JToolBar.Separator()); multiLayerToolbar.add(btn_multilayer); multiLayerToolbar.add(btn_increaseInterLayerDistance); multiLayerToolbar.add(btn_decreaseInterLayerDistance); multiLayerToolbar.add(btn_showLowerLayerInfo); multiLayerToolbar.add(btn_showUpperLayerInfo); multiLayerToolbar.add(btn_showThisLayerInfo); multiLayerToolbar.add(Box.createVerticalGlue()); multiLayerToolbar.add(btn_npChangeUndo); multiLayerToolbar.add(btn_npChangeRedo); this.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { if (e.getComponent().getSize().getHeight() != 0 && e.getComponent().getSize().getWidth() != 0) { canvas.zoomAll(); } } }); List<Component> children = SwingUtils.getAllComponents(this); for (Component component : children) if (component instanceof AbstractButton) component.setFocusable(false); if (ErrorHandling.isDebugEnabled()) { canvas.getCanvasComponent().addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { Point point = e.getPoint(); position.setText("view = " + point + ", NetPlan coord = " + canvas.getCanvasPointFromNetPlanPoint(point)); } }); position = new JLabel(); add(position, BorderLayout.SOUTH); } else { position = null; } new FileDrop(canvasComponent, new LineBorder(Color.BLACK), new FileDrop.Listener() { @Override public void filesDropped(File[] files) { for (File file : files) { try { if (!file.getName().toLowerCase(Locale.getDefault()).endsWith(".n2p")) return; loadDesignFromFile(file); break; } catch (Throwable e) { break; } } } }); btn_showNodeNames.setSelected(getVisualizationState().isCanvasShowNodeNames()); btn_showLinkIds.setSelected(getVisualizationState().isCanvasShowLinkLabels()); btn_showNonConnectedNodes.setSelected(getVisualizationState().isCanvasShowNonConnectedNodes()); final ITopologyCanvasPlugin popupPlugin = new PopupMenuPlugin(callback, this.canvas); addPlugin(new PanGraphPlugin(callback, canvas, MouseEvent.BUTTON1_MASK)); if (callback.getVisualizationState().isNetPlanEditable() && getCanvas() instanceof JUNGCanvas) addPlugin(new AddLinkGraphPlugin(callback, canvas, MouseEvent.BUTTON1_MASK, MouseEvent.BUTTON1_MASK | MouseEvent.SHIFT_MASK)); addPlugin(popupPlugin); if (callback.getVisualizationState().isNetPlanEditable()) addPlugin(new MoveNodePlugin(callback, canvas, MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK)); setBorder(BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "Network topology")); // setAllowLoadTrafficDemand(callback.allowLoadTrafficDemands()); }
From source file:org.bigwiv.blastgraph.gui.BlastGraphFrame.java
private void initComponents() { URL icon;/*ww w. ja va 2 s .com*/ icon = getClass().getResource("/org/bigwiv/blastgraph/icons/icon.png"); this.setIconImage(Toolkit.getDefaultToolkit().createImage(icon)); JComponent pane; pane = (JComponent) getContentPane(); // ====================Menu Setting======================= newItem = new JMenuItem("New From Blast"); newItem.setMnemonic('n'); newItem.addActionListener(commandActionListener); openItem = new JMenuItem("Open"); openItem.setMnemonic('o'); openItem.addActionListener(commandActionListener); appendGraphItem = new JMenuItem("Append Graph"); appendGraphItem.setMnemonic('a'); appendGraphItem.addActionListener(commandActionListener); saveItem = new JMenuItem("Save"); saveItem.setMnemonic('s'); saveItem.addActionListener(commandActionListener); saveAsGraphItem = new JMenuItem("Save As"); saveAsGraphItem.addActionListener(commandActionListener); exportGraphItem = new JMenuItem("Export"); exportGraphItem.addActionListener(commandActionListener); saveCurGraphItem = new JMenuItem("Save Current Graph"); saveCurGraphItem.addActionListener(commandActionListener); saveCurImgItem = new JMenuItem("Save Image"); saveCurImgItem.addActionListener(commandActionListener); saveAllVertexAttrItem = new JMenuItem("Save Vertex Attribute"); saveAllVertexAttrItem.addActionListener(commandActionListener); saveCurVertexAttrItem = new JMenuItem("Save Vertex Attribute"); saveCurVertexAttrItem.addActionListener(commandActionListener); saveAsMenu = new JMenu("Save As"); saveAsMenu.add(saveAsGraphItem); saveAsMenu.add(saveAllVertexAttrItem); saveCurGraphMenu = new JMenu("Save Current Graph"); saveCurGraphMenu.add(saveCurGraphItem); saveCurGraphMenu.add(saveCurImgItem); saveCurGraphMenu.add(saveCurVertexAttrItem); printItem = new JMenuItem("Print..."); printItem.setMnemonic('p'); printItem.addActionListener(commandActionListener); importVertexAttrItem = new JMenuItem("Import Vertex Attribute"); importVertexAttrItem.addActionListener(commandActionListener); closeItem = new JMenuItem("Close"); closeItem.setMnemonic('c'); closeItem.addActionListener(commandActionListener); exitItem = new JMenuItem("Exit"); exitItem.setMnemonic('x'); exitItem.addActionListener(commandActionListener); fileMenu = new JMenu("File"); fileMenu.setMnemonic('f'); fileMenu.add(newItem); fileMenu.add(openItem); fileMenu.add(appendGraphItem); fileMenu.add(new JSeparator()); fileMenu.add(closeItem); fileMenu.add(new JSeparator()); fileMenu.add(saveItem); fileMenu.add(saveAsMenu); fileMenu.add(saveCurGraphMenu); fileMenu.add(new JSeparator()); fileMenu.add(printItem); fileMenu.add(new JSeparator()); fileMenu.add(importVertexAttrItem); fileMenu.add(exportGraphItem); fileMenu.add(new JSeparator()); fileMenu.add(exitItem); // edit menu undoItem = new JMenuItem("Undo"); redoItem = new JMenuItem("Redo"); Global.COMMAND_MANAGER.registerUndoRedoItem(undoItem, redoItem); removeSingleItem = new JMenuItem("Remove Single Vertices"); removeSingleItem.addActionListener(commandActionListener); filterItem = new JMenuItem("Filt Graph"); filterItem.addActionListener(commandActionListener); settingItem = new JMenuItem("Setting"); settingItem.addActionListener(commandActionListener); markovClusterItem = new JMenuItem("Markov Cluster"); markovClusterItem.addActionListener(commandActionListener); // genomeNumFiltItem = new JMenuItem("GenomeNum Filt"); // genomeNumFiltItem.addActionListener(commandActionListener); // removeSingleLinkageItem = new JMenuItem("Remove Single Linkage"); // removeSingleLinkageItem.addActionListener(commandActionListener); editMenu = new JMenu("Edit"); editMenu.setMnemonic('e'); editMenu.add(undoItem); editMenu.add(redoItem); editMenu.add(filterItem); editMenu.add(markovClusterItem); editMenu.add(removeSingleItem); // editMenu.add(genomeNumFiltItem); // editMenu.add(removeSingleLinkageItem); editMenu.add(settingItem); // Tools Item geneContentItem = new JMenuItem("Gene Content Table"); geneContentItem.addActionListener(commandActionListener); batchSaveItem = new JMenuItem("Batch Save"); batchSaveItem.addActionListener(commandActionListener); mstItem = new JMenuItem("Minimum Spanning Tree"); mstItem.addActionListener(commandActionListener); viewNeighborItem = new JMenuItem("View Neighbor of..."); viewNeighborItem.addActionListener(commandActionListener); // // tempWorkItem = new JMenuItem("Temp Work"); // tempWorkItem.addActionListener(commandActionListener); toolsMenu = new JMenu("Tools"); toolsMenu.setMnemonic('t'); toolsMenu.add(geneContentItem); toolsMenu.add(viewNeighborItem); toolsMenu.add(mstItem); toolsMenu.add(batchSaveItem); // toolsMenu.add(tempWorkItem); // graph Menu graphMenu = new JMenu("Graph"); previousItem = new JMenuItem("Previous"); previousItem.addActionListener(commandActionListener); nextItem = new JMenuItem("Next"); nextItem.addActionListener(commandActionListener); resortItem = new JMenuItem("Resort graphs"); resortItem.addActionListener(commandActionListener); graphMenu.add(nextItem); graphMenu.add(previousItem); graphMenu.add(resortItem); // help Menu helpContentItem = new JMenuItem("Online Manual"); helpContentItem.addActionListener(commandActionListener); aboutItem = new JMenuItem("About BlastGraph"); aboutItem.addActionListener(commandActionListener); helpMenu = new JMenu("Help"); helpMenu.add(helpContentItem); helpMenu.add(aboutItem); // menu bar menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(editMenu); menuBar.add(graphMenu); menuBar.add(toolsMenu); menuBar.add(helpMenu); setJMenuBar(menuBar); // ===================mainPanel Setting=================== GridBagManager.reset(); GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH; GridBagManager.GRID_BAG.anchor = GridBagConstraints.FIRST_LINE_START; GridBagManager.GRID_BAG.weightx = 0; GridBagManager.GRID_BAG.weighty = 0; GridBagManager.GRID_BAG.insets = new Insets(2, 2, 1, 1); mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); pane.add(mainPanel); hsplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); hsplitPane.setContinuousLayout(true); hsplitPane.setOneTouchExpandable(true); hsplitPane.setResizeWeight(0.9); // ===================toolBarPanel Setting=================== // graph file toolbar fileToolBar = new JToolBar(); fileToolBar.setRollover(true); newButton = new JButton(); newButton.setBorderPainted(false); newButton.setMnemonic('n'); newButton.setToolTipText("New From Blast"); newButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/filenew.png"); // System.out.println(icon); newButton.setIcon(new ImageIcon(icon)); openButton = new JButton(); openButton.setBorderPainted(false); openButton.setMnemonic('o'); openButton.setToolTipText("Open"); openButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/fileopen.png"); openButton.setIcon(new ImageIcon(icon)); saveButton = new JButton(); saveButton.setBorderPainted(false); saveButton.setMnemonic('s'); saveButton.setToolTipText("Save"); saveButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/filesave.png"); saveButton.setIcon(new ImageIcon(icon)); saveCurImgButton = new JButton(); saveCurImgButton.setBorderPainted(false); saveCurImgButton.setToolTipText("Save current image"); saveCurImgButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/saveimage.png"); saveCurImgButton.setIcon(new ImageIcon(icon)); printButton = new JButton(); printButton.setBorderPainted(false); printButton.setToolTipText("Print..."); printButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/fileprint.png"); printButton.setIcon(new ImageIcon(icon)); fileToolBar.add(newButton); fileToolBar.add(openButton); fileToolBar.add(saveButton); fileToolBar.add(saveCurImgButton); fileToolBar.add(printButton); // graph control toolbar graphToolBar = new JToolBar(); graphToolBar.setRollover(true); previousButton = new JButton(); previousButton.setBorderPainted(false); previousButton.setToolTipText("Previous graph"); previousButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/previous.png"); previousButton.setIcon(new ImageIcon(icon)); indexField = new JTextField(); indexField.setSize(new Dimension(25, 16)); indexField.setMinimumSize(new Dimension(25, 16)); indexField.setPreferredSize(new Dimension(25, 16)); indexField.addKeyListener(keyListener); nextButton = new JButton(); nextButton.setBorderPainted(false); nextButton.setToolTipText("Next graph"); nextButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/next.png"); nextButton.setIcon(new ImageIcon(icon)); filterButton = new JButton(); filterButton.setBorderPainted(false); filterButton.setToolTipText("Filt graph"); filterButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/filter.png"); filterButton.setIcon(new ImageIcon(icon)); resortButton = new JButton(); resortButton.setBorderPainted(false); resortButton.setToolTipText("Resort graph"); resortButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/resort.png"); resortButton.setIcon(new ImageIcon(icon)); searchField = new JTextField(); searchField.setSize(new Dimension(60, 16)); searchField.setMinimumSize(new Dimension(60, 16)); searchField.setPreferredSize(new Dimension(60, 16)); searchField.addKeyListener(keyListener); searchButton = new JButton(); searchButton.setBorderPainted(false); searchButton.setToolTipText("Search"); searchButton.addActionListener(commandActionListener); icon = getClass().getResource("/org/bigwiv/blastgraph/icons/search.png"); searchButton.setIcon(new ImageIcon(icon)); graphToolBar.add(filterButton); graphToolBar.add(resortButton); // graphToolBar.add(new JToolBar.Separator()); graphToolBar.add(previousButton); graphToolBar.add(indexField); graphToolBar.add(nextButton); graphToolBar.add(searchField); graphToolBar.add(searchButton); // view toolbar (modebox & layoutbox) viewToolBar = new JToolBar(); viewToolBar.setRollover(true); modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { int index = modeBox.getSelectedIndex(); if (index == 2) { int annotCount = annotationToolBar.getComponentCount(); for (int i = 0; i < annotCount; i++) { annotationToolBar.getComponent(i).setEnabled(true); } } else { int annotCount = annotationToolBar.getComponentCount(); for (int i = 0; i < annotCount; i++) { annotationToolBar.getComponent(i).setEnabled(false); } } } }); layoutBox = this.getLayoutComboBox(); viewToolBar.add(modeBox); viewToolBar.add(layoutBox); colorComboBox = new JComboBox(new String[] { "vertex color", "index", "strand", "genomeAcc", "organism" }); viewToolBar.add(colorComboBox); // add additional menu to graphMenu modeMenu = graphMouse.getModeMenu(); modeMenu.setText("Mode"); layoutMenu = getLayoutMenu(); layoutMenu.setText("Layout"); graphMenu.add(modeMenu); graphMenu.add(layoutMenu); // annotation toolbar AnnotationControls<HitVertex, ValueEdge> annotationControls = new AnnotationControls<HitVertex, ValueEdge>( annotatingPlugin); annotationToolBar = annotationControls.getAnnotationsToolBar(); ((JButton) annotationToolBar.getComponent(1)).setBorderPainted(false); ((JToggleButton) annotationToolBar.getComponent(2)).setBorderPainted(false); // add toolbars to toolBarPanel toolBarPanel = new JPanel(); toolBarPanel.setLayout(new ModifiedFlowLayout(ModifiedFlowLayout.LEFT, 0, 0)); toolBarPanel.setBorder(new EtchedBorder()); toolBarPanel.add(fileToolBar); toolBarPanel.add(graphToolBar); toolBarPanel.add(viewToolBar); toolBarPanel.add(annotationToolBar); mainPanel.add(toolBarPanel, BorderLayout.NORTH); mainPanel.add(hsplitPane, BorderLayout.CENTER); // GridBagManager.add(mainPanel, toolBarPanel, 0, 0, 1, 1); // GridBagManager.add(mainPanel, hsplitPane, 0, 1, 1, 1); // mainPanel.add(toolBarPanel, BorderLayout.NORTH); // ===================vsplitPane Setting================= vsplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); vsplitPane.setContinuousLayout(true); vsplitPane.setOneTouchExpandable(true); vsplitPane.setResizeWeight(0.9); hsplitPane.setLeftComponent(vsplitPane); // GridBagManager.GRID_BAG.weightx = 0.9; // GridBagManager.GRID_BAG.weighty = 1; // GridBagManager.add(mainPanel, vsplitPane, 0, 1, 1, 2); // mainPanel.add(vsplitPane, BorderLayout.CENTER); // ===================vvPanel Setting=================== vvPanel = new GraphZoomScrollPane(vv); vsplitPane.setTopComponent(vvPanel); // ===================Tab Panel Setting======================= // progressPanel = new ProgressPanel(); verticesTable = new VerticesTable(); verticesTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int row = verticesTable.rowAtPoint(e.getPoint()); int col = verticesTable.columnAtPoint(e.getPoint()); // System.out.println(row + " " + col); String value = verticesTable.getValueAt(row, col).toString(); // System.out.println(value); if (Global.graph.containsVertex(new HitVertex(value))) { for (int i = 0; i < subSetList.size(); i++) { if (subSetList.get(i).contains(new HitVertex(value))) { curGraph = FilterUtils.createInducedSubgraph(subSetList.get(i), Global.graph); PickedState<HitVertex> pickedVertexState = vv.getPickedVertexState(); // picked is a reference to picked vertices // use a temp set to avoid concurrent modification Set<HitVertex> picked = pickedVertexState.getPicked(); Set<HitVertex> temp = new HashSet<HitVertex>(); for (HitVertex hitVertex : picked) { temp.add(hitVertex); } for (HitVertex hv : temp) { pickedVertexState.pick(hv, false); } pickedVertexState.pick(new HitVertex(value), true); // refreshSubGraphView(); return; } } } } }); verticesTable.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { int row = verticesTable.rowAtPoint(e.getPoint()); int col = verticesTable.columnAtPoint(e.getPoint()); String value = verticesTable.getValueAt(row, col).toString(); // System.out.println(value); if (Global.graph.containsVertex(value)) { Cursor normalCursor = new Cursor(Cursor.HAND_CURSOR); setCursor(normalCursor); } else { Cursor normalCursor = new Cursor(Cursor.DEFAULT_CURSOR); setCursor(normalCursor); } } }); verticesPanel = new JPanel(); verticesPanel.setLayout(new GridLayout()); verticesPanel.add(new JScrollPane(verticesTable)); edgesTable = new EdgesTable(); edgesPanel = new JPanel(); edgesPanel.setLayout(new GridLayout()); edgesPanel.add(new JScrollPane(edgesTable)); tabbedPane = new JTabbedPane(); tabbedPane.addTab("Vertices", verticesPanel); tabbedPane.addTab("Edges", edgesPanel); vsplitPane.setBottomComponent(tabbedPane); graphMouse.addPichedChangeListener(verticesTable, edgesTable); // ===================Info Panel Setting=================== infoPanel = new JPanel(new GridBagLayout()); GridBagManager.GRID_BAG.weightx = 0.1; GridBagManager.GRID_BAG.weighty = 1; hsplitPane.setRightComponent(infoPanel); JPanel mainInfoPanel = new JPanel(new GridBagLayout()); mainInfoPanel .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Main Info")); JPanel currentInfoPanel = new JPanel(new GridBagLayout()); currentInfoPanel.setBorder( BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Current Graph")); JPanel selectedInfoPanel = new JPanel(new GridBagLayout()); selectedInfoPanel .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Selected")); JPanel statisticsInfoPanel = new JPanel(new GridBagLayout()); statisticsInfoPanel .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Statistics")); JPanel progressInfoPanel = new JPanel(new GridBagLayout()); progressInfoPanel .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Progress")); GridBagManager.GRID_BAG.anchor = GridBagConstraints.NORTH; GridBagManager.GRID_BAG.fill = GridBagConstraints.HORIZONTAL; GridBagManager.GRID_BAG.weighty = 0; GridBagManager.add(infoPanel, mainInfoPanel, 0, 1, 1, 1); GridBagManager.add(infoPanel, currentInfoPanel, 0, 2, 1, 1); GridBagManager.add(infoPanel, selectedInfoPanel, 0, 3, 1, 1); GridBagManager.GRID_BAG.weighty = 0.5; GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH; GridBagManager.add(infoPanel, statisticsInfoPanel, 0, 4, 1, 1); GridBagManager.add(infoPanel, progressInfoPanel, 0, 5, 1, 1); // mainInfoPanel { JLabel vertices = new JLabel("Vertices:"); vertexCountLabel = new JLabel("0"); JLabel edges = new JLabel("Edges:"); edgeCountLabel = new JLabel("0"); JLabel subGraphs = new JLabel("SubGraphs:"); subGraphCountLabel = new JLabel("0"); GridBagManager.GRID_BAG.anchor = GridBagConstraints.WEST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(mainInfoPanel, vertices, 0, 0, 1, 1); GridBagManager.add(mainInfoPanel, edges, 0, 1, 1, 1); GridBagManager.add(mainInfoPanel, subGraphs, 0, 2, 1, 1); GridBagManager.GRID_BAG.anchor = GridBagConstraints.EAST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(mainInfoPanel, vertexCountLabel, 1, 0, 1, 1); GridBagManager.add(mainInfoPanel, edgeCountLabel, 1, 1, 1, 1); GridBagManager.add(mainInfoPanel, subGraphCountLabel, 1, 2, 1, 1); } // end of mainInfoPanel // currentInfoPanel { JLabel vertices = new JLabel("Vertices:"); currentVertexCountLabel = new JLabel("0"); JLabel edges = new JLabel("Edges:"); currentEdgeCountLabel = new JLabel("0"); JLabel acc = new JLabel("ACC:"); currentAccLabel = new JLabel("0"); GridBagManager.GRID_BAG.anchor = GridBagConstraints.WEST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(currentInfoPanel, vertices, 0, 0, 1, 1); GridBagManager.add(currentInfoPanel, edges, 0, 1, 1, 1); GridBagManager.add(currentInfoPanel, acc, 0, 2, 1, 1); GridBagManager.GRID_BAG.anchor = GridBagConstraints.EAST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(currentInfoPanel, currentVertexCountLabel, 1, 0, 1, 1); GridBagManager.add(currentInfoPanel, currentEdgeCountLabel, 1, 1, 1, 1); GridBagManager.add(currentInfoPanel, currentAccLabel, 1, 2, 1, 1); } // end of currentInfoPanel // selectedInfoPanel { JLabel vertices = new JLabel("Vertices:"); selectedVertexCountLabel = new JLabel("0"); JLabel edges = new JLabel("Edges:"); selectedEdgeCountLabel = new JLabel("0"); GridBagManager.GRID_BAG.anchor = GridBagConstraints.WEST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(selectedInfoPanel, vertices, 0, 0, 1, 1); GridBagManager.add(selectedInfoPanel, edges, 0, 1, 1, 1); GridBagManager.GRID_BAG.anchor = GridBagConstraints.EAST; GridBagManager.GRID_BAG.weightx = 0.5; GridBagManager.add(selectedInfoPanel, selectedVertexCountLabel, 1, 0, 1, 1); GridBagManager.add(selectedInfoPanel, selectedEdgeCountLabel, 1, 1, 1, 1); CollectionChangeListener<HitVertex> svListener = new CollectionChangeListener<HitVertex>() { @Override public void onCollectionChange(Set<HitVertex> set) { selectedVertexCountLabel.setText("" + set.size()); } }; CollectionChangeListener<ValueEdge> veListener = new CollectionChangeListener<ValueEdge>() { @Override public void onCollectionChange(Set<ValueEdge> set) { selectedEdgeCountLabel.setText("" + set.size()); } }; graphMouse.addPichedChangeListener(svListener, veListener); } // end of selectedInfoPanel {// statistics Panel GridBagManager.GRID_BAG.anchor = GridBagConstraints.NORTH; GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH; GridBagManager.add(statisticsInfoPanel, graphStatisticsPanel, 0, 0, 1, 1); } // statistics Panel {// progressInfoPanel GridBagManager.GRID_BAG.anchor = GridBagConstraints.NORTH; GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH; GridBagManager.add(progressInfoPanel, progressPanel, 0, 0, 1, 1); } // progressInfoPanel // set frame size Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); setSize((screen.width * 3) / 4, (screen.height * 9) / 10); setLocation(screen.width / 6, screen.height / 16); refreshUI(false); }
From source file:op.FrmMain.java
public void setBlocked(boolean blocked) { if (blocked) { lblWait.setVisible(true);/*from ww w. j a v a 2 s .c om*/ JPanel glass = new JPanel(); glass.addMouseListener(new MouseAdapter() { }); glass.addMouseMotionListener(new MouseMotionAdapter() { }); glass.addKeyListener(new KeyAdapter() { }); glass.setOpaque(false); setGlassPane(glass); getGlassPane().setVisible(true); ((CardLayout) pnlCard.getLayout()).show(pnlCard, "cardWait"); } else { getGlassPane().setVisible(false); setGlassPane(new JPanel()); ((CardLayout) pnlCard.getLayout()).show(pnlCard, "cardContent"); } }