Example usage for java.lang CloneNotSupportedException printStackTrace

List of usage examples for java.lang CloneNotSupportedException printStackTrace

Introduction

In this page you can find the example usage for java.lang CloneNotSupportedException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.jfree.data.xy.junit.XYBarDatasetTest.java

/**
 * Confirm that cloning works.//from   w ww.  ja v  a  2  s . c o  m
 */
public void testCloning() {
    DefaultXYDataset d1 = new DefaultXYDataset();
    double[] x1 = new double[] { 1.0, 2.0, 3.0 };
    double[] y1 = new double[] { 4.0, 5.0, 6.0 };
    double[][] data1 = new double[][] { x1, y1 };
    d1.addSeries("S1", data1);
    XYBarDataset bd1 = new XYBarDataset(d1, 5.0);
    XYBarDataset bd2 = null;
    try {
        bd2 = (XYBarDataset) bd1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(bd1 != bd2);
    assertTrue(bd1.getClass() == bd2.getClass());
    assertTrue(bd1.equals(bd2));

    // check independence
    d1 = (DefaultXYDataset) bd1.getUnderlyingDataset();
    d1.addSeries("S2", new double[][] { { 1.0 }, { 2.0 } });
    assertFalse(bd1.equals(bd2));
    DefaultXYDataset d2 = (DefaultXYDataset) bd2.getUnderlyingDataset();
    d2.addSeries("S2", new double[][] { { 1.0 }, { 2.0 } });
    assertTrue(bd1.equals(bd2));
}

From source file:orchestration.path.RectShape.java

@Override
public PlannerShape moveTo(Point pt) {
    RectShape copy = null;/*from w  w w .ja  v  a2  s. com*/
    try {
        copy = (RectShape) this.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
        System.exit(1);
    }

    copy.poly.translate(pt.x - centerPt.x, pt.y - centerPt.y);
    copy.centerPt = pt;

    return copy;
}

From source file:org.jfree.data.xy.junit.VectorSeriesCollectionTest.java

/**
 * Confirm that cloning works./*from w w  w. j a v  a  2  s.  co m*/
 */
public void testCloning() {
    VectorSeries s1 = new VectorSeries("Series");
    s1.add(1.0, 1.1, 1.2, 1.3);
    VectorSeriesCollection c1 = new VectorSeriesCollection();
    c1.addSeries(s1);
    VectorSeriesCollection c2 = null;
    try {
        c2 = (VectorSeriesCollection) c1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(c1 != c2);
    assertTrue(c1.getClass() == c2.getClass());
    assertTrue(c1.equals(c2));

    // check independence
    s1.setDescription("XYZ");
    assertFalse(c1.equals(c2));
}

From source file:org.jfree.data.xy.junit.DefaultOHLCDatasetTest.java

/**
 * Confirm that cloning works./*from   w  ww  .ja  v a2s. co m*/
 */
public void testCloning() {
    DefaultOHLCDataset d1 = new DefaultOHLCDataset("Series 1", new OHLCDataItem[0]);
    DefaultOHLCDataset d2 = null;
    try {
        d2 = (DefaultOHLCDataset) d1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));
}

From source file:org.jfree.data.xy.junit.DefaultHighLowDatasetTest.java

/**
 * Confirm that cloning works.//w  w w .  j a v  a  2 s .  c  o m
 */
public void testCloning() {
    DefaultHighLowDataset d1 = new DefaultHighLowDataset("Series 1", new Date[] { new Date(123L) },
            new double[] { 1.2 }, new double[] { 3.4 }, new double[] { 5.6 }, new double[] { 7.8 },
            new double[] { 99.9 });
    DefaultHighLowDataset d2 = null;
    try {
        d2 = (DefaultHighLowDataset) d1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));
}

From source file:orchestration.path.RectShape.java

@Override
public PlannerShape rotateBy(float degrees) {
    RectShape copy = null;//from   w  w w  . j a v a2 s .com
    try {
        copy = (RectShape) this.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
        System.exit(1);
    }

    float radians = degrees * (float) Math.PI / 180.f;

    for (int i = 0; i < poly.npoints; i++) {
        Point oldPt = new Point(copy.poly.xpoints[i], copy.poly.ypoints[i]);

        Point newPt = rotatePoint(oldPt, centerPt, radians);
        copy.poly.xpoints[i] = newPt.x;
        copy.poly.ypoints[i] = newPt.y;
    }

    copy.poly.invalidate();
    copy.headingDeg = headingDeg + degrees;

    return copy;
}

From source file:org.jfree.data.xy.junit.DefaultOHLCDatasetTest.java

/**
 * Confirm that cloning works./* w ww  . j  ava  2  s .  com*/
 */
public void testCloning2() {
    OHLCDataItem item1 = new OHLCDataItem(new Date(1L), 1.0, 2.0, 3.0, 4.0, 5.0);
    OHLCDataItem item2 = new OHLCDataItem(new Date(2L), 6.0, 7.0, 8.0, 9.0, 10.0);
    // create an array of items in reverse order
    OHLCDataItem[] items = new OHLCDataItem[] { item2, item1 };
    DefaultOHLCDataset d1 = new DefaultOHLCDataset("Series 1", items);
    DefaultOHLCDataset d2 = null;
    try {
        d2 = (DefaultOHLCDataset) d1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));

    d1.sortDataByDate();
    assertFalse(d1.equals(d2));
}

From source file:com.emergya.persistenceGeo.utils.FolderStyleDecorator.java

public FolderDto applyStyle(FolderDto toApply, String parent, FolderStyle style, Integer level) {
    FolderDto result = null;/*from  w  w  w  .j a v  a  2s .c o m*/
    try {
        if (FolderStyle.NORMAL.equals(style)) {
            result = new TreeFolderDto(toApply);
        } else {
            result = (FolderDto) toApply.clone();
            result.setId(toApply.getId());
            result.setFolderList(toApply.getFolderList());
            if (FolderStyle.STRING.equals(style)) {
                result.setName(getFolderNameString(toApply.getName(), parent));
            } else {
                result.setName(getFolderNameTree(toApply.getName(), parent, level));
            }
        }
        result.setId(toApply.getId());
    } catch (CloneNotSupportedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return result;
}

From source file:org.jfree.data.xy.junit.XIntervalSeriesCollectionTest.java

/**
 * Confirm that cloning works./*w w  w  . ja va  2s.com*/
 */
public void testCloning() {
    XIntervalSeriesCollection c1 = new XIntervalSeriesCollection();
    XIntervalSeries s1 = new XIntervalSeries("Series");
    s1.add(1.0, 1.1, 1.2, 1.3);
    c1.addSeries(s1);
    XIntervalSeriesCollection c2 = null;
    try {
        c2 = (XIntervalSeriesCollection) c1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(c1 != c2);
    assertTrue(c1.getClass() == c2.getClass());
    assertTrue(c1.equals(c2));

    // check independence
    s1.setDescription("XYZ");
    assertFalse(c1.equals(c2));
}

From source file:org.jfree.data.xy.junit.YIntervalSeriesCollectionTest.java

/**
 * Confirm that cloning works./*from  w  w w . ja va 2  s .  c om*/
 */
public void testCloning() {
    YIntervalSeriesCollection c1 = new YIntervalSeriesCollection();
    YIntervalSeries s1 = new YIntervalSeries("Series");
    s1.add(1.0, 1.1, 1.2, 1.3);
    c1.addSeries(s1);
    YIntervalSeriesCollection c2 = null;
    try {
        c2 = (YIntervalSeriesCollection) c1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(c1 != c2);
    assertTrue(c1.getClass() == c2.getClass());
    assertTrue(c1.equals(c2));

    // check independence
    s1.setDescription("XYZ");
    assertFalse(c1.equals(c2));
}