Example usage for org.jfree.data.time TimePeriodValues update

List of usage examples for org.jfree.data.time TimePeriodValues update

Introduction

In this page you can find the example usage for org.jfree.data.time TimePeriodValues update.

Prototype

public void update(int index, Number value) 

Source Link

Document

Updates (changes) the value of a data item and sends a SeriesChangeEvent to all registered listeners.

Usage

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

/**
 * Set up a quarter equal to Q1 1900.  Request the previous quarter, it 
 * should be null.//from w w w  .j  a v  a  2 s. com
 */
@Test
public void testClone() throws CloneNotSupportedException {
    TimePeriodValues series = new TimePeriodValues("Test Series");
    RegularTimePeriod jan1st2002 = new Day(1, MonthConstants.JANUARY, 2002);
    series.add(jan1st2002, new Integer(42));
    TimePeriodValues clone = (TimePeriodValues) series.clone();
    clone.setKey("Clone Series");
    clone.update(0, new Integer(10));

    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.TimePeriodValuesTest.java

/**
 * Set up a quarter equal to Q1 1900.  Request the previous quarter, it 
 * should be null.//from  w w  w. ja  v a 2s  .  c  o  m
 */
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());

}