List of usage examples for java.awt.event MouseWheelListener MouseWheelListener
MouseWheelListener
From source file:lcmc.common.ui.ResourceGraph.java
protected final void initGraph(final Graph<Vertex, Edge> graph) { this.graph = graph; final Transformer<Vertex, Point2D> vlf = TransformerUtils.mapTransformer(getVertexLocations()); putVertexLocations();//from w w w. jav a 2s .c o m layout = new StaticLayout<Vertex, Edge>(graph, vlf) { /* remove the adjust locations part, because scaling is from 0, 0 */ @Override public void setSize(final Dimension size) { if (size != null) { this.size = size; initialize(); } } }; visualizationViewer = new VisualizationViewer<Vertex, Edge>(layout); visualizationViewer.setVertexToolTipTransformer(new MyVertexToolTipFunction<Vertex>()); visualizationViewer.setEdgeToolTipTransformer(new MyEdgeToolTipFunction<Edge>()); initializeRendering(visualizationViewer); /* scaling */ /* overwriting scaler so that zooming starts from point (0, 0) */ myScaler = getScalingControl(); /* picking and popups */ /* overwriting loadPlugins method only to set scaler */ final DefaultModalGraphMouse<Vertex, Edge> graphMouse = new DefaultModalGraphMouse<Vertex, Edge>() { @Override protected void loadPlugins() { super.loadPlugins(); ((ScalingGraphMousePlugin) scalingPlugin).setScaler(myScaler); remove(animatedPickingPlugin); animatedPickingPlugin = null; } }; visualizationViewer.setGraphMouse(graphMouse); graphMouse.add(new MyPopupGraphMousePlugin<Vertex, Edge>()); visualizationViewer.addGraphMouseListener(new MyGraphMouseListener<Vertex>()); visualizationViewer.setPickSupport(new ShapePickSupport<Vertex, Edge>(visualizationViewer, 50)); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); layout.initialize(); scrollPane = new GraphZoomScrollPane(visualizationViewer); final JScrollBar vScrollBar = scrollPane.getVerticalScrollBar(); visualizationViewer.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(final MouseWheelEvent e) { if ((e.getModifiers() & MouseWheelEvent.CTRL_MASK) > 0) { final int amount = e.getWheelRotation(); vScrollBar.setValue(vScrollBar.getValue() + amount * 20); e.consume(); visualizationViewer.repaint(); } } }); }
From source file:lcmc.gui.ResourceGraph.java
/** Inits the graph. */ protected final void initGraph(final Graph<Vertex, Edge> graph) { this.graph = graph; final Transformer<Vertex, Point2D> vlf = TransformerUtils.mapTransformer(getVertexLocations()); putVertexLocations();//from w ww. java 2s . c o m layout = new StaticLayout<Vertex, Edge>(graph, vlf) { /* remove the adjust locations part, because scraling is from 0, 0 */ @Override public final void setSize(final Dimension size) { if (size != null) { this.size = size; initialize(); } } }; vv = new VisualizationViewer<Vertex, Edge>(layout); vv.getRenderContext().setEdgeArrowTransformer(new MyEdgeArrowFunction<Vertex, Edge>()); vv.getRenderContext().setEdgeLabelClosenessTransformer( new ConstantDirectionalEdgeValueTransformer<Vertex, Edge>(0.5, 0.5)); vv.getRenderContext().setVertexShapeTransformer(new MyVertexShapeSize<Vertex, Edge>(graph, vlf)); vv.getRenderContext().setVertexFillPaintTransformer( new MyPickableVertexPaintFunction<Vertex>(vv.getPickedVertexState(), false)); vv.getRenderContext().setVertexDrawPaintTransformer( new MyPickableVertexPaintFunction<Vertex>(vv.getPickedVertexState(), true)); vv.getRenderer().setVertexRenderer(pr); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<Edge>()); vv.setBackground(Tools.getDefaultColor("ResourceGraph.Background")); vv.setVertexToolTipTransformer(new MyVertexToolTipFunction<Vertex>()); vv.setEdgeToolTipTransformer(new MyEdgeToolTipFunction<Edge>()); vv.getRenderContext().setEdgeShapeTransformer(new MyLine<Vertex, Edge>()); vv.getRenderContext().setEdgeDrawPaintTransformer( new MyPickableEdgePaintFunction<Edge>(vv.getPickedEdgeState(), EDGE_DRAW_PAINT, EDGE_PICKED_PAINT)); vv.getRenderContext().setEdgeFillPaintTransformer( new MyPickableEdgePaintFunction<Edge>(vv.getPickedEdgeState(), EDGE_DRAW_PAINT, EDGE_PICKED_PAINT)); vv.getRenderContext().setArrowDrawPaintTransformer( new MyPickableEdgePaintFunction<Edge>(vv.getPickedEdgeState(), EDGE_DRAW_PAINT, EDGE_PICKED_PAINT)); vv.getRenderContext().setArrowFillPaintTransformer(new MyPickableArrowEdgePaintFunction<Edge>( vv.getPickedEdgeState(), EDGE_DRAW_PAINT, EDGE_PICKED_PAINT)); /* scaling */ /* overwriting scaler so that zooming starts from point (0, 0) */ myScaler = getScalingControl(); /* picking and popups */ /* overwriting loadPlugins method only to set scaler */ final DefaultModalGraphMouse<Vertex, Edge> graphMouse = new DefaultModalGraphMouse<Vertex, Edge>() { protected void loadPlugins() { super.loadPlugins(); ((ScalingGraphMousePlugin) scalingPlugin).setScaler(myScaler); remove(animatedPickingPlugin); animatedPickingPlugin = null; } }; vv.setGraphMouse(graphMouse); graphMouse.add(new MyPopupGraphMousePlugin<Vertex, Edge>()); vv.addGraphMouseListener(new MyGraphMouseListener<Vertex>()); vv.setPickSupport(new ShapePickSupport<Vertex, Edge>(vv, 50)); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); layout.initialize(); scrollPane = new GraphZoomScrollPane(vv); final JScrollBar vScrollBar = scrollPane.getVerticalScrollBar(); vv.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(final MouseWheelEvent e) { if ((e.getModifiers() & MouseWheelEvent.CTRL_MASK) > 0) { final int amount = e.getWheelRotation(); vScrollBar.setValue(vScrollBar.getValue() + amount * 20); e.consume(); vv.repaint(); } } }); }
From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java
/** * Constructs a JFreeChart panel.//from w w w. jav a 2s . com * * @param chart * the chart. * @param width * the preferred width of the panel. * @param height * the preferred height of the panel. * @param minimumDrawWidth * the minimum drawing width. * @param minimumDrawHeight * the minimum drawing height. * @param maximumDrawWidth * the maximum drawing width. * @param maximumDrawHeight * the maximum drawing height. * @param useBuffer * a flag that indicates whether to use the off-screen buffer to improve performance * (at the expense of memory). * @param properties * a flag indicating whether or not the chart property editor should be available via * the popup menu. * @param copy * a flag indicating whether or not a copy option should be available via the popup * menu. * @param save * a flag indicating whether or not save options should be available via the popup * menu. * @param print * a flag indicating whether or not the print option should be available via the * popup menu. * @param zoom * a flag indicating whether or not zoom options should be added to the popup menu. * @param tooltips * a flag indicating whether or not tooltips should be enabled for the chart. * * @since 1.0.13 */ public AbstractChartPanel(JFreeChart chart, int width, int height, int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth, int maximumDrawHeight, boolean useBuffer, boolean properties, boolean copy, boolean save, boolean print, boolean zoom, boolean tooltips) { super(chart, width, height, minimumDrawWidth, minimumDrawHeight, maximumDrawWidth, maximumDrawHeight, false, properties, copy, save, print, zoom, tooltips); setChart(chart); this.chartMouseListeners = new EventListenerList(); this.info = new ChartRenderingInfo(); setPreferredSize(new Dimension(width, height)); this.minimumDrawWidth = minimumDrawWidth; this.minimumDrawHeight = minimumDrawHeight; this.maximumDrawWidth = maximumDrawWidth; this.maximumDrawHeight = maximumDrawHeight; this.zoomTriggerDistance = DEFAULT_ZOOM_TRIGGER_DISTANCE; // set up popup menu... this.popup = null; if (properties || copy || save || print || zoom) { this.popup = createPopupMenu(properties, copy, save, print, zoom); } enableEvents(AWTEvent.MOUSE_EVENT_MASK); enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK); setDisplayToolTips(tooltips); // mouse listener registered in super class // addMouseListener(this); // addMouseMotionListener(this); this.defaultDirectoryForSaveAs = null; this.enforceFileExtensions = true; // initialize ChartPanel-specific tool tip delays with // values the from ToolTipManager.sharedInstance() ToolTipManager ttm = ToolTipManager.sharedInstance(); this.ownToolTipInitialDelay = ttm.getInitialDelay(); this.ownToolTipDismissDelay = ttm.getDismissDelay(); this.ownToolTipReshowDelay = ttm.getReshowDelay(); this.zoomAroundAnchor = false; this.selectionOutlinePaint = Color.blue; this.selectionFillPaint = new Color(0, 0, 255, 63); this.panMask = InputEvent.CTRL_MASK; // for MacOSX we can't use the CTRL key for mouse drags, see: // http://developer.apple.com/qa/qa2004/qa1362.html String osName = System.getProperty("os.name").toLowerCase(); if (osName.startsWith("mac os x")) { this.panMask = InputEvent.ALT_MASK; } this.overlays = new java.util.ArrayList<>(); // adding wheel listener addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { if (e.getScrollType() != MouseWheelEvent.WHEEL_UNIT_SCROLL) { return; } if (e.getWheelRotation() < 0) { shrinkSelectionOnCenter(e.getX(), e.getY(), e); } else { enlargeSelectionOnCenter(e.getX(), e.getY(), e); } } }); }
From source file:com.mirth.connect.client.ui.ChannelSetup.java
/** * Makes the destination table with a parameter that is true if a new destination should be * added as well.//from ww w .java 2s.c om */ public void makeDestinationTable(boolean addNew) { List<Connector> destinationConnectors; Object[][] tableData; int tableSize; destinationConnectors = currentChannel.getDestinationConnectors(); tableSize = destinationConnectors.size(); if (addNew) { tableSize++; } int chain = 1; tableData = new Object[tableSize][5]; for (int i = 0; i < tableSize; i++) { if (tableSize - 1 == i && addNew) { Connector connector = makeNewConnector(true); // Set the default inbound and outbound dataType and properties String dataType = currentChannel.getSourceConnector().getTransformer().getOutboundDataType(); // Use a different properties object for the inbound and outbound DataTypeProperties defaultInboundProperties = LoadedExtensions.getInstance().getDataTypePlugins() .get(dataType).getDefaultProperties(); DataTypeProperties defaultOutboundProperties = LoadedExtensions.getInstance().getDataTypePlugins() .get(dataType).getDefaultProperties(); DataTypeProperties defaultResponseInboundProperties = LoadedExtensions.getInstance() .getDataTypePlugins().get(dataType).getDefaultProperties(); DataTypeProperties defaultResponseOutboundProperties = LoadedExtensions.getInstance() .getDataTypePlugins().get(dataType).getDefaultProperties(); connector.getTransformer().setInboundDataType(dataType); connector.getTransformer().setInboundProperties(defaultInboundProperties); connector.getTransformer().setOutboundDataType(dataType); connector.getTransformer().setOutboundProperties(defaultOutboundProperties); connector.getResponseTransformer().setInboundDataType(dataType); connector.getResponseTransformer().setInboundProperties(defaultResponseInboundProperties); connector.getResponseTransformer().setOutboundDataType(dataType); connector.getResponseTransformer().setOutboundProperties(defaultResponseOutboundProperties); connector.setName(getNewDestinationName(tableSize)); connector.setTransportName(DESTINATION_DEFAULT); // We need to add the destination first so that the metadata ID is initialized. currentChannel.addDestination(connector); if (connector.isEnabled()) { tableData[i][0] = new CellData( new ImageIcon( com.mirth.connect.client.ui.Frame.class.getResource("images/bullet_blue.png")), UIConstants.ENABLED_STATUS); } else { tableData[i][0] = new CellData( new ImageIcon( com.mirth.connect.client.ui.Frame.class.getResource("images/bullet_black.png")), UIConstants.DISABLED_STATUS); } tableData[i][1] = connector.getName(); tableData[i][2] = connector.getMetaDataId(); tableData[i][3] = new ConnectorTypeData(destinationConnectors.get(i).getTransportName()); if (i > 0 && !connector.isWaitForPrevious()) { chain++; } tableData[i][4] = chain; } else { if (destinationConnectors.get(i).isEnabled()) { tableData[i][0] = new CellData( new ImageIcon( com.mirth.connect.client.ui.Frame.class.getResource("images/bullet_blue.png")), UIConstants.ENABLED_STATUS); } else { tableData[i][0] = new CellData( new ImageIcon( com.mirth.connect.client.ui.Frame.class.getResource("images/bullet_black.png")), UIConstants.DISABLED_STATUS); } tableData[i][1] = destinationConnectors.get(i).getName(); tableData[i][2] = destinationConnectors.get(i).getMetaDataId(); tableData[i][3] = new ConnectorTypeData(destinationConnectors.get(i).getTransportName()); if (i > 0 && !destinationConnectors.get(i).isWaitForPrevious()) { chain++; } tableData[i][4] = chain; } } destinationTable = new MirthTable(); destinationTable.setModel(new javax.swing.table.DefaultTableModel(tableData, new String[] { STATUS_COLUMN_NAME, DESTINATION_COLUMN_NAME, METADATA_COLUMN_NAME, CONNECTOR_TYPE_COLUMN_NAME, DESTINATION_CHAIN_COLUMN_NAME }) { boolean[] canEdit = new boolean[] { false, true, false, false, false }; public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); destinationTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); // Set the custom cell editor for the Destination Name column. destinationTable.getColumnModel() .getColumn(destinationTable.getColumnModel().getColumnIndex(DESTINATION_COLUMN_NAME)) .setCellEditor(new DestinationTableCellEditor()); destinationTable.setCustomEditorControls(true); // Must set the maximum width on columns that should be packed. destinationTable.getColumnExt(STATUS_COLUMN_NAME).setMaxWidth(UIConstants.MAX_WIDTH); destinationTable.getColumnExt(STATUS_COLUMN_NAME).setMinWidth(UIConstants.MIN_WIDTH); // Set the cell renderer for the status column. destinationTable.getColumnExt(STATUS_COLUMN_NAME).setCellRenderer(new ImageCellRenderer()); // Set the maximum width and cell renderer for the metadata ID column destinationTable.getColumnExt(METADATA_COLUMN_NAME).setMaxWidth(UIConstants.METADATA_ID_COLUMN_WIDTH); destinationTable.getColumnExt(METADATA_COLUMN_NAME).setMinWidth(UIConstants.METADATA_ID_COLUMN_WIDTH); destinationTable.getColumnExt(METADATA_COLUMN_NAME) .setCellRenderer(new NumberCellRenderer(SwingConstants.CENTER, false)); // Set the cell renderer for the destination connector type destinationTable.getColumnExt(CONNECTOR_TYPE_COLUMN_NAME).setCellRenderer(new ConnectorTypeCellRenderer()); // Set the cell renderer and the max width for the destination chain column destinationTable.getColumnExt(DESTINATION_CHAIN_COLUMN_NAME) .setCellRenderer(new NumberCellRenderer(SwingConstants.CENTER, false)); destinationTable.getColumnExt(DESTINATION_CHAIN_COLUMN_NAME).setMaxWidth(50); destinationTable.setSelectionMode(0); destinationTable.setRowSelectionAllowed(true); destinationTable.setRowHeight(UIConstants.ROW_HEIGHT); destinationTable.setFocusable(true); destinationTable.setSortable(false); destinationTable.getTableHeader().setReorderingAllowed(false); destinationTable.setOpaque(true); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); destinationTable.setHighlighters(highlighter); } // This action is called when a new selection is made on the destination // table. destinationTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { if (lastModelIndex != -1 && lastModelIndex != destinationTable.getRowCount() && !isDeleting) { Connector destinationConnector = currentChannel.getDestinationConnectors() .get(lastModelIndex); ConnectorProperties props = destinationConnectorPanel.getProperties(); ((DestinationConnectorPropertiesInterface) props).getDestinationConnectorProperties() .setResourceIds(resourceIds.get(destinationConnector.getMetaDataId())); destinationConnector.setProperties(props); } if (!loadConnector()) { if (lastModelIndex == destinationTable.getRowCount()) { destinationTable.setRowSelectionInterval(lastModelIndex - 1, lastModelIndex - 1); } else { destinationTable.setRowSelectionInterval(lastModelIndex, lastModelIndex); } } else { lastModelIndex = destinationTable.getSelectedModelIndex(); } /* * Loading the connector may have updated the current destination with incorrect * properties, so after updating lastModelIndex we need to update the * destination panel again. */ saveDestinationPanel(); checkVisibleDestinationTasks(); } } }); destinationTable.requestFocus(); // Mouse listener for trigger-button popup on the table. destinationTable.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { checkSelectionAndPopupMenu(evt); } public void mouseReleased(java.awt.event.MouseEvent evt) { checkSelectionAndPopupMenu(evt); } }); // Checks to see what to set the new row selection to based on // last index and if a new destination was added. int last = lastModelIndex; // Select each destination in turn so that the connector types can be decorated for (int row = 0; row < destinationTable.getRowCount(); row++) { destinationTable.setRowSelectionInterval(row, row); destinationConnectorPanel.decorateConnectorType(); } if (addNew) { destinationTable.setRowSelectionInterval(destinationTable.getRowCount() - 1, destinationTable.getRowCount() - 1); } else if (last == -1) { destinationTable.setRowSelectionInterval(0, 0); // Makes sure the } // event is called // when the table is // created. else if (last == destinationTable.getRowCount()) { destinationTable.setRowSelectionInterval(last - 1, last - 1); } else { destinationTable.setRowSelectionInterval(last, last); } destinationTablePane.setViewportView(destinationTable); destinationTablePane.setWheelScrollingEnabled(true); // Key Listener trigger for DEL destinationTable.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { parent.doDeleteDestination(); } } public void keyReleased(KeyEvent e) { } public void keyTyped(KeyEvent e) { } }); destinationTable.addMouseWheelListener(new MouseWheelListener() { public void mouseWheelMoved(MouseWheelEvent e) { destinationTablePane.getMouseWheelListeners()[0].mouseWheelMoved(e); } }); }
From source file:base.BasePlayer.Main.java
void setButtons() { try {/*from ww w . j ava 2 s . c om*/ // filemenu.setFont(font); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.NORTHWEST; c.insets = new Insets(1, 4, 4, 2); //c.insets = new Insets(5, 5, 2, 5); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; /* opensamples.setMargin(new Insets(0, 0, 0,0)); opensamples.setPreferredSize(buttonDimension); addtracks.setMargin(new Insets(0, 0, 0, 0)); addtracks.setPreferredSize(buttonDimension); addcontrols.setMargin(new Insets(0, 0, 0, 0)); addcontrols.setPreferredSize(buttonDimension); */ menubar.setOpaque(true); panel.add(menubar, c); c.gridx = 1; setbut = new JButton("", settingsIcon); setbut.setToolTipText("Settings"); setbut.setOpaque(false); setbut.setContentAreaFilled(false); setbut.setBackground(Main.panel.getBackground()); setbut.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { Settings.frame.setLocation( frame.getLocationOnScreen().x + frame.getWidth() / 2 - Settings.frame.getWidth() / 2, frame.getLocationOnScreen().y + frame.getHeight() / 6); Settings.frame.setState(JFrame.NORMAL); Settings.frame.setVisible(true); } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { setbut.setOpaque(true); Main.setbut.setBackground(Color.white); Main.setbut.revalidate(); } @Override public void mouseExited(MouseEvent e) { setbut.setOpaque(false); Main.setbut.revalidate(); } }); setbut.setBorder(null); c.insets = new Insets(0, 2, 0, 0); menubar.add(setbut, c); // c.gridx = 1; // c.gridx = 2; // c.gridx = 3; // zoomout.setMargin(new Insets(0, 0, 0, 0)); // panel.add(zoomout, c); /* JMenuItem empty2 = new JMenuItem(""); empty2.setEnabled(false); menubar.add(empty2); c.gridx = 4;*/ // chromosomeDropdown.setPreferredSize(buttonDimension); // panel.add(chromosomeDropdown, c); // c.gridx = 5; // back.setMargin(new Insets(0, 0, 0, 0)); // forward.setMargin(new Insets(0, 0, 0, 0)); // back.setPreferredSize(new Dimension(back.getFontMetrics(back.getFont()).stringWidth("<")+10,(int)fieldDimension.getHeight())); // forward.setPreferredSize(new Dimension(forward.getFontMetrics(forward.getFont()).stringWidth("<")+10,(int)fieldDimension.getHeight())); //back.setMinimumSize(new Dimension(back.getFontMetrics(back.getFont()).stringWidth("<")+10,(int)fieldDimension.getHeight())); // forward.setMinimumSize(new Dimension(forward.getFontMetrics(forward.getFont()).stringWidth("<")+10,(int)fieldDimension.getHeight())); // panel.add(back, c); // c.gridx = 7; // panel.add(forward, c); chromosomeDropdown.setMaximumRowCount(25); chromosomeDropdown.setEnabled(true); chromosomeDropdown.addActionListener(ChromoDropActionListener); chromosomeDropdown.addMouseListener(this); c.gridwidth = 10; c.gridx = 0; c.gridy = 1; bedScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); bedScroll.getViewport().setPreferredSize(bedDimensions); drawScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); drawScroll.getViewport().setPreferredSize(drawDimensions); chromScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); chromScroll.getViewport().setPreferredSize(chromDimensions); drawScroll.getVerticalScrollBar().setAutoscrolls(false); // chromScroll.getViewport().setPreferredSize(new Dimension(drawWidth,chromHeight-20)); // drawScroll.setBorder(BorderFactory.createEmptyBorder()); //chromScroll.setBorder(BorderFactory.createLoweredBevelBorder()); // drawScroll.setBorder(BorderFactory.createLoweredBevelBorder()); // bedScroll.setBorder(BorderFactory.createLoweredBevelBorder()); // chromScroll.setBorder(BorderFactory.createEmptyBorder()); // bedScroll.setBorder(BorderFactory.createEmptyBorder()); controlScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); controlScroll.getViewport().setPreferredSize(bedDimensions); controlScroll.getViewport().add(controlDraw); controlDraw.setVisible(false); controlScroll.setVisible(false); chromScroll.setBorder(BorderFactory.createEmptyBorder()); drawScroll.setBorder(BorderFactory.createEmptyBorder()); bedScroll.setBorder(BorderFactory.createLoweredBevelBorder()); controlScroll.setBorder(BorderFactory.createLoweredBevelBorder()); addSplit(chromosomeDropdown.getItemAt(0)); chromScroll.getViewport().add(chromDraw); drawScroll.getViewport().add(drawCanvas); drawScroll.addMouseListener(this); bedCanvas = new BedCanvas(drawWidth, 200); bedScroll.getViewport().add(bedCanvas); frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH); c.weightx = 1.0; c.weighty = 1.0; c.fill = GridBagConstraints.BOTH; trackPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, bedScroll, controlScroll); trackPane.setUI(new BasicSplitPaneUI() { public BasicSplitPaneDivider createDefaultDivider() { return new BasicSplitPaneDivider(this) { private static final long serialVersionUID = 1L; public void setBorder(Border b) { } @Override public void paint(Graphics g) { g.setColor(Color.lightGray); g.fillRect(0, 0, getSize().width, getSize().height); super.paint(g); } }; } }); trackPane.setBorder(null); trackPane.setDividerSize(0); trackPane.setPreferredSize(drawDimensions); trackPane.setResizeWeight(0.0); trackPane.setContinuousLayout(true); trackPane.setVisible(false); varpane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, trackPane, drawScroll); varpane.setUI(new BasicSplitPaneUI() { public BasicSplitPaneDivider createDefaultDivider() { return new BasicSplitPaneDivider(this) { private static final long serialVersionUID = 1L; public void setBorder(Border b) { } @Override public void paint(Graphics g) { g.setColor(Color.lightGray); g.fillRect(0, 0, getSize().width, getSize().height); super.paint(g); } }; } }); varpane.setBorder(null); varpane.setDividerSize(0); varpane.setPreferredSize(drawDimensions); varpane.setResizeWeight(0.0); varpane.setContinuousLayout(true); bedScroll.setVisible(false); controlScroll.setVisible(false); chrompan = new JPanel() { private static final long serialVersionUID = 1L; protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Draw.sidecolor); g.fillRect(0, 0, this.getWidth(), this.getHeight()); g.setColor(Color.gray); g.fillRect(0, 0, 3, this.getHeight()); g.setColor(Color.lightGray); g.fillRect(2, 0, 2, this.getHeight()); } }; chrompan.setLayout(new GridBagLayout()); GridBagConstraints gb = new GridBagConstraints(); gb.anchor = GridBagConstraints.NORTHWEST; gb.insets = new Insets(2, 10, 2, 2); gb.gridx = 0; gb.gridy = 0; gb.gridwidth = 1; gb.fill = GridBagConstraints.HORIZONTAL; refDropdown.setBackground(Color.white); refDropdown.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.lightGray)); refDropdown.setBorder(BorderFactory.createCompoundBorder(refDropdown.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); geneDropdown.setBackground(Color.white); geneDropdown.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.lightGray)); geneDropdown.setBorder(BorderFactory.createCompoundBorder(geneDropdown.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); geneDropdown.addActionListener(annoDropActionListener); JLabel refLabel = new JLabel("Reference genome:"); JLabel geneLabel = new JLabel("Gene annotation:"); chromLabel.setName("header"); chrompan.add(chromLabel, gb); gb.gridy++; chrompan.add(new JSeparator(), gb); gb.gridy++; gb.insets = new Insets(0, 10, 0, 2); chrompan.add(refLabel, gb); gb.gridy++; chrompan.add(refDropdown, gb); gb.gridy++; chrompan.add(geneLabel, gb); gb.gridy++; chrompan.add(geneDropdown, gb); gb.gridy++; gb.insets = new Insets(20, 10, 0, 2); JLabel memory = new JLabel("Memory usage:"); memory.setName("header"); chrompan.add(memory, gb); gb.insets = new Insets(0, 10, 0, 2); gb.gridy++; chrompan.add(memLabel, gb); gb.weightx = 1; gb.weighty = 1; gb.gridwidth = GridBagConstraints.REMAINDER; chrompan.add(new JLabel(), gb); chrompan.setMinimumSize(new Dimension(1, 1)); chrompan.addComponentListener(this); upPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, chrompan, chromScroll); drawScroll.addComponentListener(this); //upPanel.setBorder(BorderFactory.createLoweredBevelBorder()); upPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.white)); upPanel.setDividerLocation(Main.sidebarWidth - 2); chrompan.setBackground(Draw.sidecolor); BasicSplitPaneUI chromPaneUI = (BasicSplitPaneUI) upPanel.getUI(); chromPaneDivider = chromPaneUI.getDivider(); chromPaneDivider.addMouseListener(this); upPanel.setDividerSize(3); upPanel.setUI(new BasicSplitPaneUI() { public BasicSplitPaneDivider createDefaultDivider() { return new BasicSplitPaneDivider(this) { private static final long serialVersionUID = 1L; public void setBorder(Border b) { } @Override public void paint(Graphics g) { g.setColor(Color.lightGray); g.fillRect(0, 0, getSize().width, getSize().height); super.paint(g); } }; } }); splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upPanel, varpane); splitPane.setUI(new BasicSplitPaneUI() { public BasicSplitPaneDivider createDefaultDivider() { return new BasicSplitPaneDivider(this) { private static final long serialVersionUID = 1L; public void setBorder(Border b) { } @Override public void paint(Graphics g) { g.setColor(Color.lightGray); g.fillRect(0, 0, getSize().width, getSize().height); super.paint(g); } }; } }); BasicSplitPaneUI basicSplitPaneUI = (BasicSplitPaneUI) splitPane.getUI(); splitPaneDivider = basicSplitPaneUI.getDivider(); // splitPaneDivider.addMouseListener(this); basicSplitPaneUI = (BasicSplitPaneUI) trackPane.getUI(); trackPaneDivider = basicSplitPaneUI.getDivider(); // trackPaneDivider.addMouseListener(this); BasicSplitPaneUI splitPaneUI = (BasicSplitPaneUI) varpane.getUI(); varPaneDivider = splitPaneUI.getDivider(); // varPaneDivider.addMouseListener(this); splitPane.setDividerSize(3); splitPane.setPreferredSize(drawDimensions); splitPane.setContinuousLayout(true); panel.add(splitPane, c); add(panel, c); openvcfs.addActionListener(this); openbams.addActionListener(this); addtracks.addActionListener(this); addcontrols.addActionListener(this); openProject.addActionListener(this); saveProject.addActionListener(this); saveProjectAs.addActionListener(this); dosomething.addActionListener(this); clear.addActionListener(this); // drawScroll.getVerticalScrollBar().addMouseMotionListener(this); drawScroll.getVerticalScrollBar().addMouseListener(this); drawScroll.getVerticalScrollBar().addMouseMotionListener(this); drawScroll.getVerticalScrollBar().addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { Draw.setGlasspane(true); if (e.getWheelRotation() < 0) { if (drawCanvas.drawVariables.visiblestart > 0) { drawCanvas.drawVariables.visiblestart--; } Draw.setScrollbar((int) (drawCanvas.drawVariables.visiblestart * drawCanvas.drawVariables.sampleHeight)); } else { if (drawCanvas.drawVariables.visiblestart + drawCanvas.drawVariables.visiblesamples < Main.samples) { drawCanvas.drawVariables.visiblestart++; } Draw.setScrollbar((int) (drawCanvas.drawVariables.visiblestart * drawCanvas.drawVariables.sampleHeight)); } } } ); drawScroll.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent event) { //System.out.println(drawCanvas.drawVariables.visiblestart +" " +(short)(Main.drawScroll.getVerticalScrollBar().getValue()/drawCanvas.drawVariables.sampleHeight)); if (drawCanvas.drawVariables.visiblestart != (short) (Main.drawScroll.getVerticalScrollBar() .getValue() / drawCanvas.drawVariables.sampleHeight)) { if (!drawCanvas.sidebar) { drawCanvas.drawVariables.visiblestart = (short) (Main.drawScroll.getVerticalScrollBar() .getValue() / drawCanvas.drawVariables.sampleHeight); } if (drawCanvas.splits.size() > 1) { for (int i = 0; i < drawCanvas.splits.size(); i++) { drawCanvas.splits.get(i).updateReads = true; } } else { Draw.updateReads = true; Draw.updatevars = true; } Draw.updatevars = true; Main.drawCanvas.repaint(); } } }); zoomout.addActionListener(this); FileRead.head = new VarNode(0, (byte) 0, "N", (short) 0, (short) 0, false, (float) 0, (float) 0, null, null, new Sample("", (short) 1, null), null, null); drawCanvas.current = FileRead.head; frame.addComponentListener(this); frame.addMouseListener(this); frame.setGlassPane(glassPane); glassPane.setOpaque(false); glassPane.setVisible(false); positionField.setText("chr1:1-" + MethodLibrary.formatNumber(drawCanvas.splits.get(0).chromEnd)); positionField.setToolTipText("Current chromosomal region"); widthLabel.setText(MethodLibrary.formatNumber(drawCanvas.splits.get(0).chromEnd) + "bp"); widthLabel.setToolTipText("Current region width in base pairs"); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.nuclos.client.relation.EntityRelationshipModelEditPanel.java
private void createMouseWheelListener() { graphComponent.getGraphControl().addMouseWheelListener(new MouseWheelListener() { @Override// w ww .j av a2s .co m public void mouseWheelMoved(MouseWheelEvent e) { if (e.getModifiers() == InputEvent.CTRL_MASK) { if (e.getWheelRotation() <= 0) { graphComponent.zoomIn(); } else { if (graphComponent.getGraph().getView().getScale() > 0.2) graphComponent.zoomOut(); } } } }); }
From source file:org.pmedv.blackboard.components.BoardEditor.java
/** * Setup the listeners/*from w ww . j av a2 s .co 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:savant.view.swing.BookmarkSheet.java
public BookmarkSheet(Container c) { // set the layout of the data sheet c.setLayout(new BorderLayout()); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); /**// ww w . j av a 2 s . c o m * Create a toolbar. */ JMenuBar toolbar = new JMenuBar(); toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS)); c.add(toolbar, BorderLayout.NORTH); JButton previousButton = new JButton(); previousButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.UP)); previousButton.setToolTipText("Go to previous bookmark [ Ctrl+( ]"); previousButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); previousButton.putClientProperty("JButton.segmentPosition", "first"); previousButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToPreviousBookmark(); } }); toolbar.add(previousButton); JButton nextButton = new JButton(); nextButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.DOWN)); nextButton.setToolTipText("Go to next bookmark [ Ctrl+) ]"); nextButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); nextButton.putClientProperty("JButton.segmentPosition", "last"); nextButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToNextBookmark(); } }); toolbar.add(nextButton); JButton goButton = new JButton("Go"); goButton.setToolTipText("Go to selected bookmark"); goButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); goButton.putClientProperty("JButton.segmentPosition", "only"); goButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToSelectedBookmark(); } }); toolbar.add(goButton); toolbar.add(Box.createGlue()); addButton = new JButton(); addButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.BKMK_ADD)); addButton.setToolTipText("Add bookmark for current range"); addButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); addButton.putClientProperty("JButton.segmentPosition", "first"); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { BookmarkController fc = BookmarkController.getInstance(); fc.addCurrentRangeToBookmarks(); } }); toolbar.add(addButton); JButton deleteButton = new JButton(); deleteButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.BKMK_RM)); deleteButton.setToolTipText("Delete selected bookmarks"); deleteButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); deleteButton.putClientProperty("JButton.segmentPosition", "last"); deleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { BookmarkController fc = BookmarkController.getInstance(); int[] selectedRows = table.getSelectedRows(); Arrays.sort(selectedRows); boolean delete = false; if (selectedRows.length > 0 && confirmDelete) { Object[] options = { "Yes", "No", "Yes, don't ask again" }; JLabel message = new JLabel( "Are you sure you want to delete " + selectedRows.length + " item(s)?"); message.setPreferredSize(new Dimension(300, 20)); int confirmDeleteDialog = JOptionPane.showOptionDialog(DialogUtils.getMainWindow(), message, "Confirm Delete", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (confirmDeleteDialog == 0) { delete = true; } else if (confirmDeleteDialog == 2) { delete = true; confirmDelete = false; } } else if (selectedRows.length > 0 && !confirmDelete) { delete = true; } if (delete) { for (int i = selectedRows.length - 1; i >= 0; i--) { fc.removeBookmark(selectedRows[i]); } } } }); toolbar.add(deleteButton); toolbar.add(Box.createGlue()); JButton loadButton = new JButton(); loadButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.OPEN)); loadButton.setToolTipText("Load bookmarks from file"); loadButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); loadButton.putClientProperty("JButton.segmentPosition", "first"); loadButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loadBookmarks(table); } }); toolbar.add(loadButton); JButton saveButton = new JButton(); saveButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SAVE)); saveButton.setToolTipText("Save bookmarks to file"); saveButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); saveButton.putClientProperty("JButton.segmentPosition", "last"); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveBookmarks(table); } }); toolbar.add(saveButton); // create a table (the most important component) table = new JTable(new BookmarksTableModel()); table.setAutoCreateRowSorter(true); table.setFillsViewportHeight(true); table.setShowGrid(true); table.setGridColor(Color.gray); //table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); // add the table and its header to the subpanel c.add(table.getTableHeader()); add(table); final JScrollPane sp = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp.setWheelScrollingEnabled(false); sp.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { sp.getVerticalScrollBar().setValue(sp.getVerticalScrollBar().getValue() + e.getUnitsToScroll() * 2); } }); c.add(sp); // add glue to fill the remaining space add(Box.createGlue()); }
From source file:view.WorkspacePanel.java
/** * Creates new form MiddlePanel//from w w w. java 2s .c om */ public WorkspacePanel() { initComponents(); if (Bundle.getBundle().getCurrentLocale() == null) { Bundle.getBundle().setCurrentLocale(Bundle.Locales.English); } updateText(); status = Status.READY; cl = (CardLayout) this.rightPanel.getLayout(); topToolbar.setVisible(false); bottomToolbar.setVisible(false); rightPanel.setVisible(false); clSign.setVisible(false); rightPanel.setBackground(Color.WHITE); lblText.setVisible(false); jScrollPane1.setVisible(false); btnChangeAppearance.setVisible(false); add(jMenuBar1, BorderLayout.NORTH); ToolTipManager.sharedInstance().registerComponent(jtValidation); jSplitPane1.setDividerSize(0); cbVisibleSignature.setSelected(true); lblRevision.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); clearSignatureFields(); jsImagePanel.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { if (e.isControlDown()) { e.consume(); if (e.getWheelRotation() < 0) { zoomIn(); } else { zoomOut(); } fixTempSignaturePosition(true); } } }); }