Example usage for org.jfree.chart.date MonthConstants JANUARY

List of usage examples for org.jfree.chart.date MonthConstants JANUARY

Introduction

In this page you can find the example usage for org.jfree.chart.date MonthConstants JANUARY.

Prototype

int JANUARY

To view the source code for org.jfree.chart.date MonthConstants JANUARY.

Click Source Link

Document

Constant for January.

Usage

From source file:org.jfree.data.time.junit.MonthTest.java

/**
 * Common test setup./*from   w  w w .j av a  2 s.  c o m*/
 */
@Override
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);
}

From source file:org.jfree.data.time.junit.TimePeriodValuesTest.java

/**
 * Set up a quarter equal to Q1 1900.  Request the previous quarter, it 
 * should be null./* w  w w .j  a va2 s .  com*/
 */
public void testClone() {

    TimePeriodValues series = new TimePeriodValues("Test Series");

    RegularTimePeriod jan1st2002 = new Day(1, MonthConstants.JANUARY, 2002);
    try {
        series.add(jan1st2002, new Integer(42));
    } catch (SeriesException e) {
        System.err.println("Problem adding to collection.");
    }

    TimePeriodValues clone = null;
    try {
        clone = (TimePeriodValues) series.clone();
        clone.setKey("Clone Series");
        try {
            clone.update(0, new Integer(10));
        } catch (SeriesException e) {
            System.err.println("Problem updating series.");
        }
    } catch (CloneNotSupportedException e) {
        assertTrue(false);
    }

    int seriesValue = series.getValue(0).intValue();
    int cloneValue = clone.getValue(0).intValue();

    assertEquals(42, seriesValue);
    assertEquals(10, cloneValue);
    assertEquals("Test Series", series.getKey());
    assertEquals("Clone Series", clone.getKey());

}

From source file:org.jfree.data.time.junit.HourTest.java

/**
 * Set up an hour equal to hour zero, 1 January 1900.  Request the
 * previous hour, it should be null.//from   w  w  w. j a v a  2  s  .co m
 */
public void testFirstHourPrevious() {
    Hour first = new Hour(0, new Day(1, MonthConstants.JANUARY, 1900));
    Hour previous = (Hour) first.previous();
    assertNull(previous);
}

From source file:org.jfree.data.time.junit.DayTest.java

/**
 * Set up a day equal to 1 January 1900.  Request the previous day, it
 * should be null.//  w  w  w .java  2s  .  com
 */
public void test1Jan1900Previous() {
    Day jan1st1900 = new Day(1, MonthConstants.JANUARY, 1900);
    Day previous = (Day) jan1st1900.previous();
    assertNull(previous);
}

From source file:org.jfree.data.time.junit.HourTest.java

/**
 * Set up an hour equal to hour zero, 1 January 1900.  Request the next
 * hour, it should be null./*from   w w w. j  ava  2s .c  o  m*/
 */
public void testFirstHourNext() {
    Hour first = new Hour(0, new Day(1, MonthConstants.JANUARY, 1900));
    Hour next = (Hour) first.next();
    assertEquals(1, next.getHour());
    assertEquals(1900, next.getYear());
}

From source file:org.jfree.data.time.junit.DayTest.java

/**
 * Set up a day equal to 1 January 1900.  Request the next day, it should
 * be 2 January 1900.//w  w w  .  j a  v  a 2s.c  o m
 */
public void test1Jan1900Next() {
    Day jan1st1900 = new Day(1, MonthConstants.JANUARY, 1900);
    Day next = (Day) jan1st1900.next();
    assertEquals(2, next.getDayOfMonth());
}

From source file:org.jfree.data.time.junit.TimeSeriesTest.java

/**
 * Check that cloning works./*from   w ww .  j  a v  a  2s.c o  m*/
 */
public void testClone() {

    TimeSeries series = new TimeSeries("Test Series");

    RegularTimePeriod jan1st2002 = new Day(1, MonthConstants.JANUARY, 2002);
    try {
        series.add(jan1st2002, new Integer(42));
    } catch (SeriesException e) {
        System.err.println("Problem adding to series.");
    }

    TimeSeries clone = null;
    try {
        clone = (TimeSeries) series.clone();
        clone.setKey("Clone Series");
        try {
            clone.update(jan1st2002, new Integer(10));
        } catch (SeriesException e) {
            e.printStackTrace();
        }
    } catch (CloneNotSupportedException e) {
        assertTrue(false);
    }

    int seriesValue = series.getValue(jan1st2002).intValue();
    int cloneValue = Integer.MAX_VALUE;
    if (clone != null) {
        cloneValue = clone.getValue(jan1st2002).intValue();
    }

    assertEquals(42, seriesValue);
    assertEquals(10, cloneValue);
    assertEquals("Test Series", series.getKey());
    if (clone != null) {
        assertEquals("Clone Series", clone.getKey());
    } else {
        assertTrue(false);
    }

}

From source file:org.jfree.data.time.Month.java

/**
 * Returns the month preceding this one.  Note that the returned
 * {@link Month} is "pegged" using the default time-zone, irrespective of
 * the time-zone used to peg of the current month (which is not recorded
 * anywhere).  See the {@link #peg(Calendar)} method.
 *
 * @return The month preceding this one.
 *///from ww w  .j  av  a2  s  . c  o  m
@Override
public RegularTimePeriod previous() {
    Month result;
    if (this.month != MonthConstants.JANUARY) {
        result = new Month(this.month - 1, this.year);
    } else {
        if (this.year > 1900) {
            result = new Month(MonthConstants.DECEMBER, this.year - 1);
        } else {
            result = null;
        }
    }
    return result;
}

From source file:org.jfree.data.time.Month.java

/**
 * Returns the month following this one.  Note that the returned
 * {@link Month} is "pegged" using the default time-zone, irrespective of
 * the time-zone used to peg of the current month (which is not recorded
 * anywhere).  See the {@link #peg(Calendar)} method.
 *
 * @return The month following this one.
 *//*from   w  ww  .  j a va 2  s  .c o  m*/
@Override
public RegularTimePeriod next() {
    Month result;
    if (this.month != MonthConstants.DECEMBER) {
        result = new Month(this.month + 1, this.year);
    } else {
        if (this.year < 9999) {
            result = new Month(MonthConstants.JANUARY, this.year + 1);
        } else {
            result = null;
        }
    }
    return result;
}

From source file:org.jfree.data.time.junit.TimeSeriesTest.java

/**
 * Some tests to ensure that the createCopy(RegularTimePeriod,
 * RegularTimePeriod) method is functioning correctly.
 *//* ww  w . j av a2 s  .  co  m*/
public void testCreateCopy1() {

    TimeSeries series = new TimeSeries("Series");
    series.add(new Month(MonthConstants.JANUARY, 2003), 45.0);
    series.add(new Month(MonthConstants.FEBRUARY, 2003), 55.0);
    series.add(new Month(MonthConstants.JUNE, 2003), 35.0);
    series.add(new Month(MonthConstants.NOVEMBER, 2003), 85.0);
    series.add(new Month(MonthConstants.DECEMBER, 2003), 75.0);

    try {
        // copy a range before the start of the series data...
        TimeSeries result1 = series.createCopy(new Month(MonthConstants.NOVEMBER, 2002),
                new Month(MonthConstants.DECEMBER, 2002));
        assertEquals(0, result1.getItemCount());

        // copy a range that includes only the first item in the series...
        TimeSeries result2 = series.createCopy(new Month(MonthConstants.NOVEMBER, 2002),
                new Month(MonthConstants.JANUARY, 2003));
        assertEquals(1, result2.getItemCount());

        // copy a range that begins before and ends in the middle of the
        // series...
        TimeSeries result3 = series.createCopy(new Month(MonthConstants.NOVEMBER, 2002),
                new Month(MonthConstants.APRIL, 2003));
        assertEquals(2, result3.getItemCount());

        TimeSeries result4 = series.createCopy(new Month(MonthConstants.NOVEMBER, 2002),
                new Month(MonthConstants.DECEMBER, 2003));
        assertEquals(5, result4.getItemCount());

        TimeSeries result5 = series.createCopy(new Month(MonthConstants.NOVEMBER, 2002),
                new Month(MonthConstants.MARCH, 2004));
        assertEquals(5, result5.getItemCount());

        TimeSeries result6 = series.createCopy(new Month(MonthConstants.JANUARY, 2003),
                new Month(MonthConstants.JANUARY, 2003));
        assertEquals(1, result6.getItemCount());

        TimeSeries result7 = series.createCopy(new Month(MonthConstants.JANUARY, 2003),
                new Month(MonthConstants.APRIL, 2003));
        assertEquals(2, result7.getItemCount());

        TimeSeries result8 = series.createCopy(new Month(MonthConstants.JANUARY, 2003),
                new Month(MonthConstants.DECEMBER, 2003));
        assertEquals(5, result8.getItemCount());

        TimeSeries result9 = series.createCopy(new Month(MonthConstants.JANUARY, 2003),
                new Month(MonthConstants.MARCH, 2004));
        assertEquals(5, result9.getItemCount());

        TimeSeries result10 = series.createCopy(new Month(MonthConstants.MAY, 2003),
                new Month(MonthConstants.DECEMBER, 2003));
        assertEquals(3, result10.getItemCount());

        TimeSeries result11 = series.createCopy(new Month(MonthConstants.MAY, 2003),
                new Month(MonthConstants.MARCH, 2004));
        assertEquals(3, result11.getItemCount());

        TimeSeries result12 = series.createCopy(new Month(MonthConstants.DECEMBER, 2003),
                new Month(MonthConstants.DECEMBER, 2003));
        assertEquals(1, result12.getItemCount());

        TimeSeries result13 = series.createCopy(new Month(MonthConstants.DECEMBER, 2003),
                new Month(MonthConstants.MARCH, 2004));
        assertEquals(1, result13.getItemCount());

        TimeSeries result14 = series.createCopy(new Month(MonthConstants.JANUARY, 2004),
                new Month(MonthConstants.MARCH, 2004));
        assertEquals(0, result14.getItemCount());
    } catch (CloneNotSupportedException e) {
        assertTrue(false);
    }

}