예제 #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(
      double[] amounts, String[] labels, 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.setValues((double[]) (amounts.clone()));
    csa.setLabels((String[]) (labels.clone()));

    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;
  }
예제 #2
0
  public void updateSeries(int index, double[] amounts, String[] labels) {
    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.setValues((double[]) (amounts.clone()));
    hsa.setLabels((String[]) (labels.clone()));
  }