/**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 public Object getTransformRestoreData() { return line.clone(); }
@Override public StraightLineFigure clone() { StraightLineFigure that = (StraightLineFigure) super.clone(); that.line = (Line2D.Double) this.line.clone(); return that; } }
@Override public StraightLine clone() { return (StraightLine) super.clone(); } }
@Override public void restoreTransformTo(Object restoreData) { line = (Line2D.Double) ((Line2D.Double) restoreData).clone(); }