List of usage examples for java.awt.geom RectangularShape getMaxY
public double getMaxY()
From source file:GraphicsUtil.java
public static Point2D getPoint(RectangularShape bounds, Align align) { double x = 0.0; double y = 0.0; switch (align) { case North://ww w. j a v a 2 s . c om x = bounds.getCenterX(); y = bounds.getMinY(); break; case NorthEast: x = bounds.getMaxX(); y = bounds.getMinY(); break; case East: x = bounds.getMaxX(); y = bounds.getCenterY(); break; case SouthEast: x = bounds.getMaxX(); y = bounds.getMaxY(); break; case South: x = bounds.getCenterX(); y = bounds.getMaxY(); break; case SouthWest: x = bounds.getMinX(); y = bounds.getMaxY(); break; case West: x = bounds.getMinX(); y = bounds.getCenterY(); break; case NorthWest: x = bounds.getMinX(); y = bounds.getMinY(); break; case Center: x = bounds.getCenterX(); y = bounds.getCenterY(); break; } return new Point2D.Double(x, y); }
From source file:com.github.lucapino.sheetmaker.renderer.JavaTemplateRenderer.java
public static Point2D getPoint(RectangularShape bounds, Align align) { double x = 0.0; double y = 0.0; switch (align) { case TopCenter: x = bounds.getCenterX();/* w w w . j a v a 2s . c o m*/ y = bounds.getMinY(); break; case TopRight: x = bounds.getMaxX(); y = bounds.getMinY(); break; case MiddleRight: x = bounds.getMaxX(); y = bounds.getCenterY(); break; case BottomRight: x = bounds.getMaxX(); y = bounds.getMaxY(); break; case BottomCenter: x = bounds.getCenterX(); y = bounds.getMaxY(); break; case BottomLeft: x = bounds.getMinX(); y = bounds.getMaxY(); break; case MiddleLeft: x = bounds.getMinX(); y = bounds.getCenterY(); break; case TopLeft: x = bounds.getMinX(); y = bounds.getMinY(); break; case Center: x = bounds.getCenterX(); y = bounds.getCenterY(); break; } return new Point2D.Double(x, y); }
From source file:it.cnr.istc.utils.gui.ReverseGradientXYBarPainter.java
/** * Creates a shadow for the bar.// w w w. ja va 2s .c om * * @param bar the bar shape. * @param xOffset the x-offset for the shadow. * @param yOffset the y-offset for the shadow. * @param base the edge that is the base of the bar. * @param pegShadow peg the shadow to the base? * * @return A rectangle for the shadow. */ private Rectangle2D createShadow(RectangularShape bar, double xOffset, double yOffset, RectangleEdge base, boolean pegShadow) { double x0 = bar.getMinX(); double x1 = bar.getMaxX(); double y0 = bar.getMinY(); double y1 = bar.getMaxY(); if (base == RectangleEdge.TOP) { x0 += xOffset; x1 += xOffset; if (!pegShadow) { y0 += yOffset; } y1 += yOffset; } else if (base == RectangleEdge.BOTTOM) { x0 += xOffset; x1 += xOffset; y0 += yOffset; if (!pegShadow) { y1 += yOffset; } } else if (base == RectangleEdge.LEFT) { if (!pegShadow) { x0 += xOffset; } x1 += xOffset; y0 += yOffset; y1 += yOffset; } else if (base == RectangleEdge.RIGHT) { x0 += xOffset; if (!pegShadow) { x1 += xOffset; } y0 += yOffset; y1 += yOffset; } return new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0)); }
From source file:it.cnr.istc.utils.gui.ReverseGradientXYBarPainter.java
/** * Splits a bar into subregions (elsewhere, these subregions will have * different gradients applied to them). * * @param bar the bar shape./*from ww w . j a v a 2 s . co m*/ * @param a the first division. * @param b the second division. * @param c the third division. * * @return An array containing four subregions. */ private Rectangle2D[] splitHorizontalBar(RectangularShape bar, double a, double b, double c) { Rectangle2D[] result = new Rectangle2D[4]; double y0 = bar.getMinY(); double y1 = Math.rint(y0 + (bar.getHeight() * a)); double y2 = Math.rint(y0 + (bar.getHeight() * b)); double y3 = Math.rint(y0 + (bar.getHeight() * c)); result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), bar.getWidth(), y1 - y0); result[1] = new Rectangle2D.Double(bar.getMinX(), y1, bar.getWidth(), y2 - y1); result[2] = new Rectangle2D.Double(bar.getMinX(), y2, bar.getWidth(), y3 - y2); result[3] = new Rectangle2D.Double(bar.getMinX(), y3, bar.getWidth(), bar.getMaxY() - y3); return result; }
From source file:org.aksw.resparql.ServerMethods.java
public static String toUriPart(RectangularShape rect) { return rect.getMinX() + "-" + rect.getMaxX() + "/" + rect.getMinY() + "-" + rect.getMaxY(); }
From source file:org.apache.fop.fonts.type1.AFMFile.java
/** * Returns the FontBBox value as integer array. * @return the font's bounding box//from w w w .ja va 2 s . com */ public int[] getFontBBoxAsIntArray() { RectangularShape rect = getFontBBox(); return new int[] { (int) Math.floor(rect.getMinX()), (int) Math.floor(rect.getMinY()), (int) Math.ceil(rect.getMaxX()), (int) Math.ceil(rect.getMaxY()) }; }
From source file:org.squidy.designer.zoom.ActionShape.java
@Override protected void paintShapeZoomedIn(PPaintContext paintContext) { Graphics2D g = paintContext.getGraphics(); RectangularShape r = (RectangularShape) getZoomedOutShape(); if (r instanceof RoundRectangle2D) { // int width = (int)(r.getMaxX()-r.getMinX()); // int height = (int)(r.getMaxY()-r.getMinY()); // BufferedImage shadeStarted = new BufferedImage(width, height, // BufferedImage.TYPE_INT_RGB); // BufferedImage shadeStopped = new BufferedImage(width, height, // BufferedImage.TYPE_INT_RGB); // BufferedImage shadeFailure = new BufferedImage(width, height, // BufferedImage.TYPE_INT_RGB); // shadeStarted.getGraphics().setColor(COLOR_STARTED); // shadeStopped.getGraphics().setColor(COLOR_STOPPED); // shadeFailure.getGraphics().setColor(COLOR_FAILURE); // shadeStarted.getGraphics().fillRect(0, 0, width, height); // shadeStopped.getGraphics().fillRect(0, 0, width, height); // shadeFailure.getGraphics().fillRect(0, 0, width, height); // g.setStroke(STROKE_ZOOMED_IN); g.setStroke(StrokeUtils.getBasicStroke(7f)); g.setColor(failure ? COLOR_FAILURE : started ? COLOR_STARTED : COLOR_STOPPED); if (polygonRendering) { if (isRenderPrimitiveRect()) { if (!isHierarchicalZoomInProgress()) { Polygon shadeHorizontal = new Polygon(); Polygon shadeVertical = new Polygon(); double shift = 1; shapeZoomedIn.setFrame(r.getMinX() + shift, r.getMinY() + shift, r.getMaxX() + shift, r.getMaxY() + shift); Rectangle bounds = shapeZoomedIn.getBounds(); shadeHorizontal.addPoint(bounds.x, bounds.y + bounds.height); shadeHorizontal.addPoint(bounds.x + bounds.width, bounds.y + bounds.height); shadeVertical.addPoint(bounds.x + bounds.width, bounds.y); shadeVertical.addPoint(bounds.x + bounds.width, bounds.y + bounds.height); shift = 5;//from ww w.j a v a 2 s .c om shapeZoomedIn.setFrame(r.getMinX() + shift, r.getMinY() + shift, r.getMaxX() + shift, r.getMaxY() + shift); bounds = shapeZoomedIn.getBounds(); shadeHorizontal.addPoint(bounds.x + bounds.width, bounds.y + bounds.height); shadeHorizontal.addPoint(bounds.x, bounds.y + bounds.height); shadeVertical.addPoint(bounds.x + bounds.width, bounds.y + bounds.height); shadeVertical.addPoint(bounds.x + bounds.width, bounds.y); g.fillPolygon(shadeHorizontal); g.fillPolygon(shadeVertical); } } else { g.draw(shapeZoomedIn); } } else { for (double shift = 6.; shift >= 1.; shift -= 1.) { shapeZoomedIn.setFrame(r.getMinX() + shift, r.getMinY() + shift, r.getMaxX() + shift, r.getMaxY() + shift); if (isRenderPrimitiveRect()) { if (!isHierarchicalZoomInProgress()) { Rectangle bounds = shapeZoomedIn.getBounds(); // g.drawImage(shadeStarted,null,bounds.x, // bounds.y); // g.fillRect(bounds.x, bounds.y, bounds.width, // bounds.height); g.drawLine(bounds.x + 1, bounds.y + bounds.height, bounds.x + bounds.width - 3, bounds.y + bounds.height); g.drawLine(bounds.x + bounds.width, bounds.y + 1, bounds.x + bounds.width, bounds.y + bounds.height - 3); } } else { g.draw(shapeZoomedIn); } } } } super.paintShapeZoomedIn(paintContext); }
From source file:org.squidy.designer.zoom.ActionShape.java
@Override protected void paintShapeZoomedOut(PPaintContext paintContext) { Graphics2D g = paintContext.getGraphics(); RectangularShape r = (RectangularShape) getZoomedOutShape(); if (r instanceof RoundRectangle2D) { // g.setStroke(STROKE_ZOOMED_OUT); g.setColor(failure ? COLOR_FAILURE : started ? COLOR_STARTED : COLOR_STOPPED); g.setStroke(StrokeUtils.getBasicStroke(20f)); if (polygonRendering) { if (isRenderPrimitiveRect()) { if (!isHierarchicalZoomInProgress()) { Polygon shadeHorizontal = new Polygon(); Polygon shadeVertical = new Polygon(); double shift = 1; shapeZoomedOut.setFrame(r.getMinX() + shift, r.getMinY() + shift, r.getMaxX() + shift, r.getMaxY() + shift); Rectangle bounds = shapeZoomedOut.getBounds(); shadeHorizontal.addPoint(bounds.x, bounds.y + bounds.height); shadeHorizontal.addPoint(bounds.x + bounds.width, bounds.y + bounds.height); shadeVertical.addPoint(bounds.x + bounds.width, bounds.y); shadeVertical.addPoint(bounds.x + bounds.width, bounds.y + bounds.height); shift = 30;//from w w w .j ava2 s .c o m shapeZoomedOut.setFrame(r.getMinX() + shift, r.getMinY() + shift, r.getMaxX() + shift, r.getMaxY() + shift); bounds = shapeZoomedOut.getBounds(); shadeHorizontal.addPoint(bounds.x + bounds.width, bounds.y + bounds.height); shadeHorizontal.addPoint(bounds.x, bounds.y + bounds.height); shadeVertical.addPoint(bounds.x + bounds.width, bounds.y + bounds.height); shadeVertical.addPoint(bounds.x + bounds.width, bounds.y); g.fillPolygon(shadeHorizontal); g.fillPolygon(shadeVertical); } } else { g.draw(shapeZoomedOut); } } else { for (double shift = 30.; shift >= 1.; shift -= 5.) { shapeZoomedOut.setFrame(r.getMinX() + shift, r.getMinY() + shift, r.getMaxX() + shift, r.getMaxY() + shift); if (isRenderPrimitiveRect()) { if (!isHierarchicalZoomInProgress()) { Rectangle bounds = shapeZoomedOut.getBounds(); // g.fillRect(bounds.x, bounds.y, bounds.width, // bounds.height); g.drawLine(bounds.x + 1, bounds.y + bounds.height, bounds.x + bounds.width - 3, bounds.y + bounds.height); g.drawLine(bounds.x + bounds.width, bounds.y + 1, bounds.x + bounds.width, bounds.y + bounds.height - 3); } } else { g.draw(shapeZoomedOut); } } } } super.paintShapeZoomedOut(paintContext); }