Beispiel #1
0
 public void keyTyped(KeyEvent e) {
   for (int i = 0; i < rootCrowd.getKeyboardActionList().size(); i++) {
     if (rootCrowd.getKeyboardActionList().get(i).isFocused()) {
       if (rootCrowd.getKeyboardActionList().get(i).kP(e)) return;
     }
   }
 }
Beispiel #2
0
  public void mouseReleased(MouseEvent e) {

    Point mousePosition = new Point(MouseInfo.getPointerInfo().getLocation());
    SwingUtilities.convertPointFromScreen(mousePosition, this);

    // Mouse 1
    if (e.getButton() == MouseEvent.BUTTON1) {
      L_MOUSE_DOWN = false;
      for (int i = 0; i < rootCrowd.getMouseActionList().size(); i++) {
        // if the mouse click is in the hitbox then peform the action
        if (rootCrowd.getMouseActionList().get(i).isActive()
            && rootCrowd.getMouseActionList().get(i).isInBounds(mousePosition.x, mousePosition.y)) {
          if (rootCrowd.getMouseActionList().get(i).mU(mousePosition, e)) return;
        }
      }
    }
    // Mouse 2, BUTTON2 is middle mouse
    else if (e.getButton() == MouseEvent.BUTTON3) {
      for (int i = 0; i < rootCrowd.getMouseActionList().size(); i++) {
        // if the mouse click is in the hitbox then peform the action
        if (rootCrowd.getMouseActionList().get(i).isActive()
            && rootCrowd.getMouseActionList().get(i).isInBounds(mousePosition.x, mousePosition.y)) {
          if (rootCrowd.getMouseActionList().get(i).rMU(mousePosition, e)) return;
        }
      }
    }
  }
Beispiel #3
0
  public void mouseEntered() {
    try {
      loadedMutex.acquire();
      if (rootCrowdLoaded) {
        Point mousePosition = new Point(MouseInfo.getPointerInfo().getLocation());
        SwingUtilities.convertPointFromScreen(mousePosition, this);

        for (int i = 0; i < rootCrowd.getMouseActionList().size(); i++) {
          // if the mouse click is in the hitbox then peform the action
          if (rootCrowd.getMouseActionList().get(i).isActive()
              && rootCrowd
                  .getMouseActionList()
                  .get(i)
                  .isInBounds(mousePosition.x, mousePosition.y)) {
            rootCrowd.getMouseActionList().get(i).mI(mousePosition);
          } else if (rootCrowd.getMouseActionList().get(i).isActive()
              && !rootCrowd
                  .getMouseActionList()
                  .get(i)
                  .isInBounds(mousePosition.x, mousePosition.y)) {
            rootCrowd.getMouseActionList().get(i).mO(mousePosition);
          }
        }
      }
      loadedMutex.release();
    } catch (InterruptedException ie) {
      System.err.println("interrupedMouseEnter");
      Thread.currentThread().interrupt();
    }
  }
Beispiel #4
0
  public void paint(Graphics g) {

    dBuffer = (Graphics2D) bufferS.getDrawGraphics();

    // Draw background
    dBuffer.setColor(backgroundColour);
    dBuffer.fillRect(0, 0, resolution[0], resolution[1]);

    dBuffer.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    dBuffer.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

    // If lists are loaded then draw to buffer
    if (rootCrowdLoaded) {
      draw(rootCrowd.getDisplayList());
    } else {
      drawLoading();
    }
    // Display strategy
    bufferS.show();

    g.dispose();
    dBuffer.dispose();
  }
Beispiel #5
0
 public void drawCrowd(Crowd crowd) {
   draw(crowd.getDisplayList());
 }