List of usage examples for java.awt.geom Rectangle2D getMinY
public double getMinY()
From source file:org.gumtree.vis.plot1d.LogarithmizableAxis.java
/** * Converts a data value to a coordinate in Java2D space, assuming that * the axis runs along one edge of the specified plotArea. * Note that it is possible for the coordinate to fall outside the * plotArea./*from w w w. j a v a 2s . c om*/ * * @param value the data value. * @param plotArea the area for plotting the data. * @param edge the axis location. * * @return The Java2D coordinate. */ public double logValueToJava2D(double value, Rectangle2D plotArea, RectangleEdge edge) { Range range = getRange(); double axisMin = switchedLog10(range.getLowerBound()); double axisMax = switchedLog10(range.getUpperBound()); double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = plotArea.getMinX(); max = plotArea.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { min = plotArea.getMaxY(); max = plotArea.getMinY(); } value = switchedLog10(value); if (isInverted()) { return max - (((value - axisMin) / (axisMax - axisMin)) * (max - min)); } else { return min + (((value - axisMin) / (axisMax - axisMin)) * (max - min)); } }
From source file:org.gumtree.vis.plot1d.LogarithmizableAxis.java
/** * Converts a coordinate in Java2D space to the corresponding data * value, assuming that the axis runs along one edge of the specified * plotArea.//www . j av a2 s . c o m * * @param java2DValue the coordinate in Java2D space. * @param plotArea the area in which the data is plotted. * @param edge the axis location. * * @return The data value. */ public double java2DToLogValue(double java2DValue, Rectangle2D plotArea, RectangleEdge edge) { Range range = getRange(); double axisMin = switchedLog10(range.getLowerBound()); double axisMax = switchedLog10(range.getUpperBound()); double plotMin = 0.0; double plotMax = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { plotMin = plotArea.getX(); plotMax = plotArea.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { plotMin = plotArea.getMaxY(); plotMax = plotArea.getMinY(); } if (isInverted()) { return switchedPow10(axisMax - ((java2DValue - plotMin) / (plotMax - plotMin)) * (axisMax - axisMin)); } else { return switchedPow10(axisMin + ((java2DValue - plotMin) / (plotMax - plotMin)) * (axisMax - axisMin)); } }
From source file:org.gumtree.vis.awt.JChartPanel.java
/** * Draws a vertical line used to trace the mouse position to the horizontal * axis./* ww w. j av a 2s .c om*/ * * @param g2 the graphics device. * @param x the x-coordinate of the trace line. */ private void drawHorizontalAxisTrace(Graphics2D g2, int x) { Rectangle2D dataArea = getScreenDataArea(); if (((int) dataArea.getMinX() < x) && (x < (int) dataArea.getMaxX())) { g2.setPaint(getAxisTraceColor()); g2.setStroke(new BasicStroke(0.25f)); g2.draw(new Line2D.Float(x, (int) dataArea.getMinY(), x, (int) dataArea.getMaxY())); } }
From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java
/** * Handles a 'mouse dragged' event.//from w w w.ja v a 2 s. com * * @param e the mouse event. */ public void mouseDragged(MouseEvent e) { if (this.zoomingEnabled) { // if the popup menu has already been triggered, then ignore dragging... if (popup != null && popup.isShowing()) { return; } Graphics2D g2 = (Graphics2D) getGraphics(); // use XOR to erase the previous zoom rectangle (if any)... g2.setXORMode(java.awt.Color.gray); if (zoomRectangle != null) { if (fillZoomRectangle) { g2.fill(zoomRectangle); } else { g2.draw(zoomRectangle); } } Rectangle2D scaledDataArea = getScaledDataArea(); if (this.horizontalZoom && this.verticalZoom) { // 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()); zoomRectangle = new Rectangle2D.Double(zoomPoint.getX(), zoomPoint.getY(), xmax - zoomPoint.getX(), ymax - zoomPoint.getY()); } else if (this.horizontalZoom) { double xmax = Math.min(e.getX(), scaledDataArea.getMaxX()); zoomRectangle = new Rectangle2D.Double(zoomPoint.getX(), scaledDataArea.getMinY(), xmax - zoomPoint.getX(), scaledDataArea.getHeight()); } else if (this.verticalZoom) { double ymax = Math.min(e.getY(), scaledDataArea.getMaxY()); zoomRectangle = new Rectangle2D.Double(scaledDataArea.getMinX(), zoomPoint.getY(), scaledDataArea.getWidth(), ymax - zoomPoint.getY()); } if (zoomRectangle != null) { // use XOR to draw the new zoom rectangle... if (fillZoomRectangle) { g2.fill(zoomRectangle); } else { g2.draw(zoomRectangle); } } g2.dispose(); } }
From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * Draws a horizontal line used to trace the mouse position to the vertical axis. * //from w w w .ja v a 2 s .c o m * @param g2 * the graphics device. * @param y * the y-coordinate of the trace line. */ private void drawVerticalAxisTrace(Graphics2D g2, int y) { Rectangle2D dataArea = getScreenDataArea(); g2.setXORMode(Color.orange); if (((int) dataArea.getMinY() < y) && (y < (int) dataArea.getMaxY())) { if (this.horizontalTraceLine != null) { g2.draw(this.horizontalTraceLine); this.horizontalTraceLine.setLine((int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y); } else { this.horizontalTraceLine = new Line2D.Float((int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y); } g2.draw(this.horizontalTraceLine); } // Reset to the default 'overwrite' mode g2.setPaintMode(); }
From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * Returns a point based on (x, y) but constrained to be within the bounds of the given * rectangle. This method could be moved to JCommon. * //w ww .j a v a 2s.co m * @param x * the x-coordinate. * @param y * the y-coordinate. * @param area * the rectangle (<code>null</code> not permitted). * @return A point within the rectangle. */ private Point getPointInRectangle(int x, int y, Rectangle2D area) { x = (int) Math.max(Math.ceil(area.getMinX()), Math.min(x, Math.floor(area.getMaxX()))); y = (int) Math.max(Math.ceil(area.getMinY()), Math.min(y, Math.floor(area.getMaxY()))); return new Point(x, y); }
From source file:org.rdv.viz.chart.ChartPanel.java
/** * Draws a horizontal line used to trace the mouse position to the vertical * axis./*w w w .j a va2 s. c o m*/ * * @param g2 the graphics device. * @param y the y-coordinate of the trace line. */ private void drawVerticalAxisTrace(Graphics2D g2, int y) { Rectangle2D dataArea = getScreenDataArea(); g2.setXORMode(Color.orange); if (((int) dataArea.getMinY() < y) && (y < (int) dataArea.getMaxY())) { if (this.horizontalTraceLine != null) { g2.draw(this.horizontalTraceLine); this.horizontalTraceLine.setLine((int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y); } else { this.horizontalTraceLine = new Line2D.Float((int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y); } g2.draw(this.horizontalTraceLine); } // Reset to the default 'overwrite' mode g2.setPaintMode(); }
From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * Draws a vertical line used to trace the mouse position to the horizontal axis. * /*from w w w .j a v a 2 s.c o m*/ * @param g2 * the graphics device. * @param x * the x-coordinate of the trace line. */ private void drawHorizontalAxisTrace(Graphics2D g2, int x) { Rectangle2D dataArea = getScreenDataArea(); g2.setXORMode(Color.orange); if (((int) dataArea.getMinX() < x) && (x < (int) dataArea.getMaxX())) { if (this.verticalTraceLine != null) { g2.draw(this.verticalTraceLine); this.verticalTraceLine.setLine(x, (int) dataArea.getMinY(), x, (int) dataArea.getMaxY()); } else { this.verticalTraceLine = new Line2D.Float(x, (int) dataArea.getMinY(), x, (int) dataArea.getMaxY()); } g2.draw(this.verticalTraceLine); } // Reset to the default 'overwrite' mode g2.setPaintMode(); }
From source file:org.rdv.viz.chart.ChartPanel.java
/** * Draws a vertical line used to trace the mouse position to the horizontal * axis.//from w w w. ja va 2 s . c o m * * @param g2 the graphics device. * @param x the x-coordinate of the trace line. */ private void drawHorizontalAxisTrace(Graphics2D g2, int x) { Rectangle2D dataArea = getScreenDataArea(); g2.setXORMode(Color.orange); if (((int) dataArea.getMinX() < x) && (x < (int) dataArea.getMaxX())) { if (this.verticalTraceLine != null) { g2.draw(this.verticalTraceLine); this.verticalTraceLine.setLine(x, (int) dataArea.getMinY(), x, (int) dataArea.getMaxY()); } else { this.verticalTraceLine = new Line2D.Float(x, (int) dataArea.getMinY(), x, (int) dataArea.getMaxY()); } g2.draw(this.verticalTraceLine); } // Reset to the default 'overwrite' mode g2.setPaintMode(); }
From source file:com.isti.traceview.common.TraceViewChartPanel.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. * /*from w w w . j a v 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()); } Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h); zoom(zoomArea); } this.zoomPoint = null; this.zoomRectangle = null; } else { // Erase the zoom rectangle Graphics2D g2 = (Graphics2D) getGraphics(); drawZoomRectangle(g2); g2.dispose(); this.zoomPoint = null; this.zoomRectangle = null; } } else if (e.isPopupTrigger()) { if (this.popup != null) { displayPopupMenu(e.getX(), e.getY()); } } }