List of usage examples for java.awt.geom Rectangle2D getMinX
public double getMinX()
From source file:com.vgi.mafscaling.LogView.java
private void createGraghPanel() { JFreeChart chart = ChartFactory.createXYLineChart(null, null, null, null, PlotOrientation.VERTICAL, false, true, false);/*from w w w .j av a 2 s. co m*/ chartPanel = new ChartPanel(chart, true, true, true, true, true); chartPanel.setAutoscrolls(true); chartPanel.setPopupMenu(null); chart.setBackgroundPaint(new Color(60, 60, 65)); rpmDataset = new XYSeriesCollection(); rpmPlotRenderer = new XYLineAndShapeRenderer(); dataset = new XYSeriesCollection(); plotRenderer = new XYLineAndShapeRenderer(); NumberAxis xAxis = new NumberAxis(); xAxis.setTickLabelsVisible(false); xAxis.setTickLabelPaint(Color.WHITE); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(); yAxis.setTickLabelsVisible(false); yAxis.setTickLabelPaint(Color.WHITE); yAxis.setAutoRangeIncludesZero(false); NumberAxis y2Axis = new NumberAxis(); y2Axis.setTickLabelsVisible(false); y2Axis.setTickLabelPaint(Color.WHITE); y2Axis.setAutoRangeIncludesZero(false); plot = chartPanel.getChart().getXYPlot(); plot.setRangePannable(true); plot.setDomainPannable(true); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setBackgroundPaint(new Color(80, 80, 85)); plot.setDataset(0, rpmDataset); plot.setRenderer(0, rpmPlotRenderer); plot.setDomainAxis(0, xAxis); plot.setRangeAxis(0, yAxis); plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); plot.setDataset(1, dataset); plot.setRenderer(1, plotRenderer); plot.setRangeAxis(1, y2Axis); plot.mapDatasetToDomainAxis(1, 0); plot.mapDatasetToRangeAxis(1, 1); LegendTitle legend = new LegendTitle(plot); legend.setItemFont(new Font("Arial", 0, 10)); legend.setPosition(RectangleEdge.TOP); legend.setItemPaint(Color.WHITE); chart.addLegend(legend); xyMarker = new XYDomainMutilineAnnotation(); plot.addAnnotation(xyMarker); chartMouseListener = new ChartMouseListener() { @Override public void chartMouseMoved(ChartMouseEvent event) { try { Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea(); Point2D p = chartPanel.translateScreenToJava2D(event.getTrigger().getPoint()); double x = plot.getDomainAxis().java2DToValue(p.getX(), dataArea, plot.getDomainAxisEdge()); boolean isLeft = (p.getX() < (dataArea.getMaxX() - dataArea.getMinX()) / 2) ? true : false; if (setMarkers(x, isLeft)) { try { int selectedCol = logDataTable.getTable().getSelectedColumn(); if (selectedCol < 0) selectedCol = 0; if (logPlayWindow == null || startMarker != null || endMarker != null) { logDataTable.getTable().setRowSelectionInterval((int) x, (int) x); logDataTable.getTable().changeSelection((int) x, selectedCol, false, false); } else { logPlayWindow.setProgressBar((int) x); } } catch (Exception e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } } @Override public void chartMouseClicked(ChartMouseEvent event) { if (logPlayWindow == null) return; if (xyMarker.count() == 0) return; Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea(); Point2D p = chartPanel.translateScreenToJava2D(event.getTrigger().getPoint()); double x = plot.getDomainAxis().java2DToValue(p.getX(), dataArea, plot.getDomainAxisEdge()); if (x < 0 || (int) x >= logDataTable.getRowCount()) return; if (SwingUtilities.isLeftMouseButton(event.getTrigger())) { if (startMarker == null) { startMarker = new ValueMarker(x); startMarker.setPaint(Color.GREEN); startMarker.setStroke(new BasicStroke(1.5f)); plot.addDomainMarker(startMarker); } else { plot.removeDomainMarker(startMarker); startMarker = null; } } else if (SwingUtilities.isRightMouseButton(event.getTrigger())) { if (endMarker == null) { endMarker = new ValueMarker(x); endMarker.setPaint(Color.GREEN); endMarker.setStroke(new BasicStroke(1.5f)); plot.addDomainMarker(endMarker); } else { plot.removeDomainMarker(endMarker); endMarker = null; } } chartPanel.repaint(); logPlayWindow.setStartEndArea(startMarker, endMarker); } }; chartPanel.addChartMouseListener(chartMouseListener); }
From source file:net.sf.jasperreports.chartthemes.spring.EyeCandySixtiesChartTheme.java
@Override public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // check the value we are plotting... Number dataValue = dataset.getValue(row, column); if (dataValue == null) { return;// ww w .j a v a 2 s.c o m } double value = dataValue.doubleValue(); Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); PlotOrientation orientation = plot.getOrientation(); double barW0 = calculateBarW0(plot, orientation, adjusted, domainAxis, state, row, column); double[] barL0L1 = calculateBarL0L1(value); if (barL0L1 == null) { return; // the bar is not visible } RectangleEdge edge = plot.getRangeAxisEdge(); double transL0 = rangeAxis.valueToJava2D(barL0L1[0], adjusted, edge); double transL1 = rangeAxis.valueToJava2D(barL0L1[1], adjusted, edge); double barL0 = Math.min(transL0, transL1); double barLength = Math.abs(transL1 - transL0); // draw the bar... Rectangle2D bar = null; if (orientation == PlotOrientation.HORIZONTAL) { bar = new Rectangle2D.Double(barL0, barW0, barLength, state.getBarWidth()); } else { bar = new Rectangle2D.Double(barW0, barL0, state.getBarWidth(), barLength); } Paint itemPaint = getItemPaint(row, column); if (itemPaint instanceof GradientPaint) { itemPaint = getGradientPaintTransformer().transform((GradientPaint) itemPaint, bar); } g2.setPaint(itemPaint); g2.fill(bar); double x0 = bar.getMinX(); double x1 = x0 + getXOffset(); double x2 = bar.getMaxX(); double x3 = x2 + getXOffset(); double y0 = bar.getMinY() - getYOffset(); double y1 = bar.getMinY(); double y2 = bar.getMaxY() - getYOffset(); double y3 = bar.getMaxY(); GeneralPath bar3dRight = null; GeneralPath bar3dTop = null; if (barLength > 0.0) { bar3dRight = new GeneralPath(); bar3dRight.moveTo((float) x2, (float) y3); bar3dRight.lineTo((float) x2, (float) y1); bar3dRight.lineTo((float) x3, (float) y0); bar3dRight.lineTo((float) x3, (float) y2); bar3dRight.closePath(); if (itemPaint instanceof Color) { g2.setPaint(((Color) itemPaint).darker()); } else if (itemPaint instanceof GradientPaint) { GradientPaint gp = (GradientPaint) itemPaint; g2.setPaint(new StandardGradientPaintTransformer().transform(new GradientPaint(gp.getPoint1(), gp.getColor1().darker(), gp.getPoint2(), gp.getColor2().darker(), gp.isCyclic()), bar3dRight)); } g2.fill(bar3dRight); } bar3dTop = new GeneralPath(); bar3dTop.moveTo((float) x0, (float) y1); bar3dTop.lineTo((float) x1, (float) y0); bar3dTop.lineTo((float) x3, (float) y0); bar3dTop.lineTo((float) x2, (float) y1); bar3dTop.closePath(); g2.fill(bar3dTop); if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { g2.setStroke(getItemOutlineStroke(row, column)); g2.setPaint(getItemOutlinePaint(row, column)); g2.draw(bar); if (bar3dRight != null) { g2.draw(bar3dRight); } if (bar3dTop != null) { g2.draw(bar3dTop); } } CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar, (value < 0.0)); } // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { GeneralPath barOutline = new GeneralPath(); barOutline.moveTo((float) x0, (float) y3); barOutline.lineTo((float) x0, (float) y1); barOutline.lineTo((float) x1, (float) y0); barOutline.lineTo((float) x3, (float) y0); barOutline.lineTo((float) x3, (float) y2); barOutline.lineTo((float) x2, (float) y3); barOutline.closePath(); addItemEntity(entities, dataset, row, column, barOutline); } }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.link_and_brush.LinkAndBrushChartPanel.java
@Override public void mouseDragged(MouseEvent e) { // when not allowed to zoom / select, return if (blockSelectionOrZoom) { return;/* ww w . j ava 2 s .c om*/ } // if the popup menu has already been triggered, then ignore dragging... if (getChartFieldValueByName("popup") != null && ((JPopupMenu) getChartFieldValueByName("popup")).isShowing()) { return; } // handle panning if we have a start point if (getChartFieldValueByName("panLast") != null) { double dx = e.getX() - ((Point) getChartFieldValueByName("panLast")).getX(); double dy = e.getY() - ((Point) getChartFieldValueByName("panLast")).getY(); if (dx == 0.0 && dy == 0.0) { return; } double wPercent = -dx / ((Double) getChartFieldValueByName("panW")); double hPercent = dy / ((Double) getChartFieldValueByName("panH")); boolean old = getChart().getPlot().isNotify(); getChart().getPlot().setNotify(false); Pannable p = (Pannable) getChart().getPlot(); if (p.getOrientation() == PlotOrientation.VERTICAL) { p.panDomainAxes(wPercent, getChartRenderingInfo().getPlotInfo(), (Point) getChartFieldValueByName("panLast")); p.panRangeAxes(hPercent, getChartRenderingInfo().getPlotInfo(), (Point) getChartFieldValueByName("panLast")); } else { p.panDomainAxes(hPercent, getChartRenderingInfo().getPlotInfo(), (Point) getChartFieldValueByName("panLast")); p.panRangeAxes(wPercent, getChartRenderingInfo().getPlotInfo(), (Point) getChartFieldValueByName("panLast")); } setChartFieldValue((getChartFieldByName("panLast")), e.getPoint()); getChart().getPlot().setNotify(old); return; } // if no initial zoom point was set, ignore dragging... if (getChartFieldValueByName("zoomPoint") == null) { return; } Graphics2D g2 = (Graphics2D) getGraphics(); // erase the previous zoom rectangle (if any). We only need to do // this is we are using XOR mode, which we do when we're not using // the buffer (if there is a buffer, then at the end of this method we // just trigger a repaint) if (!(Boolean) getChartFieldValueByName("useBuffer")) { drawZoomRectangle(g2, true); } boolean hZoom = false; boolean vZoom = false; if ((PlotOrientation) getChartFieldValueByName("orientation") == PlotOrientation.HORIZONTAL) { hZoom = (Boolean) getChartFieldValueByName("rangeZoomable"); vZoom = (Boolean) getChartFieldValueByName("domainZoomable"); } else { hZoom = (Boolean) getChartFieldValueByName("domainZoomable"); vZoom = (Boolean) getChartFieldValueByName("rangeZoomable"); } Point2D zoomPoint = (Point2D) getChartFieldValueByName("zoomPoint"); Rectangle2D scaledDataArea = getScreenDataArea((int) zoomPoint.getX(), (int) zoomPoint.getY()); if (hZoom && vZoom) { // selected rectangle shouldn't extend outside the data area... double xmax = Math.min(e.getX(), scaledDataArea.getMaxX()); double ymax = Math.min(e.getY(), scaledDataArea.getMaxY()); setChartFieldValue(getChartFieldByName("zoomRectangle"), new Rectangle2D.Double(zoomPoint.getX(), zoomPoint.getY(), xmax - zoomPoint.getX(), ymax - zoomPoint.getY())); } else if (hZoom) { double xmax = Math.min(e.getX(), scaledDataArea.getMaxX()); setChartFieldValue(getChartFieldByName("zoomRectangle"), new Rectangle2D.Double(zoomPoint.getX(), scaledDataArea.getMinY(), xmax - zoomPoint.getX(), scaledDataArea.getHeight())); } else if (vZoom) { double ymax = Math.min(e.getY(), scaledDataArea.getMaxY()); setChartFieldValue(getChartFieldByName("zoomRectangle"), new Rectangle2D.Double(scaledDataArea.getMinX(), zoomPoint.getY(), scaledDataArea.getWidth(), ymax - zoomPoint.getY())); } // Draw the new zoom rectangle... if ((Boolean) getChartFieldValueByName("useBuffer")) { repaint(); } else { // with no buffer, we use XOR to draw the rectangle "over" the // chart... drawZoomRectangle(g2, true); } g2.dispose(); }
From source file:org.gvsig.remotesensing.scatterplot.chart.ScatterPlotDiagram.java
/** * @param selection ./*from w w w . ja va 2 s.c o m*/ * @return range[] rangos del rectangulo */ public Range[] getRange(Rectangle2D selection) { Range[] rangos = new Range[2]; // get the origin of the zoom selection in the Java2D space used for // drawing the chart (that is, before any scaling to fit the panel) Point2D selectOrigin = translateScreenToJava2D( new Point((int) Math.ceil(selection.getX()), (int) Math.ceil(selection.getY()))); PlotRenderingInfo plotInfo = this.info.getPlotInfo(); Rectangle2D scaledDataArea = getScreenDataArea((int) selection.getCenterX(), (int) selection.getCenterY()); if ((selection.getHeight() > 0) && (selection.getWidth() > 0)) { double hLower = (selection.getMinX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth(); double hUpper = (selection.getMaxX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth(); double vLower = (scaledDataArea.getMaxY() - selection.getMaxY()) / scaledDataArea.getHeight(); double vUpper = (scaledDataArea.getMaxY() - selection.getMinY()) / scaledDataArea.getHeight(); Plot p = this.chart.getPlot(); if (p instanceof ScatterPlotChart) { ScatterPlotChart z = (ScatterPlotChart) p; if (z.getOrientation() == PlotOrientation.HORIZONTAL) { rangos[0] = z.getRangeX(vLower, vUpper, plotInfo, selectOrigin); rangos[1] = z.getRangeY(hLower, hUpper, plotInfo, selectOrigin); } else { // devolver las coordenadas del rectangulo. rangos[0] = z.getRangeX(hLower, hUpper, plotInfo, selectOrigin); rangos[1] = z.getRangeY(vLower, vUpper, plotInfo, selectOrigin); } } } return rangos; }
From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java
/** * Draws the fast scatter plot on a Java 2D graphics device (such as the * screen or a printer)./*from ww w. j a v a2 s . c om*/ * * @param g2 the graphics device. * @param area the area within which the plot (including axis labels) should * be drawn. * @param anchor the anchor point (<code>null</code> permitted). * @param parentState the state from the parent plot (ignored). * @param info collects chart drawing information (<code>null</code> * permitted). */ @Override public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // set up info collection... if (info != null) { info.setPlotArea(area); } // adjust the drawing area for plot insets (if any)... RectangleInsets insets = getInsets(); insets.trim(area); AxisSpace space = new AxisSpace(); space = this.domainAxis.reserveSpace(g2, this, area, RectangleEdge.BOTTOM, space); space = this.rangeAxis.reserveSpace(g2, this, area, RectangleEdge.LEFT, space); Rectangle2D dataArea = space.shrink(area, null); if (info != null) { info.setDataArea(dataArea); } // draw the plot background and axes... drawBackground(g2, dataArea); AxisState domainAxisState = this.domainAxis.draw(g2, dataArea.getMaxY(), area, dataArea, RectangleEdge.BOTTOM, info); AxisState rangeAxisState = this.rangeAxis.draw(g2, dataArea.getMinX(), area, dataArea, RectangleEdge.LEFT, info); drawDomainGridlines(g2, dataArea, domainAxisState.getTicks()); drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks()); Shape originalClip = g2.getClip(); Composite originalComposite = g2.getComposite(); g2.clip(dataArea); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); render(g2, dataArea, info, null); g2.setClip(originalClip); g2.setComposite(originalComposite); drawOutline(g2, dataArea); }
From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java
/** * Draws the gridlines for the plot, if they are visible. * * @param g2 the graphics device.//w w w .java 2 s .com * @param dataArea the data area. * @param ticks the ticks. */ @Override protected void drawRangeGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) { // draw the range grid lines, if the flag says they're visible... if (isRangeGridlinesVisible()) { Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { ValueTick tick = (ValueTick) iterator.next(); double v = this.rangeAxis.valueToJava2D(tick.getValue(), dataArea, RectangleEdge.LEFT); Line2D line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v); g2.setPaint(getRangeGridlinePaint()); g2.setStroke(getRangeGridlineStroke()); g2.draw(line); } } }
From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java
/** * Zooms in on a selected region./* w w w .j a v a 2 s.com*/ * * @param selection the selected region. */ public void zoom(Rectangle2D selection) { double hLower = 0.0; double hUpper = 0.0; double vLower = 0.0; double vUpper = 0.0; if ((selection.getHeight() > 0) && (selection.getWidth() > 0)) { Rectangle2D scaledDataArea = getScaledDataArea(); hLower = (selection.getMinX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth(); hUpper = (selection.getMaxX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth(); vLower = (scaledDataArea.getMaxY() - selection.getMaxY()) / scaledDataArea.getHeight(); vUpper = (scaledDataArea.getMaxY() - selection.getMinY()) / scaledDataArea.getHeight(); Plot p = chart.getPlot(); if (p instanceof ValueAxisPlot) { ValueAxisPlot plot = (ValueAxisPlot) p; plot.zoomHorizontalAxes(hLower, hUpper); plot.zoomVerticalAxes(vLower, vUpper); } } }
From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java
/** * Draws a horizontal line used to trace the mouse position to the vertical axis. * * @param y the y-coordinate of the trace line. *//* w w w . j av a 2 s. c o m*/ private void drawVerticalAxisTrace(int y) { Graphics2D g2 = (Graphics2D) getGraphics(); Rectangle2D dataArea = getScaledDataArea(); g2.setXORMode(java.awt.Color.orange); if (((int) dataArea.getMinY() < y) && (y < (int) dataArea.getMaxY())) { if (horizontalTraceLine != null) { g2.draw(horizontalTraceLine); horizontalTraceLine.setLine((int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y); } else { horizontalTraceLine = new Line2D.Float((int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y); } g2.draw(horizontalTraceLine); } else { if (verticalTraceLine != null) { g2.draw(verticalTraceLine); verticalTraceLine = null; } if (horizontalTraceLine != null) { g2.draw(horizontalTraceLine); horizontalTraceLine = null; } } }
From source file:org.gumtree.vis.hist2d.Hist2DPanel.java
protected int findCursorOnSelectedItem(int x, int y) { if (getSelectedMask() != null && !getSelectedMask().getRectangleFrame().isEmpty()) { Rectangle2D screenArea = getScreenDataArea(); Rectangle2D maskArea = ChartMaskingUtilities .translateChartRectangle(getSelectedMask(), getScreenDataArea(), getChart()) .getRectangleFrame();/*from w w w . j a va2 s . c om*/ Rectangle2D intersect = screenArea.createIntersection(maskArea); Point2D point = new Point2D.Double(x, y); double minX = maskArea.getMinX(); double maxX = maskArea.getMaxX(); double minY = maskArea.getMinY(); double maxY = maskArea.getMaxY(); double width = maskArea.getWidth(); double height = maskArea.getHeight(); if (!intersect.isEmpty() && screenArea.contains(point)) { // if (y > minY && y < maxY) { // if (minX > screenArea.getMinX() + 1 // && minX < screenArea.getMaxX() - 1) { // if (x > minX - 4 && x < minX + (width < 8 ? width / 2 : 4)) { // return Cursor.W_RESIZE_CURSOR; // } // } // if (maxX > screenArea.getMinX() + 1 // && maxX < screenArea.getMaxX() - 1) { // if (x > maxX - (width < 8 ? width / 2 : 4) && x < maxX + 4) { // return Cursor.E_RESIZE_CURSOR; // } // } // } if (height > 8 && width > 8) { Rectangle2D center = new Rectangle2D.Double(minX + 4, minY + 4, width - 8, height - 8); if (screenArea.createIntersection(center).contains(point)) { return Cursor.MOVE_CURSOR; } } if (height > 8) { Rectangle2D west = new Rectangle2D.Double(minX - 4, minY + 4, width < 8 ? width / 2 + 4 : 8, height - 8); if (screenArea.createIntersection(west).contains(point)) { return Cursor.W_RESIZE_CURSOR; } Rectangle2D east = new Rectangle2D.Double(maxX - (width < 8 ? width / 2 : 4), minY + 4, width < 8 ? width / 2 + 4 : 8, height - 8); if (screenArea.createIntersection(east).contains(point)) { return Cursor.E_RESIZE_CURSOR; } } if (width > 8) { Rectangle2D north = new Rectangle2D.Double(minX + 4, minY - 4, width - 8, height < 8 ? height / 2 + 4 : 8); if (screenArea.createIntersection(north).contains(point)) { return Cursor.N_RESIZE_CURSOR; } Rectangle2D south = new Rectangle2D.Double(minX + 4, maxY - (height < 8 ? height / 2 : 4), width - 8, height < 8 ? height / 2 + 4 : 8); if (screenArea.createIntersection(south).contains(point)) { return Cursor.S_RESIZE_CURSOR; } } Rectangle2D northwest = new Rectangle2D.Double(minX - 4, minY - 4, width < 8 ? width / 2 + 4 : 8, height < 8 ? height / 2 + 4 : 8); if (screenArea.createIntersection(northwest).contains(point)) { return Cursor.NW_RESIZE_CURSOR; } Rectangle2D northeast = new Rectangle2D.Double(maxX - (width < 8 ? width / 2 : 4), minY - 4, width < 8 ? width / 2 + 4 : 8, height < 8 ? height / 2 + 4 : 8); if (screenArea.createIntersection(northeast).contains(point)) { return Cursor.NE_RESIZE_CURSOR; } Rectangle2D southwest = new Rectangle2D.Double(minX - 4, maxY - (height < 8 ? height / 2 : 4), width < 8 ? width / 2 + 4 : 8, height < 8 ? height / 2 + 4 : 8); if (screenArea.createIntersection(southwest).contains(point)) { return Cursor.SW_RESIZE_CURSOR; } Rectangle2D southeast = new Rectangle2D.Double(maxX - (width < 8 ? width / 2 : 4), maxY - (height < 8 ? height / 2 : 4), width < 8 ? width / 2 + 4 : 8, height < 8 ? height / 2 + 4 : 8); if (screenArea.createIntersection(southeast).contains(point)) { return Cursor.SE_RESIZE_CURSOR; } } // System.out.println("intersect X:[" + intersect.getMinX() + ", " + // (intersect.getMinX() + intersect.getWidth()) + // "], Y:[" + intersect.getMinY() + ", " + // (intersect.getMinY() + intersect.getHeight()) + // "], x=" + point.getX() + ", y=" + point.getY() + // " " + intersect.contains(point)); } return Cursor.DEFAULT_CURSOR; }
From source file:org.gvsig.remotesensing.scatterplot.chart.ScatterPlotDiagram.java
/** * Handles a 'mouse released' event. On Windows, we need to check if this * is a popup trigger, but only if we haven't already been tracking a zoom * rectangle./* w w w . jav a 2 s. c om*/ * * @param e information about the event. */ public void mouseReleased(MouseEvent e) { if (this.zoomRectangle != null) { boolean hZoom = false; boolean vZoom = false; if (this.orientation == PlotOrientation.HORIZONTAL) { hZoom = this.rangeZoomable; vZoom = this.domainZoomable; } else { hZoom = this.domainZoomable; vZoom = this.rangeZoomable; } boolean zoomTrigger1 = hZoom && Math.abs(e.getX() - this.zoomPoint.getX()) >= this.zoomTriggerDistance; boolean zoomTrigger2 = vZoom && Math.abs(e.getY() - this.zoomPoint.getY()) >= this.zoomTriggerDistance; if (zoomTrigger1 || zoomTrigger2) { if ((hZoom && (e.getX() < this.zoomPoint.getX())) || (vZoom && (e.getY() < this.zoomPoint.getY()))) { // restoreAutoBounds(); } else { double x, y, w, h; Rectangle2D screenDataArea = getScreenDataArea((int) this.zoomPoint.getX(), (int) this.zoomPoint.getY()); // for mouseReleased event, (horizontalZoom || verticalZoom) // will be true, so we can just test for either being false; // otherwise both are true if (!vZoom) { x = this.zoomPoint.getX(); y = screenDataArea.getMinY(); w = Math.min(this.zoomRectangle.getWidth(), screenDataArea.getMaxX() - this.zoomPoint.getX()); h = screenDataArea.getHeight(); } else if (!hZoom) { x = screenDataArea.getMinX(); y = this.zoomPoint.getY(); w = screenDataArea.getWidth(); h = Math.min(this.zoomRectangle.getHeight(), screenDataArea.getMaxY() - this.zoomPoint.getY()); } else { x = this.zoomPoint.getX(); y = this.zoomPoint.getY(); w = Math.min(this.zoomRectangle.getWidth(), screenDataArea.getMaxX() - this.zoomPoint.getX()); h = Math.min(this.zoomRectangle.getHeight(), screenDataArea.getMaxY() - this.zoomPoint.getY()); } if (activeROI != null) { Rectangle2D rectangleArea = new Rectangle2D.Double(x, y, w, h); g2 = (Graphics2D) getGraphics(); g2.setPaint(activeROI.getColor()); g2.draw(rectangleArea); activeROI.add(rectangleArea, getRange(rectangleArea)); RoiFromChartProcess process = new RoiFromChartProcess(); process.addParam("roi", activeROI); process.addParam("raster", (FLyrRasterSE) rasterSE); process.setActions(this); process.start(); if (gestorRois != null) { // Cargar la nueva ROI en el destor gestorRois.clearRoiGraphics(); } } } this.zoomPoint = null; this.zoomRectangle = null; updateUI(); } else { // Erase the zoom rectangle Graphics2D g2 = (Graphics2D) getGraphics(); drawRectangle(g2); g2.dispose(); this.zoomPoint = null; this.zoomRectangle = null; } } else if (e.isPopupTrigger()) { if (this.popup != null) { displayPopupMenu(e.getX(), e.getY()); } } }