List of usage examples for java.awt.event MouseWheelEvent getModifiers
@Deprecated(since = "9") public int getModifiers()
From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java
@Override public void mouseWheelMoved(final MouseWheelEvent e) { if ((e.getModifiers() & MouseEvent.CTRL_MASK) != 0) { final int rotation = e.getWheelRotation(); final Point point = e.getPoint(); final Rectangle rect = this.hexMapPanel.getVisibleRect(); final HexPosition focusedNumber = this.hexMapPanel.getHexPosition(e.getPoint()); if (rotation < 0) { menuViewZoomInActionPerformed(null); } else {//from ww w. ja v a 2s. c o m menuViewZoomOutActionPerformed(null); } final float cellx = this.hexMapPanel.getHexEngine().calculateX(focusedNumber.getColumn(), focusedNumber.getRow()); final float celly = this.hexMapPanel.getHexEngine().calculateY(focusedNumber.getColumn(), focusedNumber.getRow()); final float cellw = this.hexMapPanel.getHexEngine().getCellWidth() * this.hexMapPanel.getHexEngine().getScaleX(); final float cellh = this.hexMapPanel.getHexEngine().getCellHeight() * this.hexMapPanel.getHexEngine().getScaleY(); final float dx = cellx + cellw / 2 - point.x; final float dy = celly + cellh / 2 - point.y; rect.setLocation(Math.round(rect.x + dx), Math.round(rect.y + dy)); this.hexMapPanel.scrollRectToVisible(rect); } }
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();/* ww w . j a v a2 s . c om*/ 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 ww w . j ava 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:org.nuclos.client.relation.EntityRelationshipModelEditPanel.java
private void createMouseWheelListener() { graphComponent.getGraphControl().addMouseWheelListener(new MouseWheelListener() { @Override//from w w w. j a v a 2 s. c om 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(); } } } }); }