Example #1
0
  public void quit() {
    super.quit();
    display = null;

    if (displayFrame != null) {
      JFrame f = displayFrame;
      displayFrame = null;
      f.dispose();
    }
  }
Example #2
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);
  }
Example #3
0
 public void load(SimState state) {
   super.load(state);
   setupPortrayals();
 }
Example #4
0
 public void start() {
   super.start();
   setupPortrayals();
 }