Logo Search packages:      
Sourcecode: libjfreechart-java version File versions  Download package

Object org::jfree::chart::plot::XYPlot::clone (  )  throws CloneNotSupportedException [inline]

Returns a clone of the plot.

Returns:
A clone.
Exceptions:
CloneNotSupportedException this can occur if some component of the plot cannot be cloned.

Reimplemented from org::jfree::chart::plot::Plot.

Reimplemented in org::jfree::chart::plot::CombinedDomainXYPlot, and org::jfree::chart::plot::CombinedRangeXYPlot.

Definition at line 4903 of file XYPlot.java.

References org::jfree::data::general::Dataset::addChangeListener(), org::jfree::chart::axis::Axis::addChangeListener(), annotations, backgroundDomainMarkers, backgroundRangeMarkers, org::jfree::chart::axis::AxisSpace::clone(), org::jfree::chart::axis::ValueAxis::clone(), datasets, datasetToDomainAxisMap, datasetToRangeAxisMap, domainAxes, domainAxisLocations, fixedDomainAxisSpace, fixedRangeAxisSpace, foregroundDomainMarkers, foregroundRangeMarkers, quadrantOrigin, quadrantPaint, rangeAxes, rangeAxisLocations, renderers, and org::jfree::chart::axis::Axis::setPlot().

Referenced by org::jfree::chart::plot::junit::XYPlotTests::testCloneIndependence(), org::jfree::chart::plot::junit::XYPlotTests::testCloning(), org::jfree::chart::plot::junit::XYPlotTests::testCloning2(), org::jfree::chart::plot::junit::XYPlotTests::testCloning_QuadrantOrigin(), and org::jfree::chart::plot::junit::XYPlotTests::testCloning_QuadrantPaint().

                                                            {

        XYPlot clone = (XYPlot) 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);
        }

        clone.quadrantOrigin = (Point2D) ObjectUtilities.clone(
                this.quadrantOrigin);
        clone.quadrantPaint = (Paint[]) this.quadrantPaint.clone();
        return clone;

    }


Generated by  Doxygen 1.6.0   Back to index