public void setupPortrayals() {

    // Reset displays.
    jDisplay.reset();
    degreesChart.repaint();

    /*
     * A simple agent will be created and registered on schedule. It will
     * update information used for plotting the histogram. It is possible to
     * have underlying JFreeChart data structure in the SimState thread, but
     * it unnecessarily slows down simulation when run in the batch /
     * command line only mode.
     */
    Steppable histUpdater =
        new Steppable() {

          private static final long serialVersionUID = 6184761986120478954L;

          public void step(SimState state) {
            if (degreesFrame.isVisible()) {

              degrees = new double[((PreferentialAttachment) state).graph.numVertices()];

              Iterator i = ((PreferentialAttachment) state).graph.getVertices().iterator();
              int j = 0;
              while (i.hasNext()) {
                degrees[j] = ((SparseVertex) i.next()).degree();
                j++;
              }

              degreesChart.updateSeries(0, degrees, false);
            }
          }
        };

    this.scheduleImmediateRepeat(true, histUpdater);
  }
  public void quit() {
    super.quit();

    if (jDisplay.frame != null) jDisplay.frame.dispose();
    jDisplay.frame = null;
  }