Ejemplo n.º 1
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;
        }
      }
    }
  }
Ejemplo n.º 2
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();
    }
  }