Package ch.swingfx.twinkle
Class NotificationBuilder
- java.lang.Object
-
- ch.swingfx.twinkle.NotificationBuilder
-
public class NotificationBuilder extends java.lang.Object
This class lets you build a notification window.
-
-
Field Summary
Fields Modifier and Type Field Description private static int
ANIMATION_FADE_IN_DURATION
Duration of the fade in animation in millisecondsprivate static int
ANIMATION_FADE_IN_START_DELAY
delay before we start the fade in animation because of flickering on some systems/jres.private static int
ANIMATION_FADE_OUT_DURATION
Duration of the fade out animation in millisecondsprivate static int
DEFAULT_DISPLAY_TIME_IN_MILLIS
The default display time for a notification in millisecondsprivate int
fDisplayTime
Time in millis we want to display the notificationprivate boolean
fFadeIn
Flag that tells us if we should fade in the notificationprivate boolean
fFadeOut
Flag that tells us if we should fade out the notificationprivate javax.swing.Icon
fIcon
The Icon we want to displayprivate java.util.UUID
fId
id of thisNotificationBuilder
.private INotificationManager
fManager
The manager that shows the notificationsprivate java.lang.String
fMessage
The message we want to displayprivate INotificationEventListener
fNotificationListener
Listener that receives notification eventsprivate IPosition
fPosition
Position of the notificationprivate INotificationStyle
fStyle
styling for our windowprivate java.lang.String
fTitle
The title we want to displayprivate boolean
fWindowClosed
Flag that tells us if the window is closed or notprivate static java.awt.GraphicsDevice
sMainScreen
private static java.awt.GraphicsConfiguration
sMainScreenGraphicsConfiguration
private static java.awt.Insets
sMainScreenInsets
Insets of menu/task barsprivate static java.awt.Dimension
sMainScreenSize
The size of the main screen including all the menu/task barsprivate static java.awt.Toolkit
sToolkit
private static ch.swingfx.window.translucentandshaped.ITranslucentAndShapedWindowApi
sWindowApi
api for Translucent and Shaped Windowsprivate static int
version
version of the library
-
Constructor Summary
Constructors Constructor Description NotificationBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
closeWindow(javax.swing.JWindow window)
Closes the windowINotificationStyle
getStyle()
Get theINotificationStyle
of this notificationjava.util.UUID
showNotification()
shows the notificationprivate void
showNotificationEDT()
NotificationBuilder
withDisplayTime(int timeInMillis)
set the time the notification should be displayedNotificationBuilder
withFadeInAnimation(boolean animate)
set true if you want to fade in the notification.
Note fade in is not supported on all platform.NotificationBuilder
withFadeOutAnimation(boolean animate)
set true if you want to fade out the notification.
Note fade out is not supported on all platform.NotificationBuilder
withIcon(java.lang.String iconPath)
set the icon of the notificationNotificationBuilder
withIcon(javax.swing.Icon icon)
set the icon of the notificationNotificationBuilder
withListener(INotificationEventListener listener)
Sets aINotificationEventListener
for receiving events from the notificationNotificationBuilder
withMessage(java.lang.String message)
set the message of the notificationNotificationBuilder
withNotificationManager(INotificationManager manager)
Set theINotificationManager
that handles how the notification are displayedNotificationBuilder
withPosition(IPosition position)
Set the position of the notificationNotificationBuilder
withStyle(INotificationStyle style)
set the style of the notificationNotificationBuilder
withTitle(java.lang.String title)
set the title of the notification
-
-
-
Field Detail
-
version
private static final int version
version of the library- See Also:
- Constant Field Values
-
ANIMATION_FADE_IN_DURATION
private static final int ANIMATION_FADE_IN_DURATION
Duration of the fade in animation in milliseconds- See Also:
- Constant Field Values
-
ANIMATION_FADE_OUT_DURATION
private static final int ANIMATION_FADE_OUT_DURATION
Duration of the fade out animation in milliseconds- See Also:
- Constant Field Values
-
ANIMATION_FADE_IN_START_DELAY
private static final int ANIMATION_FADE_IN_START_DELAY
delay before we start the fade in animation because of flickering on some systems/jres.- See Also:
- Constant Field Values
-
DEFAULT_DISPLAY_TIME_IN_MILLIS
private static final int DEFAULT_DISPLAY_TIME_IN_MILLIS
The default display time for a notification in milliseconds- See Also:
- Constant Field Values
-
fId
private final java.util.UUID fId
id of thisNotificationBuilder
. Sent inNotificationEvent
-
fIcon
private javax.swing.Icon fIcon
The Icon we want to display
-
fTitle
private java.lang.String fTitle
The title we want to display
-
fMessage
private java.lang.String fMessage
The message we want to display
-
fDisplayTime
private int fDisplayTime
Time in millis we want to display the notification
-
fNotificationListener
private INotificationEventListener fNotificationListener
Listener that receives notification events
-
fStyle
private INotificationStyle fStyle
styling for our window
-
fPosition
private IPosition fPosition
Position of the notification
-
fFadeIn
private boolean fFadeIn
Flag that tells us if we should fade in the notification
-
fFadeOut
private boolean fFadeOut
Flag that tells us if we should fade out the notification
-
fWindowClosed
private boolean fWindowClosed
Flag that tells us if the window is closed or not
-
fManager
private INotificationManager fManager
The manager that shows the notifications
-
sWindowApi
private static final ch.swingfx.window.translucentandshaped.ITranslucentAndShapedWindowApi sWindowApi
api for Translucent and Shaped Windows
-
sMainScreen
private static final java.awt.GraphicsDevice sMainScreen
-
sMainScreenGraphicsConfiguration
private static final java.awt.GraphicsConfiguration sMainScreenGraphicsConfiguration
-
sMainScreenSize
private static final java.awt.Dimension sMainScreenSize
The size of the main screen including all the menu/task bars
-
sMainScreenInsets
private static java.awt.Insets sMainScreenInsets
Insets of menu/task bars
-
sToolkit
private static final java.awt.Toolkit sToolkit
-
-
Method Detail
-
withStyle
public NotificationBuilder withStyle(INotificationStyle style)
set the style of the notification- Parameters:
style
- the style of the notification- Returns:
- this
NotificationBuilder
-
withIcon
public NotificationBuilder withIcon(java.lang.String iconPath)
set the icon of the notification- Parameters:
iconPath
- path to the icon- Returns:
- this
NotificationBuilder
-
withIcon
public NotificationBuilder withIcon(javax.swing.Icon icon)
set the icon of the notification- Parameters:
icon
- the icon- Returns:
- this
NotificationBuilder
-
withTitle
public NotificationBuilder withTitle(java.lang.String title)
set the title of the notification- Parameters:
title
- the title- Returns:
- this
NotificationBuilder
-
withMessage
public NotificationBuilder withMessage(java.lang.String message)
set the message of the notification- Parameters:
message
- the message- Returns:
- this
NotificationBuilder
-
withDisplayTime
public NotificationBuilder withDisplayTime(int timeInMillis)
set the time the notification should be displayed- Parameters:
timeInMillis
- time in milliseconds. minimum 1000- Returns:
- this
NotificationBuilder
-
withPosition
public NotificationBuilder withPosition(IPosition position)
Set the position of the notification- Parameters:
position
- position of the notification- Returns:
- this
NotificationBuilder
-
withFadeInAnimation
public NotificationBuilder withFadeInAnimation(boolean animate)
set true if you want to fade in the notification.
Note fade in is not supported on all platform. If it doesn't work on a platform it will use no animation.- Parameters:
animate
- true if you want to fade in the notification- Returns:
- this
NotificationBuilder
-
withFadeOutAnimation
public NotificationBuilder withFadeOutAnimation(boolean animate)
set true if you want to fade out the notification.
Note fade out is not supported on all platform. If it doesn't work on a platform it will use no animation.- Parameters:
animate
- true if you want to fade in the notification- Returns:
- this
NotificationBuilder
-
withListener
public NotificationBuilder withListener(INotificationEventListener listener)
Sets aINotificationEventListener
for receiving events from the notification- Parameters:
listener
- listener to add- Returns:
- this
NotificationBuilder
-
withNotificationManager
public NotificationBuilder withNotificationManager(INotificationManager manager)
Set theINotificationManager
that handles how the notification are displayed- Parameters:
manager
-INotificationManager
to use- Returns:
- this
NotificationBuilder
-
getStyle
public INotificationStyle getStyle()
Get theINotificationStyle
of this notification- Returns:
- the
INotificationStyle
of this notification
-
showNotification
public java.util.UUID showNotification()
shows the notification- Returns:
- Unique identifier for this notification. Call NotificationEvent.getId() to retrieve this id
-
showNotificationEDT
private void showNotificationEDT()
-
closeWindow
private void closeWindow(javax.swing.JWindow window)
Closes the window- Parameters:
window
- the window to close
-
-