Example usage for java.awt.geom RectangularShape getMinY

List of usage examples for java.awt.geom RectangularShape getMinY

Introduction

In this page you can find the example usage for java.awt.geom RectangularShape getMinY.

Prototype

public double getMinY() 

Source Link

Document

Returns the smallest Y coordinate of the framing rectangle of the Shape in double precision.

Usage

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:/*from  ww  w . jav a2 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();//from   www. j  a va  2 s .co  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

/**
 * Splits a bar into subregions (elsewhere, these subregions will have
 * different gradients applied to them).
 *
 * @param bar the bar shape./*  ww  w . j  a v a 2  s.c  o  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:it.cnr.istc.utils.gui.ReverseGradientXYBarPainter.java

/**
 * Creates a shadow for the bar./*  w  w  w.j  av a 2s  .  c o  m*/
 *
 * @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.//  w w 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[] splitVerticalBar(RectangularShape bar, double a, double b, double c) {
    Rectangle2D[] result = new Rectangle2D[4];
    double x0 = bar.getMinX();
    double x1 = Math.rint(x0 + (bar.getWidth() * a));
    double x2 = Math.rint(x0 + (bar.getWidth() * b));
    double x3 = Math.rint(x0 + (bar.getWidth() * c));
    result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), x1 - x0, bar.getHeight());
    result[1] = new Rectangle2D.Double(x1, bar.getMinY(), x2 - x1, bar.getHeight());
    result[2] = new Rectangle2D.Double(x2, bar.getMinY(), x3 - x2, bar.getHeight());
    result[3] = new Rectangle2D.Double(x3, bar.getMinY(), bar.getMaxX() - x3, bar.getHeight());
    return result;
}

From source file:com.rapidminer.gui.plotter.charts.RapidXYBarPainter.java

@Override
public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row, int column, RectangularShape bar,
        RectangleEdge base) {/*from   w w w  .  j  a  v a  2 s.  co m*/
    Paint itemPaint = renderer.getItemPaint(row, column);

    Color c0 = null;

    if (itemPaint instanceof Color) {
        c0 = (Color) itemPaint;
    } else {
        c0 = SwingTools.DARK_BLUE;
    }

    // as a special case, if the bar color has alpha == 0, we draw
    // nothing.
    if (c0.getAlpha() == 0) {
        return;
    }

    g2.setPaint(c0);
    g2.fill(new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), bar.getWidth(), bar.getHeight()));

    // draw the outline...
    if (renderer.isDrawBarOutline()) {
        Stroke stroke = renderer.getItemOutlineStroke(row, column);
        Paint paint = renderer.getItemOutlinePaint(row, column);
        if (stroke != null && paint != null) {
            g2.setStroke(stroke);
            g2.setPaint(paint);
            g2.draw(bar);
        }
    }
}

From source file:com.rapidminer.gui.plotter.charts.RapidBarPainter.java

/**
 * Paints a single bar instance./* w  w  w . j  av  a  2 s  . c  o  m*/
 * 
 * @param g2
 *            the graphics target.
 * @param renderer
 *            the renderer.
 * @param row
 *            the row index.
 * @param column
 *            the column index.
 * @param bar
 *            the bar
 * @param base
 *            indicates which side of the rectangle is the base of the bar.
 */
@Override
public void paintBar(final Graphics2D g2, final BarRenderer renderer, final int row, final int column,
        final RectangularShape bar, final RectangleEdge base) {
    Paint itemPaint = renderer.getItemPaint(row, column);

    Color c0 = null;

    if (itemPaint instanceof Color) {
        c0 = (Color) itemPaint;
    } else {
        c0 = SwingTools.DARK_BLUE;
    }

    // as a special case, if the bar color has alpha == 0, we draw
    // nothing.
    if (c0.getAlpha() == 0) {
        return;
    }

    g2.setPaint(c0);
    g2.fill(new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), bar.getWidth(), bar.getHeight()));

    // draw the outline...
    if (renderer.isDrawBarOutline()) {
        Stroke stroke = renderer.getItemOutlineStroke(row, column);
        Paint paint = renderer.getItemOutlinePaint(row, column);
        if (stroke != null && paint != null) {
            g2.setStroke(stroke);
            g2.setPaint(paint);
            g2.draw(bar);
        }
    }

}

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   ww  w  . j  a va2s  . c  om
 */
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  av  a2 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);
}