コード例 #1
0
  ChartGenerator createNewChart(final GUIState simulation) {
    generator = createNewGenerator();
    globalAttributes = new GlobalAttributes();
    generator.addGlobalAttribute(globalAttributes); // it'll be added last

    // set up the simulation -- need a new name other than guiObjects: and it should be
    // a HashMap rather than a Bag.
    if (simulation.guiObjects == null) simulation.guiObjects = new Bag();
    simulation.guiObjects.add(generator);
    final JFrame f = generator.createFrame(simulation);
    WindowListener wl =
        new WindowListener() {
          public void windowActivated(WindowEvent e) {}

          public void windowClosed(WindowEvent e) {}

          public void windowClosing(WindowEvent e) {
            generator.quit();
          }

          public void windowDeactivated(WindowEvent e) {}

          public void windowDeiconified(WindowEvent e) {}

          public void windowIconified(WindowEvent e) {}

          public void windowOpened(WindowEvent e) {}
        };
    f.addWindowListener(wl);
    f.setVisible(true);

    return generator;
  }
コード例 #2
0
 /** Used to find the global attributes that another inspector has set so I can share it. */
 GlobalAttributes findGlobalAttributes() {
   if (generator == null) return null; // got a problem
   int len = generator.getGlobalAttributeCount();
   for (int i = 0; i < len; i++)
     if ((generator.getGlobalAttribute(i) instanceof GlobalAttributes))
       return (GlobalAttributes) generator.getGlobalAttribute(i);
   return null;
 }
コード例 #3
0
  public void updateInspector() {
    double time = simulation.state.schedule.time();
    // we should only update if we're at a new time that we've not seen yet, or if
    // we're at the start of inspection and haven't done an update yet.  It's possible
    // for this second condition to be true while the first one is false: if we're at
    // simulation start, then lastTime == Schedule.BEFORE_SIMULATION == time, but we'd
    // still want to update at least one time.
    if (time >= Schedule.EPOCH
        && time < Schedule.AFTER_SIMULATION
        && (lastTime < time || !updatedOnceAlready)) // bug fix
    {
      updatedOnceAlready = true;
      updateSeries(time, lastTime);
      lastTime = time;

      // now determine when to update
      switch (globalAttributes.redraw) {
        case REDRAW_ALWAYS: // do it now
          generator.update();
          break;
        case REDRAW_TENTH_SEC:
          updateBefore(100);
          break;
        case REDRAW_HALF_SEC:
          updateBefore(500);
          break;
        case REDRAW_ONE_SEC:
          updateBefore(1000);
          break;
        case REDRAW_TWO_SECS:
          updateBefore(2000);
          break;
        case REDRAW_FIVE_SECS:
          updateBefore(5000);
          break;
        case REDRAW_TEN_SECS:
          updateBefore(10000);
          break;
        case REDRAW_DONT: // do nothing
          break;
        default:
          System.err.println("Unknown redraw time specified");
      }
    }
  }
コード例 #4
0
ファイル: PieChartGenerator.java プロジェクト: JayH5/mason
 public void moveSeries(int index, boolean up) {
   super.moveSeries(index, up);
   update();
 }
コード例 #5
0
ファイル: PieChartGenerator.java プロジェクト: JayH5/mason
 public void removeSeries(int index) {
   super.removeSeries(index);
   update();
 }