/**
  * Constructs a dataset containing a single series. Additional series can be added.
  *
  * @param series the series (<code>null</code> ignored).
  */
 public TimePeriodValuesCollection(TimePeriodValues series) {
   this.data = new java.util.ArrayList();
   this.xPosition = TimePeriodAnchor.MIDDLE;
   this.domainIsPointsInTime = false;
   if (series != null) {
     this.data.add(series);
     series.addChangeListener(this);
   }
 }
コード例 #2
0
  /** Some checks for the add() methods. */
  public void testAdd() {
    TimePeriodValues tpv = new TimePeriodValues("Test");
    MySeriesChangeListener listener = new MySeriesChangeListener();
    tpv.addChangeListener(listener);
    tpv.add(new TimePeriodValue(new SimpleTimePeriod(new Date(1L), new Date(3L)), 99.0));
    assertEquals(99.0, tpv.getValue(0).doubleValue(), EPSILON);
    assertEquals(tpv, listener.getLastEvent().getSource());

    // a null item should throw an IllegalArgumentException
    boolean pass = false;
    try {
      tpv.add((TimePeriodValue) null);
    } catch (IllegalArgumentException e) {
      pass = true;
    }
    assertTrue(pass);
  }
 /**
  * Adds a series to the collection. A {@link org.jfree.data.general.DatasetChangeEvent} is sent to
  * all registered listeners.
  *
  * @param series the time series.
  */
 public void addSeries(TimePeriodValues series) {
   ParamChecks.nullNotPermitted(series, "series");
   this.data.add(series);
   series.addChangeListener(this);
   fireDatasetChanged();
 }