List of usage examples for java.awt.geom Rectangle2D getMinY
public double getMinY()
From source file:org.gumtree.vis.mask.ChartMaskingUtilities.java
public static Shape translateChartShape(Shape shape, Rectangle2D imageArea, JFreeChart chart) { if (shape instanceof Line2D) { Line2D line = (Line2D) shape; double length = line.getP1().distance(line.getP2()); if (length == 0) { Point2D point = line.getP1(); Point2D newPoint = ChartMaskingUtilities.translateChartPoint(point, imageArea, chart); Shape oShape = ShapeUtilities.createDiagonalCross(5f, 0.2f); // Shape oShape = ShapeUtilities.createRegularCross(3f, 0.5f); Shape newShape = ShapeUtilities.createTranslatedShape(oShape, newPoint.getX(), newPoint.getY()); return newShape; } else if (length < 1e-6) { if (line.getP1().getX() == line.getP2().getX()) { double newX = ChartMaskingUtilities.translateChartPoint(line.getP1(), imageArea, chart).getX(); Line2D newLine = new Line2D.Double(newX, imageArea.getMinY(), newX, imageArea.getMaxY()); return newLine; } else { double newY = ChartMaskingUtilities.translateChartPoint(line.getP1(), imageArea, chart).getY(); Line2D newLine = new Line2D.Double(imageArea.getMinX(), newY, imageArea.getMaxX(), newY); return newLine; }//from www.java 2 s. co m } Line2D newShape = (Line2D) line.clone(); Point2D newP1 = translateChartPoint(line.getP1(), imageArea, chart); Point2D newP2 = translateChartPoint(line.getP2(), imageArea, chart); newShape.setLine(newP1, newP2); return newShape; } else if (shape instanceof RectangularShape) { RectangularShape rect = (RectangularShape) shape; RectangularShape newShape = (RectangularShape) rect.clone(); Rectangle2D bound = rect.getBounds2D(); Point2D start = new Point2D.Double(bound.getMinX(), bound.getMinY()); Point2D end = new Point2D.Double(bound.getMaxX(), bound.getMaxY()); Point2D screenStart = translateChartPoint(start, imageArea, chart); Point2D screenEnd = translateChartPoint(end, imageArea, chart); newShape.setFrame(new Rectangle2D.Double(Math.min(screenStart.getX(), screenEnd.getX()), Math.min(screenStart.getY(), screenEnd.getY()), Math.abs(screenStart.getX() - screenEnd.getX()), Math.abs(screenStart.getY() - screenEnd.getY()))); return newShape; } else { return shape; } }
From source file:Clip.java
/** * Union this clip with another region. As a result, this clip * will become a bounding box around the two original regions. * @param r the rectangle to union with/*from www . j ava 2 s. com*/ */ public void union(Rectangle2D r) { if (status == INVALID) return; double minx = r.getMinX(); double miny = r.getMinY(); double maxx = r.getMaxX(); double maxy = r.getMaxY(); if (Double.isNaN(minx) || Double.isNaN(miny) || Double.isNaN(maxx) || Double.isNaN(maxy)) { Logger.getLogger(getClass().getName()).warning("Union with invalid clip region: " + r); return; } if (status == EMPTY) { setClip(r); status = INUSE; return; } clip[0] = Math.min(clip[0], minx); clip[1] = Math.min(clip[1], miny); clip[6] = Math.max(clip[6], maxx); clip[7] = Math.max(clip[7], maxy); }
From source file:peakml.util.jfreechart.LognAxis.java
@Override public double java2DToValue(double java2DValue, Rectangle2D plotArea, RectangleEdge edge) { Range range = getRange();//from w w w .j av a2 s . c o m double axisMin = log(range.getLowerBound()); double axisMax = log(range.getUpperBound()); double min = 0.0, max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = plotArea.getX(); max = plotArea.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { min = plotArea.getMaxY(); max = plotArea.getMinY(); } if (isInverted()) return pow(axisMax - ((java2DValue - min) / (max - min)) * (axisMax - axisMin)); else return pow(axisMin + ((java2DValue - min) / (max - min)) * (axisMax - axisMin)); }
From source file:peakml.util.jfreechart.LognAxis.java
@Override public double valueToJava2D(double value, Rectangle2D plotArea, RectangleEdge edge) { Range range = getRange();//from ww w . j av a 2 s . c o m double axisMin = log(range.getLowerBound()); double axisMax = log(range.getUpperBound()); double min = 0.0, 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 = log(value); if (isInverted()) return max - (((value - axisMin) / (axisMax - axisMin)) * (max - min)); else return min + (((value - axisMin) / (axisMax - axisMin)) * (max - min)); }
From source file:org.knime.knip.core.ui.imgviewer.panels.HistogramBC.java
private XYAnnotation slopeLine() { return new XYAnnotation() { private double x1, y1, x2, y2; @Override//from w ww .jav a 2 s . c o m public void removeChangeListener(final AnnotationChangeListener listener) { // ignore } @Override public void addChangeListener(final AnnotationChangeListener listener) { // ignore } @Override public void draw(final Graphics2D g2, final XYPlot plot, final Rectangle2D dataArea, final ValueAxis domainAxis, final ValueAxis rangeAxis, final int rendererIndex, final PlotRenderingInfo info) { calcLineCoords(dataArea); drawLine(g2); } private void drawLine(final Graphics2D g2) { final Color origColor = g2.getColor(); g2.setColor(Color.black); g2.drawLine((int) x1, (int) y1, (int) x2, (int) y2); g2.setColor(Color.lightGray); g2.drawLine((int) x1, 0, (int) x1, 192); g2.drawLine((int) x2, 0, (int) x2, 192); g2.setColor(origColor); } @SuppressWarnings("synthetic-access") private void calcLineCoords(final Rectangle2D rect) { // offset necessary since chart is not drawn on whole rectangle int offset = 12; final double x = rect.getMinX() + offset; final double y = rect.getMinY(); final double w = rect.getWidth() - 2 * offset; final double h = rect.getHeight(); final double min = bundle.getTheoreticalMin(); final double max = bundle.getTheoreticalMax(); final double defaultMin = bundle.getDataMin(); final double defaultMax = bundle.getDataMax(); final double scale = w / (defaultMax - defaultMin); double slope = 0.0; if (max != min) { slope = h / (max - min); } if (min >= defaultMin) { x1 = scale * (min - defaultMin); y1 = h; } else { x1 = 0; if (max > min) { y1 = h - ((defaultMin - min) * slope); } else { y1 = h; } } if (max <= defaultMax) { x2 = (scale * (max - defaultMin)); y2 = 0; } else { x2 = w; if (max > min) { y2 = h - ((defaultMax - min) * slope); } else { y2 = 0; } } x1 += x; x2 += x; y1 += y; y2 += y; } }; }
From source file:edu.jhuapl.graphs.jfreechart.utils.SparselyLabeledCategoryAxis.java
private void drawDomainGridline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, double value) { Line2D line = null;/*from w w w.ja v a 2 s. c o m*/ PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(dataArea.getMinX(), value, dataArea.getMaxX(), value); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(value, dataArea.getMinY(), value, dataArea.getMaxY()); } g2.setPaint(domainGridlinePaint); Stroke stroke = plot.getDomainGridlineStroke(); if (stroke == null) { stroke = CategoryPlot.DEFAULT_GRIDLINE_STROKE; } g2.setStroke(stroke); g2.draw(line); }
From source file:com.zilbo.flamingSailor.TE.model.Component.java
public boolean onSameLine(Rectangle2D otherGeom) { Double y1 = this.geom.getMinY(); Double y3 = this.geom.getMaxY(); Double y2 = otherGeom.getMinY(); Double y4 = otherGeom.getMaxY(); // we have some kind of crossover. if (y1 <= y4 && y1 >= y2) { // AND the boxes are touching if (Math.abs(this.geom.getMinX() - otherGeom.getMaxX()) < 0.5 || (this.geom.getMaxX() - otherGeom.getMinX()) < 0.5) { // assume it's a super/subscript letter and call it the same line. return true; }//ww w. jav a 2 s . co m } // we have some kind of crossover. if (y2 <= y3 && y2 >= y1) { // AND the boxes are touching // logger.info(this.geom.getMinX() - otherGeom.getMaxX()); if (Math.abs(this.geom.getMinX() - otherGeom.getMaxX()) < 0.5 || (this.geom.getMaxX() - otherGeom.getMinX()) < 0.5) { // assume it's a super/subscript letter and call it the same line. return true; } } double yAveT = (y2 + y4) / 2; // double diff = (y4-y2)/4; if ((y1 <= (yAveT)) && ((yAveT) < y3)) { return true; } yAveT = (y1 + y3) / 2; return (y2 <= yAveT) && (yAveT < y4); }
From source file:Clip.java
/** * Intersect this clip with another region. As a result, this * clip will become the intersecting area of the two regions. * @param r the rectangle to intersect with *//*from ww w.j av a 2s .c om*/ public void intersection(Rectangle2D r) { if (status == INVALID) return; if (status == EMPTY) { setClip(r); status = INUSE; return; } clip[0] = Math.max(clip[0], r.getMinX()); clip[1] = Math.max(clip[1], r.getMinY()); clip[6] = Math.min(clip[6], r.getMaxX()); clip[7] = Math.min(clip[7], r.getMaxY()); }
From source file:edu.ucla.stat.SOCR.chart.gui.CircleDrawer.java
/** * Draws the circle.//ww w .j a v a 2 s. co m * * @param g2 the graphics device. * @param area the area in which to draw. */ public void draw(Graphics2D g2, Rectangle2D area) { Ellipse2D ellipse = new Ellipse2D.Double(area.getX(), area.getY(), area.getWidth(), area.getHeight()); if (this.fillPaint != null) { g2.setPaint(this.fillPaint); g2.fill(ellipse); } if (this.outlinePaint != null && this.outlineStroke != null) { g2.setPaint(this.outlinePaint); g2.setStroke(this.outlineStroke); g2.draw(ellipse); } g2.setPaint(Color.black); g2.setStroke(new BasicStroke(1.0f)); Line2D line1 = new Line2D.Double(area.getCenterX(), area.getMinY(), area.getCenterX(), area.getMaxY()); Line2D line2 = new Line2D.Double(area.getMinX(), area.getCenterY(), area.getMaxX(), area.getCenterY()); g2.draw(line1); g2.draw(line2); }
From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java
@Override public void drawBackground(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea) { float x0 = (float) dataArea.getX(); float x1 = x0 + (float) Math.abs(getXOffset()); float x3 = (float) dataArea.getMaxX(); float x2 = x3 - (float) Math.abs(getXOffset()); float y0 = (float) dataArea.getMaxY(); float y1 = y0 - (float) Math.abs(getYOffset()); float y3 = (float) dataArea.getMinY(); float y2 = y3 + (float) Math.abs(getYOffset()); GeneralPath clip = new GeneralPath(); clip.moveTo(x0, y0);// ww w . ja v a 2 s. c om clip.lineTo(x0, y2); clip.lineTo(x1, y3); clip.lineTo(x3, y3); clip.lineTo(x3, y1); clip.lineTo(x2, y0); clip.closePath(); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, plot.getBackgroundAlpha())); // fill background... Paint backgroundPaint = plot.getBackgroundPaint(); if (backgroundPaint != null) { g2.setPaint(backgroundPaint); g2.fill(clip); } GeneralPath bottomWall = new GeneralPath(); bottomWall.moveTo(x0, y0); bottomWall.lineTo(x1, y1); bottomWall.lineTo(x3, y1); bottomWall.lineTo(x2, y0); bottomWall.closePath(); g2.setPaint(getWallPaint()); g2.fill(bottomWall); // draw background image, if there is one... Image backgroundImage = plot.getBackgroundImage(); if (backgroundImage != null) { Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX() + getXOffset(), dataArea.getY(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); plot.drawBackgroundImage(g2, adjusted); } g2.setComposite(originalComposite); }