Example usage for org.jfree.util ObjectUtilities clone

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

Introduction

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

Prototype

public static Object clone(final Object object) throws CloneNotSupportedException 

Source Link

Document

Returns a clone of the specified object, if it can be cloned, otherwise throws a CloneNotSupportedException.

Usage

From source file:edu.dlnu.liuwenpeng.render.XYBarRenderer.java

/**
 * Returns a clone of the renderer./* w  ww .jav a 2 s  . c om*/
 *
 * @return A clone.
 *
 * @throws CloneNotSupportedException  if the renderer cannot be cloned.
 */
public Object clone() throws CloneNotSupportedException {
    XYBarRenderer result = (XYBarRenderer) super.clone();
    if (this.gradientPaintTransformer != null) {
        result.gradientPaintTransformer = (GradientPaintTransformer) ObjectUtilities
                .clone(this.gradientPaintTransformer);
    }
    result.legendBar = ShapeUtilities.clone(this.legendBar);
    return result;
}

From source file:edu.dlnu.liuwenpeng.render.NewXYBarRenderer.java

/**    
* Returns a clone of the renderer.    /*from   www . ja va 2  s  .  c  om*/
*    
* @return A clone.    
*    
* @throws CloneNotSupportedException  if the renderer cannot be cloned.    
*/
public Object clone() throws CloneNotSupportedException {
    NewXYBarRenderer result = (NewXYBarRenderer) super.clone();
    if (this.gradientPaintTransformer != null) {
        result.gradientPaintTransformer = (GradientPaintTransformer) ObjectUtilities
                .clone(this.gradientPaintTransformer);
    }
    result.legendBar = ShapeUtilities.clone(this.legendBar);
    return result;
}

From source file:de.laures.cewolf.jfree.ThermometerPlot.java

/**
 * Returns a clone of the plot.//from  w w  w.  ja v a2  s .  co  m
 *
 * @return A clone.
 *
 * @throws CloneNotSupportedException  if the plot cannot be cloned.
 */
public Object clone() throws CloneNotSupportedException {

    ThermometerPlot clone = (ThermometerPlot) super.clone();

    if (clone.dataset != null) {
        clone.dataset.addChangeListener(clone);
    }
    clone.rangeAxis = (ValueAxis) ObjectUtilities.clone(this.rangeAxis);
    if (clone.rangeAxis != null) {
        clone.rangeAxis.setPlot(clone);
        clone.rangeAxis.addChangeListener(clone);
    }
    clone.valueFormat = (NumberFormat) this.valueFormat.clone();
    clone.subrangePaint = (Paint[]) this.subrangePaint.clone();

    return clone;

}

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

/**
 * Returns a clone of the plot.//w  w  w  .  jav  a  2s.c o  m
 *
 * @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;

}