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:org.gumtree.vis.awt.JChartPanel.java

private void moveSelectedText(MouseEvent e) {
    Point2D screenPoint = translateScreenToJava2D(e.getPoint());
    Rectangle2D screenArea = getScreenDataArea();
    if (screenArea.contains(screenPoint)) {

        if (textMovePoint != null) {
            //               Point2D point = translateScreenToChart(translateScreenToJava2D(e.getPoint()));
            double screenX = ChartMaskingUtilities.translateScreenX(e.getX() / getScaleX(), getScreenDataArea(),
                    getChart());//from   w  ww.j  av a 2s. c  o  m
            double screenY = ChartMaskingUtilities.translateScreenY(e.getY(), getScreenDataArea(), getChart(),
                    0);
            //               Point2D point = translateScreenToChart(translateScreenToJava2D(e.getPoint()));
            Point2D point = new Point2D.Double(screenX, screenY);
            selectedTextWrapper.setRect(selectedTextWrapper.getMinX() + point.getX() - textMovePoint.getX(),
                    selectedTextWrapper.getMinY() + point.getY() - textMovePoint.getY(),
                    selectedTextWrapper.getWidth(), selectedTextWrapper.getHeight());
            if (point != null) {
                this.textMovePoint = point;
            }
            repaint();
        }
    }
}

From source file:com.haulmont.cuba.desktop.sys.DesktopWindowManager.java

public void showTabPopup(MouseEvent e) {
    JComponent tabHeaderComponent = (JComponent) e.getComponent();
    int tabIndex = getTabIndex(tabHeaderComponent);
    JComponent tabContent = (JComponent) tabsPane.getComponentAt(tabIndex);
    WindowBreadCrumbs windowBreadCrumbs = tabs.get(tabContent);

    Window window = windowBreadCrumbs.getCurrentWindow();

    JPopupMenu popupMenu = createWindowPopupMenu(window);
    if (popupMenu.getComponentCount() > 0) {
        popupMenu.show(tabHeaderComponent, e.getX(), e.getY());
    }//from   ww w. ja  v a 2 s . c  o  m
}

From source file:org.gumtree.vis.awt.JChartPanel.java

@Override
public void mousePressed(MouseEvent e) {
    if (selectedTextWrapper != null && getCursor() == Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)) {
        Point2D screenXY = ChartMaskingUtilities.translateChartPoint(
                new Point2D.Double(selectedTextWrapper.getMinX(), selectedTextWrapper.getMinY()),
                getScreenDataArea(), getChart());
        Rectangle2D screenRect = new Rectangle2D.Double(screenXY.getX(), screenXY.getY() - 15,
                selectedTextWrapper.getWidth(), selectedTextWrapper.getHeight());
        if (screenRect.contains(e.getX(), e.getY())) {

            double screenX = ChartMaskingUtilities.translateScreenX(e.getX() / getScaleX(), getScreenDataArea(),
                    getChart());/*w w w  .j  a  va 2 s.c  o  m*/
            double screenY = ChartMaskingUtilities.translateScreenY(e.getY(), getScreenDataArea(), getChart(),
                    0);
            //         Point2D point = translateScreenToChart(translateScreenToJava2D(e.getPoint()));
            Point2D point = new Point2D.Double(screenX, screenY);
            if (point != null) {
                this.textMovePoint = point;
            }
        } else {
            this.textMovePoint = null;
        }
    } else {
        super.mousePressed(e);
    }
}

From source file:com.isti.traceview.common.TraceViewChartPanel.java

/**
 * Returns a string for the tooltip.//from   w w  w .  jav  a 2s .c o  m
 * 
 * @param e
 *            the mouse event.
 * @return A tool tip or <code>null</code> if no tooltip is available.
 */
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:org.rdv.viz.chart.ChartPanel.java

/**
 * Returns a string for the tooltip./*from ww w .j a va  2s.c om*/
 *
 * @param e  the mouse event.
 *
 * @return A tool tip or <code>null</code> if no tooltip is available.
 */
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.SE.myPlayer.MusicPlayerGUI.java

private void songData_TableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_songData_TableMouseClicked
        try {/*from  ww  w .j  a  v a 2  s .c o m*/
            if (evt.getClickCount() == 2 | next == 1 | previous == 1 && SwingUtilities.isLeftMouseButton(evt)) {
                currentSongRow = songData_Table.getSelectedRow();
                songLocation = songData[currentSongRow];
                sd.addToRecent(songLocation);
                for (ObjectBean list1 : list) {
                    list1.getMpg().addJmenuItemsToRecentSongs();
                }
                songPlay();
            } else if (SwingUtilities.isRightMouseButton(evt)) {
                Point point = evt.getPoint();
                int alreadySelectedRow = songData_Table.getSelectedRow();
                int currentRow = songData_Table.rowAtPoint(point);
                songData_Table.setRowSelectionInterval(alreadySelectedRow, currentRow);
                if (songData_Table.isRowSelected(currentRow)) {
                    songTable_PopUp.show(songData_Table, evt.getX(), evt.getY());
                } else {
                    songTable_PopUp.show(songTable_PopUp, evt.getX(), evt.getY());
                }
            }
        } catch (Exception e) {
            currentSongRow = songData_Table.getSelectedRow();
            songLocation = songData[currentSongRow];
            sd.addToRecent(songLocation);
            for (ObjectBean list1 : list) {
                list1.getMpg().addJmenuItemsToRecentSongs();
            }
            songPlay();
        }
        ;
    }

From source file:com.isti.traceview.common.TraceViewChartPanel.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.
 * /*from  ww w .  j  a  va 2  s  .co m*/
 * @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()))) {
                restoreAutoBounds();
            } else {
                double x, y, w, h;
                Rectangle2D screenDataArea = getScreenDataArea((int) this.zoomPoint.getX(),
                        (int) this.zoomPoint.getY());
                // 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(),
                            screenDataArea.getMaxX() - 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(),
                            screenDataArea.getMaxY() - this.zoomPoint.getY());
                } else {
                    x = this.zoomPoint.getX();
                    y = this.zoomPoint.getY();
                    w = Math.min(this.zoomRectangle.getWidth(),
                            screenDataArea.getMaxX() - this.zoomPoint.getX());
                    h = Math.min(this.zoomRectangle.getHeight(),
                            screenDataArea.getMaxY() - 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.peterbochs.instrument.InstrumentPanel.java

public void updateCallGraph() {
    graph = new mxGraph() {
        public void drawState(mxICanvas canvas, mxCellState state, String label) {
            if (getModel().isVertex(state.getCell()) && canvas instanceof PeterSwingCanvas) {
                PeterSwingCanvas c = (PeterSwingCanvas) canvas;
                c.drawVertex(state, label);
            } else {
                // draw edge, at least
                //               super.drawState(canvas, state, label);
                super.drawState(canvas, state, true);
            }//from  w w  w .ja va2 s.co m
        }

        // Ports are not used as terminals for edges, they are
        // only used to compute the graphical connection point

        public boolean isPort(Object cell) {
            mxGeometry geo = getCellGeometry(cell);

            return (geo != null) ? geo.isRelative() : false;
        }

        // Implements a tooltip that shows the actual
        // source and target of an edge
        public String getToolTipForCell(Object cell) {
            if (model.isEdge(cell)) {
                return convertValueToString(model.getTerminal(cell, true)) + " -> "
                        + convertValueToString(model.getTerminal(cell, false));
            }

            return super.getToolTipForCell(cell);
        }

        public boolean isCellFoldable(Object cell, boolean collapse) {
            return false;
        }
    };
    graphComponent = new CallGraphComponent(graph);
    Object parent = graph.getDefaultParent();

    addCells(parent);
    graph.setCellsDisconnectable(false);

    graphComponent.setGridVisible(true);
    graphComponent.setGridColor(Color.lightGray);
    graphComponent.setBackground(Color.white);
    graphComponent.getViewport().setOpaque(false);
    graphComponent.setBackground(Color.WHITE);
    graphComponent.setConnectable(false);
    graphComponent.getGraphControl().addMouseListener(new MouseAdapter() {
        public void mouseReleased(MouseEvent e) {
            Object cell = graphComponent.getCellAt(e.getX(), e.getY());

            if (cell != null) {
                String label = graph.getLabel(cell);
                if (label.contains("->")) {
                    cellClientEvent(label);
                }
            }
        }
    });

    graph.setCellsResizable(false);
    graph.setCellsMovable(false);
    graph.setCellsEditable(false);
    graph.foldCells(false);
    graph.setGridSize(10);
    jPanel3.removeAll();
    jPanel3.add(graphComponent, BorderLayout.CENTER);

    graphOutline = new mxGraphOutline(graphComponent);
    graphOutline.setBackground(Color.white);
    graphOutline.setBorder(new LineBorder(Color.LIGHT_GRAY));
    jCallGraphPreviewPanel.removeAll();
    jCallGraphPreviewPanel.add(graphOutline, BorderLayout.CENTER);
    jCallGraphPreviewPanel.setPreferredSize(new Dimension(100, 100));
}

From source file:org.alex73.skarynka.scan.ui.book.BooksController.java

public BooksController() {
    try {/* w  w w.j  a  v a2s .co m*/
        panel = new BooksPanel();
        ((AbstractDocument) panel.txtNewName.getDocument()).setDocumentFilter(bookNameFilter);

        listScanDirs();

        panel.table.setModel(model());
        panel.table.setRowSelectionAllowed(true);
        panel.table.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) {
                    BookRow b = books.get(panel.table.getSelectedRow());
                    DataStorage.openBook(b.bookName, true);
                }
            }

            @Override
            public void mousePressed(MouseEvent e) {
                if (SwingUtilities.isRightMouseButton(e)) {
                    for (int i = 0; i < panel.menuProcess.getComponentCount(); i++) {
                        Component item = panel.menuProcess.getComponent(i);
                        if ((item instanceof JMenuItem) && (item.getName() != null)) {
                            panel.menuProcess.remove(i);
                            i--;
                        }
                    }
                    if (Context.getPermissions().BookControl) {
                        for (int scale : new int[] { 25, 50, 75, 100, 200 }) {
                            JMenuItem item = new JMenuItem(scale + "%");
                            item.setName(scale + "%");
                            item.addActionListener(new ChangeScale(scale));
                            panel.menuProcess.add(item);
                        }
                    }

                    currentBooksNames.clear();
                    int[] selected = panel.table.getSelectedRows();
                    boolean allLocals = true;
                    boolean processAllowed = Context.getPermissions().BookControl;
                    for (int row : selected) {
                        BookRow b = books.get(panel.table.convertRowIndexToModel(row));
                        currentBooksNames.add(b.bookName);
                        if (!b.local) {
                            allLocals = false;
                        }
                    }
                    panel.itemFinish.setVisible(allLocals);
                    if (processAllowed) {
                        for (Map.Entry<String, String> en : Context.getProcessCommands().entrySet()) {
                            JMenuItem item = new JMenuItem(en.getValue());
                            item.setName(en.getKey());
                            item.addActionListener(commandListener);
                            panel.menuProcess.add(item);
                        }
                    }
                    panel.menuProcess.show(panel.table, e.getX(), e.getY());
                }
            }
        });

        panel.btnCreate.setEnabled(false);
        panel.btnCreate.addActionListener(
                new ActionErrorListener(panel, "ERROR_BOOK_CREATE", LOG, "Error create book") {
                    protected void action(ActionEvent e) throws Exception {
                        File bookDir = new File(Context.getBookDir(), panel.txtNewName.getText());
                        if (bookDir.exists()) {
                            JOptionPane.showMessageDialog(panel,
                                    Messages.getString("PANEL_BOOK_NEW_BOOK_EXIST"),
                                    Messages.getString("PANEL_BOOK_TITLE"), JOptionPane.WARNING_MESSAGE);
                            return;
                        }

                        DataStorage.openBook(panel.txtNewName.getText(), true);
                    }
                });

        setMenuListeners();
    } catch (Throwable ex) {
        LOG.error("Error list books", ex);
        JOptionPane.showMessageDialog(DataStorage.mainFrame,
                "Error: " + ex.getClass() + " / " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    }
}

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

/**
 * Receives notification of mouse clicks on the panel. These are translated and passed on to any
 * registered {@link ChartMouseListener}s.
 * //  w w w  . j  av a  2 s  .c om
 * @param event
 *            Information about the mouse event.
 */

@Override
public void mouseClicked(MouseEvent event) {

    Insets insets = getInsets();
    int x = (int) ((event.getX() - insets.left) / this.scaleX);
    int y = (int) ((event.getY() - insets.top) / this.scaleY);

    this.anchor = new Point2D.Double(x, y);
    if (this.chart == null) {
        return;
    }
    this.chart.setNotify(true); // force a redraw
    // new entity code...
    Object[] listeners = this.chartMouseListeners.getListeners(ChartMouseListener.class);
    if (listeners.length == 0) {
        return;
    }

    ChartEntity entity = null;
    if (this.info != null) {
        EntityCollection entities = this.info.getEntityCollection();
        if (entities != null) {
            entity = entities.getEntity(x, y);
        }
    }
    ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), event, entity);
    for (int i = listeners.length - 1; i >= 0; i -= 1) {
        ((ChartMouseListener) listeners[i]).chartMouseClicked(chartEvent);
    }

}