Java Code Examples for org.jfree.data.time.Millisecond#getLastMillisecond()

The following examples show how to use org.jfree.data.time.Millisecond#getLastMillisecond() . 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: MillisecondTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 */
public void testGetLastMillisecondWithCalendar() {
    Millisecond m = new Millisecond(250, 50, 45, 21, 21, 4, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(987889550250L, m.getLastMillisecond(calendar));
    
    // try null calendar
    boolean pass = false;
    try {
        m.getLastMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example 2
Source File: MillisecondTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 */
public void testGetLastMillisecondWithTimeZone() {
    Millisecond m = new Millisecond(750, 55, 1, 2, 7, 7, 1950);
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    Calendar c = new GregorianCalendar(zone);
    assertEquals(-614962684250L, m.getLastMillisecond(c));
    
    // try null calendar
    boolean pass = false;
    try {
        m.getLastMillisecond((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 vote down vote up
/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 */
public void testGetLastMillisecondWithCalendar() {
    Millisecond m = new Millisecond(250, 50, 45, 21, 21, 4, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(987889550250L, m.getLastMillisecond(calendar));

    // try null calendar
    boolean pass = false;
    try {
        m.getLastMillisecond((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 vote down vote up
/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 */
public void testGetLastMillisecondWithTimeZone() {
    Millisecond m = new Millisecond(750, 55, 1, 2, 7, 7, 1950);
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    Calendar c = new GregorianCalendar(zone);
    assertEquals(-614962684250L, m.getLastMillisecond(c));

    // try null calendar
    boolean pass = false;
    try {
        m.getLastMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example 5
Source File: DateAxisTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 6
Source File: DateAxisTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 7
Source File: DateAxisTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 8
Source File: DateAxisTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 9
Source File: DateAxisTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 10
Source File: DateAxisTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 11
Source File: DateAxisTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 12
Source File: DateAxisTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 13
Source File: DateAxisTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 14
Source File: DateAxisTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * 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 15
Source File: DateAxisTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * 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 16
Source File: DateAxisTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 17
Source File: DateAxisTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 18
Source File: DateAxisTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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());
}