org.jfree.data.time.Millisecond Java Examples

The following examples show how to use org.jfree.data.time.Millisecond. 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 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 #2
Source File: TimeSeriesCollectorFunction.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static Class getTimePeriodClass( final String timePeriodStr ) {
  Class retClass = Millisecond.class;
  if ( timePeriodStr.equalsIgnoreCase( SECOND_PERIOD_TYPE_STR ) ) {
    retClass = Second.class;
  } else if ( timePeriodStr.equalsIgnoreCase( MINUTE_PERIOD_TYPE_STR ) ) {
    retClass = Minute.class;
  } else if ( timePeriodStr.equalsIgnoreCase( HOUR_PERIOD_TYPE_STR ) ) {
    retClass = Hour.class;
  } else if ( timePeriodStr.equalsIgnoreCase( DAY_PERIOD_TYPE_STR ) ) {
    retClass = Day.class;
  } else if ( timePeriodStr.equalsIgnoreCase( WEEK_PERIOD_TYPE_STR ) ) {
    retClass = Week.class;
  } else if ( timePeriodStr.equalsIgnoreCase( MONTH_PERIOD_TYPE_STR ) ) {
    retClass = Month.class;
  } else if ( timePeriodStr.equalsIgnoreCase( QUARTER_PERIOD_TYPE_STR ) ) {
    retClass = Quarter.class;
  } else if ( timePeriodStr.equalsIgnoreCase( YEAR_PERIOD_TYPE_STR ) ) {
    retClass = Year.class;
  }
  return retClass;
}
 
Example #3
Source File: ChartConstants.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static Class getTimePeriodClass( final String timePeriodStr ) {
  Class retClass = Millisecond.class;
  if ( timePeriodStr.equalsIgnoreCase( SECOND_PERIOD_TYPE_STR ) ) {
    retClass = Second.class;
  } else if ( timePeriodStr.equalsIgnoreCase( MINUTE_PERIOD_TYPE_STR ) ) {
    retClass = Minute.class;
  } else if ( timePeriodStr.equalsIgnoreCase( HOUR_PERIOD_TYPE_STR ) ) {
    retClass = Hour.class;
  } else if ( timePeriodStr.equalsIgnoreCase( DAY_PERIOD_TYPE_STR ) ) {
    retClass = Day.class;
  } else if ( timePeriodStr.equalsIgnoreCase( WEEK_PERIOD_TYPE_STR ) ) {
    retClass = Week.class;
  } else if ( timePeriodStr.equalsIgnoreCase( MONTH_PERIOD_TYPE_STR ) ) {
    retClass = Month.class;
  } else if ( timePeriodStr.equalsIgnoreCase( QUARTER_PERIOD_TYPE_STR ) ) {
    retClass = Quarter.class;
  } else if ( timePeriodStr.equalsIgnoreCase( YEAR_PERIOD_TYPE_STR ) ) {
    retClass = Year.class;
  }
  return retClass;
}
 
Example #4
Source File: AnomalyGraphGenerator.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
/**
 * Returns data with series 0 = current and 1 = baseline. This method assumes there is exactly one
 * metric in the response data.
 */
private TimeSeriesCollection createTimeSeries(final TimeOnTimeComparisonResponse data) {
  final TimeSeries baseline = new TimeSeries(BASELINE_LABEL);
  final TimeSeries current = new TimeSeries(CURRENT_LABEL);
  for (int i = 0; i < data.getNumRows(); i++) {
    Row row = data.getRow(i);
    // Plot the baseline data as an overlay on the corresponding current data point.
    // long baselineStart = row.getBaselineStart().getMillis();
    long currentStart = row.getCurrentStart().getMillis();
    Date date = new Date(currentStart);
    RegularTimePeriod timePeriod = new Millisecond(date);
    Metric metric = row.getMetrics().get(0);
    baseline.add(timePeriod, metric.getBaselineValue());
    current.add(timePeriod, metric.getCurrentValue());
  }

  final TimeSeriesCollection dataset = new TimeSeriesCollection();
  dataset.addSeries(current);
  dataset.addSeries(baseline);
  return dataset;
}
 
Example #5
Source File: MillisecondTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #6
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 #7
Source File: TimeSeriesGraphUpdater.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
private TimeSeries computeSingleTimeSeries(final List<Band> bandList, int pixelX, int pixelY, int currentLevel, String positionName) {
    final Band firstBand = bandList.get(0);
    final String firstBandName = firstBand.getName();
    final int lastUnderscore = firstBandName.lastIndexOf("_");
    final String suffix = positionName.isEmpty()?positionName: "_" + positionName;
    final String timeSeriesName = firstBandName.substring(0, lastUnderscore);
    final TimeSeries timeSeries = new TimeSeries(timeSeriesName + suffix);
    for (Band band : bandList) {
        final TimeCoding timeCoding = this.timeSeries.getRasterTimeMap().get(band);
        if (timeCoding != null) {
            final ProductData.UTC startTime = timeCoding.getStartTime();
            final Millisecond timePeriod = new Millisecond(startTime.getAsDate(),
                                                           ProductData.UTC.UTC_TIME_ZONE,
                                                           Locale.getDefault());
            final double value = getValue(band, pixelX, pixelY, currentLevel);
            timeSeries.add(new TimeSeriesDataItem(timePeriod, value));
        }
    }
    return timeSeries;
}
 
Example #8
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 #9
Source File: TimeSeriesGraphModel.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
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 #10
Source File: MillisecondTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #11
Source File: MillisecondTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #12
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 #13
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 #14
Source File: MillisecondTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    Millisecond m1 = new Millisecond(599, 23, 45, 7, 9, 10, 2007);
    Millisecond m2 = new Millisecond(599, 23, 45, 7, 9, 10, 2007);
    assertTrue(m1.equals(m2));
    int hash1 = m1.hashCode();
    int hash2 = m2.hashCode();
    assertEquals(hash1, hash2);
}
 
Example #15
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 #16
Source File: MillisecondTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * In Tallinn, the 4.55:59.123pm on 21 Mar 2002 is 
 * java.util.Date(1016722559123L).  Use this to check the Millisecond 
 * constructor.
 */
public void testDateConstructor2() {

    TimeZone zone = TimeZone.getTimeZone("Europe/Tallinn");
    Calendar c = new GregorianCalendar(zone);
    Millisecond m1 = new Millisecond(new Date(1016722559122L), zone);
    Millisecond m2 = new Millisecond(new Date(1016722559123L), zone);

    assertEquals(122, m1.getMillisecond());
    assertEquals(1016722559122L, m1.getLastMillisecond(c));

    assertEquals(123, m2.getMillisecond());
    assertEquals(1016722559123L, m2.getFirstMillisecond(c));

}
 
Example #17
Source File: MillisecondTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * In GMT, the 4.55:59.123pm on 21 Mar 2002 is 
 * java.util.Date(1016729759123L).  Use this to check the Millisecond 
 * constructor.
 */
public void testDateConstructor1() {

    TimeZone zone = TimeZone.getTimeZone("GMT");
    Calendar c = new GregorianCalendar(zone);
    Millisecond m1 = new Millisecond(new Date(1016729759122L), zone);
    Millisecond m2 = new Millisecond(new Date(1016729759123L), zone);

    assertEquals(122, m1.getMillisecond());
    assertEquals(1016729759122L, m1.getLastMillisecond(c));

    assertEquals(123, m2.getMillisecond());
    assertEquals(1016729759123L, m2.getFirstMillisecond(c));

}
 
Example #18
Source File: MillisecondTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    Millisecond milli1 = new Millisecond(999, second1);
    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);
    Millisecond milli2 = new Millisecond(999, second2);
    assertTrue(milli1.equals(milli2));
}
 
Example #19
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 #20
Source File: MillisecondTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getFirstMillisecond() method.
 */
public void testGetFirstMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Millisecond m = new Millisecond(500, 15, 43, 15, 1, 4, 2006);
    assertEquals(1143902595500L, m.getFirstMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}
 
Example #21
Source File: MillisecondTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getLastMillisecond() method.
 */
public void testGetLastMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Millisecond m = new Millisecond(750, 1, 1, 1, 1, 1, 1970);
    assertEquals(61750L, m.getLastMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}
 
Example #22
Source File: MillisecondTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getStart() method.
 */
public void testGetStart() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55);
    cal.set(Calendar.MILLISECOND, 555);
    Millisecond m = new Millisecond(555, 55, 47, 3, 16, 1, 2006);
    assertEquals(cal.getTime(), m.getStart());
    Locale.setDefault(saved);        
}
 
Example #23
Source File: MillisecondTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the getEnd() method.
 */
public void testGetEnd() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55);
    cal.set(Calendar.MILLISECOND, 555);
    Millisecond m = new Millisecond(555, 55, 47, 3, 16, 1, 2006);
    assertEquals(cal.getTime(), m.getEnd());
    Locale.setDefault(saved);                
}
 
Example #24
Source File: TimeSeriesGraphUpdater.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private TimeSeries computeSingleTimeSeries(InsituRecord[] insituRecords, String insituName) {
    TimeSeries timeSeries = new TimeSeries(insituName);
    for (InsituRecord insituRecord : insituRecords) {
        final ProductData.UTC startTime = ProductData.UTC.create(insituRecord.time, 0);
        final Millisecond timePeriod = new Millisecond(startTime.getAsDate(),
                                                       ProductData.UTC.UTC_TIME_ZONE,
                                                       Locale.getDefault());
        timeSeries.addOrUpdate(timePeriod, insituRecord.value);
    }
    return timeSeries;
}
 
Example #25
Source File: TileCacheMonitor.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private static TimeSeriesCollection addSubPlot(CombinedDomainXYPlot plot, String label) {
    final TimeSeriesCollection seriesCollection = new TimeSeriesCollection(new TimeSeries(label, Millisecond.class));
    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    XYPlot subplot = new XYPlot(seriesCollection, null, rangeAxis, new StandardXYItemRenderer());
    subplot.setBackgroundPaint(Color.lightGray);
    subplot.setDomainGridlinePaint(Color.white);
    subplot.setRangeGridlinePaint(Color.white);
    plot.add(subplot);
    return seriesCollection;
}
 
Example #26
Source File: GsnChartJfreechart.java    From gsn with GNU General Public License v3.0 5 votes vote down vote up
public JFreeChart createChart(Collection<Data> datas) {
    TimeSeries t1 = new TimeSeries("S1");
    Iterator<Data> iter = datas.iterator() ; 
    Data data ;
    while (iter.hasNext()) {
        data = iter.next();
        t1.addOrUpdate(RegularTimePeriod.createInstance(Millisecond.class, new Date((Long)data.getP2()), TimeZone.getDefault()), data.getValue());
    }
    XYDataset dataset = new TimeSeriesCollection(t1);
    JFreeChart chart = ChartFactory.createTimeSeriesChart(
            null,
            null, 
            null, 
            dataset, 
            false,
            false, 
            false
    );
    chart.setAntiAlias(true);
    chart.setTextAntiAlias(true);
    chart.setBackgroundPaint(Color.WHITE);
    //
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setNoDataMessage("No Data to Display");
    plot.setDomainGridlinesVisible(true);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setInsets(new RectangleInsets(5,14,0,5));
    //
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(ssdf);
    axis.setTickLabelFont(TICK_FONT);
    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setTickLabelFont(TICK_FONT);
    //
    return chart;
}
 
Example #27
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 #28
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 #29
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 #30
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());
}