/**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 !!! }
/**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 !!! }
@Override protected void drawStroke(Graphics2D g) { Ellipse2D.Double r = (Ellipse2D.Double) ellipse.clone(); double grow = AttributeKeys.getPerpendicularDrawGrowth(this); r.x -= grow; r.y -= grow; r.width += grow * 2; r.height += grow * 2; if (r.width > 0 && r.height > 0) { g.draw(r); } }
/** * Checks if a Point2D.Double is inside the figure. */ @Override public boolean contains(Point2D.Double p) { Ellipse2D.Double r = (Ellipse2D.Double) ellipse.clone(); double grow = AttributeKeys.getPerpendicularHitGrowth(this); r.x -= grow; r.y -= grow; r.width += grow * 2; r.height += grow * 2; return r.contains(p); }
@Override public Object getTransformRestoreData() { return new Object[]{ ellipse.clone(), TRANSFORM.getClone(this), FILL_GRADIENT.getClone(this), STROKE_GRADIENT.getClone(this),}; }
@Override public Object getTransformRestoreData() { return ellipse.clone(); } }
@Override public EllipseFigure clone() { EllipseFigure that = (EllipseFigure) super.clone(); that.ellipse = (Ellipse2D.Double) this.ellipse.clone(); return that; }
@Override protected void drawFill(Graphics2D g) { Ellipse2D.Double r = (Ellipse2D.Double) ellipse.clone(); double grow = AttributeKeys.getPerpendicularFillGrowth(this); r.x -= grow; r.y -= grow; r.width += grow * 2; r.height += grow * 2; if (r.width > 0 && r.height > 0) { g.fill(r); } }
@Override public void restoreTransformTo(Object geometry) { Object[] restoreData = (Object[]) geometry; ellipse = (Ellipse2D.Double) ((Ellipse2D.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 public ODGEllipseFigure clone() { ODGEllipseFigure that = (ODGEllipseFigure) super.clone(); that.ellipse = (Ellipse2D.Double) this.ellipse.clone(); that.cachedTransformedShape = null; return that; }
@Override public SVGEllipseFigure clone() { SVGEllipseFigure that = (SVGEllipseFigure) super.clone(); that.ellipse = (Ellipse2D.Double) this.ellipse.clone(); that.cachedTransformedShape = null; return that; }
@Override public void restoreTransformTo(Object geometry) { Object[] restoreData = (Object[]) geometry; ellipse = (Ellipse2D.Double) ((Ellipse2D.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 public Object getTransformRestoreData() { return new Object[]{ ellipse.clone(), TRANSFORM.getClone(this), FILL_GRADIENT.getClone(this), STROKE_GRADIENT.getClone(this),}; }