List of usage examples for java.awt.event MouseEvent getX
public int getX()
From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java
/** * Returns a string for the tooltip./*w w w . j a v a2s. co 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), (int) (e.getY() - insets.top)); if (entity != null) { result = entity.getToolTipText(); } } } return result; }
From source file:com.jcraft.weirdx.DDXWindowImpSwing.java
@SuppressWarnings("unused") public void mouseDragged(MouseEvent e) { if (threeButton) { if (threeBstate != s) { if (threeBstate == sp) { procPressed(threeBPressed); threeBPressed = null;/* w ww.j a v a 2 s . com*/ threeBstate = s; } else if (threeBstate == spp) { e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK))) | InputEvent.BUTTON2_MASK, e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()); } else if (threeBstate == sppr) { return; } } } int x = e.getX() + window.x; int y = e.getY() + window.y; XWindow.sprite.hot.x = x; XWindow.sprite.hot.y = y; int mod = e.getModifiers(); // button 1 -> 16 // button 2 -> 8 // button 3 -> 4 // shift -> 1 // control -> 2 // alt -> 12 ?? int state = 0; int detail = 0; if ((mod & InputEvent.BUTTON1_MASK) != 0) { state |= (1 << 8); detail = 1; } if ((mod & InputEvent.BUTTON2_MASK) != 0) { state |= (1 << 9); detail = 2; } if ((mod & InputEvent.BUTTON3_MASK) != 0) { state |= (1 << 10); detail = 3; } if ((mod & InputEvent.SHIFT_MASK) != 0) state |= 1; if ((mod & InputEvent.CTRL_MASK) != 0) state |= 4; // alt -> state|=8; XWindow.sprite.hot.state = state; px = x; py = y; event.mkMotionNotify(1, window.screen.rootId, /*window.id,*/ XWindow.sprite.win.id, 0, px, py, e.getX(), e.getY(), state, 1); try { if (!XWindow.checkMotion(event, window)) { return; } event.mkMotionNotify(1, window.screen.rootId, /*window.id,*/ XWindow.sprite.win.id, 0, px, py, px - XWindow.sprite.win.x, py - XWindow.sprite.win.y, //e.getX(), //e.getY(), state, 1); if (XWindow.grab != null) XWindow.sendGrabbedEvent(event, false, 1); else XWindow.sendDeviceEvent(XWindow.sprite.win, event, XWindow.grab, null, 1); } catch (Exception ee) { } }
From source file:com.jcraft.weirdx.DDXWindowImp.java
public void mousePressed(MouseEvent e) { if (threeButton) { if (threeBstate == s) { threeBPressed = e;/*from w ww. ja v a 2 s .co m*/ threeBstate = sp; return; } if (threeBstate == sp // || threeBstate==sppr ) { threeBPressed = null; threeBstate = spp; e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK))) | InputEvent.BUTTON2_MASK, e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()); } } procPressed(e); }
From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java
/** * Implementation of the MouseMotionListener's method * * @param e the event.//from www . ja v a 2s . co m */ public void mouseMoved(MouseEvent e) { //crosshair if (this.horizontalAxisTrace && this.verticalAxisTrace && this.crosshairNotBlocked) { Rectangle2D rect = this.getScaledDataArea(); double ux = userX(e); double uy = userY(e); if (!(rect.contains(e.getX(), e.getY()) && disableCrosshairTillLeavesDisplay)) { if (disableCrosshairTillLeavesDisplay) { disableCrosshairTillLeavesDisplay = false; drawHorizontalAxisTrace(e.getX()); drawVerticalAxisTrace(e.getY()); } else { drawHorizontalAxisTrace(e.getX()); drawVerticalAxisTrace(e.getY()); if (rect.contains(e.getX(), e.getY())) { float uxf = (float) ux; float uyf = (float) uy; this.writeToStatusBar("( " + uxf + " , " + uyf + " )"); } else { this.writeToStatusBar(""); } } } } if (this.chartMouseListeners.isEmpty()) { return; } Insets insets = getInsets(); int x = e.getX() - insets.left; int y = e.getY() - insets.top; ChartEntity entity = null; if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } ChartMouseEvent event = new ChartMouseEvent(getChart(), e, entity); Iterator iterator = chartMouseListeners.iterator(); while (iterator.hasNext()) { ChartMouseListener listener = (ChartMouseListener) iterator.next(); listener.chartMouseMoved(event); } }
From source file:com.jcraft.weirdx.DDXWindowImp.java
@SuppressWarnings("unused") public void mouseDragged(MouseEvent e) { if (threeButton) { if (threeBstate != s) { if (threeBstate == sp) { procPressed(threeBPressed); threeBPressed = null;/* w ww . j a v a 2s.c o m*/ threeBstate = s; } else if (threeBstate == spp) { e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK))) | InputEvent.BUTTON2_MASK, e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()); } else if (threeBstate == sppr) { return; } } } if (window == null) return; // calc abs cursor position use old window position for calculation // as mouseDragged (if you use Panel) delivers its coordinates relative to the position after mousepressed // UPDATE: this was a bug of the IBM JDK // int x=e.getX()+oldwindowx; // int y=e.getY()+oldwindowy; int x = e.getX() + window.x; int y = e.getY() + window.y; // set new drag position (absolute) XWindow.sprite.hot.x = x; XWindow.sprite.hot.y = y; int mod = e.getModifiers(); // button 1 -> 16 // button 2 -> 8 // button 3 -> 4 // shift -> 1 // control -> 2 // alt -> 12 ?? int state = 0; int detail = 0; if ((mod & InputEvent.BUTTON1_MASK) != 0) { state |= (1 << 8); detail = 1; } if ((mod & InputEvent.BUTTON2_MASK) != 0) { state |= (1 << 9); detail = 2; } if ((mod & InputEvent.BUTTON3_MASK) != 0) { state |= (1 << 10); detail = 3; } if ((mod & InputEvent.SHIFT_MASK) != 0) state |= 1; if ((mod & InputEvent.CTRL_MASK) != 0) state |= 4; // alt -> state|=8; XWindow.sprite.hot.state = state; px = x; py = y; event.mkMotionNotify(1, window.screen.rootId, XWindow.sprite.win.id, 0, px, py, e.getX(), e.getY(), state, 1); try { if (!XWindow.checkMotion(event, window)) { return; } event.mkMotionNotify(1, window.screen.rootId, XWindow.sprite.win.id, 0, px, py, px - XWindow.sprite.win.x, py - XWindow.sprite.win.y, state, 1); if (XWindow.grab != null) { XWindow.sendGrabbedEvent(event, false, 1); } else { XWindow.sendDeviceEvent(XWindow.sprite.win, event, XWindow.grab, null, 1); } } catch (Exception ee) { } }
From source file:de.codesourcery.eve.skills.ui.components.impl.MarketPriceEditorComponent.java
/** * Checks whether a mouse-click event should trigger a context-sensitive * popup menu and renders the menu if so. * //w w w. j a v a 2 s . c om * @param e */ private void maybeShowPopup(MouseEvent e) { if (!e.isPopupTrigger()) { return; } final int[] selectedRows = table.getSelectedRows(); if (ArrayUtils.isEmpty(selectedRows)) { final int row = table.rowAtPoint(e.getPoint()); if (row < 0) { if (log.isDebugEnabled()) { log.debug("maybeShowPopup(): Outside of table."); } return; } table.getSelectionModel().setSelectionInterval(row, row); } // translate row indices for (int i = 0; i < selectedRows.length; i++) { selectedRows[i] = table.getRowSorter().convertRowIndexToModel(selectedRows[i]); } if (populatePopupMenu(e, selectedRows)) { popupMenu.show(e.getComponent(), e.getX(), e.getY()); } }
From source file:org.gumtree.vis.plot1d.Plot1DPanel.java
@Override public void mousePressed(MouseEvent e) { int mods = e.getModifiers(); // if (isMaskingEnabled() && (mods & maskingKeyMask) != 0) { if (isInternalLegendEnabled && isInternalLegendSelected) { int cursorType = findCursorOnSelectedItem(e.getX(), e.getY()); if (cursorType == Cursor.DEFAULT_CURSOR) { Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY()); if (screenDataArea != null) { legendPoint = e.getPoint(); } else { legendPoint = null;//from w w w .j a va 2 s. c om } } else { if (cursorType == Cursor.MOVE_CURSOR) { legendPoint = e.getPoint(); } } } if (isMaskingEnabled()) { // Prepare masking service. int cursorType = findCursorOnSelectedItem(e.getX(), e.getY()); if (cursorType == Cursor.DEFAULT_CURSOR && (mods & maskingKeyMask) != 0) { Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY()); if (screenDataArea != null) { this.maskPoint = getPointInRectangle(e.getX(), e.getY(), screenDataArea).getX(); } else { this.maskPoint = Double.NaN; } } else { if (cursorType == Cursor.MOVE_CURSOR) { // this.maskMovePoint = translateScreenToChart( // translateScreenToJava2D(e.getPoint())).getX(); Insets insets = getInsets(); this.maskMovePoint = ChartMaskingUtilities.translateScreenX( (e.getX() - insets.left) / getScaleX(), getScreenDataArea(), getChart()); } setMaskDragIndicator(cursorType); } } if (getMaskDragIndicator() == Cursor.DEFAULT_CURSOR) { super.mousePressed(e); } }
From source file:edu.ucla.stat.SOCR.chart.demo.SOCR_EM_MixtureModelChartDemo.java
public Point2D getPointInChart(MouseEvent e) { Insets insets = getInsets();// ww w .ja v a 2 s .c om //System.out.println("inset.top="+insets.top+" inset.left="+insets.left); //System.out.println("scaleX="+chartPaneltest.getScaleX()+" scaleY="+chartPaneltest.getScaleY()); //System.out.println(e.getX()); // int mouseX = (int) ((e.getX() - insets.left) / chartPaneltest.getScaleX()); // int mouseY = (int) ((e.getY() - insets.top) / chartPaneltest.getScaleY()); int mouseX = (int) (e.getX() - insets.left); int mouseY = (int) (e.getY() - insets.top); // Point2D pt = new Point2D.Double(); //pt.setLocation(mouseX, mouseY); //return pt; // System.out.println("x = " + mouseX + ", y = " + mouseY); Point2D p = chartPaneltest.translateScreenToJava2D(new Point(mouseX, mouseY)); XYPlot plot = (XYPlot) chart.getPlot(); ChartRenderingInfo info = chartPaneltest.getChartRenderingInfo(); Rectangle2D dataArea = info.getPlotInfo().getDataArea(); ValueAxis domainAxis = plot.getDomainAxis(); RectangleEdge domainAxisEdge = plot.getDomainAxisEdge(); ValueAxis rangeAxis = plot.getRangeAxis(); RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge(); double chartX = domainAxis.java2DToValue(p.getX(), dataArea, domainAxisEdge); double chartY = rangeAxis.java2DToValue(p.getY(), dataArea, rangeAxisEdge); Point2D pt2 = new Point2D.Double(); //double scale = (double)CHART_SIZE_X/(double)CHART_SIZE_Y; //System.out.println("scale="+scale); pt2.setLocation(chartX, chartY); //System.out.println("Chart: x = " + (chartX) + ", y = " + chartY); return pt2; }
From source file:com.SE.myPlayer.MusicPlayerGUI.java
private void progressBarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_progressBarMouseClicked try {/*from w ww . ja v a2 s . com*/ if (songLocation != null) { progressClick = (long) (((double) evt.getX() / (double) progressBar.getWidth()) * progressBar.getMaximum()); progressBarSeek(progressClick); } } catch (BasicPlayerException ex) { System.out.println("Error in progressBarMouseClicked method....." + ex); } }
From source file:base.BasePlayer.BedTable.java
@Override public void mouseDragged(MouseEvent event) { mouseDrag = true;/* ww w . java 2 s. c o m*/ if (resizeColumn > 0) { resizeTable(resizeColumn, event.getX() - this.dragX); this.dragX = event.getX(); } }