List of usage examples for java.awt.geom RectangularShape setFrame
public abstract void setFrame(double x, double y, double w, double h);
From source file:ShapeTransform.java
/** * Resizes a rectangle. This works for real rectangles and produces funny * results for RoundRects etc ..//from w w w.ja v a 2 s. c o m * * @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. * /* ww w . j av a 2s . c o 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: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 w w . j a v a 2s . c o 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); }
From source file:tufts.vue.LWComponent.java
/** @return our shape, full transformed into map coords and ultimate scale when drawn at 100% map zoom * this is used for portal clipping, and will be imperfect for some scaled shapes, such as RountRect's * This only works for raw shapes that are RectangularShapes -- other Shape types just return the bounding * box in map coordinates (e.g., a link shape) */// w ww.j a va 2s .com public RectangularShape getMapShape() { // Will not work for shapes like RoundRect when scaled -- e..g, corner scaling will be off final Shape s = getZeroShape(); // if (getMapScale() != 1f && s instanceof RectangularShape) { // todo: do if any transform, not just scale if (s instanceof RectangularShape) { // todo: cache this: only need to updaate if location, size or scale changes // (Also, on the scale or location change of any parent!) RectangularShape rshape = (RectangularShape) s; rshape = (RectangularShape) rshape.clone(); AffineTransform a = getZeroTransform(); Point2D.Float loc = new Point2D.Float(); a.transform(loc, loc); rshape.setFrame(loc.x, loc.y, rshape.getWidth() * a.getScaleX(), rshape.getHeight() * a.getScaleY()); //System.out.println("TRANSFORMED SHAPE: " + rshape + " for " + this); return rshape; } else { return getMapBounds(); } }