List of usage examples for org.jfree.util PublicCloneable clone
public Object clone() throws CloneNotSupportedException;
From source file:nl.vu.nat.jfreechartcustom.XYBlockRenderer.java
/** * Returns a clone of this renderer./* ww w . j a v a 2 s. c o m*/ * * @return A clone of this renderer. * * @throws CloneNotSupportedException if there is a problem creating the * clone. */ public Object clone() throws CloneNotSupportedException { XYBlockRenderer clone = (XYBlockRenderer) super.clone(); if (this.paintScale instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.paintScale; clone.paintScale = (PaintScale) pc.clone(); } return clone; }
From source file:ucar.unidata.idv.control.chart.MyXYPlot.java
/** * Returns a clone of the plot.//w w w. j a va2 s .c om * * @return A clone. * * @throws CloneNotSupportedException this can occur if some component of * the plot cannot be cloned. */ public Object clone() throws CloneNotSupportedException { MyXYPlot clone = (MyXYPlot) super.clone(); clone.domainAxes = (ObjectList) ObjectUtilities.clone(this.domainAxes); for (int i = 0; i < this.domainAxes.size(); i++) { ValueAxis axis = (ValueAxis) this.domainAxes.get(i); if (axis != null) { ValueAxis clonedAxis = (ValueAxis) axis.clone(); clone.domainAxes.set(i, clonedAxis); clonedAxis.setPlot(clone); clonedAxis.addChangeListener(clone); } } clone.domainAxisLocations = (ObjectList) this.domainAxisLocations.clone(); clone.rangeAxes = (ObjectList) ObjectUtilities.clone(this.rangeAxes); for (int i = 0; i < this.rangeAxes.size(); i++) { ValueAxis axis = (ValueAxis) this.rangeAxes.get(i); if (axis != null) { ValueAxis clonedAxis = (ValueAxis) axis.clone(); clone.rangeAxes.set(i, clonedAxis); clonedAxis.setPlot(clone); clonedAxis.addChangeListener(clone); } } clone.rangeAxisLocations = (ObjectList) ObjectUtilities.clone(this.rangeAxisLocations); // the datasets are not cloned, but listeners need to be added... clone.datasets = (ObjectList) ObjectUtilities.clone(this.datasets); for (int i = 0; i < clone.datasets.size(); ++i) { XYDataset d = getDataset(i); if (d != null) { d.addChangeListener(clone); } } clone.datasetToDomainAxisMap = new TreeMap(); clone.datasetToDomainAxisMap.putAll(this.datasetToDomainAxisMap); clone.datasetToRangeAxisMap = new TreeMap(); clone.datasetToRangeAxisMap.putAll(this.datasetToRangeAxisMap); clone.renderers = (ObjectList) ObjectUtilities.clone(this.renderers); for (int i = 0; i < this.renderers.size(); i++) { XYItemRenderer renderer2 = (XYItemRenderer) this.renderers.get(i); if (renderer2 instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) renderer2; clone.renderers.set(i, pc.clone()); } } clone.foregroundDomainMarkers = (Map) ObjectUtilities.clone(this.foregroundDomainMarkers); clone.backgroundDomainMarkers = (Map) ObjectUtilities.clone(this.backgroundDomainMarkers); clone.foregroundRangeMarkers = (Map) ObjectUtilities.clone(this.foregroundRangeMarkers); clone.backgroundRangeMarkers = (Map) ObjectUtilities.clone(this.backgroundRangeMarkers); clone.annotations = (List) ObjectUtilities.deepClone(this.annotations); if (this.fixedDomainAxisSpace != null) { clone.fixedDomainAxisSpace = (AxisSpace) ObjectUtilities.clone(this.fixedDomainAxisSpace); } if (this.fixedRangeAxisSpace != null) { clone.fixedRangeAxisSpace = (AxisSpace) ObjectUtilities.clone(this.fixedRangeAxisSpace); } return clone; }