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:ch.zhaw.iamp.rct.ui.GrammarWindow.java

private void zoomSliderMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_zoomSliderMouseWheelMoved
    zoomSlider.setValue(zoomSlider.getValue() - evt.getWheelRotation() * 4);
}

From source file:ch.zhaw.iamp.rct.ui.GrammarWindow.java

private void graphPanelWrapperMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_graphPanelWrapperMouseWheelMoved
    zoomSlider.setValue(zoomSlider.getValue() - evt.getWheelRotation() * 4);
}

From source file:edu.purdue.cc.bionet.ui.GraphVisualizer.java

/**
 * Performs the necessary actions to set up the Graph.
 */// w  w  w .  j av a  2 s .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:Filter3dTest.java

public void mouseWheelMoved(MouseWheelEvent e) {
    mouseHelper(MOUSE_WHEEL_UP, MOUSE_WHEEL_DOWN, e.getWheelRotation());
}

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 {/* w  w w.  j a  v  a2  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: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();/* w w w.j a  v  a 2 s . co 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:base.BasePlayer.BedTable.java

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

    } else {/*  w  w  w. jav  a 2s  .  com*/
        tablescroll.getVerticalScrollBar().setValue(tablescroll.getVerticalScrollBar().getValue() + 16);

    }
    repaint();

}

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;//from w  ww .  j a v  a2s .com
    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: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  w  w .  ja  v a  2 s .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:net.sf.firemox.clickable.target.card.MCard.java

public void mouseWheelMoved(MouseWheelEvent e) {
    // Update mouse wheel layout only if this card is in play with nested cards
    if (getIdZone() == IdZones.PLAY && getComponentCount() > 1) {
        final LayoutManager layoutManager = getLayout();
        if (layoutManager != null && layoutManager instanceof AttachmentLayout
                && e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
            if (e.getWheelRotation() < 0) {
                ((AttachmentLayout) layoutManager).decreaseCardLayout(-e.getWheelRotation());
            } else {
                ((AttachmentLayout) layoutManager).increaseCardLayout(e.getWheelRotation());
            }// w  ww.j  av a2  s.  co  m
        }
        doLayout();
        getParent().doLayout();
        getContainer().doLayout();
    }
}