List of usage examples for java.awt.event MouseEvent getY
public int getY()
From source file:JavaXWin.java
public WindowWatcher(JDesktopPane desktop) { m_desktop = desktop;/*from w w w . j a v a 2 s .c om*/ setOpaque(true); m_northResizer = new NorthResizeEdge(this); m_southResizer = new SouthResizeEdge(this); m_eastResizer = new EastResizeEdge(this); m_westResizer = new WestResizeEdge(this); setLayout(new BorderLayout()); add(m_northResizer, BorderLayout.NORTH); add(m_southResizer, BorderLayout.SOUTH); add(m_eastResizer, BorderLayout.EAST); add(m_westResizer, BorderLayout.WEST); MouseInputAdapter ma = new MouseInputAdapter() { public void mousePressed(MouseEvent e) { m_XDifference = e.getX(); m_YDifference = e.getY(); } public void mouseDragged(MouseEvent e) { int vx = 0; int vy = 0; if (m_desktop.getParent() instanceof JViewport) { vx = ((JViewport) m_desktop.getParent()).getViewPosition().x; vy = ((JViewport) m_desktop.getParent()).getViewPosition().y; } int w = m_desktop.getParent().getWidth(); int h = m_desktop.getParent().getHeight(); int x = getX(); int y = getY(); int ex = e.getX(); int ey = e.getY(); if ((ey + y > vy && ey + y < h + vy) && (ex + x > vx && ex + x < w + vx)) { setLocation(ex - m_XDifference + x, ey - m_YDifference + y); } else if (!(ey + y > vy && ey + y < h + vy) && (ex + x > vx && ex + x < w + vx)) { if (!(ey + y > vy) && ey + y < h + vy) setLocation(ex - m_XDifference + x, vy - m_YDifference); else if (ey + y > vy && !(ey + y < h + vy)) setLocation(ex - m_XDifference + x, (h + vy) - m_YDifference); } else if ((ey + y > vy && ey + y < h + vy) && !(ex + x > vx && ex + x < w + vx)) { if (!(ex + x > vx) && ex + x < w + vx) setLocation(vx - m_XDifference, ey - m_YDifference + y); else if (ex + x > vx && !(ex + x < w)) setLocation((w + vx) - m_XDifference, ey - m_YDifference + y); } else if (!(ey + y > vy) && ey + y < h + vy && !(ex + x > vx) && ex + x < w + vx) setLocation(vx - m_XDifference, vy - m_YDifference); else if (!(ey + y > vy) && ey + y < h + vy && ex + x > vx && !(ex + x < w + vx)) setLocation((w + vx) - m_XDifference, vy - m_YDifference); else if (ey + y > vy && !(ey + y < h + vy) && !(ex + x > vx) && ex + x < w + vx) setLocation(vx - m_XDifference, (h + vy) - m_YDifference); else if (ey + y > vy && !(ey + y < h + vy) && ex + x > vx && !(ex + x < w + vx)) setLocation((w + vx) - m_XDifference, (h + vy) - m_YDifference); } public void mouseEntered(MouseEvent e) { setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); } public void mouseExited(MouseEvent e) { setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }; addMouseListener(ma); addMouseMotionListener(ma); }
From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java
public void mouseClicked(MouseEvent e) { if (e.getSource() instanceof ChartPanel && ((e.getButton() == MouseEvent.BUTTON2) || (e.getButton() == MouseEvent.BUTTON1) && ((e.getModifiers() & InputEvent.CTRL_MASK) != 0))) { CenterZoomNumberAxis czna = (CenterZoomNumberAxis) _cp.getChart().getXYPlot().getDomainAxis(); NumberAxis range = (NumberAxis) _cp.getChart().getXYPlot().getRangeAxis(); Rectangle2D screenDataArea = _cp.getScreenDataArea(e.getX(), e.getY()); double y1 = czna.getLowerBound(); double y2 = czna.getUpperBound(); double x1 = screenDataArea.getX(); double x2 = x1 + screenDataArea.getWidth(); double transformedx = (((y2 - y1) / (x2 - x1)) * (e.getX() - x1)) + y1; MRMDialog mrmd = (MRMDialog) MRMAncestor(); PeaksTableModel model = (PeaksTableModel) mrmd.peaksTable.getModel(); MRMTransition mrt = mrmd.transitionOnPlot; mrt.setCalcXatMaxYAllDaughters(transformedx); mrt.setCalcMaxYAllDaughters(//from w ww .java2 s.c om range.getLowerBound() + 0.95 * (range.getUpperBound() - range.getLowerBound())); model.setValueAt(new Float(mrt.getCalcXatMaxYAllDaughters()), mrt.getTableRow(), MRMDialog.peaksData.MidTime.colno); for (MRMDaughter d : mrt.getDaughters().values()) { model.setValueAt(new Float(mrt.getCalcXatMaxYAllDaughters()), d.getElutionDataTableRow(), MRMDialog.peaksData.MidTime.colno); } mrmd.updateChartsAndFields(false); } if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) { _cp.mouseClicked(e); } else { _cp.mouseClicked(e); } }
From source file:AsymptoticFreedom.AppletAF.java
private void theViewPanelMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_theViewPanelMousePressed // TODO add your handling code here: //System.out.printf("pressed >> x : %d, y : %d\n",evt.getX(), evt.getY()); for (int i = 0; i < theViewPanel.getQuarkSize(); i++) { if (theViewPanel.quark_list.get(i).pos.distance(new Point(evt.getX(), evt.getY())) < 25) { //System.out.printf("Selected %d quark!\n",i); pre_x_pos = evt.getX();//from ww w .j a v a 2s.c om pre_y_pos = evt.getY(); //theViewPanel.repaint(); } } theViewPanel.repaint(); }
From source file:AsymptoticFreedom.AppletAF.java
private void theViewPanelMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_theViewPanelMouseDragged // TODO add your handling code here: //System.out.printf("Draggred>> x : %d, y : %d\n",evt.getX(), evt.getY()); for (int i = 0; i < theViewPanel.getQuarkSize(); i++) { if (theViewPanel.quark_list.get(i).pos.distance(new Point(evt.getX(), evt.getY())) < 25) { //System.out.printf("Selected %d quark!\n",i); theViewPanel.quark_list.get(i).translate(evt.getX() - pre_x_pos, evt.getY() - pre_y_pos); //System.out.format("%d %d\n",evt.getX()-pre_x_pos,evt.getY()-pre_y_pos); pre_x_pos = evt.getX();//from w w w . j av a 2s.com pre_y_pos = evt.getY(); } } theViewPanel.repaint(); }
From source file:nl.phanos.liteliveresultsclient.gui.ResultsWindows.java
private void jTable1MouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseMoved // TODO add your handling code here: jMenuBar1.setVisible(evt.getY() < 50); }
From source file:com.projity.pm.graphic.graph.GraphInteractor.java
public void mouseDragged(MouseEvent e) { if (isReadOnly()) return;/* w w w . jav a 2 s. com*/ if (!SwingUtilities.isLeftMouseButton(e)) return; if (selected instanceof GraphicNode) { GraphicNode node = (GraphicNode) selected; boolean sw = switchOnLinkCreation(e.getX(), e.getY()); if (state != LINK_CREATION && sw) { drawBarShadow(lastShadowX, lastLinkShadowY, true); beforeLinkState = state; state = LINK_CREATION; selectCursor(); sourceNode = (GraphicNode) selected; drawLinkSelectionBarShadow(sourceNode); setLinkOrigin(); } else if (state == LINK_CREATION && !sw && allowLinkSelectionToMove()) { drawLinkShadow(lastLinkShadowX, lastLinkShadowY, true); drawBarShadow(lastShadowX, lastLinkShadowY, true); state = beforeLinkState; selectCursor(); sourceNode = null; } } if (state == LINK_CREATION) { GraphZone zone = ui.getNodeAt(e.getX(), e.getY()); GraphicNode newDestinationNode = zone == null ? null : (GraphicNode) zone.getObject(); drawLinkSelectionBarShadow(destinationNode); drawLinkShadow(lastLinkShadowX, lastLinkShadowY, true); scrollToVisible(e.getX(), e.getY()); drawLinkShadow(e.getX(), e.getY(), true); if (newDestinationNode != null && newDestinationNode.isLinkable() && sourceNode != newDestinationNode) { destinationNode = newDestinationNode; drawLinkSelectionBarShadow(destinationNode); } else destinationNode = null; } else if (isMove()) { drawBarShadow(lastShadowX, lastShadowY, true); scrollToVisible(e.getX(), e.getY()); drawBarShadow(e.getX(), e.getY(), true); } }
From source file:com.projity.pm.graphic.graph.GraphInteractor.java
public void mouseReleased(MouseEvent e) { if (isReadOnly()) return;/*from w w w . j a va 2 s .co m*/ if (!SwingUtilities.isLeftMouseButton(e)) return; if (selected == null || state == NOTHING_SELECTED) return; if (isRepaintOnRelease()) getGraph().repaint(); double x1 = e.getX(); double y1 = e.getY(); executeAction(x1, y1); reset(); findState(x1, y1); }
From source file:biz.wolschon.finance.jgnucash.accountProperties.AccountProperties.java
/** * @return a panel to edit the settings of this section *///from w ww .ja v a2 s . co m private JPanel getMySettingsPanel() { if (mySettingsPanel == null) { mySettingsPanel = new JPanel(); mySettingsPanel.setLayout(new BorderLayout()); myPropertySheet = new PropertySheetPanel(); myPropertySheet.setToolBarVisible(true); myPropertySheet.setSorting(false); myPropertySheet.setMode(PropertySheetPanel.VIEW_AS_CATEGORIES); myPropertySheet.setDescriptionVisible(true); myPropertySheet.addPropertySheetChangeListener(new PropertyChangeListener() { @Override public void propertyChange(final PropertyChangeEvent aEvt) { Object property = aEvt.getSource(); if (property instanceof DefaultProperty) { DefaultProperty prop = (DefaultProperty) property; try { myAccount.setUserDefinedAttribute(prop.getName(), prop.getValue().toString()); } catch (Exception e) { LOGGER.error("error in writing userDefinedAttribute", e); } } } }); myPropertySheet.getTable().addMouseListener(new MouseAdapter() { /** show popup if mouseReleased is a popupTrigger on this platform. * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent) */ @Override public void mouseReleased(final MouseEvent aE) { if (aE.isPopupTrigger()) { JPopupMenu menu = getPropertyPopup(); menu.show(myPropertySheet, aE.getX(), aE.getY()); } super.mouseClicked(aE); } /** show popup if mousePressed is a popupTrigger on this platform. * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent) */ @Override public void mousePressed(final MouseEvent aE) { if (aE.isPopupTrigger()) { JPopupMenu menu = getPropertyPopup(); menu.show(myPropertySheet, aE.getX(), aE.getY()); } super.mouseClicked(aE); } }); // updateCustomAttributesPanel(); // for (ConfigurationSetting setting : getConfigSection().getSettings()) { // MyProperty myProperty = new MyProperty(setting); // myProperty.addPropertyChangeListener(savingPropertyChangeListener); // propertySheet.addProperty(myProperty); // } mySettingsPanel.add(new JLabel("custom attributes:"), BorderLayout.NORTH); mySettingsPanel.add(myPropertySheet, BorderLayout.CENTER); mySettingsPanel.add(getAddCustomAttrPanel(), BorderLayout.SOUTH); // MyPropertyEditorFactory propertyEditorFactory = new MyPropertyEditorFactory(); // propertySheet.setEditorFactory(propertyEditorFactory); // propertySheet.setRendererFactory(propertyEditorFactory); } return mySettingsPanel; }
From source file:com.sec.ose.osi.ui.frm.main.report.project.JListProjectWithPopup.java
private void initialize() { this.addListSelectionListener(new FileSelectionListener()); this.addMouseListener(new MouseAdapter() { @SuppressWarnings("deprecation") public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { log.debug("JLIstProjectWithPop.mouseClicked() : MouseEvent.BUTTON3"); /// clicked right button mEventHandler.handle(EventHandler.RIGHT_BTN_CLICKED); if (JListProjectWithPopup.this.getSelectedValues() != null // existed selected item && JListProjectWithPopup.this.getSelectedValues().length > 0) { log.debug("button3"); mPopup.show(e.getComponent(), e.getX(), e.getY()); }/*from w w w . jav a 2s .co m*/ } } }); }
From source file:net.sf.xmm.moviemanager.gui.DialogIMDbMultiAdd.java
/** * Not yet fully implemented//from w w w . j a v a 2s . com * @param e */ void handleFileLocationPopup(MouseEvent e) { if (!GUIUtil.isRightMouseButton(e)) return; JPopupMenu fileLocationPopup = new JPopupMenu(); JMenuItem fileLocationItem = new JMenuItem("Open content folder"); fileLocationPopup.add(fileLocationItem); fileLocationPopup.show(fileLocation, e.getX(), e.getY()); }