public void init(Controller c) {
    super.init(c);

    // Make the Display2D.  We'll have it display stuff later.
    display = new Display2D(500, 500, this, 1); // at 400x400, we've got 4x4 per array position
    displayFrame = display.createFrame();
    c.registerFrame(displayFrame); // register the frame so it appears in the "Display" list
    displayFrame.setVisible(true);

    // attach the portrayals from bottom to top
    display.attach(foodPortrayal, "Food");
    display.attach(agentPortrayal, "Agents");
    displayFrame.setTitle("Agents");
    // specify the backdrop color  -- what gets painted behind the displays
    display.setBackdrop(Color.yellow);
    // Make the Display2D.  We'll have it display stuff later.
    display2 = new Display2D(400, 400, this, 1); // at 400x400, we've got 4x4 per array position
    displayFrame2 = display2.createFrame();
    displayFrame2.setTitle("Statistic");
    c.registerFrame(displayFrame2); // register the frame so it appears in the "Display" list
    displayFrame2.setVisible(false);
    // specify the backdrop color  -- what gets painted behind the displays
    display2.setBackdrop(Color.GRAY);
    // attach the portrayals from bottom to top
    display2.attach(summaryPortrayal, "Summary");
  }
示例#2
0
  /** initialize the simulation */
  public void init(Controller controller) {
    super.init(controller);

    display = new Display2D(800, 600, this);

    display.attach(polyPortrayal, "Polys");

    displayFrame = display.createFrame();
    controller.registerFrame(displayFrame);
    displayFrame.setVisible(true);

    // the happiness chart setup
    happinessChart = new TimeSeriesChartGenerator();
    happinessChart.setTitle("Percent of Happy Persons in Simulation");
    happinessChart.setRangeAxisLabel("Percent Happy");
    happinessChart.setDomainAxisLabel("Opportunities to Move");
    JFrame chartFrame = happinessChart.createFrame(this);
    chartFrame.pack();
    controller.registerFrame(chartFrame);

    // the # moves histogram setup
    numMovesHisto = new HistogramGenerator();
    numMovesHisto.setTitle("Number of Moves People Have Made");
    numMovesHisto.setDomainAxisLabel("Number of Moves");
    numMovesHisto.setRangeAxisLabel("%");
    JFrame histoFrame = numMovesHisto.createFrame(this);
    histoFrame.pack();
    controller.registerFrame(histoFrame);
  }
示例#3
0
  public void init(Controller c) {
    super.init(c);
    // Make the Display3D.  We'll have it display stuff later.
    display = new Display3D(600, 600, this);

    // attach the portrayals to the displayer, from bottom to top
    display.attach(heatPortrayal, "Heat");
    display.attach(bugPortrayal, "Bugs");
    heatPortrayal.setValueName("Heat");

    HeatBugs hbState = (HeatBugs) state;

    // center the bug graph.  Right now it's located at the (0,0) position.  For
    // example, if it's a 5x5 graph, and the origin is at (0,0), we want to move it
    // to (2,2).  So we want it to be at (  (5-1)/2 = 2,  (5-1/2) = 2  ).  Similarly,
    // if it's a 6x6 graph we want the origin to be at (2.5, 2.5), dead center between
    // the (2,2) and (3,3) grid positions.  To center
    // the origin there, we need to move the graph in the opposite direction.
    // so the general equation for each dimension: (numGridPoints - 1) / -2.0.
    display.translate((hbState.gridWidth - 1) / -2.0, (hbState.gridHeight - 1) / -2.0, 0);

    // now let's scale it so it fits inside a 1x1x1 cube centered at the origin.  We don't
    // have to, but it'll look nicer.
    display.scale(1.0 / Math.max(hbState.gridWidth, hbState.gridHeight));

    displayFrame = display.createFrame();
    c.registerFrame(displayFrame); // register the frame so it appears in the "Display" list
    displayFrame.setVisible(true);
  }
  public void init(Controller c) {
    super.init(c);

    // Instantiate JungDisplay
    jDisplay = new JungDisplay(this);
    jDisplay.frame.setTitle("Preferential attachment graph");
    c.registerFrame(jDisplay.frame);
    jDisplay.frame.setVisible(true);

    // Instantiate histogram
    degreesChart = new HistogramGenerator();
    degreesChart.setTitle("Degree Histogram");
    degreesChart.addSeries(
        this.degrees, ((PreferentialAttachment) state).maxDegree, "Degree histogram", null);
    degreesChart.update();
    degreesFrame = degreesChart.createFrame(this);
    degreesFrame.getContentPane().setLayout(new BorderLayout());
    degreesFrame.getContentPane().add(degreesChart, BorderLayout.CENTER);
    degreesFrame.pack();
    c.registerFrame(degreesFrame);
  }
示例#5
0
  public void init(final Controller c) {
    super.init(c);

    // make the displayer
    display =
        new Display2D(448, 560, this) {
          public void createConsoleMenu() {}

          public void quit() {
            super.quit();
            ((SimpleController) c).doClose();
          }
        };

    display.setBackdrop(Color.black);

    displayFrame = display.createFrame();
    displayFrame.setTitle("MASON Pac Man");
    c.registerFrame(displayFrame); // register the frame so it appears in the "Display" list
    displayFrame.setVisible(true);

    // Notice the order: first the background, then the dots, then the agents, then the overlay
    display.attach(mazePortrayal, "Maze");
    // display.attach( background, "Background");
    display.attach(dotPortrayal, "Dots", 8, 8, true);
    display.attach(agentPortrayal, "Agents", 8, 8, true);
    display.attach(new Overlay(this), "Overlay");

    // Some stuff to make this feel less like MASON
    // delete the header
    display.remove(display.header);
    // delete all listeners
    display.removeListeners();
    // delete the scroll bars
    display.display.setVerticalScrollBarPolicy(display.display.VERTICAL_SCROLLBAR_NEVER);
    display.display.setHorizontalScrollBarPolicy(display.display.HORIZONTAL_SCROLLBAR_NEVER);
    // when we close the window, the application quits
    displayFrame.setDefaultCloseOperation(javax.swing.JFrame.DISPOSE_ON_CLOSE);
    // can't resize
    displayFrame.setResizable(false);
    // add antialiasing and interpolation
    display.insideDisplay.setupHints(true, false, false);

    // the window won't be the right size now -- modify it.
    displayFrame.pack();

    // Now we add in the listeners we want
    addListeners(display);
  }