Class FeedbackControl

java.lang.Object
edu.cnu.mdi.feedback.FeedbackControl

public class FeedbackControl extends Object
Controller for managing mouse-over feedback for a given IContainer.

A FeedbackControl instance coordinates a set of IFeedbackProvider listeners. Whenever the mouse moves, each provider is asked to contribute feedback strings based on the current mouse position in both screen and world coordinates. If the set of feedback strings has changed since the last update, the container's FeedbackPane (if any) is updated accordingly.

Feedback is suppressed when the Control key is held down during mouse movement.

  • Constructor Details

    • FeedbackControl

      public FeedbackControl(IContainer container)
      Creates a feedback controller for the specified container.
      Parameters:
      container - the IContainer whose feedback is being managed; must not be null
  • Method Details

    • addFeedbackProvider

      public void addFeedbackProvider(IFeedbackProvider provider)
      Adds a feedback provider to this controller.

      If the provider is already registered, it is first removed so that it is not stored twice.

      Parameters:
      provider - the feedback provider listener to add; must not be null
    • removeFeedbackProvider

      public void removeFeedbackProvider(IFeedbackProvider provider)
      Removes a feedback provider from this controller.

      This method is intentionally a safe no-op in all cases where the provider cannot be present:

      The silent no-op on a null listener list is deliberate. The primary caller for removal is AItem.prepareForRemoval(), which is invoked whenever an item is deleted from a layer. Items self-register in their constructor via addFeedbackProvider(IFeedbackProvider), but only if the container's view has called initFeedback() to create a listener list in the first place. If initFeedback() was never called — which is a normal, legitimate configuration for views that do not display a feedback pane — no listener list ever exists, and the item's removal path must not produce a spurious warning or exception.

      Logging of mismatched add/remove call sites, if desired, should be performed at a higher level where the intended registration state is known.

      Parameters:
      provider - the feedback provider to remove; ignored if null
    • updateFeedback

      public void updateFeedback(MouseEvent mouseEvent, Point2D.Double wp, boolean dragging)
      Updates the feedback in response to a mouse movement.

      The controller:

      1. Skips processing entirely if the Control key is held down.
      2. Requests fresh feedback strings from all providers.
      3. Compares the new strings with the previous set; if unchanged, no update is performed.
      4. If changed and a FeedbackPane is attached to the container, updates the pane.
      Parameters:
      mouseEvent - the mouse event, used for the screen location and modifier-state checks
      wp - the corresponding world-space point for the mouse location
      dragging - true if the mouse is currently being dragged; currently not used in the logic but reserved for possible future policy changes