Example usage for java.awt.event MouseWheelEvent getWheelRotation

List of usage examples for java.awt.event MouseWheelEvent getWheelRotation

Introduction

In this page you can find the example usage for java.awt.event MouseWheelEvent getWheelRotation.

Prototype

public int getWheelRotation() 

Source Link

Document

Returns the number of "clicks" the mouse wheel was rotated, as an integer.

Usage

From source file:base.BasePlayer.AminoTable.java

@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    if (e.getWheelRotation() < 0) {
        tablescroll.getVerticalScrollBar().setValue(tablescroll.getVerticalScrollBar().getValue() - 16);

    } else {//w w w. j av  a 2s.c  o  m
        tablescroll.getVerticalScrollBar().setValue(tablescroll.getVerticalScrollBar().getValue() + 16);

    }

}

From source file:corelyzer.ui.CorelyzerGLCanvas.java

private void zoomSceneWithScrollWheel(final MouseWheelEvent e) {
    // FIXME MouseWheelEvent info
    /*/*from   www . jav  a2  s . c  om*/
     * 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();
}

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

private void transitionListInitializations() {
    listTransition = new JList();
    listTransition.setCellRenderer(new coloredMRMListRenderer());
    listTransition.setModel(new DefaultListModel());
    listTransition.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    _tlsl = new transitionListSelectionListener();
    listTransition.addListSelectionListener(_tlsl);
    listTransition.addMouseWheelListener(new MouseWheelListener() {
        public void mouseWheelMoved(MouseWheelEvent event) {
            int move = event.getWheelRotation();
            int curIndex = listTransition.getSelectedIndex();
            int newIndex = curIndex;
            if (move > 0) {
                newIndex = Math.min(curIndex + move, listTransition.getModel().getSize());
                listTransition.setSelectedIndex(newIndex);
            }/*from w ww .  j  av a  2 s  . c  o  m*/
            if (move < 0) {
                newIndex = Math.max(curIndex + move, 0);
                listTransition.setSelectedIndex(newIndex);
            }
            listTransition.ensureIndexIsVisible(newIndex);
        }
    });

    for (MRMTransition curTran : _mrmTransitions)
        ((DefaultListModel) listTransition.getModel()).addElement(curTran);
    listTransition.setVisible(true);
    listScrollPane.getViewport().setView(listTransition);
    listScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    listScrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
        public void adjustmentValueChanged(AdjustmentEvent ae) {
            if (!ae.getValueIsAdjusting()) {
                listTransition.repaint();
            }
        }
    });
}

From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java

/**
 * Constructs a JFreeChart panel./*from  ww  w .j  a va  2  s  . c o  m*/
 * 
 * @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:base.BasePlayer.BedCanvas.java

BedCanvas(int width, int height) {

    this.width = width;
    this.height = height;
    bufImage = MethodLibrary.toCompatibleImage(new BufferedImage((int) Main.screenSize.getWidth(),
            (int) Main.screenSize.getHeight(), BufferedImage.TYPE_INT_ARGB));
    buf = (Graphics2D) bufImage.getGraphics();
    //   buf.setRenderingHints(Draw.rh);
    nodeImage = MethodLibrary.toCompatibleImage(new BufferedImage((int) Main.screenSize.getWidth(),
            (int) Main.screenSize.getHeight(), BufferedImage.TYPE_INT_ARGB));
    nodebuf = (Graphics2D) nodeImage.getGraphics();
    //   nodebuf.setRenderingHints(Draw.rh);
    backupComposite = nodebuf.getComposite();
    buf.setFont(Draw.defaultFont);/*from   ww  w  .  ja  v a 2 s  .c o m*/
    //nodebuf.setFont(Draw.defaultFont);
    addMouseListener(this);
    addKeyListener(this);
    addMouseMotionListener(this);
    addMouseWheelListener(new MouseWheelListener() {
        public void mouseWheelMoved(MouseWheelEvent mwe) {
            bedTrack.get(hoverIndex).mouseWheel -= mwe.getWheelRotation();
            if (bedTrack.get(hoverIndex).mouseWheel > 0) {
                bedTrack.get(hoverIndex).mouseWheel = 0;
            }
            repaint();
        }
    });
}

From source file:org.forester.archaeopteryx.TreePanel.java

final public void mouseWheelMoved(final MouseWheelEvent e) {
    final int notches = e.getWheelRotation();
    if (inOvVirtualRectangle(e)) {
        if (!isInOvRect()) {
            setInOvRect(true);//from ww  w  .  j  a v a 2s. c o m
            repaint();
        }
    } else {
        if (isInOvRect()) {
            setInOvRect(false);
            repaint();
        }
    }
    if (e.isControlDown()) {
        if (notches < 0) {
            getTreeFontSet().increaseFontSize();
            getControlPanel().displayedPhylogenyMightHaveChanged(true);
        } else {
            getTreeFontSet().decreaseFontSize();
            getControlPanel().displayedPhylogenyMightHaveChanged(true);
        }
    } else if (e.isShiftDown()) {
        if ((getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED)
                || (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR)) {
            if (notches < 0) {
                for (int i = 0; i < (-notches); ++i) {
                    setStartingAngle((getStartingAngle() % TWO_PI) + ANGLE_ROTATION_UNIT);
                    getControlPanel().displayedPhylogenyMightHaveChanged(false);
                }
            } else {
                for (int i = 0; i < notches; ++i) {
                    setStartingAngle((getStartingAngle() % TWO_PI) - ANGLE_ROTATION_UNIT);
                    if (getStartingAngle() < 0) {
                        setStartingAngle(TWO_PI + getStartingAngle());
                    }
                    getControlPanel().displayedPhylogenyMightHaveChanged(false);
                }
            }
        } else {
            if (notches < 0) {
                for (int i = 0; i < (-notches); ++i) {
                    getControlPanel().zoomInY(Constants.WHEEL_ZOOM_IN_FACTOR);
                    getControlPanel().displayedPhylogenyMightHaveChanged(false);
                }
            } else {
                for (int i = 0; i < notches; ++i) {
                    getControlPanel().zoomOutY(Constants.WHEEL_ZOOM_OUT_FACTOR);
                    getControlPanel().displayedPhylogenyMightHaveChanged(false);
                }
            }
        }
    } else {
        if (notches < 0) {
            for (int i = 0; i < (-notches); ++i) {
                getControlPanel().zoomInX(Constants.WHEEL_ZOOM_IN_FACTOR,
                        Constants.WHEEL_ZOOM_IN_X_CORRECTION_FACTOR);
                getControlPanel().zoomInY(Constants.WHEEL_ZOOM_IN_FACTOR);
                getControlPanel().displayedPhylogenyMightHaveChanged(false);
            }
        } else {
            for (int i = 0; i < notches; ++i) {
                getControlPanel().zoomOutY(Constants.WHEEL_ZOOM_OUT_FACTOR);
                getControlPanel().zoomOutX(Constants.WHEEL_ZOOM_OUT_FACTOR,
                        Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR);
                getControlPanel().displayedPhylogenyMightHaveChanged(false);
            }
        }
    }
    requestFocus();
    requestFocusInWindow();
    requestFocus();
}

From source file:org.nuclos.client.relation.EntityRelationshipModelEditPanel.java

private void createMouseWheelListener() {
    graphComponent.getGraphControl().addMouseWheelListener(new MouseWheelListener() {

        @Override/*w ww  . j a  v  a 2s  . 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();
                }
            }

        }
    });
}

From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java

private void rescaleFromMouseWheel(java.awt.event.MouseWheelEvent evt) {
    if (lockView) {
        return;/*  ww  w.  j  a va2s .c om*/
    }

    int notches = evt.getWheelRotation();
    if (notches < 0) {
        mouseScale /= mouseWheelSensitivity;
    } else {
        mouseScale *= mouseWheelSensitivity;
    }
    tempTransform = new Transform3D(new Matrix3d(1., 0., 0., 0., 1., 0., 0., 0., 1.),
            //sceneCenter,
            new Vector3d(0.0, 0.0, 0.0), externScale * mouseScale);
    objScale.setTransform(tempTransform);
}

From source file:pl.edu.icm.visnow.lib.basic.viewers.Viewer2D.Display2DPanel.java

private void formMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_formMouseWheelMoved
    if (!autoNormalize && !noObjects) {
        float scale = 1.0f;
        if (evt.getWheelRotation() > 0) {
            scale = 1.0f / mouseWheelSensitivity;
        } else {//from  www  .  jav a 2s  . c o m
            scale = 1.0f * mouseWheelSensitivity;
        }

        //autoCenter = false;
        root.getExternalTransform().scale(scale, scale);
        update();
        controlsFrame.update();
    }
}

From source file:processing.app.EditorTab.java

public void mouseWheelMoved(MouseWheelEvent e) {
    if (e.isControlDown()) {
        if (e.getWheelRotation() < 0) {
            editor.base.handleFontSizeChange(1);
        } else {//w  ww.  j  av a 2 s . com
            editor.base.handleFontSizeChange(-1);
        }
    } else {
        e.getComponent().getParent().dispatchEvent(e);
    }
}