Example usage for org.jfree.data.xy DefaultOHLCDataset sortDataByDate

List of usage examples for org.jfree.data.xy DefaultOHLCDataset sortDataByDate

Introduction

In this page you can find the example usage for org.jfree.data.xy DefaultOHLCDataset sortDataByDate.

Prototype

public void sortDataByDate() 

Source Link

Document

Sorts the data into ascending order by date.

Usage

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

/**
 * Confirm that cloning works.//from ww  w  .  j av a  2 s.  c  o m
 */
@Test
public void testCloning2() throws CloneNotSupportedException {
    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 = (DefaultOHLCDataset) d1.clone();
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));

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

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

/**
 * Confirm that cloning works./*  w w w. j  a v a 2  s.  c o m*/
 */
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));
}