Example usage for java.awt.event MouseEvent isShiftDown

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

Introduction

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

Prototype

public boolean isShiftDown() 

Source Link

Document

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

Usage

From source file:com.diversityarrays.kdxplore.chartcommon.KDXploreChartPanel.java

@Override
public void mousePressed(MouseEvent e) {
    if (e.isShiftDown() || shiftDownatStart) {
        super.mousePressed(e);
        shiftDownatStart = true;//from  w w w.j a va  2s  . com
    } else {
        super.mousePressed(e);
    }
}

From source file:com.diversityarrays.kdxplore.chartcommon.KDXploreChartPanel.java

@Override
public void mouseDragged(MouseEvent e) {
    if (e.isShiftDown() || shiftDownatStart) {
        super.mouseDragged(e);

    } else {/*ww  w  .  j  a v a 2s .  c  o m*/

        Insets insets = getInsets();
        int x = (int) ((e.getX() - insets.left) / this.getScaleX());
        int y = (int) ((e.getY() - insets.top) / this.getScaleY());

        ChartEntity entity = null;
        if (this.getChartRenderingInfo() != null) {
            EntityCollection entities = this.getChartRenderingInfo().getEntityCollection();
            if (entities != null) {
                entity = entities.getEntity(x, y);
            }
        }

        if (this.getChart() != null) {
            ChartMouseEvent event = new ChartMouseEvent(getChart(), e, entity);

            EventListener[] listeners = this.getListeners(ChartMouseListener.class);

            for (int i = listeners.length - 1; i >= 0; i -= 1) {
                if (listeners[i] instanceof KDXChartMouseListener) {
                    ((KDXChartMouseListener) listeners[i]).chartMouseSelected(event);
                }
            }
        }
    }
}

From source file:com.diversityarrays.kdxplore.chartcommon.KDXploreChartPanel.java

@Override
public void mouseReleased(MouseEvent e) {
    if (e.isShiftDown() || shiftDownatStart) {
        super.mouseReleased(e);
        shiftDownatStart = false;/* w w w  . jav  a  2 s.  co  m*/

        Insets insets = getInsets();
        int x = (int) ((e.getX() - insets.left) / this.getScaleX());
        int y = (int) ((e.getY() - insets.top) / this.getScaleY());

        ChartEntity entity = null;
        if (this.getChartRenderingInfo() != null) {
            EntityCollection entities = this.getChartRenderingInfo().getEntityCollection();
            if (entities != null) {
                entity = entities.getEntity(x, y);
            }
        }

        Object[] listeners = this.getListeners(ChartMouseListener.class);

        if (this.getChart() != null) {
            ChartMouseEvent event = new ChartMouseEvent(getChart(), e, entity);
            for (int i = listeners.length - 1; i >= 0; i -= 1) {
                if (listeners[i] instanceof KDXChartMouseListener) {
                    ((KDXChartMouseListener) listeners[i]).chartMouseZoomingReleased(event);
                }
            }
        }

    } else {
        super.mouseReleased(e);

        Insets insets = getInsets();
        int x = (int) ((e.getX() - insets.left) / this.getScaleX());
        int y = (int) ((e.getY() - insets.top) / this.getScaleY());

        ChartEntity entity = null;
        if (this.getChartRenderingInfo() != null) {
            EntityCollection entities = this.getChartRenderingInfo().getEntityCollection();
            if (entities != null) {
                entity = entities.getEntity(x, y);
            }
        }

        Object[] listeners = this.getListeners(ChartMouseListener.class);

        if (this.getChart() != null) {
            ChartMouseEvent event = new ChartMouseEvent(getChart(), e, entity);
            for (int i = listeners.length - 1; i >= 0; i -= 1) {
                if (listeners[i] instanceof KDXChartMouseListener) {
                    ((KDXChartMouseListener) listeners[i]).chartMouseSelectedReleased(event);
                }
            }
        }
    }
}

From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java

public void mouseEntered(MouseEvent e) {
    if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) {

    } else {/*from   w  w w . jav a  2s . c  o  m*/
        _cp.mouseEntered(e);
    }
}

From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java

public void mouseExited(MouseEvent e) {
    if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) {

    } else {//  www .ja v  a 2  s  .  c  o m
        _cp.mouseExited(e);
    }
}

From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java

public void mouseMoved(MouseEvent e) {
    if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) {
        _cp.mouseMoved(e);//from   w  ww  . j  av a  2  s .  c o m
    } else {
        _cp.mouseMoved(e);
    }
}

From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java

public void mousePressed(MouseEvent e) {
    if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) {
        if (this.coElutionRegion == null) {
            shifted = true;/*w ww .j  av  a2s  .c  om*/
            Rectangle2D screenDataArea = _cp.getScreenDataArea(e.getX(), e.getY());
            if (screenDataArea != null) {
                this.coElutionStart = getPointInRectangle(e.getX(), e.getY(), screenDataArea);
            } else {
                this.coElutionStart = null;
            }
        }
    } else {
        _cp.mousePressed(e);
    }
}

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 av  a 2  s .  c  om*/
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:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java

public void mouseDragged(MouseEvent e) {
    if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) {
        if (this.coElutionStart == null) {
            return;
        }/*from  www.j a  va  2  s .  co m*/
        Graphics2D g2 = (Graphics2D) _cp.getGraphics();
        if (this.coElutionRegion != null)
            drawCoElutionRegion(g2);
        if (e.getX() < this.coElutionStart.getX())
            return;
        // Erase the previous zoom rectangle (if any)...
        Rectangle2D scaledDataArea = _cp.getScreenDataArea((int) this.coElutionStart.getX(),
                (int) this.coElutionStart.getY());

        // selected rectangle shouldn't extend outside the data area...
        double xmax = Math.min(e.getX(), scaledDataArea.getMaxX());
        double ymax = Math.min(e.getY(), scaledDataArea.getMaxY());
        /*
                    this.coElutionRegion = new Rectangle2D.Double(
                this.coElutionStart.getX(), this.coElutionStart.getY(),
                xmax - this.coElutionStart.getX(), ymax - this.coElutionStart.getY());
        */
        this.coElutionRegion = new Rectangle2D.Double(this.coElutionStart.getX(), scaledDataArea.getMinY(),
                Math.abs(e.getX() - coElutionStart.getX()), scaledDataArea.getHeight());

        // Draw the new zoom rectangle...
        drawCoElutionRegion(g2);

        g2.dispose();

    } else {
        _cp.mouseDragged(e);
    }
}

From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java

public void mouseReleased(MouseEvent e) {
    try {//w  w w  .  j  av a  2  s. c o m
        if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) {
            //            Rectangle2D scaledDataArea = _chartPanel.getScreenDataArea(
            //                    (int) this.coElutionStart.getX(), (int) this.coElutionStart.getY());
            JFreeChart jfc = _cp.getChart();
            XYPlot p = jfc.getXYPlot();
            CenterZoomNumberAxis czna = (CenterZoomNumberAxis) p.getDomainAxis();
            Rectangle2D screenDataArea = _cp.getScreenDataArea(e.getX(), e.getY());
            Rectangle2D plotboundaries = _cp.getChartRenderingInfo().getPlotInfo().getPlotArea();

            double leftmostOnAxis = czna.getLowerBound();
            double rightmostOnAxis = czna.getUpperBound();
            double leftmostOnRange = this.coElutionRegion.getX();
            double rightmostOnRange = this.coElutionRegion.getX() + this.coElutionRegion.getWidth();
            double leftmostonscreen = screenDataArea.getX();
            double rightmostonscreen = leftmostonscreen + screenDataArea.getWidth();
            double slope = (rightmostOnAxis - leftmostOnAxis) / (rightmostonscreen - leftmostonscreen);
            double transformedLeftRange = (slope * (leftmostOnRange - leftmostonscreen)) + leftmostOnAxis;
            double transformedRightRange = (slope * (rightmostOnRange - leftmostonscreen)) + leftmostOnAxis;
            shifted = false;
            MRMDialog ultimateParent = (MRMDialog) MRMAncestor();
            if (ultimateParent != null) {
                MRMTransition transition = ultimateParent.transitionOnPlot;
                MRMTransition mrmt = transition;
                if (mrmt != null) {
                    int row = mrmt.getTableRow();
                    _ptm.data[row][MRMDialog.peaksData.CoStart.colno] = new Float(0f);
                    _ptm.data[row][MRMDialog.peaksData.CoEnd.colno] = new Float(10000000f);
                    _ptm.setValueAt(new Float(transformedRightRange), row, MRMDialog.peaksData.CoEnd.colno);
                    _ptm.setValueAt(new Float(transformedLeftRange), row, MRMDialog.peaksData.CoStart.colno);
                }
            }
            Graphics2D g2 = (Graphics2D) _cp.getGraphics();
            if (this.coElutionRegion != null)
                drawCoElutionRegion(g2);
            this.coElutionRegion = null;
            this.coElutionStart = null;
        } else {
            _cp.mouseReleased(e);
        }
    } catch (Exception ee) {
    }
}