Class NotificationManager
Notifications, i.e. displays them on screen.
Don't use this class directly, but use Notification.show().
If multiple messages are sent in a short period of time, they are put in a queue and displayed one after the other.
The user can stop the timer (freeze the message) by moving the mouse cursor above the panel. As a visual cue, the background color changes from semi-transparent to opaque while the timer is frozen.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) classprivate static classprivate final classstatic classA panel with rounded edges and line border.private final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ComponentListenerkeeps the displayed notification aligned when the layout around it changes, e.g.private Notificationprivate longprivate longprivate final Timerprivate static NotificationManagerprivate final MapFrameListenerbrings the displayed notification over to the map view as soon as one is opened, and back when it is closedprivate static final intmargin between the notification panel and the borders of its anchor, in unscaled pixelsprivate Componentthe componentcurrentNotificationPanelis aligned to,nullwhile nothing is displayedprivate static final Colorprivate static final Colorprivate static final IntegerPropertyprivate final Timerprivate final Deque<Notification>private booleanprivate final HierarchyListenerrealigns the displayed notification when toggling fullscreen, before the window is painted with it at its old positionprivate final Timer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidStops listening to the anchor of the notification that is no longer displayed.static NotificationManager(package private) static PointgetNotificationPosition(Component anchor, Container container, Dimension size, int margin) Computes the position of a notification panel in the coordinate system ofcontainer, which unlike the one of the main window does not depend on the window decorations, i.e.private voidDisplays the next queued notification, unless one is being displayed already or the queue is empty.(package private) voidreplaceExistingNotification(Notification oldNotification, Notification newNotification) Show the given notification by replacing the given queued/displaying notification(package private) voidshowNotification(Notification note) Show the given notification (unless a duplicate notification is being shown at the moment or is already queued)private voidprivate voidstopHideTimer(Notification expected) Hides the displayed notification and starts the pause before the next one.private voidAligns the displayed notification to the map view, or to the content pane while no map view is displayed, and keeps listening to that anchor for as long as the notification is displayed.
-
Field Details
-
hideTimer
-
pauseTimer
-
unfreezeDelayTimer
-
running
-
currentNotification
-
currentNotificationPanel
-
notificationAnchor
the componentcurrentNotificationPanelis aligned to,nullwhile nothing is displayed -
anchorListener
keeps the displayed notification aligned when the layout around it changes, e.g. in fullscreen mode -
showingListener
realigns the displayed notification when toggling fullscreen, before the window is painted with it at its old position -
mapFrameListener
brings the displayed notification over to the map view as soon as one is opened, and back when it is closed -
queue
-
pauseTime
-
displayTimeStart
-
elapsedTime
-
instance
-
MARGIN
margin between the notification panel and the borders of its anchor, in unscaled pixels- See Also:
-
PANEL_SEMITRANSPARENT
-
PANEL_OPAQUE
-
-
Constructor Details
-
NotificationManager
-
-
Method Details
-
showNotification
Show the given notification (unless a duplicate notification is being shown at the moment or is already queued)- Parameters:
note- The note to show.- See Also:
-
replaceExistingNotification
Show the given notification by replacing the given queued/displaying notification- Parameters:
oldNotification- the notification to replacenewNotification- the notification to show
-
processQueue
Displays the next queued notification, unless one is being displayed already or the queue is empty.Only the state transition is guarded by the monitor of
queue. The rest waits for the EDT, and the EDT takes that very monitor as well, so holding it any longer would deadlock every caller that is not the EDT itself. -
updateNotificationPosition
Aligns the displayed notification to the map view, or to the content pane while no map view is displayed, and keeps listening to that anchor for as long as the notification is displayed. -
detachAnchorListener
Stops listening to the anchor of the notification that is no longer displayed. -
getNotificationPosition
static Point getNotificationPosition(Component anchor, Container container, Dimension size, int margin) Computes the position of a notification panel in the coordinate system ofcontainer, which unlike the one of the main window does not depend on the window decorations, i.e. on fullscreen mode.The panel is aligned to the bottom left corner of
anchor, or to its top left corner if it is taller, so that the beginning of a long message stays readable.- Parameters:
anchor- the component the notification is aligned to, e.g. the map viewcontainer- the container the notification panel is added tosize- the size of the notification panelmargin- the margin to keep between the notification panel and the borders ofanchor- Returns:
- the location of the upper left corner of the notification panel
-
startHideTimer
-
stopHideTimer
Hides the displayed notification and starts the pause before the next one.- Parameters:
expected- the notification to hide, ornullfor whichever is displayed. Nothing happens if another notification is displayed by now.
-
getInstance
-