List of usage examples for java.awt.event MouseEvent getY
public int getY()
From source file:ucar.unidata.idv.control.chart.TimeSeriesChartWrapper.java
/** * Is mouse on bottom axis//from w w w . ja v a2 s. c o m * * @param mouseEvent the event * * @return on bottom axis */ private boolean isOnBottomDomainAxis(MouseEvent mouseEvent) { Rectangle2D dataArea = chartPanel.getScreenDataArea(); if (mouseEvent.getX() < dataArea.getX()) { return false; } if (mouseEvent.getX() > dataArea.getX() + dataArea.getWidth()) { return false; } double bottom = dataArea.getY() + dataArea.getHeight(); return mouseEvent.getY() >= bottom - 20; }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.link_and_brush.LinkAndBrushChartPanel.java
@Override public void mouseReleased(MouseEvent e) { // if we've been panning, we need to reset now that the mouse is // released... Rectangle2D zoomRectangle = (Rectangle2D) getChartFieldValueByName("zoomRectangle"); Point2D zoomPoint = (Point2D) getChartFieldValueByName("zoomPoint"); if (getChartFieldValueByName("panLast") != null) { setChartFieldValue((getChartFieldByName("panLast")), null); setCursor(Cursor.getDefaultCursor()); } else if (zoomRectangle != null) { boolean hZoom = false; boolean vZoom = false; if ((PlotOrientation) getChartFieldValueByName("orientation") == PlotOrientation.HORIZONTAL) { hZoom = (Boolean) getChartFieldValueByName("rangeZoomable"); vZoom = (Boolean) getChartFieldValueByName("domainZoomable"); } else {/*from w w w . ja v a 2 s . com*/ hZoom = (Boolean) getChartFieldValueByName("domainZoomable"); vZoom = (Boolean) getChartFieldValueByName("rangeZoomable"); } boolean zoomTrigger1 = hZoom && Math .abs(e.getX() - zoomPoint.getX()) >= (Integer) getChartFieldValueByName("zoomTriggerDistance"); boolean zoomTrigger2 = vZoom && Math .abs(e.getY() - zoomPoint.getY()) >= (Integer) getChartFieldValueByName("zoomTriggerDistance"); if (zoomTrigger1 || zoomTrigger2) { if ((hZoom && (e.getX() < zoomPoint.getX())) || (vZoom && (e.getY() < zoomPoint.getY()))) { restoreAutoBounds(); } else { double x, y, w, h; Rectangle2D screenDataArea = getScreenDataArea((int) zoomPoint.getX(), (int) zoomPoint.getY()); double maxX = screenDataArea.getMaxX(); double maxY = screenDataArea.getMaxY(); // for mouseReleased event, (horizontalZoom || verticalZoom) // will be true, so we can just test for either being false; // otherwise both are true if (!vZoom) { x = zoomPoint.getX(); y = screenDataArea.getMinY(); w = Math.min(zoomRectangle.getWidth(), maxX - zoomPoint.getX()); h = screenDataArea.getHeight(); } else if (!hZoom) { x = screenDataArea.getMinX(); y = zoomPoint.getY(); w = screenDataArea.getWidth(); h = Math.min(zoomRectangle.getHeight(), maxY - zoomPoint.getY()); } else { x = zoomPoint.getX(); y = zoomPoint.getY(); w = Math.min(zoomRectangle.getWidth(), maxX - zoomPoint.getX()); h = Math.min(zoomRectangle.getHeight(), maxY - zoomPoint.getY()); } Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h); zoom(zoomArea); } setChartFieldValue(getChartFieldByName("zoomPoint"), null); setChartFieldValue(getChartFieldByName("zoomRectangle"), null); } else { // erase the zoom rectangle Graphics2D g2 = (Graphics2D) getGraphics(); if ((Boolean) getChartFieldValueByName("useBuffer")) { repaint(); } else { drawZoomRectangle(g2, true); } g2.dispose(); setChartFieldValue(getChartFieldByName("zoomPoint"), null); setChartFieldValue(getChartFieldByName("zoomRectangle"), null); } } else if (e.isPopupTrigger()) { if (getChartFieldValueByName("popup") != null) { displayPopupMenu(e.getX(), e.getY()); } } }
From source file:edu.ucla.stat.SOCR.chart.demo.SOCR_EM_MixtureModelChartDemo.java
public Point2D getPointInChart(MouseEvent e) { Insets insets = getInsets();// ww w.j a v a2s . com //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:userinterface.properties.GUIGraphHandler.java
private void popUpTriggered(MouseEvent e) { if (e.getSource() == theTabs)//just show the background popup {/*from w w w . j av a 2 s . c o m*/ int index = theTabs.indexAtLocation(e.getX(), e.getY()); if (index != -1) { graphOptions.setEnabled(true); zoomMenu.setEnabled(true); exportMenu.setEnabled(true); importMenu.setEnabled(true); printGraph.setEnabled(true); deleteGraph.setEnabled(true); theTabs.setSelectedIndex(index); this.graphMenu.show(theTabs, e.getX(), e.getY()); } else { graphOptions.setEnabled(false); zoomMenu.setEnabled(false); exportMenu.setEnabled(false); importMenu.setEnabled(true); printGraph.setEnabled(false); deleteGraph.setEnabled(false); this.graphMenu.show(theTabs, e.getX(), e.getY()); } return; } for (int i = 0; i < models.size(); i++) { if (e.getSource() == models.get(i)) { graphOptions.setEnabled(true); zoomMenu.setEnabled(true); exportMenu.setEnabled(true); importMenu.setEnabled(true); printGraph.setEnabled(true); deleteGraph.setEnabled(true); exportImageEPS.setEnabled(true); exportMatlab.setEnabled(getModel(i) instanceof Graph); exportXML.setEnabled(getModel(i) instanceof Graph); theTabs.setSelectedIndex(i); this.graphMenu.show(models.get(i), e.getX(), e.getY()); return; } } }
From source file:org.apache.syncope.ide.netbeans.view.ResourceExplorerTopComponent.java
private void leafRightClickAction(final MouseEvent evt, final DefaultMutableTreeNode node) { JPopupMenu menu = new JPopupMenu(); JMenuItem deleteItem = new JMenuItem("Delete"); menu.add(deleteItem);//from w w w .ja va 2 s. com deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { int result = JOptionPane.showConfirmDialog(null, "Are you sure to delete the item?"); if (result == JOptionPane.OK_OPTION) { DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); boolean deleted; if (parent.getUserObject().equals(PluginConstants.MAIL_TEMPLATES)) { deleted = mailTemplateManagerService.delete((String) node.getUserObject()); } else { deleted = reportTemplateManagerService.delete((String) node.getUserObject()); } if (deleted) { node.removeFromParent(); treeModel.reload(parent); } else { JOptionPane.showMessageDialog(null, "Error while deleting new element", "Error", JOptionPane.ERROR_MESSAGE); } } } }); menu.show(evt.getComponent(), evt.getX(), evt.getY()); }
From source file:org.jax.maanova.fit.gui.ResidualPlotPanel.java
private void mouseMoved(MouseEvent e) { if (this.showTooltip) { Point2D chartPoint = this.chartPanel.toChartPoint(e.getPoint()); // find the nearest probe XYProbeData[] xyProbeData = this.getXYData(); double nearestDistance = Double.POSITIVE_INFINITY; int nearestArrayIndex = -1; int nearestDotIndex = -1; for (int arrayIndex = 0; arrayIndex < xyProbeData.length; arrayIndex++) { double[] currXData = xyProbeData[arrayIndex].getXData(); double[] currYData = xyProbeData[arrayIndex].getYData(); for (int dotIndex = 0; dotIndex < currXData.length; dotIndex++) { double currDist = chartPoint.distanceSq(currXData[dotIndex], currYData[dotIndex]); if (currDist < nearestDistance) { nearestDistance = currDist; nearestArrayIndex = arrayIndex; nearestDotIndex = dotIndex; }//from www. j a v a2s. c o m } } if (nearestArrayIndex == -1) { this.clearProbePopup(); } else { XYProbeData nearestArrayData = xyProbeData[nearestArrayIndex]; Point2D probeJava2DCoord = this.getJava2DCoordinates(nearestArrayData.getXData()[nearestDotIndex], nearestArrayData.getYData()[nearestDotIndex]); double java2DDist = probeJava2DCoord.distance(e.getX(), e.getY()); // is the probe close enough to be worth showing (in pixel distance) if (java2DDist <= PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS * 2) { this.showProbePopup(nearestArrayIndex, nearestArrayData.getProbeIndices()[nearestDotIndex], nearestArrayData.getXData()[nearestDotIndex], nearestArrayData.getYData()[nearestDotIndex], e.getX(), e.getY()); } else { this.clearProbePopup(); } } } }
From source file:com.jcraft.weirdx.DDXWindowImpSwing.java
public void mouseReleased(MouseEvent e) { if (threeButton) { if (threeBstate == sppr) { threeBPressed = null;/* ww w. j a v a 2 s.co m*/ threeBstate = s; return; } if (threeBstate == sp) { procPressed(threeBPressed); threeBPressed = null; threeBstate = s; } else if (threeBstate == spp) { threeBPressed = null; threeBstate = sppr; 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()); } } procReleased(e); }
From source file:edu.ku.brc.specify.tasks.ExpressSearchTask.java
/** * Shows the Reset menu./*from w ww . ja v a 2 s. c o m*/ * @param e the mouse event */ protected void showContextMenu(MouseEvent e) { if (e.isPopupTrigger()) { JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(UIRegistry.getResourceString("ES_TEXT_RESET")); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ex) { searchText.setEnabled(true); searchText.setBackground(textBGColor); searchText.setText(""); if (statusBar != null) { statusBar.setProgressDone(EXPRESSSEARCH); } } }); popup.add(menuItem); popup.show(e.getComponent(), e.getX(), e.getY()); } }
From source file:com.archivas.clienttools.arcmover.gui.panels.ProfilePanel.java
private void onFileListMouseClicked(MouseEvent evt) { try {/*from w ww . j a v a 2 s . c om*/ if (evt.isPopupTrigger()) { updateSelectedFile(); updateRightClickMenu(); rightClickMenu.show(fileList, evt.getX(), evt.getY()); } } catch (Exception e1) { String msg = "Unexpected error showing right-click menu"; LOG.log(Level.WARNING, msg, e1); JOptionPane.showMessageDialog(this, msg, "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:edu.ucla.stat.SOCR.analyses.gui.NormalPower.java
public void mouseDragged(MouseEvent evt) { //////////////System.out.println("mouseDragged evt = " + evt); //int x = evt.getX(); xPosition = evt.getX();//ww w .j av a 2s. c o m yPosition = evt.getY(); double xPositionOld = muA; double yPositionOld = 0; double xPositionNew = graphSampleMean.xGraphInverse(xPosition); double yPositionNew = graphSampleMean.yGraphInverse(yPosition); double diff = xPositionNew - xPositionOld; //double scale = Math.abs(mu0 - muA) / 100; //////////////System.out.println("mouseDragged mu0 = " + mu0 + ", muA = " + muA + " sampleSE = " + sampleSE + ", scale = " + scale); if (/*Math.abs(xPositionOld - xPositionNew) > scale && */graphSampleMean .withinSampleMeanCurve(xPositionNew, yPositionNew)) { muA = muA + diff; graphSampleMean.setSampleMeanOption(true); //////////////////////System.out.println("New muA = " + muA); try { doSampleMeanNormalCurve(); //doAnalysis(); } catch (Exception e) { //////////////////////System.out.println(e); } muAText.setText(muA + ""); repaint(); ////System.gc(); } }