List of usage examples for org.jfree.data.xy DefaultOHLCDataset DefaultOHLCDataset
public DefaultOHLCDataset(Comparable key, OHLCDataItem[] data)
From source file:org.jfree.data.xy.DefaultOHLCDatasetTest.java
/** * A small test for the data range calculated on this dataset. *//* w w w . j ava 2 s.c om*/ @Test public void testDataRange() { OHLCDataItem[] data = new OHLCDataItem[3]; data[0] = new OHLCDataItem(new Date(11L), 2.0, 4.0, 1.0, 3.0, 100.0); data[1] = new OHLCDataItem(new Date(22L), 4.0, 9.0, 2.0, 5.0, 120.0); data[2] = new OHLCDataItem(new Date(33L), 3.0, 7.0, 3.0, 6.0, 140.0); DefaultOHLCDataset d = new DefaultOHLCDataset("S1", data); Range r = DatasetUtilities.findRangeBounds(d, true); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(9.0, r.getUpperBound(), EPSILON); }
From source file:org.jfree.data.xy.DefaultOHLCDatasetTest.java
/** * Confirm that the equals method can distinguish all the required fields. */// w w w .j a v a 2 s .co m @Test public void testEquals() { DefaultOHLCDataset d1 = new DefaultOHLCDataset("Series 1", new OHLCDataItem[0]); DefaultOHLCDataset d2 = new DefaultOHLCDataset("Series 1", new OHLCDataItem[0]); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1 = new DefaultOHLCDataset("Series 2", new OHLCDataItem[0]); assertFalse(d1.equals(d2)); d2 = new DefaultOHLCDataset("Series 2", new OHLCDataItem[0]); assertTrue(d1.equals(d2)); d1 = new DefaultOHLCDataset("Series 2", new OHLCDataItem[] { new OHLCDataItem(new Date(123L), 1.2, 3.4, 5.6, 7.8, 99.9) }); assertFalse(d1.equals(d2)); d2 = new DefaultOHLCDataset("Series 2", new OHLCDataItem[] { new OHLCDataItem(new Date(123L), 1.2, 3.4, 5.6, 7.8, 99.9) }); assertTrue(d1.equals(d2)); }
From source file:org.jfree.data.xy.junit.DefaultOHLCDatasetTest.java
/** * A small test for the data range calculated on this dataset. */// w ww . j a v a 2s . c om public void testDataRange() { OHLCDataItem[] data = new OHLCDataItem[3]; data[0] = new OHLCDataItem(new Date(11L), 2.0, 4.0, 1.0, 3.0, 100.0); data[1] = new OHLCDataItem(new Date(22L), 4.0, 9.0, 2.0, 5.0, 120.0); data[2] = new OHLCDataItem(new Date(33L), 3.0, 7.0, 3.0, 6.0, 140.0); DefaultOHLCDataset d = new DefaultOHLCDataset("S1", data); Range r = DatasetUtilities.findRangeBounds(d, true); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(9.0, r.getUpperBound(), EPSILON); }
From source file:org.jfree.data.xy.junit.DefaultOHLCDatasetTest.java
/** * Confirm that the equals method can distinguish all the required fields. */// w w w . j a v a 2s . c o m public void testEquals() { DefaultOHLCDataset d1 = new DefaultOHLCDataset("Series 1", new OHLCDataItem[0]); DefaultOHLCDataset d2 = new DefaultOHLCDataset("Series 1", new OHLCDataItem[0]); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1 = new DefaultOHLCDataset("Series 2", new OHLCDataItem[0]); assertFalse(d1.equals(d2)); d2 = new DefaultOHLCDataset("Series 2", new OHLCDataItem[0]); assertTrue(d1.equals(d2)); d1 = new DefaultOHLCDataset("Series 2", new OHLCDataItem[] { new OHLCDataItem(new Date(123L), 1.2, 3.4, 5.6, 7.8, 99.9) }); assertFalse(d1.equals(d2)); d2 = new DefaultOHLCDataset("Series 2", new OHLCDataItem[] { new OHLCDataItem(new Date(123L), 1.2, 3.4, 5.6, 7.8, 99.9) }); assertTrue(d1.equals(d2)); }
From source file:net.commerce.zocalo.freechart.ChartTest.java
private static OHLCDataset createOHLCDataSet(Minute now) { OHLCDataItem item1 = new OHLCDataItem(new Date(now.getFirstMillisecond()), .34, .40, .22, .22, 5); OHLCDataItem item2 = new OHLCDataItem(new Date(now.getFirstMillisecond() + (1000 * 5)), .22, .35, .21, .31, 54);/*from w w w . ja va2 s . co m*/ OHLCDataItem item3 = new OHLCDataItem(new Date(now.getFirstMillisecond() + (1000 * 12)), .31, .35, .30, .34, 4); OHLCDataItem item4 = new OHLCDataItem(new Date(now.getFirstMillisecond() + (1000 * 18)), .34, .43, .32, .41, 8); OHLCDataItem item5 = new OHLCDataItem(new Date(now.getFirstMillisecond() + (1000 * 35)), .41, .41, .20, .21, 14); OHLCDataItem item6 = new OHLCDataItem(new Date(now.getFirstMillisecond() + (1000 * 42)), .21, .40, .21, .40, 14); OHLCDataItem item7 = new OHLCDataItem(new Date(now.getFirstMillisecond() + (1000 * 54)), .40, .53, .40, .52, 14); OHLCDataItem[] items = { item1, item2, item3, item4, item5, item6, item7 }; return new DefaultOHLCDataset(new Comparable() { public int compareTo(Object object) { return 1; } }, items); }
From source file:org.jfree.data.xy.DefaultOHLCDatasetTest.java
/** * Confirm that cloning works./* www. j a v a 2 s.c o m*/ */ @Test public void testCloning() throws CloneNotSupportedException { DefaultOHLCDataset d1 = new DefaultOHLCDataset("Series 1", new OHLCDataItem[0]); DefaultOHLCDataset d2 = (DefaultOHLCDataset) d1.clone(); assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); }
From source file:com.charts.FiveYearChart.java
protected AbstractXYDataset getDataSet(YStockQuote currentStock) throws ParseException { //This is the dataset we are going to create DefaultOHLCDataset result = null;/* w w w . j a v a 2 s . c o m*/ //This is the data needed for the dataset OHLCDataItem[] data; //This is where we go get the data, replace with your own data source data = getData(currentStock); //Create a dataset, an Open, High, Low, Close dataset result = new DefaultOHLCDataset(currentStock.get_symbol(), data); return result; }
From source file:org.jfree.data.xy.junit.DefaultOHLCDatasetTest.java
/** * Confirm that cloning works.//from w w w .j av a2 s.c o 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.DefaultOHLCDatasetTest.java
/** * Confirm that cloning works.//from w ww . ja va2s.c om */ @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.DefaultOHLCDatasetTest.java
/** * Verify that this class implements {@link PublicCloneable}. *//*from w w w.j av a2 s .co m*/ @Test public void testPublicCloneable() { DefaultOHLCDataset d1 = new DefaultOHLCDataset("Series 1", new OHLCDataItem[0]); assertTrue(d1 instanceof PublicCloneable); }