org.jfree.data.time.Day Java Examples
The following examples show how to use
org.jfree.data.time.Day.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CategoricalChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected int getDateUnitAsInt( final Class domainTimePeriod ) { if ( Second.class.equals( domainTimePeriod ) ) { return DateTickUnit.SECOND; } if ( Minute.class.equals( domainTimePeriod ) ) { return DateTickUnit.MINUTE; } if ( Hour.class.equals( domainTimePeriod ) ) { return DateTickUnit.HOUR; } if ( Day.class.equals( domainTimePeriod ) ) { return DateTickUnit.DAY; } if ( Month.class.equals( domainTimePeriod ) ) { return DateTickUnit.MONTH; } if ( Year.class.equals( domainTimePeriod ) ) { return DateTickUnit.YEAR; } if ( Second.class.equals( domainTimePeriod ) ) { return DateTickUnit.MILLISECOND; } return DateTickUnit.DAY; }
Example #2
Source File: DayTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithTimeZone() { Day d = new Day(1, 2, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); Calendar c = new GregorianCalendar(zone); assertEquals(-628358400001L, d.getLastMillisecond(c)); // try null calendar boolean pass = false; try { d.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example #3
Source File: XYPlotTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a sample dataset. * * @return Series 1. */ private IntervalXYDataset createDataset1() { // create dataset 1... TimeSeries series1 = new TimeSeries("Series 1", Day.class); series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3); series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4); series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3); series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3); series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4); series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3); series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5); series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3); series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4); series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6); series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3); series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2); series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2); series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2); series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2); TimeSeriesCollection collection = new TimeSeriesCollection(series1); return collection; }
Example #4
Source File: XYChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
private int getDateUnitAsInt( final Class domainTimePeriod ) { if ( Second.class.equals( domainTimePeriod ) ) { return DateTickUnit.SECOND; } if ( Minute.class.equals( domainTimePeriod ) ) { return DateTickUnit.MINUTE; } if ( Hour.class.equals( domainTimePeriod ) ) { return DateTickUnit.HOUR; } if ( Day.class.equals( domainTimePeriod ) ) { return DateTickUnit.DAY; } if ( Month.class.equals( domainTimePeriod ) ) { return DateTickUnit.MONTH; } if ( Year.class.equals( domainTimePeriod ) ) { return DateTickUnit.YEAR; } if ( Second.class.equals( domainTimePeriod ) ) { return DateTickUnit.MILLISECOND; } return DateTickUnit.DAY; }
Example #5
Source File: DayTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithTimeZone() { Day d = new Day(26, 4, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); Calendar c = new GregorianCalendar(zone); assertEquals(-621187200000L, d.getFirstMillisecond(c)); // try null calendar boolean pass = false; try { d.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example #6
Source File: TimePeriodValuesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * A test for bug report 1161340. I wasn't able to reproduce the problem * with this test. */ public void test1161340() { TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(); TimePeriodValues v1 = new TimePeriodValues("V1"); v1.add(new Day(11, 3, 2005), 1.2); v1.add(new Day(12, 3, 2005), 3.4); dataset.addSeries(v1); assertEquals(1, dataset.getSeriesCount()); dataset.removeSeries(v1); assertEquals(0, dataset.getSeriesCount()); TimePeriodValues v2 = new TimePeriodValues("V2"); v1.add(new Day(5, 3, 2005), 1.2); v1.add(new Day(6, 3, 2005), 3.4); dataset.addSeries(v2); assertEquals(1, dataset.getSeriesCount()); }
Example #7
Source File: XYPlotTest.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * Creates a sample dataset. * * @return Series 1. */ private IntervalXYDataset createDataset1() { // create dataset 1... TimeSeries series1 = new TimeSeries("Series 1", Day.class); series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3); series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4); series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3); series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3); series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4); series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3); series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5); series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3); series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4); series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6); series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3); series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2); series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2); series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2); series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2); TimeSeriesCollection collection = new TimeSeriesCollection(series1); return collection; }
Example #8
Source File: JFreeChartTest.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * Serialize a time seroes chart, restore it, and check for equality. */ @Test public void testSerialization4() { RegularTimePeriod t = new Day(); TimeSeries series = new TimeSeries("Series 1"); series.add(t, 36.4); t = t.next(); series.add(t, 63.5); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date", "Value", dataset); JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1); assertEquals(c1, c2); }
Example #9
Source File: TimeSeriesDataItemTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Test the equals() method. */ public void testEquals() { TimeSeriesDataItem item1 = new TimeSeriesDataItem( new Day(23, 9, 2001), 99.7 ); TimeSeriesDataItem item2 = new TimeSeriesDataItem( new Day(23, 9, 2001), 99.7 ); assertTrue(item1.equals(item2)); assertTrue(item2.equals(item1)); item1.setValue(new Integer(5)); assertFalse(item1.equals(item2)); item2.setValue(new Integer(5)); assertTrue(item1.equals(item2)); }
Example #10
Source File: XYAreaLineChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected int getDateUnitAsInt( final Class domainTimePeriod ) { if ( Second.class.equals( domainTimePeriod ) ) { return DateTickUnit.SECOND; } if ( Minute.class.equals( domainTimePeriod ) ) { return DateTickUnit.MINUTE; } if ( Hour.class.equals( domainTimePeriod ) ) { return DateTickUnit.HOUR; } if ( Day.class.equals( domainTimePeriod ) ) { return DateTickUnit.DAY; } if ( Month.class.equals( domainTimePeriod ) ) { return DateTickUnit.MONTH; } if ( Year.class.equals( domainTimePeriod ) ) { return DateTickUnit.YEAR; } if ( Second.class.equals( domainTimePeriod ) ) { return DateTickUnit.MILLISECOND; } return DateTickUnit.DAY; }
Example #11
Source File: XYPlotTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Creates a sample dataset. * * @return Series 1. */ private IntervalXYDataset createDataset1() { // create dataset 1... TimeSeries series1 = new TimeSeries("Series 1", Day.class); series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3); series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4); series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3); series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3); series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4); series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3); series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5); series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3); series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4); series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6); series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3); series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2); series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2); series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2); series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2); TimeSeriesCollection collection = new TimeSeriesCollection(series1); return collection; }
Example #12
Source File: JFreeChartTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Serialize a time seroes chart, restore it, and check for equality. */ @Test public void testSerialization4() { RegularTimePeriod t = new Day(); TimeSeries series = new TimeSeries("Series 1"); series.add(t, 36.4); t = t.next(); series.add(t, 63.5); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date", "Value", dataset); JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1); assertEquals(c1, c2); }
Example #13
Source File: JFreeChartTest.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Serialize a time seroes chart, restore it, and check for equality. */ @Test public void testSerialization4() { RegularTimePeriod t = new Day(); TimeSeries series = new TimeSeries("Series 1"); series.add(t, 36.4); t = t.next(); series.add(t, 63.5); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date", "Value", dataset); JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1); assertEquals(c1, c2); }
Example #14
Source File: DayTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithCalendar() { Day d = new Day(1, 12, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(1007164800000L, d.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { d.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example #15
Source File: TimePeriodValueTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { TimePeriodValue tpv1 = new TimePeriodValue(new Day(30, 7, 2003), 55.75); TimePeriodValue tpv2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(tpv1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); tpv2 = (TimePeriodValue) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(tpv1, tpv2); }
Example #16
Source File: DefaultWindDatasetTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Creates a sample dataset for testing. * * @return A sample dataset. */ public DefaultWindDataset createSampleDataset1() { Day t = new Day(1, 4, 2006); Object[] item1 = createItem(t, 3, 7); Object[] item2 = createItem(t.next(), 4, 8); Object[] item3 = createItem(t.next(), 5, 9); Object[][] series1 = new Object[][] {item1, item2, item3}; Object[] item1b = createItem(t, 6, 10); Object[] item2b = createItem(t.next(), 7, 11); Object[] item3b = createItem(t.next(), 8, 12); Object[][] series2 = new Object[][] {item1b, item2b, item3b}; Object[][][] data = new Object[][][] {series1, series2}; return new DefaultWindDataset(data); }
Example #17
Source File: DayTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { Day d1 = new Day(1, 2, 2003); Day d2 = new Day(1, 2, 2003); assertTrue(d1.equals(d2)); int h1 = d1.hashCode(); int h2 = d2.hashCode(); assertEquals(h1, h2); }
Example #18
Source File: SealedHistoryPricesPanel.java From MtgDesktopCompanion with GNU General Public License v3.0 | 5 votes |
@Override public JFreeChart initChart() { TimeSeriesCollection dataset = new TimeSeriesCollection(); TimeSeries series1 = new TimeSeries(title); if(cpVariations!=null) for (Entry<Date, Double> d : cpVariations.entrySet()) series1.add(new Day(d.getKey()), d.getValue().doubleValue()); dataset.addSeries(series1); return ChartFactory.createTimeSeriesChart("Price Variation", "Date", "Value", dataset, true, true,false); }
Example #19
Source File: PeriodAxisLabelInfoTest.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() { PeriodAxisLabelInfo info1 = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); PeriodAxisLabelInfo info2 = (PeriodAxisLabelInfo) TestUtilities.serialised(info1); assertEquals(info1, info2); }
Example #20
Source File: TimeSeriesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some simple checks for the hashCode() method. */ public void testHashCode() { TimeSeries s1 = new TimeSeries("Test"); TimeSeries s2 = new TimeSeries("Test"); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); s1.add(new Day(1, 1, 2007), 500.0); s2.add(new Day(1, 1, 2007), 500.0); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); s1.add(new Day(2, 1, 2007), null); s2.add(new Day(2, 1, 2007), null); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); s1.add(new Day(5, 1, 2007), 111.0); s2.add(new Day(5, 1, 2007), 111.0); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); s1.add(new Day(9, 1, 2007), 1.0); s2.add(new Day(9, 1, 2007), 1.0); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); }
Example #21
Source File: TimeSeriesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Tests the equals method. */ public void testEquals() { TimeSeries s1 = new TimeSeries("Time Series 1"); TimeSeries s2 = new TimeSeries("Time Series 2"); boolean b1 = s1.equals(s2); assertFalse("b1", b1); s2.setKey("Time Series 1"); boolean b2 = s1.equals(s2); assertTrue("b2", b2); RegularTimePeriod p1 = new Day(); RegularTimePeriod p2 = p1.next(); s1.add(p1, 100.0); s1.add(p2, 200.0); boolean b3 = s1.equals(s2); assertFalse("b3", b3); s2.add(p1, 100.0); s2.add(p2, 200.0); boolean b4 = s1.equals(s2); assertTrue("b4", b4); s1.setMaximumItemCount(100); boolean b5 = s1.equals(s2); assertFalse("b5", b5); s2.setMaximumItemCount(100); boolean b6 = s1.equals(s2); assertTrue("b6", b6); s1.setMaximumItemAge(100); boolean b7 = s1.equals(s2); assertFalse("b7", b7); s2.setMaximumItemAge(100); boolean b8 = s1.equals(s2); assertTrue("b8", b8); }
Example #22
Source File: DayTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Set up a day equal to 1 January 1900. Request the next day, it should * be 2 January 1900. */ public void test1Jan1900Next() { Day jan1st1900 = new Day(1, MonthConstants.JANUARY, 1900); Day next = (Day) jan1st1900.next(); assertEquals(2, next.getDayOfMonth()); }
Example #23
Source File: DayTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * In Helsinki, the end of 29 Feb 2004 is * java.util.Date(1,078,091,999,999L). Use this to check the Day * constructor. */ public void testDateConstructor2() { TimeZone zone = TimeZone.getTimeZone("Europe/Helsinki"); Calendar c = new GregorianCalendar(zone); Day d1 = new Day(new Date(1078091999999L), zone); Day d2 = new Day(new Date(1078092000000L), zone); assertEquals(MonthConstants.FEBRUARY, d1.getMonth()); assertEquals(1078091999999L, d1.getLastMillisecond(c)); assertEquals(MonthConstants.MARCH, d2.getMonth()); assertEquals(1078092000000L, d2.getFirstMillisecond(c)); }
Example #24
Source File: ConvertChartContext.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
private XYDataset createTimePeriodDataset() { if (sampleTimePeriodDataset == null) { TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(); Day today = new Day(); TimePeriodValues series1 = new TimePeriodValues("First"); TimePeriodValues series2 = new TimePeriodValues("Second"); for (int i = 0; i < 24; i++) { Minute m0 = new Minute(0, new Hour(i, today)); Minute m1 = new Minute(15, new Hour(i, today)); Minute m2 = new Minute(30, new Hour(i, today)); Minute m3 = new Minute(45, new Hour(i, today)); Minute m4 = new Minute(0, new Hour(i + 1, today)); series1.add(new SimpleTimePeriod(m0.getStart(), m1.getStart()), Math.random()); series2.add(new SimpleTimePeriod(m1.getStart(), m2.getStart()), Math.random()); series1.add(new SimpleTimePeriod(m2.getStart(), m3.getStart()), Math.random()); series2.add(new SimpleTimePeriod(m3.getStart(), m4.getStart()), Math.random()); } dataset.addSeries(series1); dataset.addSeries(series2); sampleTimePeriodDataset = dataset; } return sampleTimePeriodDataset; }
Example #25
Source File: TimeSeriesDataItemTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Test that an instance is equal to itself. * * SourceForge Bug ID: 558850. */ public void testEqualsSelf() { TimeSeriesDataItem item = new TimeSeriesDataItem( new Day(23, 9, 2001), 99.7 ); assertTrue(item.equals(item)); }
Example #26
Source File: DayTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Set up a day equal to 31 December 9999. Request the next day, it should * be null. */ public void test31Dec9999Next() { Day dec31st9999 = new Day(31, MonthConstants.DECEMBER, 9999); Day next = (Day) dec31st9999.next(); assertNull(next); }
Example #27
Source File: SecondTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Tests the equals method. */ public void testEquals() { Day day1 = new Day(29, MonthConstants.MARCH, 2002); Hour hour1 = new Hour(15, day1); Minute minute1 = new Minute(15, hour1); Second second1 = new Second(34, minute1); Day day2 = new Day(29, MonthConstants.MARCH, 2002); Hour hour2 = new Hour(15, day2); Minute minute2 = new Minute(15, hour2); Second second2 = new Second(34, minute2); assertTrue(second1.equals(second2)); }
Example #28
Source File: DayTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * In Helsinki, the end of 29 Feb 2004 is * java.util.Date(1,078,091,999,999L). Use this to check the Day * constructor. */ public void testDateConstructor2() { TimeZone zone = TimeZone.getTimeZone("Europe/Helsinki"); Calendar c = new GregorianCalendar(zone); Day d1 = new Day(new Date(1078091999999L), zone); Day d2 = new Day(new Date(1078092000000L), zone); assertEquals(MonthConstants.FEBRUARY, d1.getMonth()); assertEquals(1078091999999L, d1.getLastMillisecond(c)); assertEquals(MonthConstants.MARCH, d2.getMonth()); assertEquals(1078092000000L, d2.getFirstMillisecond(c)); }
Example #29
Source File: MinuteTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Tests the equals method. */ public void testEquals() { Day day1 = new Day(29, MonthConstants.MARCH, 2002); Hour hour1 = new Hour(15, day1); Minute minute1 = new Minute(15, hour1); Day day2 = new Day(29, MonthConstants.MARCH, 2002); Hour hour2 = new Hour(15, day2); Minute minute2 = new Minute(15, hour2); assertTrue(minute1.equals(minute2)); }
Example #30
Source File: PeriodAxisLabelInfoTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() { PeriodAxisLabelInfo info1 = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); PeriodAxisLabelInfo info2 = (PeriodAxisLabelInfo) TestUtilities.serialised(info1); assertEquals(info1, info2); }