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;
  }