Java Code Examples for org.jfree.data.time.Millisecond#getFirstMillisecond()
The following examples show how to use
org.jfree.data.time.Millisecond#getFirstMillisecond() .
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: TimeSeriesGraphModel.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
void updateAnnotation(RasterDataNode raster) { removeAnnotation(); final AbstractTimeSeries timeSeries = getTimeSeries(); TimeCoding timeCoding = timeSeries.getRasterTimeMap().get(raster); if (timeCoding != null) { final ProductData.UTC startTime = timeCoding.getStartTime(); final Millisecond timePeriod = new Millisecond(startTime.getAsDate(), ProductData.UTC.UTC_TIME_ZONE, Locale.getDefault()); double millisecond = timePeriod.getFirstMillisecond(); Range valueRange = null; for (int i = 0; i < timeSeriesPlot.getRangeAxisCount(); i++) { valueRange = Range.combine(valueRange, timeSeriesPlot.getRangeAxis(i).getRange()); } if (valueRange != null) { XYAnnotation annotation = new XYLineAnnotation(millisecond, valueRange.getLowerBound(), millisecond, valueRange.getUpperBound()); timeSeriesPlot.addAnnotation(annotation, true); } } }
Example 2
Source File: MillisecondTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithCalendar() { Millisecond m = new Millisecond(500, 55, 40, 2, 15, 4, 2000); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(955766455500L, m.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example 3
Source File: MillisecondTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithTimeZone() { Millisecond m = new Millisecond(500, 50, 59, 15, 1, 4, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); Calendar c = new GregorianCalendar(zone); assertEquals(-623289609500L, m.getFirstMillisecond(c)); // try null calendar boolean pass = false; try { m.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example 4
Source File: MillisecondTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithCalendar() { Millisecond m = new Millisecond(500, 55, 40, 2, 15, 4, 2000); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(955766455500L, m.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example 5
Source File: MillisecondTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithTimeZone() { Millisecond m = new Millisecond(500, 50, 59, 15, 1, 4, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); Calendar c = new GregorianCalendar(zone); assertEquals(-623289609500L, m.getFirstMillisecond(c)); // try null calendar boolean pass = false; try { m.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
Example 6
Source File: DateAxisTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A basic check for the testPreviousStandardDate() method when the * tick unit is 10 milliseconds (just for the sake of having a multiple). */ public void testPreviousStandardDateMillisecondB() { MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnitType.MILLISECOND, 10); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd, TimeZone.getDefault()); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd, TimeZone.getDefault()); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd, TimeZone.getDefault()); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); }
Example 7
Source File: DateAxisTest.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * A basic check for the testPreviousStandardDate() method when the * tick unit is 10 milliseconds (just for the sake of having a multiple). */ @Test public void testPreviousStandardDateMillisecondB() { MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 10); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); }
Example 8
Source File: DateAxisTest.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 millisecond. */ @Test public void testPreviousStandardDateMillisecondA() { MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 1); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); }
Example 9
Source File: DateAxisTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A basic check for the testPreviousStandardDate() method when the * tick unit is 10 milliseconds (just for the sake of having a multiple). */ public void testPreviousStandardDateMillisecondB() { MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 10); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); }
Example 10
Source File: DateAxisTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 millisecond. */ public void testPreviousStandardDateMillisecondA() { MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 1); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); }
Example 11
Source File: DateAxisTest.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 millisecond. */ @Test public void testPreviousStandardDateMillisecondA() { MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 1); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); }
Example 12
Source File: DateAxisTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 millisecond. */ public void testPreviousStandardDateMillisecondA() { MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnitType.MILLISECOND, 1); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd, TimeZone.getDefault()); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd, TimeZone.getDefault()); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd, TimeZone.getDefault()); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); }
Example 13
Source File: DateAxisTest.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * A basic check for the testPreviousStandardDate() method when the * tick unit is 10 milliseconds (just for the sake of having a multiple). */ @Test public void testPreviousStandardDateMillisecondB() { MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 10); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); }
Example 14
Source File: DateAxisTest.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 millisecond. */ @Test public void testPreviousStandardDateMillisecondA() { MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 1); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); }
Example 15
Source File: DateAxisTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * A basic check for the testPreviousStandardDate() method when the * tick unit is 10 milliseconds (just for the sake of having a multiple). */ @Test public void testPreviousStandardDateMillisecondB() { MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 10); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); }
Example 16
Source File: DateAxisTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 millisecond. */ @Test public void testPreviousStandardDateMillisecondA() { MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 1); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); }
Example 17
Source File: DateAxisTest.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * A basic check for the testPreviousStandardDate() method when the * tick unit is 10 milliseconds (just for the sake of having a multiple). */ @Test public void testPreviousStandardDateMillisecondB() { MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 10); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); }
Example 18
Source File: DateAxisTest.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 millisecond. */ @Test public void testPreviousStandardDateMillisecondA() { MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 1); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); }
Example 19
Source File: DateAxisTest.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * A basic check for the testPreviousStandardDate() method when the * tick unit is 10 milliseconds (just for the sake of having a multiple). */ @Test public void testPreviousStandardDateMillisecondB() { MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 10); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); }