Exemple #1
0
  /**
   * Adds a series, plus a (possibly null) SeriesChangeListener which will receive a <i>single</i>
   * event if/when the series is deleted from the chart by the user. Returns the series attributes.
   */
  public SeriesAttributes addSeries(Collection objs, String name, SeriesChangeListener stopper) {
    int i = getSeriesCount();

    // need to have added the dataset BEFORE calling this since it'll try to change the name of the
    // series
    PieChartSeriesAttributes csa = buildNewAttributes(name, stopper);

    // set information
    csa.setElements(new ArrayList(objs));

    seriesAttributes.add(csa);

    revalidate(); // display the new series panel
    update();

    // won't update properly unless I force it here by letting all the existing scheduled events to
    // go through.  Dumb design.  :-(
    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            update();
          }
        });

    return csa;
  }
Exemple #2
0
  public void updateSeries(int index, Object[] objs) {
    if (index < 0) // this happens when we're a dead chart but the inspector doesn't know
    return;

    if (index
        >= getNumSeriesAttributes()) // this can happen when we close a window if we use the
                                     // Histogram in a display
    return;

    PieChartSeriesAttributes hsa = (PieChartSeriesAttributes) (getSeriesAttribute(index));
    hsa.setElements((Object[]) (objs.clone()));
  }