Example usage for java.awt.event MouseEvent getX

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

Introduction

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

Prototype

public int getX() 

Source Link

Document

Returns the horizontal x position of the event relative to the source component.

Usage

From source file:grafix.telas.MolduraAreaDados.java

protected void gerarStatus(final java.awt.event.MouseEvent evt) {
    System.out.println(evt.getX());
    //descartarEvento(evt);
}

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

@Override
public void mouseMoved(MouseEvent e) {
    double[] p = getWorld(e.getX(), e.getY());
    window.setCoords(p[0], p[1]);
}

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

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

    } else {/*from w w w .ja v a2s.  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: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);
    }/*ww  w. ja va 2  s  . c o m*/

    return tooltip;

}

From source file:playground.sergioo.networkBusLaneAdder2012.gui.BusLaneAdderPanel.java

@Override
public void mouseMoved(MouseEvent e) {
    double[] p = getWorld(e.getX(), e.getY());
    busLaneAdderWindow.setCoords(p[0], p[1]);
}

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

@Override
public void mousePressed(MouseEvent e) {
    this.requestFocus();
    iniX = e.getX();
    iniY = e.getY();
}

From source file:com.iisigroup.ris.WebFileScanUtilBrowserUI.java

/**
 * Auto-generated method for setting the popup menu for a component
 *///from   w ww.  j  a v a2  s  .  com
private void setComponentPopupMenu(final java.awt.Component parent, final javax.swing.JPopupMenu menu) {
    parent.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mousePressed(java.awt.event.MouseEvent e) {
            if (e.isPopupTrigger())
                menu.show(parent, e.getX(), e.getY());
        }

        public void mouseReleased(java.awt.event.MouseEvent e) {
            if (e.isPopupTrigger())
                menu.show(parent, e.getX(), e.getY());
        }
    });
}

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);/*from www.  j  a va2s . co 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//from   www  . j ava2s . c  om
 * 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: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  av  a 2  s  .  c om
            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();
}