Example usage for java.awt.event MouseEvent getY

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

Introduction

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

Prototype

public int getY() 

Source Link

Document

Returns the vertical y position of the event relative to the source component.

Usage

From source file:gda.plots.SimplePlot.java

/**
 * Part of the implementation of MouseListener - overrides the super class (ChartPanel) implementation so that the
 * mouse can be used to select a rectangle as well as for zooming.
 * /*from w w w.  j  av  a2  s . com*/
 * @param e
 *            the mouse event which caused the call
 */
@Override
public void mousePressed(MouseEvent e) {
    // Unless a rectangle is being dragged we just
    // want to call the super class method (which
    // deals with zooming)
    if (rd == null) {
        super.mousePressed(e);
        if (magnifyingImage || magnifyingData) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                magnifyRectangle = null;
                magnifyXPoint = e.getX();
                magnifyYPoint = e.getY();
            }
            if (!e.isPopupTrigger()) {
                Graphics2D g2 = (Graphics2D) getGraphics();
                g2.setXORMode(dragColour);
                if (magnifyRectangle != null) {
                    g2.fill(magnifyRectangle);
                }
                g2.dispose();
            }
        }
    } else {
        rd.mousePressed(e);
    }
}

From source file:base.BasePlayer.BedCanvas.java

@SuppressWarnings("unchecked")
public void mousePressed(MouseEvent event) {
    resize = false;// w w w  .  ja va 2 s .  c o  m
    pressY = event.getY();
    mouseDrag = true;

    this.requestFocus();
    Main.drawCanvas.pressX = event.getX();

    Main.drawCanvas.tempDrag = Main.drawCanvas.pressX;
    switch (event.getModifiers()) {

    case InputEvent.BUTTON1_MASK: {

        //   if(this.settingsbutton > -1) {
        if (sidebar && this.hoverIndex < bedTrack.size()
                && this.sideMouseRect.intersects(bedTrack.get(this.hoverIndex).settingsButton)) {

            this.bedTrack.get(this.hoverIndex).getPopup().show(this, mouseX, mouseY);
            //settingsbutton = -1;
            break;
        }

        //}
        if (resizer) {
            preresize = mouseY;
            preresizer = this.trackDivider.get(this.resizeDivider) * this.getHeight();
            tempDivider = (ArrayList<Double>) trackDivider.clone();
        }

        break;
    }
    case InputEvent.BUTTON3_MASK: {

        this.zoomDrag = false;
        if (sidebar) {
            this.bedTrack.get(hoverIndex).getPopup().show(this, mouseX, mouseY);
        }

    }
    }

}

From source file:gda.plots.SimplePlot.java

/**
 * Part of the implementation of MouseListener. Overrides the super class (ChartPanel) implementation so that the
 * mouse can be used to select a rectangle as well as for zooming.
 * /*from www.j  av a  2 s. c o m*/
 * @see #mousePressed(java.awt.event.MouseEvent)
 * @see #mouseDragged(java.awt.event.MouseEvent)
 * @param e
 *            the mouse event which caused the call
 */
@Override
public void mouseReleased(MouseEvent e) {
    // Unless a rectangle is being dragged we just
    // want to call the super class method (which
    // deals with zooming)
    if (rd == null) {
        super.mouseReleased(e);

        if (magnifyingImage || magnifyingData) {
            // If the button released is BUTTON1 then the rectangle for
            // magnification will have been resized.
            if (e.getButton() == MouseEvent.BUTTON1) {
                magnifyWidth = e.getX() - magnifyXPoint;
                magnifyHeight = e.getY() - magnifyYPoint;
                magnifyRectangleIsNew = true;
            }

            // If the button released is BUTTON2 then the rectangle will
            // have been being dragged around. Need to redraw in XOR mode
            // one
            // last time to remove rectangle from plot.
            else if (e.getButton() == MouseEvent.BUTTON2) {
                Graphics2D g2 = (Graphics2D) getGraphics();
                g2.setXORMode(dragColour);
                if (magnifyRectangle != null) {
                    g2.fill(magnifyRectangle);
                }
                g2.dispose();
            }
            recalculateMagnifyRectangle(e);
            magnifier.update(magnifyRectangle);
        }
    } else {
        rd.mouseReleased(e);
    }
}

From source file:GUI.MainWindow.java

private void VulnReferencesListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_VulnReferencesListMouseClicked

    int clicked = evt.getButton();
    if (clicked == MouseEvent.BUTTON1 && evt.getClickCount() == 2) {
        // A double click. Lets see if there is already a link or if we are creating a new one
        Object obj = VulnReferencesList.getSelectedValue();
        if (obj == null) {
            // We should simply show the 'add reference' prompy
        } else if (obj instanceof Reference) {
            // User probably wants to edit the existing reference
            Reference ref = (Reference) obj;
            addReference(VulnTree, VulnReferencesList, ref);
        }// w  w w  . j a v  a  2s .c om
    } else if (clicked == MouseEvent.BUTTON3) {
        // A right click. Show the context menu
        //int selected = VulnReferencesList.getSelectedIndex();
        List l = VulnReferencesList.getSelectedValuesList();
        int selected = l.size();

        System.out.println("selected: " + selected);
        // None are selected enable insert and disable all the rest
        InsertReference.setEnabled(true);
        EditReferenceOption.setEnabled(false);
        LaunchInBrowser.setEnabled(false);
        DeleteReferenceOption.setEnabled(false);

        if (selected == 1) {
            // One was selected to enable the right options
            InsertReference.setEnabled(true);
            EditReferenceOption.setEnabled(true);
            LaunchInBrowser.setEnabled(true);
            DeleteReferenceOption.setEnabled(true);
        } else if (selected >= 2) {
            // One was selected to enable the right options
            InsertReference.setEnabled(true);
            EditReferenceOption.setEnabled(false);
            LaunchInBrowser.setEnabled(true);
            DeleteReferenceOption.setEnabled(true);
        }

        VulnReferencesContextMenu.show((Component) evt.getSource(), evt.getX(), evt.getY());
    }
}

From source file:base.BasePlayer.BedCanvas.java

@SuppressWarnings("unchecked")
public void mouseDragged(MouseEvent event) {
    switch (event.getModifiers()) {

    case InputEvent.BUTTON1_MASK: {
        if (sidebar) {
            return;
        }//from w  w  w .  j a v  a2s. c o  m
        this.mouseX = event.getX();
        this.mouseY = event.getY();

        if (resizer && this.getHeight() > this.trackDivider.size() * 20) {

            this.trackDivider.set(this.resizeDivider, mouseY / (double) this.getHeight());

            if ((positivelock || negative)
                    && this.trackDivider.get(this.resizeDivider) * this.getHeight() - preresizer >= 0) {
                positivelock = false;
                negative = false;
                preresize = mouseY;
                tempDivider = (ArrayList<Double>) trackDivider.clone();

            } else if ((!negative || negativelock)
                    && this.trackDivider.get(this.resizeDivider) * this.getHeight() - preresizer < 0) {
                negativelock = false;
                preresize = mouseY;
                tempDivider = (ArrayList<Double>) trackDivider.clone();
                negative = true;
            }

            if (negativelock) { // || (this.trackDivider.get(this.resizeDivider+1)*this.getHeight()) -(this.trackDivider.get(this.resizeDivider)*this.getHeight()) < 20) {
                this.trackDivider.set(this.resizeDivider,
                        (this.trackDivider.get(this.resizeDivider + 1) * this.getHeight() - 19)
                                / (double) this.getHeight());
            }
            if (positivelock) { // || (this.trackDivider.get(this.resizeDivider+1)*this.getHeight()) -(this.trackDivider.get(this.resizeDivider)*this.getHeight()) < 20) {
                this.trackDivider.set(this.resizeDivider, 19 / (double) this.getHeight());
            }
            if (this.trackDivider.get(this.resizeDivider) * this.getHeight() - preresizer < 0) {

                negative = true;
                positivelock = true;
                if (this.resizeDivider > 0) {

                    for (int i = 1; i < this.resizeDivider + 1; i++) {
                        if ((this.trackDivider.get(i) * this.getHeight())
                                - (this.trackDivider.get(i - 1) * this.getHeight()) < 20) {

                            this.trackDivider.set(i, ((this.trackDivider.get(i - 1) * this.getHeight()) + 19)
                                    / (double) this.getHeight());
                        } else {
                            positivelock = false;
                            if (i != this.resizeDivider) {
                                this.trackDivider.set(i, (this.tempDivider.get(i) / preresize) * mouseY);
                            }
                        }
                    }
                }
                if ((this.trackDivider.get(0) * this.getHeight()) >= 20) {
                    this.trackDivider.set(0, (this.tempDivider.get(0) / preresize) * mouseY);
                    positivelock = false;
                } else {
                    this.trackDivider.set(0, 19 / (double) this.getHeight());
                }

            } else {

                negative = false;
                negativelock = true;
                if (this.resizeDivider < this.trackDivider.size() - 1) {

                    for (int i = this.resizeDivider; i < this.trackDivider.size() - 1; i++) {

                        if ((this.trackDivider.get(i + 1) * this.getHeight())
                                - (this.trackDivider.get(i) * this.getHeight()) < 20) {

                            this.trackDivider.set(i, ((this.trackDivider.get(i + 1) * this.getHeight()) - 19)
                                    / (double) this.getHeight());
                        } else {

                            negativelock = false;
                            if (i != this.resizeDivider) {
                                try {
                                    this.trackDivider.set(i,
                                            1 - ((1 - this.tempDivider.get(i)) / (this.getHeight() - preresize))
                                                    * (this.getHeight() - mouseY));
                                } catch (Exception e) {

                                    //   e.printStackTrace();
                                }
                            }
                        }
                    }
                    if (this.getHeight()
                            - (this.trackDivider.get(this.trackDivider.size() - 2) * this.getHeight()) >= 20) {
                        negativelock = false;
                    } else {
                        this.trackDivider.set(this.trackDivider.size() - 2,
                                (this.getHeight() - 19) / (double) this.getHeight());
                    }

                }
            }

            preresizer = this.trackDivider.get(this.resizeDivider) * this.getHeight();
            repaint();

        } else if (lineZoomer) {

            if (Main.drawCanvas.selectedSplit.start > 1
                    || Main.drawCanvas.selectedSplit.end < Main.drawCanvas.selectedSplit.chromEnd) {
                Main.drawCanvas.gotoPos(
                        Main.drawCanvas.selectedSplit.start
                                - (Main.drawCanvas.tempDrag - mouseX) / Main.drawCanvas.selectedSplit.pixel * 2,
                        Main.drawCanvas.selectedSplit.end + (Main.drawCanvas.tempDrag - mouseX)
                                / Main.drawCanvas.selectedSplit.pixel * 2);
            }

            Main.drawCanvas.tempDrag = mouseX;
            Main.chromDraw.updateExons = true;
            repaint();
            Main.chromDraw.repaint();
            Draw.updatevars = true;
            Main.drawCanvas.repaint();

        } else {
            if (getCursor().getType() != Cursor.N_RESIZE_CURSOR) {
                zoomDrag = true;

                repaint();
            }
            return;
        }
        break;
    }
    case InputEvent.BUTTON3_MASK: {
        if (sidebar) {
            return;
        }
        if ((int) Main.drawCanvas.selectedSplit.start == 1
                && (int) Main.drawCanvas.selectedSplit.end == Main.drawCanvas.selectedSplit.chromEnd) {
            break;
        }

        Main.drawCanvas.mouseDrag = true;
        Main.drawCanvas.moveX = event.getX();
        Main.drawCanvas.drag(Main.drawCanvas.moveX);
        break;
    }
    case 17: {
        if (sidebar) {
            return;
        }
        if ((int) Main.drawCanvas.selectedSplit.start == 1
                && (int) Main.drawCanvas.selectedSplit.end == Main.drawCanvas.selectedSplit.chromEnd) {
            break;
        }

        Main.drawCanvas.mouseDrag = true;
        Main.drawCanvas.moveX = event.getX();
        Main.drawCanvas.drag(Main.drawCanvas.moveX);
        break;
    }
    }
}

From source file:gda.plots.SimplePlot.java

/**
 * Recalculates the rectangle which should be magnified.
 * //from w w  w .j  a va 2s.c o  m
 * @param e
 *            the MouseEvent which triggered the recalculation
 */
private void recalculateMagnifyRectangle(MouseEvent e) {
    if (magnifyWidth == 0 || magnifyHeight == 0)
        return;

    Rectangle2D scaledDataArea = getScreenDataArea();

    double widthToUse;
    double heightToUse;
    double xToUse;
    double yToUse;

    // If magnifyWidth is positive then e.getX() is
    // the end of the rectangle so the start is (e.getX() - magnifyWidth ).
    // If magnifyWidth is negative then e.getX() is the start of a
    // rectangle with the opposite sign width. Similarly for y.

    if (magnifyWidth > 0) {
        xToUse = e.getX() - magnifyWidth;
        widthToUse = magnifyWidth;
    } else {
        xToUse = e.getX();
        widthToUse = -1.0 * magnifyWidth;
    }

    if (magnifyHeight > 0) {
        yToUse = e.getY() - magnifyHeight;
        heightToUse = magnifyHeight;
    } else {
        yToUse = e.getY();
        heightToUse = -1.0 * magnifyHeight;
    }

    // xToUse and yToUse now specify the top left of the rectangle. In order
    // to keep the magnified rectangle inside the data area the start point
    // must be inside a rectangle which is the scaledDataArea reduced in
    // width
    // and height by the width and height of the magnifyRectangle.

    Point2D revisedStartPoint = ShapeUtilities.getPointInRectangle(xToUse, yToUse,
            new Rectangle2D.Double(scaledDataArea.getMinX(), scaledDataArea.getMinY(),
                    scaledDataArea.getWidth() - magnifyWidth, scaledDataArea.getHeight() - magnifyHeight));
    magnifyRectangle = new Rectangle2D.Double(revisedStartPoint.getX(), revisedStartPoint.getY(), widthToUse,
            heightToUse);
}

From source file:FourByFour.java

public void mousePressed(MouseEvent e) {
    board.checkSelection2D(e.getX(), e.getY(), 1);
    repaint();
}

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

final private boolean inOvVirtualRectangle(final MouseEvent e) {
    return (inOvVirtualRectangle(e.getX(), e.getY()));
}

From source file:gda.plots.SimplePlot.java

/**
 * Part of the implementation of MouseMotionListener - overrides the super class (ChartPanel) implementation so that
 * the mouse can be used to select a rectangle as well as for zooming.
 * /*from w  w w  .  j a  va2  s . c o  m*/
 * @param e
 *            the mouse event which caused the call
 */
@Override
public void mouseDragged(MouseEvent e) {
    // If the rectangle dragger is not in operation then call the
    // super class method (to deal with any possible zooming) then
    // deal with magnifyingImage or magnifyingData.

    if (rd == null) {
        super.mouseDragged(e);
        if ((magnifyingImage || magnifyingData) && (e.getModifiers() & InputEvent.BUTTON3_MASK) == 0) {
            Graphics2D g2 = (Graphics2D) getGraphics();
            g2.setXORMode(dragColour);
            if (magnifyRectangle != null) {
                if (magnifyRectangleIsNew) {
                    magnifyRectangleIsNew = false;
                } else {
                    g2.fill(magnifyRectangle);
                }
            }
            if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {
                magnifyWidth = e.getX() - magnifyXPoint;
                magnifyHeight = e.getY() - magnifyYPoint;
            }
            recalculateMagnifyRectangle(e);

            if ((e.getModifiers() & InputEvent.BUTTON2_MASK) != 0) {
                magnifier.update(magnifyRectangle);
            }

            if (magnifyRectangle != null) {
                g2.fill(magnifyRectangle);
            }
            g2.dispose();
        }
    } else {
        rd.mouseDragged(e);
    }
}

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

final boolean inOvRectangle(final MouseEvent e) {
    return ((e.getX() >= getOvRectangle().getX() - 1)
            && (e.getX() <= getOvRectangle().getX() + getOvRectangle().getWidth() + 1)
            && (e.getY() >= getOvRectangle().getY() - 1)
            && (e.getY() <= getOvRectangle().getY() + getOvRectangle().getHeight() + 1));
}