Ejemplo n.º 1
0
  /**
   * Sets a dataset for the plot.
   *
   * @param index the dataset index.
   * @param dataset the dataset (<code>null</code> permitted).
   */
  public void setDataset(int index, ValueDataset dataset) {

    ValueDataset existing = (ValueDataset) this.datasets.get(index);
    if (existing != null) {
      existing.removeChangeListener(this);
    }
    this.datasets.set(index, dataset);
    if (dataset != null) {
      dataset.addChangeListener(this);
    }

    // send a dataset change event to self...
    DatasetChangeEvent event = new DatasetChangeEvent(this, dataset);
    datasetChanged(event);
  }
Ejemplo n.º 2
0
  /**
   * Sets the dataset for the plot, replacing the existing dataset if there is one, and triggers a
   * {@link PlotChangeEvent}.
   *
   * @param dataset the dataset (<code>null</code> permitted).
   * @see #getDataset()
   */
  public void setDataset(ValueDataset dataset) {

    // if there is an existing dataset, remove the plot from the list of
    // change listeners...
    ValueDataset existing = this.dataset;
    if (existing != null) {
      existing.removeChangeListener(this);
    }

    // set the new dataset, and register the chart as a change listener...
    this.dataset = dataset;
    if (dataset != null) {
      setDatasetGroup(dataset.getGroup());
      dataset.addChangeListener(this);
    }

    // send a dataset change event to self...
    DatasetChangeEvent event = new DatasetChangeEvent(this, dataset);
    datasetChanged(event);
  }