List of usage examples for java.awt.event MouseEvent getY
public int getY()
From source file:net.sf.jabref.gui.plaintextimport.TextInputDialog.java
private void maybeShowPopup(MouseEvent e) { if (e.isPopupTrigger()) { popMenu.show(e.getComponent(), e.getX(), e.getY()); } }
From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java
public void mouseReleased(MouseEvent e) { try {// w w w.j av a2 s . c o m if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) { // Rectangle2D scaledDataArea = _chartPanel.getScreenDataArea( // (int) this.coElutionStart.getX(), (int) this.coElutionStart.getY()); JFreeChart jfc = _cp.getChart(); XYPlot p = jfc.getXYPlot(); CenterZoomNumberAxis czna = (CenterZoomNumberAxis) p.getDomainAxis(); Rectangle2D screenDataArea = _cp.getScreenDataArea(e.getX(), e.getY()); Rectangle2D plotboundaries = _cp.getChartRenderingInfo().getPlotInfo().getPlotArea(); double leftmostOnAxis = czna.getLowerBound(); double rightmostOnAxis = czna.getUpperBound(); double leftmostOnRange = this.coElutionRegion.getX(); double rightmostOnRange = this.coElutionRegion.getX() + this.coElutionRegion.getWidth(); double leftmostonscreen = screenDataArea.getX(); double rightmostonscreen = leftmostonscreen + screenDataArea.getWidth(); double slope = (rightmostOnAxis - leftmostOnAxis) / (rightmostonscreen - leftmostonscreen); double transformedLeftRange = (slope * (leftmostOnRange - leftmostonscreen)) + leftmostOnAxis; double transformedRightRange = (slope * (rightmostOnRange - leftmostonscreen)) + leftmostOnAxis; shifted = false; MRMDialog ultimateParent = (MRMDialog) MRMAncestor(); if (ultimateParent != null) { MRMTransition transition = ultimateParent.transitionOnPlot; MRMTransition mrmt = transition; if (mrmt != null) { int row = mrmt.getTableRow(); _ptm.data[row][MRMDialog.peaksData.CoStart.colno] = new Float(0f); _ptm.data[row][MRMDialog.peaksData.CoEnd.colno] = new Float(10000000f); _ptm.setValueAt(new Float(transformedRightRange), row, MRMDialog.peaksData.CoEnd.colno); _ptm.setValueAt(new Float(transformedLeftRange), row, MRMDialog.peaksData.CoStart.colno); } } Graphics2D g2 = (Graphics2D) _cp.getGraphics(); if (this.coElutionRegion != null) drawCoElutionRegion(g2); this.coElutionRegion = null; this.coElutionStart = null; } else { _cp.mouseReleased(e); } } catch (Exception ee) { } }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakAnnotationCalibrationPanel.java
public void onMouseClicked(MouseEvent e) { // find peak under mouse if (e.getButton() == MouseEvent.BUTTON3 && e.getClickCount() == 1 && (e.getModifiers() & MOD_MASK) == e.BUTTON3_MASK) { // open popup createPopupMenu().show(theChartPanel, e.getX(), e.getY()); }// www.j a v a2s. c o m }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopTree.java
@Override public void setLookupSelectHandler(Runnable selectHandler) { impl.addMouseListener(new MouseAdapter() { @Override/*from w w w.j a v a 2 s .c o m*/ public void mousePressed(MouseEvent e) { if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { int rowForLocation = impl.getRowForLocation(e.getX(), e.getY()); TreePath pathForLocation = impl.getPathForRow(rowForLocation); if (pathForLocation != null) { CollectionDatasource treeCds = getDatasource(); if (treeCds != null) { TreeModelAdapter.Node treeItem = (TreeModelAdapter.Node) pathForLocation .getLastPathComponent(); if (treeItem != null) { treeCds.setItem(treeItem.getEntity()); selectHandler.run(); } } } } } }); }
From source file:JavaXWin.java
public void mouseDragged(MouseEvent e) { int h = m_resizeComponent.getHeight(); int w = m_resizeComponent.getWidth(); int x = m_resizeComponent.getX(); int y = m_resizeComponent.getY(); int ex = e.getX(); int ey = e.getY(); switch (m_mode) { case SOUTH:/* ww w . j a va 2 s . c o m*/ if (h + (ey - m_dragY) >= MIN_HEIGHT) m_resizeComponent.setBounds(x, y, w, h + (ey - m_dragY)); else m_resizeComponent.setBounds(x, y, w, MIN_HEIGHT); break; case SOUTHEAST: if (h + (ey - m_dragY) >= MIN_HEIGHT && w + (ex - (getWidth() - CORNER)) >= MIN_WIDTH) m_resizeComponent.setBounds(x, y, w + (ex - (getWidth() - CORNER)), h + (ey - m_dragY)); else if (h + (ey - m_dragY) >= MIN_HEIGHT && !(w + (ex - (getWidth() - CORNER)) >= MIN_WIDTH)) m_resizeComponent.setBounds(x, y, MIN_WIDTH, h + (ey - m_dragY)); else if (!(h + (ey - m_dragY) >= MIN_HEIGHT) && w + (ex - (getWidth() - CORNER)) >= MIN_WIDTH) m_resizeComponent.setBounds(x, y, w + (ex - (getWidth() - CORNER)), MIN_HEIGHT); else m_resizeComponent.setBounds(x, y, MIN_WIDTH, MIN_HEIGHT); break; case SOUTHWEST: if (h + (ey - m_dragY) >= MIN_HEIGHT && w - (ex - m_dragX) >= MIN_WIDTH) m_resizeComponent.setBounds(x + (ex - m_dragX), y, w - (ex - m_dragX), h + (ey - m_dragY)); else if (h + (ey - m_dragY) >= MIN_HEIGHT && !(w - (ex - m_dragX) >= MIN_WIDTH)) { if (x + MIN_WIDTH < m_rightX) m_resizeComponent.setBounds(m_rightX - MIN_WIDTH, y, MIN_WIDTH, h + (ey - m_dragY)); else m_resizeComponent.setBounds(x, y, w, h + (ey - m_dragY)); } else if (!(h + (ey - m_dragY) >= MIN_HEIGHT) && w - (ex - m_dragX) >= MIN_WIDTH) m_resizeComponent.setBounds(x + (ex - m_dragX), y, w - (ex - m_dragX), MIN_HEIGHT); else m_resizeComponent.setBounds(m_rightX - MIN_WIDTH, y, MIN_WIDTH, MIN_HEIGHT); break; } m_rightX = x + w; m_resizeComponent.validate(); }
From source file:JavaXWin.java
public void mouseDragged(MouseEvent e) { int h = m_resizeComponent.getHeight(); int w = m_resizeComponent.getWidth(); int x = m_resizeComponent.getX(); int y = m_resizeComponent.getY(); int ex = e.getX(); int ey = e.getY(); switch (m_mode) { case NORTH:/*from www .ja v a 2s . c o m*/ if (h - (ey - m_dragY) >= MIN_HEIGHT) m_resizeComponent.setBounds(x, y + (ey - m_dragY), w, h - (ey - m_dragY)); else m_resizeComponent.setBounds(x, m_lowerY - MIN_HEIGHT, w, MIN_HEIGHT); break; case NORTHEAST: if (h - (ey - m_dragY) >= MIN_HEIGHT && w + (ex - (getWidth() - CORNER)) >= MIN_WIDTH) m_resizeComponent.setBounds(x, y + (ey - m_dragY), w + (ex - (getWidth() - CORNER)), h - (ey - m_dragY)); else if (h - (ey - m_dragY) >= MIN_HEIGHT && !(w + (ex - (getWidth() - CORNER)) >= MIN_WIDTH)) m_resizeComponent.setBounds(x, y + (ey - m_dragY), MIN_WIDTH, h - (ey - m_dragY)); else if (!(h - (ey - m_dragY) >= MIN_HEIGHT) && w + (ex - (getWidth() - CORNER)) >= MIN_WIDTH) m_resizeComponent.setBounds(x, m_lowerY - MIN_HEIGHT, w + (ex - (getWidth() - CORNER)), MIN_HEIGHT); else m_resizeComponent.setBounds(x, m_lowerY - MIN_HEIGHT, MIN_WIDTH, MIN_HEIGHT); break; case NORTHWEST: if (h - (ey - m_dragY) >= MIN_HEIGHT && w - (ex - m_dragX) >= MIN_WIDTH) m_resizeComponent.setBounds(x + (ex - m_dragX), y + (ey - m_dragY), w - (ex - m_dragX), h - (ey - m_dragY)); else if (h - (ey - m_dragY) >= MIN_HEIGHT && !(w - (ex - m_dragX) >= MIN_WIDTH)) { if (x + MIN_WIDTH < m_rightX) m_resizeComponent.setBounds(m_rightX - MIN_WIDTH, y + (ey - m_dragY), MIN_WIDTH, h - (ey - m_dragY)); else m_resizeComponent.setBounds(x, y + (ey - m_dragY), w, h - (ey - m_dragY)); } else if (!(h - (ey - m_dragY) >= MIN_HEIGHT) && w - (ex - m_dragX) >= MIN_WIDTH) m_resizeComponent.setBounds(x + (ex - m_dragX), m_lowerY - MIN_HEIGHT, w - (ex - m_dragX), MIN_HEIGHT); else m_resizeComponent.setBounds(m_rightX - MIN_WIDTH, m_lowerY - MIN_HEIGHT, MIN_WIDTH, MIN_HEIGHT); break; } m_rightX = x + w; m_resizeComponent.validate(); }
From source file:com.limegroup.gnutella.gui.tables.ActionIconAndNameEditor.java
public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, int row, int column) { ActionIconAndNameHolder in = (ActionIconAndNameHolder) value; action = in.getAction();// w ww. j ava2 s . c o m final Component component = new ActionIconAndNameRenderer().getTableCellRendererComponent(table, value, isSelected, true, row, column); component.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (actionRegion == null) { component_mousePressed(e); } else { if (actionRegion.contains(e.getPoint())) { component_mousePressed(e); } else { if (e.getClickCount() >= 2) { Toolkit.getDefaultToolkit().getSystemEventQueue() .postEvent(new MouseEvent(table, MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), component.getX() + e.getX(), component.getY() + e.getY(), e.getClickCount(), false)); } } } } else if (e.getButton() == MouseEvent.BUTTON3) { Toolkit.getDefaultToolkit().getSystemEventQueue() .postEvent(new MouseEvent(table, e.getID(), e.getWhen(), e.getModifiers(), component.getX() + e.getX(), component.getY() + e.getY(), e.getClickCount(), true)); } } }); return component; }
From source file:net.sf.jabref.gui.maintable.MainTableSelectionListener.java
/** * Process general right-click events on the table. Show the table context menu at * the position where the user right-clicked. * @param e The mouse event defining the popup trigger. * @param row The row where the event occurred. *///w ww . j ava 2s . c o m private void processPopupTrigger(MouseEvent e, int row) { int selRow = table.getSelectedRow(); if ((selRow == -1) || !table.isRowSelected(table.rowAtPoint(e.getPoint()))) { table.setRowSelectionInterval(row, row); } RightClickMenu rightClickMenu = new RightClickMenu(JabRefGUI.getMainFrame(), panel); rightClickMenu.show(table, e.getX(), e.getY()); }
From source file:com.hexidec.ekit.component.RelativeImageView.java
/** Select or grow image when clicked. *//*from ww w .j ava2 s.c o m*/ public void mousePressed(MouseEvent e) { Dimension size = fComponent.getSize(); if ((e.getX() >= (size.width - 7)) && (e.getY() >= (size.height - 7)) && (getSelectionState() == 2)) { // Click in selected grow-box: Point loc = fComponent.getLocationOnScreen(); fGrowBase = new Point(loc.x + e.getX() - fWidth, loc.y + e.getY() - fHeight); fGrowProportionally = e.isShiftDown(); } else { // Else select image: fGrowBase = null; JTextComponent comp = (JTextComponent) fContainer; int start = fElement.getStartOffset(); int end = fElement.getEndOffset(); int mark = comp.getCaret().getMark(); int dot = comp.getCaret().getDot(); if (e.isShiftDown()) { // extend selection if shift key down: if (mark <= start) { comp.moveCaretPosition(end); } else { comp.moveCaretPosition(start); } } else { // just select image, without shift: if (mark != start) { comp.setCaretPosition(start); } if (dot != end) { comp.moveCaretPosition(end); } } } }
From source file:forge.screens.match.CMatchUI.java
@Override public SpellAbility getAbilityToPlay(List<SpellAbility> abilities, ITriggerEvent triggerEvent) { if (triggerEvent == null) { if (abilities.isEmpty()) { return null; }/*from w ww .j av a2 s .com*/ if (abilities.size() == 1) { return abilities.get(0); } return GuiChoose.oneOrNone("Choose ability to play", abilities); } if (abilities.isEmpty()) { return null; } if (abilities.size() == 1 && !abilities.get(0).promptIfOnlyPossibleAbility()) { if (abilities.get(0).canPlay()) { return abilities.get(0); //only return ability if it's playable, otherwise return null } return null; } //show menu if mouse was trigger for ability final JPopupMenu menu = new JPopupMenu("Abilities"); boolean enabled; boolean hasEnabled = false; int shortcut = KeyEvent.VK_1; //use number keys as shortcuts for abilities 1-9 for (final SpellAbility ab : abilities) { enabled = ab.canPlay(); if (enabled) { hasEnabled = true; } GuiUtils.addMenuItem(menu, FSkin.encodeSymbols(ab.toString(), true), shortcut > 0 ? KeyStroke.getKeyStroke(shortcut, 0) : null, new Runnable() { @Override public void run() { CPrompt.SINGLETON_INSTANCE.selectAbility(ab); } }, enabled); if (shortcut > 0) { shortcut++; if (shortcut > KeyEvent.VK_9) { shortcut = 0; //stop adding shortcuts after 9 } } } if (hasEnabled) { //only show menu if at least one ability can be played SwingUtilities.invokeLater(new Runnable() { //use invoke later to ensure first ability selected by default public void run() { MenuSelectionManager.defaultManager() .setSelectedPath(new MenuElement[] { menu, menu.getSubElements()[0] }); } }); MouseEvent mouseEvent = ((MouseTriggerEvent) triggerEvent).getMouseEvent(); menu.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY()); } return null; //delay ability until choice made }