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:com.SE.myPlayer.MusicPlayerGUI.java

private void folder_Playlist_TreeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_folder_Playlist_TreeMouseClicked
        DefaultMutableTreeNode selectedNode;

        if (evt.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(evt)) {
            selectedNode = (DefaultMutableTreeNode) folder_Playlist_Tree.getSelectionPath().getLastPathComponent();
            getSongTable(selectedNode.toString());
            lastOpen = selectedNode.toString();
            for (ObjectBean list1 : list) {
                if (list1.getTitle().equals("library")) {
                    list1.setLastOpen(lastOpen);
                }//  w w w  . j  ava  2 s .com
            }
        } else if (SwingUtilities.isRightMouseButton(evt)) {
            DefaultTreeModel myModel = (DefaultTreeModel) folder_Playlist_Tree.getModel();
            DefaultMutableTreeNode root = (DefaultMutableTreeNode) myModel.getRoot();

            TreeNode[] nodes = myModel.getPathToRoot(root);
            TreePath treepath = new TreePath(nodes);
            folder_Playlist_Tree.setSelectionPath(treepath);
            folder_Playlist_Tree.scrollPathToVisible(treepath);

            TreePath path = folder_Playlist_Tree.getPathForLocation(evt.getX(), evt.getY());
            folder_Playlist_Tree.setSelectionPath(path);
            folder_Playlist_Tree.scrollPathToVisible(path);
            if (!folder_Playlist_Tree.isSelectionEmpty()) {
                selectedNode = (DefaultMutableTreeNode) folder_Playlist_Tree.getSelectionPath()
                        .getLastPathComponent();
                if (!"playlist".equals(selectedNode.toString()) && !"library".equals(selectedNode.toString())) {
                    folderTree_PopUp.show(folder_Playlist_Tree, evt.getX(), evt.getY());
                }
            }
        }
    }

From source file:simMPLS.ui.simulator.JVentanaHija.java

/** Este mtodo se ejecuta cuando se hace clic con el botn derecho en la pantalla
 * de diseo.//from w  w w . j  a  v  a2s .co  m
 * @since 1.0
 * @param evt Evento que hace que este mtodo se dispare.
 */
private void clicDerechoEnPanelDisenio(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_clicDerechoEnPanelDisenio
    if (evt.getButton() == MouseEvent.BUTTON3) {
        TTopologyElement et = escenario.getTopology().obtenerElementoEnPosicion(evt.getPoint());
        if (et == null) {
            diseFondoPopUp.show(this, evt.getX() + 7, evt.getY() - 27);
        } else {
            if (et.getElementType() == TTopologyElement.NODO) {
                TNode nt = (TNode) et;
                dVerNombreMenuItem.setSelected(nt.getShowName());
                elementoDisenioClicDerecho = et;
                diseElementoPopUp.show(this, evt.getX() + 7, evt.getY() + 15);
            } else if (et.getElementType() == TTopologyElement.LINK) {
                TLink ent = (TLink) et;
                dVerNombreMenuItem.setSelected(ent.obtenerMostrarNombre());
                elementoDisenioClicDerecho = et;
                diseElementoPopUp.show(this, evt.getX() + 7, evt.getY() + 15);
            }
        }
    } else {
        elementoDisenioClicDerecho = null;
        panelDisenio.repaint();
    }
}

From source file:org.rdv.viz.chart.ChartPanel.java

/**
 * Handles a 'mouse released' event.  On Windows, we need to check if this
 * is a popup trigger, but only if we haven't already been tracking a zoom
 * rectangle./*ww  w .j  av  a 2 s. com*/
 *
 * @param e  information about the event.
 */
public void mouseReleased(MouseEvent e) {

    if (this.zoomRectangle != null) {
        boolean hZoom = false;
        boolean vZoom = false;
        if (this.orientation == PlotOrientation.HORIZONTAL) {
            hZoom = this.rangeZoomable;
            vZoom = this.domainZoomable;
        } else {
            hZoom = this.domainZoomable;
            vZoom = this.rangeZoomable;
        }

        boolean zoomTrigger1 = hZoom && Math.abs(e.getX() - this.zoomPoint.getX()) >= this.zoomTriggerDistance;
        boolean zoomTrigger2 = vZoom && Math.abs(e.getY() - this.zoomPoint.getY()) >= this.zoomTriggerDistance;
        if (zoomTrigger1 || zoomTrigger2) {
            if ((hZoom && (e.getX() < this.zoomPoint.getX()))
                    || (vZoom && (e.getY() < this.zoomPoint.getY()))) {
                // restore the the range for the domain and range axis from
                // the history
                Plot p = this.chart.getPlot();
                if (p instanceof XYPlot && !rangeHistory.empty()) {
                    XYPlot xyPlot = (XYPlot) p;
                    ValueAxis rangeAxis = xyPlot.getRangeAxis();
                    ValueAxis domainAxis = xyPlot.getDomainAxis();

                    if (rangeAxis.getRange().equals(rangeHistory.pop())
                            && domainAxis.getRange().equals(rangeHistory.pop())) {
                        xyPlot.getRangeAxis().setRange(rangeHistory.pop());
                        xyPlot.getDomainAxis().setRange(rangeHistory.pop());

                        if (!rangeHistory.empty()) {
                            rangeHistory.push(domainAxis.getRange());
                            rangeHistory.push(rangeAxis.getRange());
                        }
                    } else {
                        rangeHistory.clear();
                        restoreAutoBounds();
                    }
                } else {
                    restoreAutoBounds();
                }

            } else {
                double x, y, w, h;
                Rectangle2D screenDataArea = getScreenDataArea((int) this.zoomPoint.getX(),
                        (int) this.zoomPoint.getY());
                double maxX = screenDataArea.getMaxX();
                double maxY = screenDataArea.getMaxY();
                // for mouseReleased event, (horizontalZoom || verticalZoom)
                // will be true, so we can just test for either being false;
                // otherwise both are true
                if (!vZoom) {
                    x = this.zoomPoint.getX();
                    y = screenDataArea.getMinY();
                    w = Math.min(this.zoomRectangle.getWidth(), maxX - this.zoomPoint.getX());
                    h = screenDataArea.getHeight();
                } else if (!hZoom) {
                    x = screenDataArea.getMinX();
                    y = this.zoomPoint.getY();
                    w = screenDataArea.getWidth();
                    h = Math.min(this.zoomRectangle.getHeight(), maxY - this.zoomPoint.getY());
                } else {
                    x = this.zoomPoint.getX();
                    y = this.zoomPoint.getY();
                    w = Math.min(this.zoomRectangle.getWidth(), maxX - this.zoomPoint.getX());
                    h = Math.min(this.zoomRectangle.getHeight(), maxY - this.zoomPoint.getY());
                }
                Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h);
                zoom(zoomArea);
            }
            this.zoomPoint = null;
            this.zoomRectangle = null;
        } else {
            // Erase the zoom rectangle
            Graphics2D g2 = (Graphics2D) getGraphics();
            drawZoomRectangle(g2);
            g2.dispose();
            this.zoomPoint = null;
            this.zoomRectangle = null;
        }

    }

    else if (e.isPopupTrigger()) {
        if (this.popup != null) {
            displayPopupMenu(e.getX(), e.getY());
        }
    }

}

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

/**
 * Implementation of the MouseMotionListener's method.
 * /*from w w w .j  ava  2  s .co  m*/
 * @param e
 *            the event.
 */

@Override
public void mouseMoved(MouseEvent e) {
    Graphics2D g2 = (Graphics2D) getGraphics();
    if (this.horizontalAxisTrace) {
        drawHorizontalAxisTrace(g2, e.getX());
    }
    if (this.verticalAxisTrace) {
        drawVerticalAxisTrace(g2, e.getY());
    }
    g2.dispose();

    Object[] listeners = this.chartMouseListeners.getListeners(ChartMouseListener.class);
    if (listeners.length == 0) {
        return;
    }
    Insets insets = getInsets();
    int x = (int) ((e.getX() - insets.left) / this.scaleX);
    int y = (int) ((e.getY() - insets.top) / this.scaleY);

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

    // we can only generate events if the panel's chart is not null
    // (see bug report 1556951)
    if (this.chart != null) {
        ChartMouseEvent event = new ChartMouseEvent(getChart(), e, entity);
        for (int i = listeners.length - 1; i >= 0; i -= 1) {
            ((ChartMouseListener) listeners[i]).chartMouseMoved(event);
        }
    }

}

From source file:edmondskarp.Gui.EdmondsKarpGui.java

private void myPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_myPanelMouseClicked
    if (evt.getButton() == MouseEvent.BUTTON1) {

        if (MODE == ERASE) {
            eraseShape(evt.getPoint());// ww w.j av  a2 s. c  om
        } else if (MODE == DRAW) {

            if (isSecond) {
                Circle circ = getSelectedCircle(evt.getPoint());
                if (circ != null && circ != shapeTmp) {
                    addArrow(circ);
                    shapeTmp.setSelect(false);
                    isSecond = false;
                    update();
                    return;
                }
            } else {
                Circle circ = getSelectedCircle(evt.getPoint());
                if (circ != null) {
                    shapeTmp = circ;
                    shapeTmp.setSelect(true);
                    isSecond = true;
                    update();
                    return;
                }

            }

            if (getSelectedCircle(evt.getPoint()) == null && !isSecond) {
                addCircle(evt.getPoint());
            } else {
                isSecond = false;
                shapeTmp.setSelect(false);
                update();
            }
        }
    } else if (evt.getButton() == MouseEvent.BUTTON3) {
        if (getSelectedCircle(evt.getPoint()) != null) {
            pointTmp.setLocation(evt.getPoint().getX(), evt.getPoint().getY());
            jPopupMenu1.show(myPanel, evt.getX(), evt.getY());
        } else if (getSelectedArrow(evt.getPoint()) != null) {
            pointTmp.setLocation(evt.getPoint().getX(), evt.getPoint().getY());
            jPopupMenu2.show(myPanel, evt.getX(), evt.getY());
        }
    }
}

From source file:GUI.MainWindow.java

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

    // Do nothing 
    Object obj = VulnTree.getLastSelectedPathComponent();

    if (obj == null) // No vulns selected so no interaction required
    {/*from  w ww . ja v  a2  s.c  o m*/
        return;
    }

    if (evt.getButton() == MouseEvent.BUTTON3) {

        // At least one vuln was selected so we need to see how many and modify the context menu
        if (VulnTree.getSelectionCount() == 1) { // User cannot merge because they don't have two selected
            MergeButton.setEnabled(false);
        } else {
            MergeButton.setEnabled(true);
        }
        VulnTreeContextMenu.show(VulnTree, evt.getX(), evt.getY());
    } else if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) {
        showNotes();
    }
}

From source file:com.t3.client.ui.T3Frame.java

private AssetPanel createAssetPanel() {
    final AssetPanel panel = new AssetPanel("mainAssetPanel");
    panel.addImagePanelMouseListener(new MouseAdapter() {
        @Override//ww  w  .j  a  v a  2s  . c o m
        public void mouseReleased(MouseEvent e) {
            // TODO use for real popup logic
            //            if (SwingUtilities.isLeftMouseButton(e)) {
            //               if (e.getClickCount() == 2) {
            //
            //                  List<Object> idList = panel.getSelectedIds();
            //                  if (idList == null || idList.size() == 0) {
            //                     return;
            //                  }
            //
            //                  final int index = (Integer) idList.get(0);
            //                  createZone(panel.getAsset(index));
            //               }
            //            }
            if (SwingUtilities.isRightMouseButton(e) && TabletopTool.getPlayer().isGM()) {
                List<Object> idList = panel.getSelectedIds();
                if (idList == null || idList.size() == 0) {
                    return;
                }
                final int index = (Integer) idList.get(0);

                JPopupMenu menu = new JPopupMenu();
                menu.add(new JMenuItem(new AbstractAction() {
                    {
                        putValue(NAME, I18N.getText("action.newMap"));
                    }

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        createZone(panel.getAsset(index));
                    }
                }));
                panel.showImagePanelPopup(menu, e.getX(), e.getY());
            }
        }

        private void createZone(Asset asset) {
            Zone zone = ZoneFactory.createZone();
            zone.setName(asset.getName());
            BufferedImage image = ImageManager.getImageAndWait(asset.getId());
            if (image.getWidth() < 200 || image.getHeight() < 200) {
                zone.setBackgroundPaint(new DrawableTexturePaint(asset));
            } else {
                zone.setMapAsset(asset.getId());
                zone.setBackgroundPaint(new DrawableColorPaint(Color.black));
            }
            MapPropertiesDialog newMapDialog = new MapPropertiesDialog(TabletopTool.getFrame());
            newMapDialog.setZone(zone);
            newMapDialog.setVisible(true);

            if (newMapDialog.getStatus() == MapPropertiesDialog.Status.OK) {
                TabletopTool.addZone(zone);
            }
        }
    });
    return panel;
}

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

/**
 * Returns a string for the tooltip.//  w ww . j  a  v  a 2  s  .  c  om
 * 
 * @param e
 *            the mouse event.
 * 
 * @return A tool tip or <code>null</code> if no tooltip is available.
 */

@Override
public String getToolTipText(MouseEvent e) {

    String result = null;
    if (this.info != null) {
        EntityCollection entities = this.info.getEntityCollection();
        if (entities != null) {
            Insets insets = getInsets();
            ChartEntity entity = entities.getEntity((int) ((e.getX() - insets.left) / this.scaleX),
                    (int) ((e.getY() - insets.top) / this.scaleY));
            if (entity != null) {
                result = entity.getToolTipText();
            }
        }
    }
    return result;

}

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

/**
 * Handles a 'mouse pressed' event.//from  w  ww . j  a  v  a2  s.  c o  m
 * <P>
 * This event is the popup trigger on Unix/Linux. For Windows, the popup trigger is the 'mouse
 * released' event.
 * 
 * @param e
 *            The mouse event.
 */

@Override
public void mousePressed(MouseEvent e) {
    if (this.chart == null) {
        return;
    }
    Plot plot = this.chart.getPlot();
    int mods = e.getModifiers();
    if ((mods & this.panMask) == this.panMask) {
        // can we pan this plot?
        if (plot instanceof Pannable) {
            Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY());
            if (screenDataArea != null && screenDataArea.contains(e.getPoint())) {
                this.panW = screenDataArea.getWidth();
                this.panH = screenDataArea.getHeight();
                this.panLast = e.getPoint();
                setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
            }
        }
    } else if (this.selectionRectangle == null) {
        Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY());
        if (screenDataArea != null) {
            this.zoomPoint = getPointInRectangle(e.getX(), e.getY(), screenDataArea);
        } else {
            this.zoomPoint = null;
        }
        if (e.isPopupTrigger()) {
            if (this.popup != null) {
                displayPopupMenu(e.getX(), e.getY());
            }
        }
    }
}

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

/**
 * Handles a 'mouse dragged' event./*  w  w w  .j  av a  2 s  .  c o  m*/
 * 
 * @param e
 *            the mouse event.
 */

@Override
public void mouseDragged(MouseEvent e) {

    // if the popup menu has already been triggered, then ignore dragging...
    if (this.popup != null && this.popup.isShowing()) {
        return;
    }

    // handle panning if we have a start point
    if (this.panLast != null) {
        double dx = e.getX() - this.panLast.getX();
        double dy = e.getY() - this.panLast.getY();
        if (dx == 0.0 && dy == 0.0) {
            return;
        }
        double wPercent = -dx / this.panW;
        double hPercent = dy / this.panH;
        boolean old = this.chart.getPlot().isNotify();
        this.chart.getPlot().setNotify(false);
        Pannable p = (Pannable) this.chart.getPlot();
        if (p.getOrientation() == PlotOrientation.VERTICAL) {
            panAxes(wPercent, hPercent, e);
        } else {
            panAxes(hPercent, wPercent, e);
        }
        this.panLast = e.getPoint();
        this.chart.getPlot().setNotify(old);
        return;
    }

    // if no initial zoom point was set, ignore dragging...
    if (this.zoomPoint == null) {
        return;
    }

    boolean hZoom = false;
    boolean vZoom = false;
    if (this.orientation == PlotOrientation.HORIZONTAL) {
        hZoom = this.rangeZoomable;
        vZoom = this.domainZoomable;
    } else {
        hZoom = this.domainZoomable;
        vZoom = this.rangeZoomable;
    }
    Rectangle2D scaledDataArea = getScreenDataArea((int) this.zoomPoint.getX(), (int) this.zoomPoint.getY());
    if (hZoom && vZoom) {
        // 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.selectionRectangle = new Rectangle2D.Double(this.zoomPoint.getX(), this.zoomPoint.getY(),
                xmax - this.zoomPoint.getX(), ymax - this.zoomPoint.getY());
    } else if (hZoom) {
        double xmax = Math.min(e.getX(), scaledDataArea.getMaxX());
        this.selectionRectangle = new Rectangle2D.Double(this.zoomPoint.getX(), scaledDataArea.getMinY(),
                xmax - this.zoomPoint.getX(), scaledDataArea.getHeight());
    } else if (vZoom) {
        double ymax = Math.min(e.getY(), scaledDataArea.getMaxY());
        this.selectionRectangle = new Rectangle2D.Double(scaledDataArea.getMinX(), this.zoomPoint.getY(),
                scaledDataArea.getWidth(), ymax - this.zoomPoint.getY());
    }

    // Draw the new zoom rectangle...
    repaint();

}