Example usage for java.awt.event MouseWheelEvent consume

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

Introduction

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

Prototype

public void consume() 

Source Link

Document

Consumes this event so that it will not be processed in the default manner by the source which originated it.

Usage

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  va2  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 www.  j  a v a2  s .  com

    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:view.WorkspacePanel.java

/**
 * Creates new form MiddlePanel/*  w w  w .  j a  va 2  s .co m*/
 */
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);
            }
        }
    });
}