List of usage examples for java.awt.event MouseWheelEvent getPoint
public Point getPoint()
From source file:edu.purdue.cc.bionet.ui.HeatMap.java
/** * The mouseWheelMoved method of the MouseWheelListener interface. * /* w ww .j ava 2s . co m*/ * @param e The event which triggered this action. */ public void mouseWheelMoved(MouseWheelEvent e) { this.scale((float) Math.pow(1.25, -e.getWheelRotation()), e.getPoint()); }
From source file:edu.purdue.cc.bionet.ui.GraphVisualizer.java
/** * Performs the necessary actions to set up the Graph. *//*w ww. j av a 2s .com*/ protected void setup() { this.graph = (UndirectedSparseGraph<V, E>) this.getGraphLayout().getGraph(); this.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<V>()); // this.getRenderContext( ).setEdgeLabelTransformer( new ToStringLabeller<E>( )); this.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); PluggableGraphMouse mouse = new PluggableGraphMouse() { public void mouseWheelMoved(MouseWheelEvent e) { scale((float) Math.pow(1.25, -e.getWheelRotation()), e.getPoint()); } }; mouse.add(new PickingGraphMousePlugin()); mouse.add(new PickingGraphMousePlugin(-1, InputEvent.BUTTON1_MASK | InputEvent.CTRL_MASK)); this.setGraphMouse(mouse); this.getPickedVertexState().addItemListener(this); this.getPickedEdgeState().addItemListener(this); this.addMouseListener(this); this.addComponentListener(new LayoutScaler()); // set up coloring Transformer v = new Transformer<V, Paint>() { public Paint transform(V v) { if (getPickedVertexState().isPicked(v)) { return pickedVertexPaint; } else { if (commonNeighborIndicator && isCommonNeighbor(v)) { return commonNeighborPaint; } else { return vertexPaint; } } } }; Transformer vo = new Transformer<V, Paint>() { public Paint transform(V v) { if (getPickedVertexState().isPicked(v)) { return pickedVertexOutline; } else { if (commonNeighborIndicator && isCommonNeighbor(v)) { return commonNeighborOutline; } else { return vertexOutline; } } } }; this.getRenderContext().setVertexFillPaintTransformer(v); this.getRenderContext().setVertexDrawPaintTransformer(vo); Transformer e = new Transformer<E, Paint>() { public Paint transform(E e) { if (getPickedEdgeState().isPicked(e)) { return pickedEdgePaint; } else { return edgePaint; } } }; this.getRenderContext().setEdgeDrawPaintTransformer(e); this.setPickedLabelColor(this.pickedLabelColor); this.commonNeighbors = new NeighborCollection<V, E>(this); }
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 w w w . ja v a 2 s. 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:corelyzer.ui.CorelyzerGLCanvas.java
private void scrollSceneWithScrollWheel(final MouseWheelEvent e) { int scrollAmount = e.getScrollAmount(); int wheelRotation = e.getWheelRotation(); int ample = 3; Point currentPos = e.getPoint(); int dY = ample * scrollAmount * wheelRotation; float sy;// w w w .j a v a2 s . c o m float h; canvasLock.lock(); { h = SceneGraph.getCanvasHeight(canvasId); sy = h / canvas.getHeight(); SceneGraph.panScene(0, dY * sy); this.convertMousePointToSceneSpace(currentPos, scenePos); SceneGraph.positionMouse(scenePos[0], scenePos[1]); } canvasLock.unlock(); prePos = currentPos; }
From source file:corelyzer.ui.CorelyzerGLCanvas.java
private void zoomSceneWithScrollWheel(final MouseWheelEvent e) { // FIXME MouseWheelEvent info /*/*from w w w . j a v a 2s . c o m*/ * System.out.println(e); * * String mesg = "Component: " + e.getComponent(); mesg += ", id: " + * e.getID(); mesg += ", when: " + e.getWhen(); mesg += ", modifiers: " * + e.getModifiers(); mesg += ", x: " + e.getX(); mesg += ", y: " + * e.getY(); mesg += ", clickCount: " + e.getClickCount(); mesg += * ", scrollType: " + e.getScrollType(); mesg += ", scrollAmount: " + * e.getScrollAmount(); mesg += ", wheelRot: " + e.getWheelRotation(); * * System.out.println(mesg); */ // -- int scrollAmount = e.getScrollAmount(); int wheelRotation = e.getWheelRotation(); Point mousePos = e.getPoint(); /* * // int scrollType = e.getScrollType(); // int scrollUnit = * e.getUnitsToScroll(); * * System.out.println("---- ScrollAmount: " + scrollAmount); * System.out.println("---- ScrollType: " + scrollType); * System.out.println("---- ScrollUnit: " + scrollUnit); * System.out.println("---- WheelRotation: " + wheelRotation); * System.out.println("---- Mouse Location: " + mousePos); */ // determine what point to zoom in or out on float cp[] = { 0.0f, 0.0f }; // canvas position x,y float sc[] = { 0.0f, 0.0f }; // scene center x,y float s; // scale factor // float w; // canvas width canvasLock.lock(); { this.convertMousePointToSceneSpace(mousePos, cp); sc[0] = SceneGraph.getSceneCenterX(); sc[1] = SceneGraph.getSceneCenterY(); /* * System.out.println("Mouse Position Translated to " + cp[0] + ", " * + cp[1]); * * System.out.println("Difference from center " + (cp[0] - sc[0]) + * ", " + (cp[1] - sc[1])); */ // each amount is approximately 5% if (wheelRotation <= 0) { s = (float) Math.pow(.95, scrollAmount); } else { s = (float) Math.pow(1.05f, scrollAmount); } // System.out.println("Scale Factor " + s); SceneGraph.scaleScene(s); // mouse in same place in screen, used to determine pan amount float ncp[] = { 0.0f, 0.0f }; this.convertMousePointToSceneSpace(mousePos, ncp); // System.out.println("New Pos of mouse point after scale " + ncp[0] // + // ", " + ncp[1]); ncp[0] = ncp[0] - cp[0]; ncp[1] = ncp[1] - cp[1]; // System.out.println("Difference of " + ncp[0] + ", " + ncp[1]); SceneGraph.panScene(-ncp[0], -ncp[1]); } canvasLock.unlock(); }