/**Returns a deep copy of the argument. */ static Shape cloneShape(Shape rhs) { if(rhs==null) return null; if(rhs instanceof Rectangle2D.Double) { return (Rectangle2D.Double)((Rectangle2D.Double)rhs).clone(); } else if(rhs instanceof Ellipse2D.Double) { return (Ellipse2D.Double)((Ellipse2D.Double)rhs).clone(); } else if(rhs instanceof Line2D.Double) { return (Line2D.Double)((Line2D.Double)rhs).clone(); } else if(rhs instanceof Polygon) { return new Polygon(((Polygon)rhs).xpoints, ((Polygon)rhs).ypoints, ((Polygon)rhs).npoints); } else if(rhs instanceof GeneralPath) { return (GeneralPath)((GeneralPath)rhs).clone(); } return new GeneralPath(); // dodgy !!! }
protected Rectangle2D.Double getDrawingArea() { if (cachedDrawingArea == null) { if (drawing != null) { cachedDrawingArea = drawing.getDrawingArea(); } else { cachedDrawingArea = new Rectangle2D.Double(); } } return (Rectangle2D.Double) cachedDrawingArea.clone(); }
@Override public Rectangle2D.Double getBounds() { Rectangle2D.Double bounds = (Rectangle2D.Double) rectangle.clone(); return bounds; }
@Override protected void drawFill(final Graphics2D g) { final Rectangle2D.Double r = (Rectangle2D.Double) bounds.clone(); final double grow = AttributeKeys.getPerpendicularFillGrowth(this); Geom.grow(r, grow, grow); g.fill(r); }
@Override public Rectangle2D getBounds2D() { if (bounds == null) { } return (Rectangle2D.Double) bounds.clone(); }
@Override public RectangleFigure clone() { RectangleFigure that = (RectangleFigure) super.clone(); that.rectangle = (Rectangle2D.Double) this.rectangle.clone(); return that; } // EVENT HANDLING
@Override protected void drawStroke(Graphics2D g) { Rectangle2D.Double r = (Rectangle2D.Double) rectangle.clone(); double grow = AttributeKeys.getPerpendicularDrawGrowth(this); Geom.grow(r, grow, grow); g.draw(r); } // SHAPE AND BOUNDS
@Override public Object getTransformRestoreData() { return new Object[]{ rectangle.clone(), get(TRANSFORM) }; }
@Override public void restoreTransformTo(Object geometry) { Object[] restoreData = (Object[]) geometry; bounds = (Rectangle2D.Double) ((Rectangle2D.Double) restoreData[0]).clone(); TRANSFORM.setClone(this, (AffineTransform) restoreData[1]); FILL_GRADIENT.setClone(this, (Gradient) restoreData[2]); STROKE_GRADIENT.setClone(this, (Gradient) restoreData[3]); invalidate(); }
@Override protected void drawFill(Graphics2D g) { Rectangle2D.Double r = (Rectangle2D.Double) rectangle.clone(); double grow = AttributeKeys.getPerpendicularFillGrowth(this); Geom.grow(r, grow, grow); g.fill(r); }
@Override protected void drawStroke(final Graphics2D g) { final Rectangle2D.Double r = (Rectangle2D.Double) bounds.clone(); final double grow = AttributeKeys.getPerpendicularDrawGrowth(this); Geom.grow(r, grow, grow); g.draw(r); }
@Override public Rectangle2D.Double getBounds() { final Rectangle2D.Double b = (Rectangle2D.Double) bounds.clone(); return b; }
@Override public TextAreaFigure clone() { TextAreaFigure that = (TextAreaFigure) super.clone(); that.bounds = (Rectangle2D.Double) this.bounds.clone(); return that; }
@Override public Rectangle2D.Double getBounds() { Rectangle2D.Double bounds = (Rectangle2D.Double) rectangle.clone(); return bounds; }
@Override public ImageFigure clone() { ImageFigure that = (ImageFigure) super.clone(); that.rectangle = (Rectangle2D.Double) this.rectangle.clone(); return that; }
@Override public Rectangle2D.Double getFigureDrawingArea() { Rectangle2D.Double r = (Rectangle2D.Double) rectangle.clone(); double grow = AttributeKeys.getPerpendicularHitGrowth(this); Geom.grow(r, grow, grow); return r; }
@Override public SwingPointFigure clone() { final SwingPointFigure that = (SwingPointFigure) super.clone(); that.bounds = (Rectangle2D.Double) this.bounds.clone(); return that; }
@Override protected void drawStroke(final Graphics2D g) { final Rectangle2D.Double r = (Rectangle2D.Double) bounds.clone(); final double grow = AttributeKeys.getPerpendicularDrawGrowth(this); Geom.grow(r, grow, grow); g.draw(r); }
@Override protected void drawFill(final Graphics2D g) { final Rectangle2D.Double r = (Rectangle2D.Double) bounds.clone(); final double grow = AttributeKeys.getPerpendicularFillGrowth(this); Geom.grow(r, grow, grow); g.fill(r); }