Example usage for java.awt.geom RectangularShape getX

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

Introduction

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

Prototype

public abstract double getX();

Source Link

Document

Returns the X coordinate of the upper-left corner 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

/**
 * Resizes a rectangle. This works for real rectangles and produces funny
 * results for RoundRects etc ..// w w  w  .  j  av a  2  s  .  com
 * 
 * @param rectangularShape
 *          the rectangle
 * @param width
 *          the new width of the rectangle
 * @param height
 *          the new height of the rectangle.
 * @return the resized rectangle.
 */
public static Shape resizeRect(final RectangularShape rectangularShape, final double width,
        final double height) {
    final RectangularShape retval = (RectangularShape) rectangularShape.clone();
    retval.setFrame(retval.getX(), retval.getY(), width, height);
    return retval;
}

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.
 * // www .jav a  2 s . c om
 * @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: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 a va 2  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:org.jcurl.demo.tactics.old.MenuView.java

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