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:ucar.unidata.idv.control.chart.TimeSeriesChartWrapper.java

/**
 * Get the tool tip text//from w ww  .j a v a  2  s  .c o  m
 *
 * @param event The event
 *
 * @return tool tip
 */
public String chartPanelGetToolTipText(MouseEvent event) {
    ChartAnnotation annotation = findClosestAnnotation(getAllAnnotations(), event.getX(), event.getY(), false,
            false);
    if (annotation == null) {
        return null;
    }
    return annotation.getToolTipText();
}

From source file:game.Clue.ClueGameUI.java

public void mouseReleased(MouseEvent e) {

    System.out.println("Mouse clicked/released on chosen room" + e.getSource().toString());

    if (player == null) {
        return;/*from   w  w  w  . jav a  2  s. c o  m*/
    }

    //validate move by sending move request to Server before allowing move
    int valid = 1;

    player.setVisible(false);

    Component c = jPanel5.findComponentAt(e.getX(), e.getY());

    if (c instanceof JLabel) {
        Container parent = c.getParent();
        if (parent.getComponentCount() == 0) {
            System.out.println("------");
            //parent.remove(0);
            parent.add(player);

        } else {
            System.out.println("%%%%%");
            parent.add(player);
            parent.validate();
            //return;
        }

    } else {
        Container parent = (Container) c;
        if (parent.getComponentCount() == 1) {
            System.out.println("*****");
            return;
        } else {
            System.out.println("&&&&&");
            parent.add(player);
        }

    }
    if (valid != 0) {
        System.out.println("Player move allowed" + " x:" + e.getX() + "y: " + e.getY());
        System.out.println("Previous x:" + previous_room_x + "  Y:" + previous_room_y);
        player.setLocation(previous_room_x, previous_room_y);
        // player.setLocation(e.getX(),e.getY());
    } else {

    }
    player.setHorizontalAlignment(SwingConstants.CENTER);
    player.setVisible(true);

}

From source file:gdt.jgui.entity.webset.JWeblinkEditor.java

private void showLoginMenu(MouseEvent e) {
    try {/*from   w  w w . ja  v a  2  s .  c  om*/
        JPopupMenu logonMenu = new JPopupMenu();
        JMenuItem copyItem = new JMenuItem("Copy");
        logonMenu.add(copyItem);
        copyItem.setHorizontalTextPosition(JMenuItem.RIGHT);
        copyItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    StringSelection stringSelection = new StringSelection(loginField.getText());
                    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
                    clipboard.setContents(stringSelection, JWeblinkEditor.this);
                } catch (Exception ee) {
                    Logger.getLogger(getClass().getName()).info(ee.toString());
                }
            }
        });
        logonMenu.show(e.getComponent(), e.getX(), e.getY());
    } catch (Exception ee) {
        Logger.getLogger(getClass().getName()).severe(ee.toString());
    }
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.SpectraPanel.java

public void mouseReleased(MouseEvent e) {
    if (MouseUtils.isPopupTrigger(e)) {
        // clear all
        if (zoom_rectangle != null) {
            Graphics2D g2 = (Graphics2D) getGraphics();
            g2.setXORMode(java.awt.Color.gray);
            g2.draw(zoom_rectangle);/*from   w w w  .  jav  a  2 s  .  c  o  m*/
            g2.dispose();
        }
        mouse_start_point = null;
        zoom_rectangle = null;

        // open popup
        current_peak = findPeakAt(e.getPoint());
        enforceSelection(current_peak);
        createPopupMenu(current_peak != null).show(theChartPanel, e.getX(), e.getY());
    } else {
        if (zoom_rectangle != null && mouse_start_point != null) {
            if (Math.abs(e.getX() - mouse_start_point.getX()) > 10) {
                //if( e.getX() < mouse_start_point.getX() ) {
                // unzoom all
                //    onZoomNone();
                //}
                //else {        

                // zoom area           
                double start_x = Math.min(e.getX(), mouse_start_point.getX());
                double end_x = Math.max(e.getX(), mouse_start_point.getX());

                Rectangle2D data_area = theChartPanel.getScreenDataArea((int) start_x,
                        (int) mouse_start_point.getY());

                double new_lower_bound = screenToDataCoordX(start_x);
                double new_upper_bound = screenToDataCoordX(Math.min(end_x, data_area.getMaxX()));
                thePlot.getDomainAxis().setRange(new Range(new_lower_bound, new_upper_bound));
            } else {
                // clear rectangle
                Graphics2D g2 = (Graphics2D) getGraphics();
                g2.setXORMode(java.awt.Color.gray);
                g2.draw(zoom_rectangle);
                g2.dispose();
            }
        }

        // restore zooming
        if (!was_moving && is_moving)
            onActivateZooming();

        zoom_rectangle = null;
        mouse_start_point = null;
    }
}

From source file:org.gumtree.vis.hist2d.Hist2DPanel.java

/**
 * Implementation of the MouseMotionListener's method.
 *
 * @param e  the event./* w w  w. j  a  va2  s  .  c  o m*/
 */
public void mouseMoved(MouseEvent e) {
    if (getHorizontalAxisTrace()) {
        setHorizontalTraceLocation(e.getX());
    }
    if (getVerticalAxisTrace()) {
        setVerticalTraceLocation(e.getY());
    }

    Insets insets = getInsets();
    int x = (int) ((e.getX() - insets.left) / getScaleX());
    int y = (int) ((e.getY() - insets.top) / getScaleY());

    ChartEntity entity = null;
    if (getChartRenderingInfo() != null) {
        EntityCollection entities = getChartRenderingInfo().getEntityCollection();
        if (entities != null) {
            entity = entities.getEntity(x, y);
        }
    }
    if (entity instanceof XYItemEntity) {
        IDataset dataset = (IDataset) ((XYItemEntity) entity).getDataset();
        int item = ((XYItemEntity) entity).getItem();
        setChartX(dataset.getXValue(0, item));
        setChartY(dataset.getYValue(0, item));
        setChartZ(((XYZDataset) dataset).getZValue(0, item));
    }

    if (getHorizontalAxisTrace() || getVerticalAxisTrace() || isToolTipFollowerEnabled()) {
        repaint();
    }

    //        if ((e.getModifiers() & maskingKeyMask) != 0) {
    //           int cursorType = findSelectedMask(e.getX(), e.getY());
    //           setCursor(Cursor.getPredefinedCursor(cursorType));
    //        } else if (getCursor() != defaultCursor) {
    //           setCursor(defaultCursor);
    //        }
    //        
    // we can only generate events if the panel's chart is not null
    // (see bug report 1556951)
    Object[] listeners = getListeners(ChartMouseListener.class);

    if (getChart() != null) {
        XYZChartMouseEvent event = new XYZChartMouseEvent(getChart(), e, entity);
        event.setXYZ(getChartX(), getChartY(), getChartZ());
        for (int i = listeners.length - 1; i >= 0; i -= 1) {
            ((ChartMouseListener) listeners[i]).chartMouseMoved(event);
        }
    }
    super.mouseMoved(e);

}

From source file:MouseNavigateTest.java

/**
 * Dispatches mouse events as appropriate. Should not need to overide this
 * method./*from w ww  .j  a  v  a  2  s  .c om*/
 */
//*****************************************************************************
protected void processMouseEvent(java.awt.event.MouseEvent evt) {
    if (m_Object != null) {
        if (isStartBehaviorEvent(evt) != false)
            adjustTransform(evt.getX(), evt.getY());

        else if (isStopBehaviorEvent(evt) != false)
            onEndDrag();
    }
}

From source file:edu.ku.brc.specify.tasks.subpane.ESResultsTablePanel.java

/**
 * /*  w ww  .  jav a  2  s.c om*/
 */
protected void addContextMenu() {
    MouseAdapter mouseAdapter = new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            super.mousePressed(e);

            if (e.isPopupTrigger()) {
                if (table.getSelectedColumnCount() > 0) {
                    if (popupMenu != null && popupMenu.isVisible()) {
                        popupMenu.setVisible(false);
                    }

                    if (popupMenu == null) {
                        popupMenu = new JPopupMenu();
                        JMenuItem mi = popupMenu.add(new JMenuItem(UIRegistry.getResourceString("Remove")));
                        mi.addActionListener(createRemoveItemAL());
                    }
                    Point p = table.getLocationOnScreen();
                    popupMenu.setLocation(p.x + e.getX() + 1, p.y + e.getY() + 1);
                    popupMenu.setVisible(true);
                }
            }
        }
    };
    table.addMouseListener(mouseAdapter);
}

From source file:nosqltools.MainForm.java

public void connect() {
    String user;//www .ja v  a  2  s  .co  m
    String pass;
    String dbname;
    String serveradd;
    int port;

    LoginDialog dlg_login = new LoginDialog(null);
    dlg_login.setVisible(true);

    //If user chose login and not cancel option on dialog box
    if (dlg_login.isToLogin()) {
        Text_MessageBar.setText(Initializations.DBATTEMPTING);
        Text_MessageBar.setForeground(Color.ORANGE);
        user = dlg_login.getUsername();
        pass = dlg_login.getPassword();
        dbname = dlg_login.getDatabase();
        serveradd = dlg_login.getServerAddr();
        port = dlg_login.getPort();

        if (dbcon.connect(user, pass, dbname, serveradd, port)) {
            DefaultTreeModel defTableMod = dbcon.buildDBTree();
            if (defTableMod != null && dbcon.isConnectionSuccess()) {
                jTree1.setModel(defTableMod);
                Text_MessageBar.setText(Initializations.DBCONNSUCCESS);
                Text_MessageBar.setForeground(Color.GREEN);
                Menu_Collections.setEnabled(true);

                //load the data of collection in panel_text on double click
                jTree1.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent me) {
                        if (me.getButton() == MouseEvent.BUTTON1) {
                            if (me.getClickCount() == 2) {
                                //get the path of the mouse click ex:[localhost,test,testData] 
                                Op_Refresh.setEnabled(true);
                                tp = jTree1.getPathForLocation(me.getX(), me.getY());
                                if (tp != null) {
                                    List<String> coll_db = dbcon.getAllCollections();
                                    int cnt = tp.getPathCount();
                                    for (int i = 0; i < cnt; i++) {
                                        //if one of the collection matches the coll that was clicked by the user load data
                                        if (coll_db.contains(tp.getPathComponent(i).toString())) {
                                            indexOfCurrentCollection = i;
                                            sb = dbcon.getCollectionData(tp.getPathComponent(i).toString());

                                            if (sb != null) {
                                                Panel_Text.setVisible(true);

                                                JsonNode jNode1;
                                                try {
                                                    jNode1 = mapper.readTree(sb.toString());
                                                    textArea.setText(mapper.writerWithDefaultPrettyPrinter()
                                                            .writeValueAsString(jNode1));
                                                } catch (IOException ex) {
                                                    Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE,
                                                            null, ex);
                                                }

                                                Text_MessageBar.setText(Initializations.INITSTRING);
                                                // textArea.setText(sb.toString());
                                                validateDataPanel_text(sb);
                                                /*
                                                if (json_util.isValid(sb.toString())) 
                                                {
                                                    json_util.isDataParsed(textArea.getText());
                                                    Text_MessageBar.setText(Initializations.JSONFILESUCCESS);
                                                } 
                                                else 
                                                {
                                                    sb.setLength(0);
                                                    //JOptionPane.showMessageDialog(this, Initializations.JSONINCORRECTFORMAT , Initializations.VALIDATIONERROR , JOptionPane.ERROR_MESSAGE);
                                                        
                                                    try
                                                    {
                                                Object obj = parser.parse(sb.toString());
                                                    }
                                                    catch(org.json.simple.parser.ParseException pe)
                                                    {
                                                       Text_MessageBar.setText(Initializations.ERRORLINE + json_util.getLineNumber(pe.getPosition(), textArea.getText()) + " - " + pe);
                                                    }
                                                } */
                                            } else {
                                                Panel_Text.setVisible(false);
                                                Text_MessageBar.setText(Initializations.SYSTEMCOLL);
                                                Text_MessageBar.setForeground(Color.RED);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                });
            } else {
                jTree1.setModel(null);
                Text_MessageBar.setText(Initializations.DBCONNFAIL);
                Text_MessageBar.setForeground(Color.RED);
            }
        } else {
            jTree1.setModel(null);
            Text_MessageBar.setText(Initializations.DBCONNFAIL);
            Text_MessageBar.setForeground(Color.RED);
        }
    } else {
        jTree1.setModel(null);
        Text_MessageBar.setText(Initializations.DBCONNFAIL);
        Text_MessageBar.setForeground(Color.RED);
    }

}

From source file:ucar.unidata.idv.control.chart.TimeSeriesChartWrapper.java

/**
 * Callback method for receiving notification of a mouse click on a chart.
 *
 * @param event  information about the event.
 *
 * @return Did we handle this event/*from  w  ww  .j  av a 2  s  .c o m*/
 */
public boolean chartPanelMousePressed(MouseEvent event) {
    if (SwingUtilities.isRightMouseButton(event)) {
        closestAnnotation = findClosestAnnotation(getAllAnnotations(), event.getX(), event.getY(), false,
                false);
    }
    return EVENT_PASSON;
}

From source file:com.mirth.connect.client.ui.DashboardPanel.java

/**
 * Makes the status table with all current server information.
 *///from w w w .ja v  a  2 s.c om
public void makeStatusTable() {
    List<String> columns = new ArrayList<String>();

    for (DashboardColumnPlugin plugin : LoadedExtensions.getInstance().getDashboardColumnPlugins().values()) {
        if (plugin.isDisplayFirst()) {
            columns.add(plugin.getColumnHeader());
        }
    }

    columns.addAll(Arrays.asList(defaultColumns));

    for (DashboardColumnPlugin plugin : LoadedExtensions.getInstance().getDashboardColumnPlugins().values()) {
        if (!plugin.isDisplayFirst()) {
            columns.add(plugin.getColumnHeader());
        }
    }

    DashboardTreeTableModel model = new DashboardTreeTableModel();
    model.setColumnIdentifiers(columns);
    model.setNodeFactory(new DefaultDashboardTableNodeFactory());

    for (DashboardTablePlugin plugin : LoadedExtensions.getInstance().getDashboardTablePlugins().values()) {
        dashboardTable = plugin.getTable();

        if (dashboardTable != null) {
            break;
        }
    }

    defaultVisibleColumns.addAll(columns);

    if (dashboardTable == null) {
        dashboardTable = new MirthTreeTable("dashboardPanel", defaultVisibleColumns);
    }

    dashboardTable.setColumnFactory(new DashboardTableColumnFactory());
    dashboardTable.setTreeTableModel(model);
    dashboardTable.setDoubleBuffered(true);
    dashboardTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    dashboardTable.setHorizontalScrollEnabled(true);
    dashboardTable.packTable(UIConstants.COL_MARGIN);
    dashboardTable.setRowHeight(UIConstants.ROW_HEIGHT);
    dashboardTable.setOpaque(true);
    dashboardTable.setRowSelectionAllowed(true);
    dashboardTable.setSortable(true);
    dashboardTable.putClientProperty("JTree.lineStyle", "Horizontal");
    dashboardTable.setAutoCreateColumnsFromModel(false);
    dashboardTable.setShowGrid(true, true);
    dashboardTable.restoreColumnPreferences();
    dashboardTable.setMirthColumnControlEnabled(true);

    dashboardTable.setTreeCellRenderer(new DefaultTreeCellRenderer() {
        @Override
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
                boolean leaf, int row, boolean hasFocus) {
            JLabel label = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row,
                    hasFocus);

            TreePath path = dashboardTable.getPathForRow(row);
            if (path != null) {
                AbstractDashboardTableNode node = ((AbstractDashboardTableNode) path.getLastPathComponent());
                if (node.isGroupNode()) {
                    setIcon(UIConstants.ICON_GROUP);
                } else {
                    DashboardStatus status = node.getDashboardStatus();
                    if (status.getStatusType() == StatusType.CHANNEL) {
                        setIcon(UIConstants.ICON_CHANNEL);
                    } else {
                        setIcon(UIConstants.ICON_CONNECTOR);
                    }
                }
            }

            return label;
        }
    });
    dashboardTable.setLeafIcon(UIConstants.ICON_CONNECTOR);
    dashboardTable.setOpenIcon(UIConstants.ICON_CHANNEL);
    dashboardTable.setClosedIcon(UIConstants.ICON_CHANNEL);

    dashboardTableScrollPane.setViewportView(dashboardTable);

    dashboardTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent event) {
            checkSelectionAndPopupMenu(event);
        }

        @Override
        public void mouseReleased(MouseEvent event) {
            checkSelectionAndPopupMenu(event);
        }

        @Override
        public void mouseClicked(MouseEvent event) {
            int clickedRow = dashboardTable.rowAtPoint(new Point(event.getX(), event.getY()));
            if (clickedRow == -1) {
                return;
            }

            TreePath path = dashboardTable.getPathForRow(clickedRow);
            if (path != null && ((AbstractDashboardTableNode) path.getLastPathComponent()).isGroupNode()) {
                return;
            }

            if (event.getClickCount() >= 2 && dashboardTable.getSelectedRowCount() == 1
                    && dashboardTable.getSelectedRow() == clickedRow) {
                parent.doShowMessages();
            }
        }
    });

    dashboardTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent event) {
            /*
             * MIRTH-3199: Only update the panel plugin if the selection is finished. This does
             * mean that the logs aren't updated live when adding to or removing from a
             * currently adjusting selection, but it's much more efficient when it comes to the
             * number of requests being done from the client. Plus, it actually will still
             * update while a selection is adjusting if the refresh interval on the dashboard
             * elapses. We can change this so that plugins are updated during a selection
             * adjustment, but it would first require a major rewrite of the connection log /
             * status column plugin.
             */
            updatePopupMenu(!event.getValueIsAdjusting());
        }
    });
}