Example usage for org.jfree.util ObjectUtilities deepClone

List of usage examples for org.jfree.util ObjectUtilities deepClone

Introduction

In this page you can find the example usage for org.jfree.util ObjectUtilities deepClone.

Prototype

public static Collection deepClone(final Collection collection) throws CloneNotSupportedException 

Source Link

Document

Returns a new collection containing clones of all the items in the specified collection.

Usage

From source file:org.trade.strategy.data.HeikinAshiDataset.java

/**
 * Returns a clone of this instance./* w  ww . j  a  v a  2s  .c  o m*/
 * 
 * 
 * 
 * 
 * @return A clone. * @throws CloneNotSupportedException if there is a
 *         problem.
 */
@SuppressWarnings("unchecked")
public Object clone() throws CloneNotSupportedException {
    HeikinAshiDataset clone = (HeikinAshiDataset) super.clone();
    clone.data = (List<IndicatorSeries>) ObjectUtilities.deepClone(this.data);
    return clone;
}

From source file:org.trade.strategy.data.CandleDataset.java

/**
 * Returns a clone of this instance.//from  w ww . jav a2  s .  co  m
 * 
 * 
 * 
 * 
 * @return A clone. * @throws CloneNotSupportedException if there is a
 *         problem.
 */
@SuppressWarnings("unchecked")
public Object clone() throws CloneNotSupportedException {
    CandleDataset clone = (CandleDataset) super.clone();
    clone.data = (List<IndicatorSeries>) ObjectUtilities.deepClone(this.data);
    return clone;
}

From source file:org.jfree.data.DefaultKeyedValues2D.java

/**
 * Returns a clone.//  ww  w  .j  a  va  2s .co  m
 *
 * @return A clone.
 *
 * @throws CloneNotSupportedException  this class will not throw this
 *         exception, but subclasses (if any) might.
 */
@Override
public Object clone() throws CloneNotSupportedException {
    DefaultKeyedValues2D clone = (DefaultKeyedValues2D) super.clone();
    // for the keys, a shallow copy should be fine because keys
    // should be immutable...
    clone.columnKeys = new java.util.ArrayList(this.columnKeys);
    clone.rowKeys = new java.util.ArrayList(this.rowKeys);

    // but the row data requires a deep copy
    clone.rows = (List) ObjectUtilities.deepClone(this.rows);
    return clone;
}

From source file:org.jfree.data.gantt.TaskSeriesCollection.java

/**
 * Returns an independent copy of this dataset.
 *
 * @return A clone of the dataset.//w  ww . j  a va 2  s. c  o  m
 *
 * @throws CloneNotSupportedException if there is some problem cloning
 *     the dataset.
 */
@Override
public Object clone() throws CloneNotSupportedException {
    TaskSeriesCollection clone = (TaskSeriesCollection) super.clone();
    clone.data = (List) ObjectUtilities.deepClone(this.data);
    clone.keys = new java.util.ArrayList(this.keys);
    return clone;
}

From source file:utilesChart.util.TimeSeriesCollection.java

/**
 * Returns a clone of this time series collection.
 *
 * @return A clone./*from   w ww.  j  a  v a  2  s  .c  o m*/
 *
 * @throws java.lang.CloneNotSupportedException
 */
public Object clone() throws CloneNotSupportedException {
    TimeSeriesCollection clone = (TimeSeriesCollection) super.clone();
    clone.data = (List) ObjectUtilities.deepClone(this.data);
    clone.workingCalendar = (Calendar) this.workingCalendar.clone();
    return clone;
}

From source file:org.jfree.data.time.TimeSeriesCollection.java

/**
 * Returns a clone of this time series collection.
 *
 * @return A clone.//from  w w w  .j  a v a  2s.co m
 *
 * @throws java.lang.CloneNotSupportedException if there is a problem 
 *         cloning.
 */
@Override
public Object clone() throws CloneNotSupportedException {
    TimeSeriesCollection clone = (TimeSeriesCollection) super.clone();
    clone.data = (List) ObjectUtilities.deepClone(this.data);
    clone.workingCalendar = (Calendar) this.workingCalendar.clone();
    return clone;
}

From source file:org.jfree.data.xy.XYSeries.java

/**
 * Returns a clone of the series.//from   w  ww.  j  a va  2  s.c  om
 *
 * @return A clone of the series.
 *
 * @throws CloneNotSupportedException if there is a cloning problem.
 */
@Override
public Object clone() throws CloneNotSupportedException {
    XYSeries clone = (XYSeries) super.clone();
    clone.data = (List) ObjectUtilities.deepClone(this.data);
    return clone;
}

From source file:org.jfree.data.time.TimeSeries.java

/**
 * Returns a clone of the time series.//from   w ww .j a  va 2  s.c  om
 * <P>
 * Notes:
 * <ul>
 *   <li>no need to clone the domain and range descriptions, since String
 *     object is immutable;</li>
 *   <li>we pass over to the more general method clone(start, end).</li>
 * </ul>
 *
 * @return A clone of the time series.
 *
 * @throws CloneNotSupportedException not thrown by this class, but
 *         subclasses may differ.
 */
@Override
public Object clone() throws CloneNotSupportedException {
    TimeSeries clone = (TimeSeries) super.clone();
    clone.data = (List) ObjectUtilities.deepClone(this.data);
    return clone;
}

From source file:ucar.unidata.idv.control.chart.MyXYPlot.java

/**
 * Returns a clone of the plot.// w  ww.j a  v  a 2s  .  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;

}