Class FeedbackControl
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 Summary
ConstructorsConstructorDescriptionFeedbackControl(IContainer container) Creates a feedback controller for the specified container. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFeedbackProvider(IFeedbackProvider provider) Adds a feedback provider to this controller.voidremoveFeedbackProvider(IFeedbackProvider provider) Removes a feedback provider from this controller.voidupdateFeedback(MouseEvent mouseEvent, Point2D.Double wp, boolean dragging) Updates the feedback in response to a mouse movement.
-
Constructor Details
-
FeedbackControl
Creates a feedback controller for the specified container.- Parameters:
container- theIContainerwhose feedback is being managed; must not benull
-
-
Method Details
-
addFeedbackProvider
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 benull
-
removeFeedbackProvider
Removes a feedback provider from this controller.This method is intentionally a safe no-op in all cases where the provider cannot be present:
- If
providerisnull, the call is ignored. - If no listener list has been created yet (i.e.
addFeedbackProvider(edu.cnu.mdi.feedback.IFeedbackProvider)was never called on this instance), the provider cannot be registered, so there is nothing to remove and the call returns silently.
The silent no-op on a
nulllistener list is deliberate. The primary caller for removal isAItem.prepareForRemoval(), which is invoked whenever an item is deleted from a layer. Items self-register in their constructor viaaddFeedbackProvider(IFeedbackProvider), but only if the container's view has calledinitFeedback()to create a listener list in the first place. IfinitFeedback()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 ifnull
- If
-
updateFeedback
Updates the feedback in response to a mouse movement.The controller:
- Skips processing entirely if the Control key is held down.
- Requests fresh feedback strings from all providers.
- Compares the new strings with the previous set; if unchanged, no update is performed.
- If changed and a
FeedbackPaneis attached to the container, updates the pane.
- Parameters:
mouseEvent- the mouse event, used for the screen location and modifier-state checkswp- the corresponding world-space point for the mouse locationdragging-trueif the mouse is currently being dragged; currently not used in the logic but reserved for possible future policy changes
-