Example usage for java.awt.geom RectangularShape getHeight

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

Introduction

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

Prototype

public abstract double getHeight();

Source Link

Document

Returns the height of the framing rectangle in double precision.

Usage

From source file:GraphicsUtil.java

public static Rectangle2D contract(RectangularShape rect, double amountX, double amountY) {
    return new Rectangle2D.Double(rect.getX() + amountX, rect.getY() + amountY, rect.getWidth() - (2 * amountX),
            rect.getHeight() - (2 * amountY));
}

From source file:GraphicsUtil.java

public static Rectangle2D expand(RectangularShape rect, double amountX, double amountY) {
    return new Rectangle2D.Double(rect.getX() - amountX, rect.getY() - amountY, rect.getWidth() + (2 * amountX),
            rect.getHeight() + (2 * amountY));
}

From source file:ShapeTransform.java

/**
 * Translates a given shape. Special care is taken to preserve the shape's
 * original class, if the shape is a rectangle or a line.
 * /*from  w  w  w. jav  a  2 s  . co m*/
 * @param s
 *          the shape
 * @param x
 *          the x coordinate where the shape is translated to
 * @param y
 *          the y coordinate where the shape is translated to
 * @return the translated shape
 */
public static Shape translateShape(final Shape s, final double x, final double y) {
    if (s instanceof RectangularShape) {
        final RectangularShape rect = (RectangularShape) s;
        final RectangularShape retval = (RectangularShape) rect.clone();
        retval.setFrame(retval.getX() + x, retval.getY() + y, retval.getWidth(), retval.getHeight());
        return retval;
    }
    if (s instanceof Line2D) {
        final Line2D line = (Line2D) s;
        final Line2D retval = (Line2D) line.clone();
        retval.setLine(retval.getX1() + x, retval.getY1() + y, retval.getX2() + x, retval.getY2() + y);
        return retval;
    }

    final AffineTransform af = AffineTransform.getTranslateInstance(x, y);
    return af.createTransformedShape(s);
}

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 w ww  .  ja  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:net.sf.mzmine.modules.visualization.metamsecorrelate.visual.pseudospectra.PseudoSpectraRenderer.java

public PseudoSpectraRenderer(Color color, boolean isTransparent) {

    this.isTransparent = isTransparent;

    // Set painting color
    setBasePaint(color);//w w  w.  j  av a2  s  .  c om

    // Shadow makes fake peaks
    setShadowVisible(false);

    // Set the tooltip generator
    SpectraToolTipGenerator tooltipGenerator = new SpectraToolTipGenerator();
    setBaseToolTipGenerator(tooltipGenerator);

    // We want to paint the peaks using simple color without any gradient
    // effects
    setBarPainter(new StandardXYBarPainter() {
        @Override
        public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row, int column, RectangularShape bar,
                RectangleEdge base) {
            super.paintBar(g2, renderer, row, column, new Rectangle2D.Double(
                    bar.getX() + (bar.getWidth() - 2) / 2, bar.getY(), 2, bar.getHeight()), base);
        }
    });
}

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 om*/
 * @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  ava 2  s .  com
    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./*from   w w  w  . j a v a  2s .c om*/
 * 
 * @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.jcurl.demo.tactics.old.MenuView.java

private void pan(final double rx, final double ry, final int dt) {
    if (getModel() == null)
        return;/*  w  ww  .j a  v a2  s  .  c om*/
    final RectangularShape src = getModel().getZoom();
    src.setFrame(src.getX() + src.getWidth() * rx, src.getY() + src.getHeight() * ry, src.getWidth(),
            src.getHeight());
    zoom(src, dt);
}

From source file:org.jcurl.demo.tactics.old.MenuView.java

private void zoom(final Point2D center, final double ratio, final int dt) {
    if (getModel() == null)
        return;//from   ww w .j av  a  2s .  co m
    final RectangularShape src = getModel().getZoom();
    if (log.isDebugEnabled())
        log.debug(src);
    final double w = src.getWidth() * ratio;
    final double h = src.getHeight() * ratio;
    final double cx, cy;
    if (center == null) {
        cx = src.getCenterX();
        cy = src.getCenterY();
    } else {
        cx = center.getX();
        cy = center.getY();
    }
    zoom(new Rectangle2D.Double(cx - w / 2, cy - h / 2, Math.abs(w), Math.abs(h)), dt);
}