Example usage for java.awt.event MouseEvent isControlDown

List of usage examples for java.awt.event MouseEvent isControlDown

Introduction

In this page you can find the example usage for java.awt.event MouseEvent isControlDown.

Prototype

public boolean isControlDown() 

Source Link

Document

Returns whether or not the Control modifier is down on this event.

Usage

From source file:EventTestPane.java

/**
 * Return a string representation of the modifiers for a MouseEvent. Note
 * that the methods called here are inherited from InputEvent.
 *///from   w  w w . j  a  va 2s.c o m
protected String mousemods(MouseEvent e) {
    int mods = e.getModifiers();
    String s = "";
    if (e.isShiftDown())
        s += "Shift ";
    if (e.isControlDown())
        s += "Ctrl ";
    if ((mods & InputEvent.BUTTON1_MASK) != 0)
        s += "Button 1 ";
    if ((mods & InputEvent.BUTTON2_MASK) != 0)
        s += "Button 2 ";
    if ((mods & InputEvent.BUTTON3_MASK) != 0)
        s += "Button 3 ";
    return s;
}

From source file:com.tradedesksoftware.ets.client.charting.ChartShiftController.java

public void mouseMoved(MouseEvent mouseEvent) {
    if (mouseEvent.isControlDown()) {
        final Rectangle scaledDataArea = chartPanel.getScreenDataArea();
        if (mouseEvent.getX() > (int) scaledDataArea.x && mouseEvent.getY() > (int) scaledDataArea.y
                && mouseEvent.getX() < (int) scaledDataArea.x + scaledDataArea.width
                && mouseEvent.getY() < (int) scaledDataArea.y + scaledDataArea.height)
            chartPanel.setCursor(MOVE);//from   w  ww  . j  a  va2 s  .co  m
        else
            chartPanel.setCursor(ARROW);
    }
}

From source file:com.tradedesksoftware.ets.client.charting.ChartShiftController.java

public void mouseDragged(MouseEvent mouseEvent) {
    if (!mouseEvent.isControlDown())
        return;/*w w w.j a  v  a2 s  .c  o m*/

    if (oldx > -1 && oldy > -1) {
        ValueAxis domAxis = getPlotAxis(chartPanel.getChart(), !axesSwaped);
        ValueAxis rngAxis = getPlotAxis(chartPanel.getChart(), axesSwaped);

        int xdif = mouseEvent.getX() - oldx;
        int ydif = mouseEvent.getY() - oldy;

        final Rectangle scaledDataArea = chartPanel.getScreenDataArea();

        double xdelta = (double) xdif * domAxis.getRange().getLength() / (scaledDataArea.width);
        double ydelta = (double) ydif * rngAxis.getRange().getLength() / (scaledDataArea.height);

        domAxis.setRange(domAxis.getLowerBound() - xdelta, domAxis.getUpperBound() - xdelta);
        rngAxis.setRange(rngAxis.getLowerBound() + ydelta, rngAxis.getUpperBound() + ydelta);
    }

    oldx = mouseEvent.getX();
    oldy = mouseEvent.getY();
}

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

@Override
public void mouseDragged(MouseEvent mouseEvent) {
    if (!mouseEvent.isControlDown()) {
        return;// w ww.j a  v a2s . c  o  m
    }

    if (oldx > -1 && oldy > -1) {
        int xdif = mouseEvent.getX() - oldx;
        int ydif = mouseEvent.getY() - oldy;

        final Rectangle2D scaledDataArea = chartPanel.getScreenDataArea();

        ValueAxis[] domAxes = getPlotAxis(chartPanel.getChart(), !axesSwaped);
        if (domAxes != null) {
            double[] xDelta = new double[domAxes.length];
            for (int i = 0; i < domAxes.length; i++) {
                xDelta[i] = xdif * domAxes[i].getRange().getLength() / (scaledDataArea.getWidth());
            }
            for (int i = 0; i < domAxes.length; i++) {
                domAxes[i].setRange(domAxes[i].getLowerBound() - xDelta[i],
                        domAxes[i].getUpperBound() - xDelta[i]);
            }
        }

        ValueAxis[] rngAxes = getPlotAxis(chartPanel.getChart(), axesSwaped);
        if (rngAxes != null) {
            double[] yDelta = new double[rngAxes.length];
            for (int i = 0; i < rngAxes.length; i++) {
                yDelta[i] = ydif * rngAxes[i].getRange().getLength() / (scaledDataArea.getHeight());
            }
            if (!onlyXShift) {
                for (int i = 0; i < rngAxes.length; i++) {
                    rngAxes[i].setRange(rngAxes[i].getLowerBound() + yDelta[i],
                            rngAxes[i].getUpperBound() + yDelta[i]);
                }
            }
        }
    }

    oldx = mouseEvent.getX();
    oldy = mouseEvent.getY();
}

From source file:gda.images.GUI.CmuCameraDisplayPanel.java

@Override
public void configure() {
    //logger.info("Cmu Camera Panel config called");
    samplePanel = new RTPCameraClient();
    samplePanel.setPreferredSize(ImageSize);
    samplePanel.setMinimumSize(ImageSize);
    samplePanel.setMaximumSize(ImageSize);
    samplePanel.getImageModifier().setDisplayCrossHair(true);

    samplePanel.addMouseListener(new MouseListener() {

        @Override/*  w  ww.j  a v  a  2s  . c o  m*/
        public void mouseClicked(MouseEvent mevt) {
            //logger.info("mouse clicked at " + mevt.getLocationOnScreen());
            //samplePanel.setCentre(mevt.getLocationOnScreen());
            if (mevt.isControlDown()) {
                Point p = mevt.getPoint();
                x = p.x;
                y = p.y;
                samplePanel.getImageModifier().setCentre(p);
                save();
            }
            //samplePanel.revalidate();

        }

        @Override
        public void mouseEntered(MouseEvent arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void mouseExited(MouseEvent arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void mousePressed(MouseEvent arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void mouseReleased(MouseEvent arg0) {
            // TODO Auto-generated method stub

        }

    });
    try {
        config = LocalParameters.getXMLConfiguration();
    } catch (ConfigurationException e) {
        logger.error("unable to configure beam centre values ", e);

    } catch (IOException e) {
        logger.error("unable to read beam centre values ", e);
    }
    this.load();
    //samplePanel.setDisplayCrossHair(true);
    //samplePanel.setDisplayBeamSize(true);

    //
    samplePanel.getImageModifier().setCentre(new Point(x, y));
    //samplePanel.setBeamSize(new Point(50, 50), new Point(200, 200));

    this.setLayout(new BorderLayout());
    this.add(samplePanel, BorderLayout.CENTER);
    this.add(getButtonPanel(), BorderLayout.SOUTH);

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            CmuCameraDisplayPanel.this.add(samplePanel);
            //samplePanel.setXScale(0.9);
            //samplePanel.setYScale(1.1);
            //samplePanel.setDisplayScale(true);
            //samplePanel.start();
        }
    });

    videoReceiver.addImageListener(this);
}

From source file:net.sourceforge.entrainer.jfreechart.UnitChart.java

private void init() {
    chart = new JFreeChart(getXYPlot());
    chartPanel = new ChartPanel(chart);

    chartPanel.addChartMouseListener(new ChartMouseListener() {
        public void chartMouseClicked(ChartMouseEvent event) {
        }//from w  ww  .  ja  v a 2  s .  c o  m

        public void chartMouseMoved(ChartMouseEvent event) {
            if (event.getEntity() != null
                    && (currentEntity == null || !currentEntity.equals(event.getEntity()))) {
                if (event.getEntity() instanceof XYItemEntity) {
                    showPopup((XYItemEntity) event.getEntity());
                }
            } else if (event.getEntity() == null && timer != null) {
                timer.dismiss();
                timer = null;
                currentEntity = null;
            }
        }
    });

    getContentPane().add(chartPanel);

    addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.isControlDown() && e.getClickCount() == 1) {
                openBrowser(getLocalDocAddress());
            }
        }
    });
}

From source file:figs.treeVisualization.gui.TimeAxisTree2DPanel.java

/**
 * Handle mouse clicked events.//from  w w  w  .j  av  a 2  s . c  om
 * <P>
 * Overrides the parent method because we have two seperate areas.
 */
@Override
public void mouseClicked(MouseEvent evt) {
    Point2D point = evt.getPoint();
    boolean rightButton = SwingUtilities.isRightMouseButton(evt) || evt.isControlDown();

    if (this.fLeftTreeArea.contains(point)) {
        /** In tree area. */
        Element elem = this.fTreePainter.java2DToClade(point, this.fLeftTreeArea, this.getMouseClickDistance());
        if (elem == null) {
            /** Unselect every thing. */
            if (rightButton && this.fSelectedCladeList != null) {
                this.fSelectedCladeList = null;
                this.notifyTree2DPanelChangeListeners(
                        new Tree2DPanelChangeEvent(this, Tree2DPanelChangeEvent.ITEM_SELECTED));
            }
            return;
        }

        if (rightButton) {
            this.fSelectedCladeList = new LinkedList<Element>();
            this.fSelectedCladeList.add(elem);
            this.notifyTree2DPanelChangeListeners(
                    new Tree2DPanelChangeEvent(this, Tree2DPanelChangeEvent.ITEM_SELECTED));
        } else {
            /** Unselect every thing and add only this one. */
            this.fSelectedCladeList.clear();
            this.fSelectedCladeList.add(elem);

            /** Now show a CladeEditorDialog */
            CladeEditorDialog.showDialog(this, elem);
        }
    } else {
        /** In time axis area */
    }
}

From source file:net.sourceforge.entrainer.gui.socket.EntrainerSocketConnector.java

private void init() {
    initConnector();//from  w  w w .  jav a  2s .  com
    initListeners();
    wireSliders();
    initGui();

    addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.isControlDown() && e.getClickCount() == 1) {
                openBrowser(getLocalDocAddress());
            }
        }
    });
}

From source file:eu.esdihumboldt.hale.ui.views.styledmap.tool.InstanceTool.java

/**
 * @see AbstractMapTool#click(MouseEvent, GeoPosition)
 *//*  w  ww.ja v  a2s . c  o  m*/
@Override
public void click(MouseEvent me, GeoPosition pos) {
    if (me.getClickCount() == 2) {
        mapKit.setCenterPosition(pos);
        mapKit.setZoom(mapKit.getMainMap().getZoom() - 1);
    } else if (me.getClickCount() == 1) {
        if (me.isAltDown() && getPositions().size() < 1) {
            // add pos
            addPosition(pos);
        } else if (getPositions().size() == 1) {
            // finish box selection
            // action & reset
            addPosition(pos);

            // action
            try {
                List<Point2D> points = getPoints();
                Rectangle rect = new Rectangle((int) points.get(0).getX(), (int) points.get(0).getY(), 0, 0);
                rect.add(points.get(1));

                updateSelection(rect, me.isControlDown() || me.isMetaDown(), true);
            } catch (IllegalGeoPositionException e) {
                log.error("Error calculating selection box", e); //$NON-NLS-1$
            }

            reset();
        } else {
            // click selection
            reset();

            updateSelection(me.getPoint(), me.isControlDown() || me.isMetaDown(), true);
        }
    }
}

From source file:net.java.treaty.viz.ContractView.java

private void updateGraphView() {

    class Updater extends SwingWorker<VisualizationViewer, Object> {
        @Override//from w  w  w  .j a va  2 s.com
        public VisualizationViewer doInBackground() {
            Layout<Node, Edge> layout = new ContractLayout(graph, ContractView.this.getSize());
            final VisualizationViewer<Node, Edge> vv = new VisualizationViewer<Node, Edge>(layout);

            configureRenderer(vv.getRenderContext());

            // configureRenderer(vv.getRenderContext(),instance);
            vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
            vv.setPreferredSize(ContractView.this.getSize()); // Sets the
            // viewing
            // area size
            vv.setBackground(Color.white);

            // deactivate if CTRL is pressed, then stretcher is in charge
            DefaultModalGraphMouse gm = new DefaultModalGraphMouse() {
                @Override
                public void mousePressed(MouseEvent e) {
                    if (!e.isControlDown()) {
                        super.mousePressed(e);
                    }
                }

                @Override
                public void mouseReleased(MouseEvent e) {
                    if (!e.isControlDown()) {
                        super.mouseReleased(e);
                    }
                }
            };
            gm.setMode(edu.uci.ics.jung.visualization.control.ModalGraphMouse.Mode.ANNOTATING);
            vv.setGraphMouse(gm);
            vv.addMouseListener(new Stretcher());

            vv.setVertexToolTipTransformer(new Transformer<Node, String>() {
                @Override
                public String transform(Node v) {
                    if (v instanceof ResourceNode) {
                        ResourceNode rn = (ResourceNode) v;
                        return getToolTip(rn.resource);
                    } else if (v instanceof CompositionNode) {
                        CompositionNode rn = (CompositionNode) v;
                        return getToolTip(rn.type, rn.condition);
                    } else if (v instanceof EndNode) {
                        EndNode rn = (EndNode) v;
                        return getToolTip(rn.connector);
                    } else if (v instanceof RelationshipConditionNode) {
                        RelationshipConditionNode rn = (RelationshipConditionNode) v;
                        return getToolTip(rn.condition);
                    } else if (v instanceof ExistsConditionNode) {
                        ExistsConditionNode rn = (ExistsConditionNode) v;
                        return getToolTip(rn.condition);
                    } else if (v instanceof PropertyConditionNode) {
                        PropertyConditionNode rn = (PropertyConditionNode) v;
                        return getToolTip(rn.condition);
                    }

                    else
                        return null;
                }
            });
            return vv;
        }

        @Override
        protected void done() {
            try {
                VisualizationViewer vv = get();
                ContractView.this.removeAll();
                ContractView.this.add(vv, BorderLayout.CENTER);
                ContractView.this.revalidate();
                ContractView.this.repaint();
                ContractView.this.invalidate();
            } catch (Exception ignore) {
                ignore.printStackTrace();
            }
        }

    }
    ;

    new Updater().execute();
    ContractView.this.revalidate();
    ContractView.this.repaint();
    ContractView.this.invalidate();

}