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:playground.sergioo.networkBusLaneAdder2012.gui.BusLaneAdderPanel.java

@Override
public void mouseClicked(MouseEvent e) {
    double[] p = getWorld(e.getX(), e.getY());
    if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON3)
        camera.centerCamera(p);//  w  w w. j  av a 2 s.  c  o  m
    else {
        if (busLaneAdderWindow.getOption().equals(Options.SELECT_NODES)
                && e.getButton() == MouseEvent.BUTTON1) {
            ((NetworkTwoNodesPainterManager) ((NetworkPainter) getActiveLayer().getPainter())
                    .getNetworkPainterManager()).selectNearestNode(p[0], p[1]);
            busLaneAdderWindow.refreshLabel(Labels.NODES);
        } else if (busLaneAdderWindow.getOption().equals(Options.SELECT_NODES)
                && e.getButton() == MouseEvent.BUTTON3) {
            ((NetworkTwoNodesPainterManager) ((NetworkPainter) getActiveLayer().getPainter())
                    .getNetworkPainterManager()).unselectNearestNode(p[0], p[1]);
            busLaneAdderWindow.refreshLabel(Labels.NODES);
        } else if (busLaneAdderWindow.getOption().equals(Options.ZOOM) && e.getButton() == MouseEvent.BUTTON1) {
            camera.zoomIn(p[0], p[1]);
        } else if (busLaneAdderWindow.getOption().equals(Options.ZOOM) && e.getButton() == MouseEvent.BUTTON3) {
            camera.zoomOut(p[0], p[1]);
        }
    }
    repaint();
}

From source file:de.codesourcery.eve.skills.ui.utils.PopupMenuBuilder.java

/**
 * Checks whether a mouse-click event/*ww  w. ja va  2 s .com*/
 * should trigger a context-sensitive popup menu
 * and renders the menu if so.
 * 
 * @param e
 */
protected void maybeShowPopup(MouseEvent e) {

    if (!e.isPopupTrigger()) {
        return;
    }

    popupMenu.removeAll();

    if (populateMenu() > 0) {
        popupMenu.show(e.getComponent(), e.getX(), e.getY());
    }
}

From source file:net.sf.mzmine.modules.visualization.twod.TwoDPlot.java

public String getToolTipText(MouseEvent event) {

    String tooltip = super.getToolTipText(event);

    if (tooltip == null) {
        int mouseX = event.getX();
        int mouseY = event.getY();
        Rectangle2D plotArea = getScreenDataArea();
        RectangleEdge xAxisEdge = plot.getDomainAxisEdge();
        RectangleEdge yAxisEdge = plot.getRangeAxisEdge();
        double rt = (double) xAxis.java2DToValue(mouseX, plotArea, xAxisEdge);
        double mz = (double) yAxis.java2DToValue(mouseY, plotArea, yAxisEdge);

        tooltip = "Retention time: " + rtFormat.format(rt) + "\nm/z: " + mzFormat.format(mz);
    }/*from   ww  w.j  av  a2  s  .  c o m*/

    return tooltip;

}

From source file:playground.sergioo.capacitiesChanger2012.gui.NetworkPanel.java

@Override
public void mouseClicked(MouseEvent e) {
    double[] p = getWorld(e.getX(), e.getY());
    if (e.getClickCount() == 2) {
        if (window.getOption().equals(Options.SELECT_LINK) && e.getButton() == MouseEvent.BUTTON1) {
            ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().selectLink(p[0], p[1]);
            Link link = ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager()
                    .getSelectedLink();//from ww  w  .j a  v a 2 s.co m
            try {
                link.setCapacity(
                        Double.parseDouble(JOptionPane.showInputDialog("New capacity", link.getCapacity())));
            } catch (Exception e2) {

            }
            ((SimpleSelectionNetworkPainter) getActiveLayer().getPainter()).calculateMinMax();
            window.refreshLabel(Labels.LINK);
        } else if (e.getButton() == MouseEvent.BUTTON3) {
            ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().selectLink(p[0], p[1]);
            Link link = ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager()
                    .getSelectedLink();
            try {
                link.setFreespeed(
                        Double.parseDouble(JOptionPane.showInputDialog("New free speed", link.getFreespeed())));
            } catch (Exception e2) {

            }
            ((SimpleSelectionNetworkPainter) getActiveLayer().getPainter()).calculateMinMax();
            window.refreshLabel(Labels.LINK);
        }
    } else {
        if (window.getOption().equals(Options.SELECT_LINK) && e.getButton() == MouseEvent.BUTTON1) {
            ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().selectLink(p[0], p[1]);
            window.refreshLabel(Labels.LINK);
        } else if (window.getOption().equals(Options.SELECT_LINK) && e.getButton() == MouseEvent.BUTTON3) {
            ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().unselectLink();
            window.refreshLabel(Labels.LINK);
        } else if (window.getOption().equals(Options.SELECT_NODE) && e.getButton() == MouseEvent.BUTTON1) {
            ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().selectNode(p[0], p[1]);
            window.refreshLabel(Labels.NODE);
        } else if (window.getOption().equals(Options.SELECT_NODE) && e.getButton() == MouseEvent.BUTTON3) {
            ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().unselectNode();
            window.refreshLabel(Labels.NODE);
        } else if (window.getOption().equals(Options.ZOOM) && e.getButton() == MouseEvent.BUTTON1)
            camera.zoomIn(p[0], p[1]);
        else if (window.getOption().equals(Options.ZOOM) && e.getButton() == MouseEvent.BUTTON3)
            camera.zoomOut(p[0], p[1]);
    }
    repaint();
}

From source file:org.jax.maanova.plot.MaanovaChartPanel.java

private void myMousePressed(MouseEvent e) {
    this.dragRectangle = new Rectangle(e.getX(), e.getY(), 0, 0);
}

From source file:AncestorTree.java

public boolean isCellEditable(EventObject evt) {
    if (evt instanceof MouseEvent) {
        MouseEvent mEvt = (MouseEvent) evt;
        if (mEvt.getClickCount() == 1) {
            int row = m_tree.getRowForLocation(mEvt.getX(), mEvt.getY());
            if (row != m_lastRow) {
                m_lastRow = row;/*from ww w .  j  a  v a 2 s  .  c o  m*/
                m_lastClick = System.currentTimeMillis();
                return false;
            } else if (System.currentTimeMillis() - m_lastClick > 1000) {
                m_lastRow = -1;
                m_lastClick = 0;
                prepareEditor();
                mEvt.consume();
                return true;
            } else
                return false;
        }
    }
    return false;
}

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

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

    } else {//from  ww w.ja v a 2 s  .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:de.dakror.villagedefense.game.entity.Entity.java

public boolean mouseMoved(MouseEvent e) {
    if (alpha == 0)
        return false;

    return hovered = contains(e.getX(), e.getY());
}

From source file:net.bioclipse.model.ScatterPlotMouseHandler.java

@Override
public void mousePressed(MouseEvent e) {
    super.mousePressed(e);
    ChartPanel chartPanel = getChartPanel(e);
    startX = e.getX();//  www . j  ava2 s .  co  m
    startY = e.getY();

    if (!e.isShiftDown()) {
        ((ScatterPlotRenderer) ((XYPlot) chartPanel.getChart().getPlot()).getRenderer()).clearMarkedPoints();
        currentSelection = new ChartSelection();
        chartPanel.getChart().plotChanged(new PlotChangeEvent(chartPanel.getChart().getPlot()));
    } else {
        ((ScatterPlotRenderer) ((XYPlot) chartPanel.getChart().getPlot()).getRenderer())
                .removeMarkedPoint(null);
    }
    if (currentSelection == null) {
        currentSelection = new ChartSelection();
    }

    mouseDragSelection = new ChartSelection();
    currentSelection.setDescriptor(ChartUtils.getChartDescriptor(chartPanel.getChart()));
}

From source file:com.mirth.connect.client.ui.components.MirthIconTextField.java

public MirthIconTextField(ImageIcon icon) {
    setIcon(icon);// w ww.  j  av  a 2  s .c o  m

    addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent evt) {
            if (isIconActive(evt) && iconPopupMenuComponent != null) {
                JPopupMenu iconPopupMenu = new JPopupMenu();
                iconPopupMenu.insert(iconPopupMenuComponent, 0);
                iconPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
            }
        }
    });

    addMouseMotionListener(new MouseMotionAdapter() {
        @Override
        public void mouseMoved(MouseEvent evt) {
            int cursorType = getCursor().getType();

            if (isIconActive(evt)) {
                if (StringUtils.isNotBlank(alternateToolTipText)) {
                    MirthIconTextField.super.setToolTipText(alternateToolTipText);
                }

                if (iconPopupMenuComponent != null) {
                    if (cursorType != Cursor.HAND_CURSOR) {
                        setCursor(new Cursor(Cursor.HAND_CURSOR));
                    }
                } else {
                    if (cursorType != Cursor.DEFAULT_CURSOR) {
                        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    }
                }
            } else {
                if (StringUtils.isNotBlank(alternateToolTipText)) {
                    MirthIconTextField.super.setToolTipText(originalToolTipText);
                }

                if (cursorType != Cursor.TEXT_CURSOR) {
                    setCursor(new Cursor(Cursor.TEXT_CURSOR));
                }
            }
        }
    });
}