org.jfree.data.time.Month Java Examples

The following examples show how to use org.jfree.data.time.Month. 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: DateAxis.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Corrects the given tick date for the position setting.
 *
 * @param time  the tick date/time.
 * @param unit  the tick unit.
 * @param position  the tick position.
 *
 * @return The adjusted time.
 */
private Date correctTickDateForPosition(Date time, DateTickUnit unit,
        DateTickMarkPosition position) {
    Date result = time;
    switch (unit.getUnit()) {
        case DateTickUnit.MILLISECOND :
        case DateTickUnit.SECOND :
        case DateTickUnit.MINUTE :
        case DateTickUnit.HOUR :
        case DateTickUnit.DAY :
            break;
        case DateTickUnit.MONTH :
            result = calculateDateForPosition(new Month(time,
                    this.timeZone, this.locale), position);
            break;
        case DateTickUnit.YEAR :
            result = calculateDateForPosition(new Year(time,
                    this.timeZone, this.locale), position);
            break;

        default: break;
    }
    return result;
}
 
Example #2
Source File: MonthTests.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() {
    Month m = new Month(3, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(986083199999L, m.getLastMillisecond(calendar));

    // try null calendar
    boolean pass = false;
    try {
        m.getLastMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #3
Source File: DateAxis.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Corrects the given tick date for the position setting.
 *
 * @param time  the tick date/time.
 * @param unit  the tick unit.
 * @param position  the tick position.
 *
 * @return The adjusted time.
 */
private Date correctTickDateForPosition(Date time, DateTickUnit unit,
        DateTickMarkPosition position) {
    Date result = time;
    switch (unit.getUnit()) {
        case DateTickUnit.MILLISECOND :
        case DateTickUnit.SECOND :
        case DateTickUnit.MINUTE :
        case DateTickUnit.HOUR :
        case DateTickUnit.DAY :
            break;
        case DateTickUnit.MONTH :
            result = calculateDateForPosition(new Month(time,
                    this.timeZone, this.locale), position);
            break;
        case DateTickUnit.YEAR :
            result = calculateDateForPosition(new Year(time,
                    this.timeZone, this.locale), position);
            break;

        default: break;
    }
    return result;
}
 
Example #4
Source File: PeriodAxis.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new axis.
 * 
 * @param label  the axis label (<code>null</code> permitted).
 * @param first  the first time period in the axis range 
 *               (<code>null</code> not permitted).
 * @param last  the last time period in the axis range 
 *              (<code>null</code> not permitted).
 * @param timeZone  the time zone (<code>null</code> not permitted).
 */
public PeriodAxis(String label, 
                  RegularTimePeriod first, RegularTimePeriod last, 
                  TimeZone timeZone) {
    
    super(label, null);
    this.first = first;
    this.last = last;
    this.timeZone = timeZone;
    this.calendar = Calendar.getInstance(timeZone);
    this.autoRangeTimePeriodClass = first.getClass();
    this.majorTickTimePeriodClass = first.getClass();
    this.minorTickMarksVisible = false;
    this.minorTickTimePeriodClass = RegularTimePeriod.downsize(
            this.majorTickTimePeriodClass);
    setAutoRange(true);
    this.labelInfo = new PeriodAxisLabelInfo[2];
    this.labelInfo[0] = new PeriodAxisLabelInfo(Month.class, 
            new SimpleDateFormat("MMM"));
    this.labelInfo[1] = new PeriodAxisLabelInfo(Year.class, 
            new SimpleDateFormat("yyyy"));
    
}
 
Example #5
Source File: TimeSeriesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getIndex() method.
 */
public void testGetIndex() {
    TimeSeries series = new TimeSeries("Series");
    assertEquals(-1, series.getIndex(new Month(1, 2003)));

    series.add(new Month(1, 2003), 45.0);
    assertEquals(0, series.getIndex(new Month(1, 2003)));
    assertEquals(-1, series.getIndex(new Month(12, 2002)));
    assertEquals(-2, series.getIndex(new Month(2, 2003)));

    series.add(new Month(3, 2003), 55.0);
    assertEquals(-1, series.getIndex(new Month(12, 2002)));
    assertEquals(0, series.getIndex(new Month(1, 2003)));
    assertEquals(-2, series.getIndex(new Month(2, 2003)));
    assertEquals(1, series.getIndex(new Month(3, 2003)));
    assertEquals(-3, series.getIndex(new Month(4, 2003)));
}
 
Example #6
Source File: MonthTests.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() {
    Month m = new Month(2, 1950);
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    Calendar c = new GregorianCalendar(zone);
    assertEquals(-626025600001L, m.getLastMillisecond(c));
    
    // try null calendar
    boolean pass = false;
    try {
        m.getLastMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);            
}
 
Example #7
Source File: MonthTests.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() {
    Month m = new Month(2, 1950);
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    Calendar c = new GregorianCalendar(zone);
    assertEquals(-626025600001L, m.getLastMillisecond(c));

    // try null calendar
    boolean pass = false;
    try {
        m.getLastMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #8
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 #9
Source File: MonthTests.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() {
    Month m = new Month(2, 1950);
    TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
    Calendar c = new GregorianCalendar(zone);
    assertEquals(-628444800000L, m.getFirstMillisecond(c));

    // try null calendar
    boolean pass = false;
    try {
        m.getFirstMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #10
Source File: CategoricalChartExpression.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
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: MonthTests.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() {
    Month m = new Month(3, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(986083199999L, m.getLastMillisecond(calendar));
    
    // try null calendar
    boolean pass = false;
    try {
        m.getLastMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #12
Source File: TimeSeriesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the getIndex() method.
 */
public void testGetIndex() {
    TimeSeries series = new TimeSeries("Series", Month.class);
    assertEquals(-1, series.getIndex(new Month(1, 2003)));
    
    series.add(new Month(1, 2003), 45.0);
    assertEquals(0, series.getIndex(new Month(1, 2003)));
    assertEquals(-1, series.getIndex(new Month(12, 2002)));
    assertEquals(-2, series.getIndex(new Month(2, 2003)));
    
    series.add(new Month(3, 2003), 55.0);
    assertEquals(-1, series.getIndex(new Month(12, 2002)));
    assertEquals(0, series.getIndex(new Month(1, 2003)));
    assertEquals(-2, series.getIndex(new Month(2, 2003)));
    assertEquals(1, series.getIndex(new Month(3, 2003)));
    assertEquals(-3, series.getIndex(new Month(4, 2003)));   
}
 
Example #13
Source File: DateAxis.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Corrects the given tick date for the position setting.
 *
 * @param time  the tick date/time.
 * @param unit  the tick unit.
 * @param position  the tick position.
 *
 * @return The adjusted time.
 */
private Date correctTickDateForPosition(Date time, DateTickUnit unit,
        DateTickMarkPosition position) {
    Date result = time;
    switch (unit.getUnit()) {
        case DateTickUnit.MILLISECOND :
        case DateTickUnit.SECOND :
        case DateTickUnit.MINUTE :
        case DateTickUnit.HOUR :
        case DateTickUnit.DAY :
            break;
        case DateTickUnit.MONTH :
            result = calculateDateForPosition(new Month(time,
                    this.timeZone, this.locale), position);
            break;
        case DateTickUnit.YEAR :
            result = calculateDateForPosition(new Year(time,
                    this.timeZone, this.locale), position);
            break;

        default: break;
    }
    return result;
}
 
Example #14
Source File: DateAxis.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Corrects the given tick date for the position setting.
 *
 * @param time  the tick date/time.
 * @param unit  the tick unit.
 * @param position  the tick position.
 *
 * @return The adjusted time.
 */
private Date correctTickDateForPosition(Date time, DateTickUnit unit,
        DateTickMarkPosition position) {
    Date result = time;
    switch (unit.getUnit()) {
        case DateTickUnit.MILLISECOND :
        case DateTickUnit.SECOND :
        case DateTickUnit.MINUTE :
        case DateTickUnit.HOUR :
        case DateTickUnit.DAY :
            break;
        case DateTickUnit.MONTH :
            result = calculateDateForPosition(new Month(time,
                    this.timeZone, this.locale), position);
            break;
        case DateTickUnit.YEAR :
            result = calculateDateForPosition(new Year(time,
                    this.timeZone, this.locale), position);
            break;

        default: break;
    }
    return result;
}
 
Example #15
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 #16
Source File: MonthTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * In GMT, the end of Feb 2000 is java.util.Date(951,868,799,999L).  Use
 * this to check the Month constructor.
 */
public void testDateConstructor1() {

    TimeZone zone = TimeZone.getTimeZone("GMT");
    Calendar c = new GregorianCalendar(zone);
    Month m1 = new Month(new Date(951868799999L), zone, 
    		Locale.getDefault());
    Month m2 = new Month(new Date(951868800000L), zone, 
    		Locale.getDefault());

    assertEquals(MonthConstants.FEBRUARY, m1.getMonth());
    assertEquals(951868799999L, m1.getLastMillisecond(c));

    assertEquals(MonthConstants.MARCH, m2.getMonth());
    assertEquals(951868800000L, m2.getFirstMillisecond(c));

}
 
Example #17
Source File: MonthTests.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() {
    Month m = new Month(1, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(978307200000L, m.getFirstMillisecond(calendar));
    
    // try null calendar
    boolean pass = false;
    try {
        m.getFirstMillisecond((Calendar) null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #18
Source File: MonthTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Common test setup.
 */
protected void setUp() {
    this.jan1900 = new Month(MonthConstants.JANUARY, 1900);
    this.feb1900 = new Month(MonthConstants.FEBRUARY, 1900);
    this.nov9999 = new Month(MonthConstants.NOVEMBER, 9999);
    this.dec9999 = new Month(MonthConstants.DECEMBER, 9999);
}
 
Example #19
Source File: MonthTests.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"));
    Month m = new Month(3, 1970);
    assertEquals(5094000000L, m.getFirstMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}
 
Example #20
Source File: MonthTests.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"));
    Month m = new Month(3, 1970);
    assertEquals(5094000000L, m.getFirstMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}
 
Example #21
Source File: PeriodAxis.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new axis.
 *
 * @param label  the axis label (<code>null</code> permitted).
 * @param first  the first time period in the axis range
 *               (<code>null</code> not permitted).
 * @param last  the last time period in the axis range
 *              (<code>null</code> not permitted).
 * @param timeZone  the time zone (<code>null</code> not permitted).
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @since 1.0.13
 */
public PeriodAxis(String label, RegularTimePeriod first,
        RegularTimePeriod last, TimeZone timeZone, Locale locale) {
    super(label, null);
    ParamChecks.nullNotPermitted(timeZone, "timeZone");
    ParamChecks.nullNotPermitted(locale, "locale");
    this.first = first;
    this.last = last;
    this.timeZone = timeZone;
    this.locale = locale;
    this.calendar = Calendar.getInstance(timeZone, locale);
    this.first.peg(this.calendar);
    this.last.peg(this.calendar);
    this.autoRangeTimePeriodClass = first.getClass();
    this.majorTickTimePeriodClass = first.getClass();
    this.minorTickMarksVisible = false;
    this.minorTickTimePeriodClass = RegularTimePeriod.downsize(
            this.majorTickTimePeriodClass);
    setAutoRange(true);
    this.labelInfo = new PeriodAxisLabelInfo[2];
    SimpleDateFormat df0 = new SimpleDateFormat("MMM", locale);
    df0.setTimeZone(timeZone);
    this.labelInfo[0] = new PeriodAxisLabelInfo(Month.class, df0);
    SimpleDateFormat df1 = new SimpleDateFormat("yyyy", locale);
    df1.setTimeZone(timeZone);
    this.labelInfo[1] = new PeriodAxisLabelInfo(Year.class, df1);
}
 
Example #22
Source File: MonthTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Common test setup.
 */
protected void setUp() {
    this.jan1900 = new Month(MonthConstants.JANUARY, 1900);
    this.feb1900 = new Month(MonthConstants.FEBRUARY, 1900);
    this.nov9999 = new Month(MonthConstants.NOVEMBER, 9999);
    this.dec9999 = new Month(MonthConstants.DECEMBER, 9999);
}
 
Example #23
Source File: MonthTests.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"));
    Month m = new Month(3, 1970);
    assertEquals(7772399999L, m.getLastMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}
 
Example #24
Source File: MonthTests.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, 31, 23, 59, 59);
    cal.set(Calendar.MILLISECOND, 999);
    Month m = new Month(1, 2006);
    assertEquals(cal.getTime(), m.getEnd());
    Locale.setDefault(saved);                
}
 
Example #25
Source File: PeriodAxis.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new axis.
 *
 * @param label  the axis label (<code>null</code> permitted).
 * @param first  the first time period in the axis range
 *               (<code>null</code> not permitted).
 * @param last  the last time period in the axis range
 *              (<code>null</code> not permitted).
 * @param timeZone  the time zone (<code>null</code> not permitted).
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @since 1.0.13
 */
public PeriodAxis(String label, RegularTimePeriod first,
        RegularTimePeriod last, TimeZone timeZone, Locale locale) {
    super(label, null);
    if (timeZone == null) {
        throw new IllegalArgumentException("Null 'timeZone' argument.");
    }
    if (locale == null) {
        throw new IllegalArgumentException("Null 'locale' argument.");
    }
    this.first = first;
    this.last = last;
    this.timeZone = timeZone;
    this.locale = locale;
    this.calendar = Calendar.getInstance(timeZone, locale);
    this.first.peg(this.calendar);
    this.last.peg(this.calendar);
    this.autoRangeTimePeriodClass = first.getClass();
    this.majorTickTimePeriodClass = first.getClass();
    this.minorTickMarksVisible = false;
    this.minorTickTimePeriodClass = RegularTimePeriod.downsize(
            this.majorTickTimePeriodClass);
    setAutoRange(true);
    this.labelInfo = new PeriodAxisLabelInfo[2];
    this.labelInfo[0] = new PeriodAxisLabelInfo(Month.class,
            new SimpleDateFormat("MMM", locale));
    this.labelInfo[1] = new PeriodAxisLabelInfo(Year.class,
            new SimpleDateFormat("yyyy", locale));
}
 
Example #26
Source File: CombinedXYPlotDemo1.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a sample dataset.  You wouldn't normally hard-code the
 * population of a dataset in this way (it would be better to read the
 * values from a file or a database query), but for a self-contained demo
 * this is the least complicated solution.
 *
 * @return The dataset.
 */
private static IntervalXYDataset createDataset1() {

    // create dataset 1...
    TimeSeries series1 = new TimeSeries("Series 1");
    series1.add(new Month(1, 2005), 7627.743);
    series1.add(new Month(2, 2005), 7713.138);
    series1.add(new Month(3, 2005), 6776.939);
    series1.add(new Month(4, 2005), 5764.537);
    series1.add(new Month(5, 2005), 4777.880);
    series1.add(new Month(6, 2005), 4836.496);
    series1.add(new Month(7, 2005), 3887.618);
    series1.add(new Month(8, 2005), 3926.933);
    series1.add(new Month(9, 2005), 4932.710);
    series1.add(new Month(10, 2005), 4027.123);
    series1.add(new Month(11, 2005), 8092.322);
    series1.add(new Month(12, 2005), 8170.414);
    series1.add(new Month(1, 2006), 8196.070);
    series1.add(new Month(2, 2006), 8269.886);
    series1.add(new Month(3, 2006), 5371.156);
    series1.add(new Month(4, 2006), 5355.718);
    series1.add(new Month(5, 2006), 5356.777);
    series1.add(new Month(6, 2006), 8420.042);
    series1.add(new Month(7, 2006), 8444.347);
    series1.add(new Month(8, 2006), 8515.034);
    series1.add(new Month(9, 2006), 8506.974);
    series1.add(new Month(10, 2006), 8584.329);
    series1.add(new Month(11, 2006), 8633.246);
    series1.add(new Month(12, 2006), 8680.224);
    series1.add(new Month(1, 2007), 8707.561);
    return new TimeSeriesCollection(series1);

}
 
Example #27
Source File: CombinedXYPlotDemo1.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a sample dataset.  You wouldn't normally hard-code the
 * population of a dataset in this way (it would be better to read the
 * values from a file or a database query), but for a self-contained demo
 * this is the least complicated solution.
 *
 * @return The dataset.
 */
private static IntervalXYDataset createDataset1() {

    // create dataset 1...
    TimeSeries series1 = new TimeSeries("Series 1");
    series1.add(new Month(1, 2005), 7627.743);
    series1.add(new Month(2, 2005), 7713.138);
    series1.add(new Month(3, 2005), 6776.939);
    series1.add(new Month(4, 2005), 5764.537);
    series1.add(new Month(5, 2005), 4777.880);
    series1.add(new Month(6, 2005), 4836.496);
    series1.add(new Month(7, 2005), 3887.618);
    series1.add(new Month(8, 2005), 3926.933);
    series1.add(new Month(9, 2005), 4932.710);
    series1.add(new Month(10, 2005), 4027.123);
    series1.add(new Month(11, 2005), 8092.322);
    series1.add(new Month(12, 2005), 8170.414);
    series1.add(new Month(1, 2006), 8196.070);
    series1.add(new Month(2, 2006), 8269.886);
    series1.add(new Month(3, 2006), 5371.156);
    series1.add(new Month(4, 2006), 5355.718);
    series1.add(new Month(5, 2006), 5356.777);
    series1.add(new Month(6, 2006), 8420.042);
    series1.add(new Month(7, 2006), 8444.347);
    series1.add(new Month(8, 2006), 8515.034);
    series1.add(new Month(9, 2006), 8506.974);
    series1.add(new Month(10, 2006), 8584.329);
    series1.add(new Month(11, 2006), 8633.246);
    series1.add(new Month(12, 2006), 8680.224);
    series1.add(new Month(1, 2007), 8707.561);
    return new TimeSeriesCollection(series1);

}
 
Example #28
Source File: PeriodAxis.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new axis.
 *
 * @param label  the axis label (<code>null</code> permitted).
 * @param first  the first time period in the axis range
 *               (<code>null</code> not permitted).
 * @param last  the last time period in the axis range
 *              (<code>null</code> not permitted).
 * @param timeZone  the time zone (<code>null</code> not permitted).
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @since 1.0.13
 */
public PeriodAxis(String label, RegularTimePeriod first,
        RegularTimePeriod last, TimeZone timeZone, Locale locale) {
    super(label, null);
    ParamChecks.nullNotPermitted(timeZone, "timeZone");
    ParamChecks.nullNotPermitted(locale, "locale");
    this.first = first;
    this.last = last;
    this.timeZone = timeZone;
    this.locale = locale;
    this.calendar = Calendar.getInstance(timeZone, locale);
    this.first.peg(this.calendar);
    this.last.peg(this.calendar);
    this.autoRangeTimePeriodClass = first.getClass();
    this.majorTickTimePeriodClass = first.getClass();
    this.minorTickMarksVisible = false;
    this.minorTickTimePeriodClass = RegularTimePeriod.downsize(
            this.majorTickTimePeriodClass);
    setAutoRange(true);
    this.labelInfo = new PeriodAxisLabelInfo[2];
    SimpleDateFormat df0 = new SimpleDateFormat("MMM", locale);
    df0.setTimeZone(timeZone);
    this.labelInfo[0] = new PeriodAxisLabelInfo(Month.class, df0);
    SimpleDateFormat df1 = new SimpleDateFormat("yyyy", locale);
    df1.setTimeZone(timeZone);
    this.labelInfo[1] = new PeriodAxisLabelInfo(Year.class, df1);
}
 
Example #29
Source File: MonthTests.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"));
    Month m = new Month(3, 1970);
    assertEquals(7772399999L, m.getLastMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}
 
Example #30
Source File: MonthTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * In Auckland, the end of Feb 2000 is java.util.Date(951,821,999,999L).
 * Use this to check the Month constructor.
 */
public void testDateConstructor2() {

    TimeZone zone = TimeZone.getTimeZone("Pacific/Auckland");
    Calendar c = new GregorianCalendar(zone);
    Month m1 = new Month(new Date(951821999999L), zone);
    Month m2 = new Month(new Date(951822000000L), zone);

    assertEquals(MonthConstants.FEBRUARY, m1.getMonth());
    assertEquals(951821999999L, m1.getLastMillisecond(c));

    assertEquals(MonthConstants.MARCH, m2.getMonth());
    assertEquals(951822000000L, m2.getFirstMillisecond(c));

}