/**
  * Handles a scroll event by passing it on to the registered handlers.
  *
  * @param e the scroll event.
  */
 protected void handleScroll(ScrollEvent e) {
   if (this.liveHandler != null && this.liveHandler.isEnabled()) {
     this.liveHandler.handleScroll(this, e);
   }
   for (MouseHandlerFX handler : this.auxiliaryMouseHandlers) {
     if (handler.isEnabled()) {
       handler.handleScroll(this, e);
     }
   }
 }
  /**
   * Handles a mouse moved event by passing it on to the registered handlers.
   *
   * @param e the mouse event.
   */
  private void handleMouseMoved(MouseEvent e) {
    if (this.liveHandler != null && this.liveHandler.isEnabled()) {
      this.liveHandler.handleMouseMoved(this, e);
    }

    for (MouseHandlerFX handler : this.auxiliaryMouseHandlers) {
      if (handler.isEnabled()) {
        handler.handleMouseMoved(this, e);
      }
    }
  }
  /**
   * Handles a mouse released event by passing it on to the registered handlers.
   *
   * @param e the mouse event.
   */
  private void handleMouseClicked(MouseEvent e) {
    if (this.liveHandler != null && this.liveHandler.isEnabled()) {
      this.liveHandler.handleMouseClicked(this, e);
    }

    // pass on the event to the auxiliary handlers
    for (MouseHandlerFX handler : this.auxiliaryMouseHandlers) {
      if (handler.isEnabled()) {
        handler.handleMouseClicked(this, e);
      }
    }
  }
 /**
  * Returns the mouse handler with the specified ID, or {@code null} if there is no handler with
  * that ID. This method will look for handlers in both the regular and auxiliary handler lists.
  *
  * @param id the ID ({@code null} not permitted).
  * @return The handler with the specified ID
  */
 public MouseHandlerFX getMouseHandler(String id) {
   for (MouseHandlerFX h : this.availableMouseHandlers) {
     if (h.getID().equals(id)) {
       return h;
     }
   }
   for (MouseHandlerFX h : this.auxiliaryMouseHandlers) {
     if (h.getID().equals(id)) {
       return h;
     }
   }
   return null;
 }
 /**
  * Adds a mouse handler to the list of available handlers (handlers that are candidates to take
  * the position of live handler). The handler must have an ID that uniquely identifies it amongst
  * the handlers registered with this canvas.
  *
  * @param handler the handler ({@code null} not permitted).
  */
 public void addMouseHandler(MouseHandlerFX handler) {
   if (!this.hasUniqueID(handler)) {
     throw new IllegalArgumentException(
         "There is already a handler with that ID (" + handler.getID() + ").");
   }
   this.availableMouseHandlers.add(handler);
 }
 /**
  * Validates that the specified handler has an ID that uniquely identifies it amongst the existing
  * handlers for this canvas.
  *
  * @param handler the handler ({@code null} not permitted).
  * @return A boolean.
  */
 private boolean hasUniqueID(MouseHandlerFX handler) {
   for (MouseHandlerFX h : this.availableMouseHandlers) {
     if (handler.getID().equals(h.getID())) {
       return false;
     }
   }
   for (MouseHandlerFX h : this.auxiliaryMouseHandlers) {
     if (handler.getID().equals(h.getID())) {
       return false;
     }
   }
   return true;
 }
  /**
   * Handles a mouse pressed event by (1) selecting a live handler if one is not already selected,
   * (2) passing the event to the live handler if there is one, and (3) passing the event to all
   * enabled auxiliary handlers.
   *
   * @param e the mouse event.
   */
  private void handleMousePressed(MouseEvent e) {
    if (this.liveHandler == null) {
      for (MouseHandlerFX handler : this.availableMouseHandlers) {
        if (handler.isEnabled() && handler.hasMatchingModifiers(e)) {
          this.liveHandler = handler;
        }
      }
    }

    if (this.liveHandler != null) {
      this.liveHandler.handleMousePressed(this, e);
    }

    // pass on the event to the auxiliary handlers
    for (MouseHandlerFX handler : this.auxiliaryMouseHandlers) {
      if (handler.isEnabled()) {
        handler.handleMousePressed(this, e);
      }
    }
  }