public HexPanelListener() {
   /*
    * Set this object as the listener
    * for the hex panel for
    * *both* types of Mouse Listener
    */
   Controller.getHexPanel().addMouseMotionListener(this);
   Controller.getHexPanel().addMouseListener(this);
 }
Example #2
0
 /**
  * Clear the error message and close the window. This can be called from outside this class. It is
  * called automatically when the user clicks the OK button or close box of the window that
  * displays the error message.
  */
 public synchronized void clearErrorMessage() {
   if (popup == null) return;
   popup.dispose();
   errorMessage = null;
   if (errorSource != null) errorSource.errorCleared();
   errorSource = null;
   popup = null;
 }
Example #3
0
  /**
   * Create a new board
   *
   * @param c
   */
  public Board(Game c) {
    // add leap motion controller
    leapAdapter = new SensorAdapter(c);
    sensorListener = new SensorListener(leapAdapter);
    shootListener = new ShootListener(leapAdapter);
    leapController = new Controller();
    leapController.addListener(sensorListener);
    leapController.addListener(shootListener);

    addKeyListener(new KeyboardAdapter(c, this));

    this.menu = new Menu(this, c);
    setFocusable(true);
    setDoubleBuffered(true);
    this.c = c;
    c.setPlayer(ItemFactory.createPlayer());
    c.setBackground(ItemFactory.createBackground());
  }
  public RotatableCanvas(Object parent, AlignViewport av, Controller c, Vector points, int npoint) {
    this.parent = parent;
    this.points = points;
    this.npoint = npoint;
    this.controller = c;
    this.av = av;

    controller.addListener(this);

    prefsize = getPreferredSize();
    orig = new float[npoint][3];

    for (int i = 0; i < npoint; i++) {
      SequencePoint sp = (SequencePoint) points.elementAt(i);
      for (int j = 0; j < 3; j++) {
        orig[i][j] = sp.coord[j];
      }
    }
    // Initialize the matrices to identity

    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (i != j) {
          idmat.addElement(i, j, 0);
          objmat.addElement(i, j, 0);
          rotmat.addElement(i, j, 0);
        } else {
          idmat.addElement(i, j, 0);
          objmat.addElement(i, j, 0);
          rotmat.addElement(i, j, 0);
        }
      }
    }

    axes = new float[3][3];
    initAxes();

    findCentre();
    findWidth();

    scale = findScale();

    //    System.out.println("Scale factor = " + scale);

    addMouseListener(this);
    addKeyListener(this);
    if (getParent() != null) {
      getParent().addKeyListener(this);
    }
    addMouseMotionListener(this);

    // Add rubberband
    rubberband = new RubberbandRectangle(this);
    rubberband.setActive(true);
    rubberband.addListener(this);
  }
Example #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);
  }
 /** Deal with mouseReleased (mouse up) events on the HexPanel. */
 public void mouseReleased(final MouseEvent e) {
   Controller.hexPanelMouseReleased(e);
 }
 /** Defines the procedure for dragging a mouse button across the HexPanel */
 public void mouseDragged(final MouseEvent e) {
   Controller.hexPanelMouseDragged(e);
 }
 private void fireSequenceSelectionEvent(Selection sel) {
   controller.handleSequenceSelectionEvent(new SequenceSelectionEvent(this, sel));
 }
 public void removeNotify() {
   controller.removeListener(this);
   super.removeNotify();
 }