public class DesktopNotify
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DEBUG |
static int |
DEFAULT |
protected static int |
defTextOrientation |
static int |
ERROR |
static int |
FAIL |
static int |
HELP |
static int |
INFORMATION |
static int |
INPUT_REQUEST |
static int |
LEFT_TO_RIGHT |
static int |
NONE |
static int |
RIGHT_TO_LEFT |
static int |
SUCCESS |
static int |
TIP |
static int |
WARNING |
Modifier | Constructor and Description |
---|---|
protected |
DesktopNotify(java.lang.String title,
java.lang.String message,
int type,
int orientation,
java.awt.Image icon)
A protected constructor for a DesktopNotify object, called internally.
|
Modifier and Type | Method and Description |
---|---|
protected long |
expTime() |
java.awt.event.ActionListener |
getAction() |
static int |
getDefaultTextOrientation()
Gets the current default text orientation.
|
static NotifyTheme |
getDefaultTheme()
Gets the theme currently in use when creating notifications.
|
static int |
getLogLevel()
Returns the level allowed for logging messages.
|
NotifyTheme |
getTheme() |
void |
hide()
Hides this notification immediately if it is already being displayed.
|
boolean |
isVisible() |
static void |
logDebug(java.lang.String tag,
java.lang.String message)
Logs a debug message.
|
static void |
logError(java.lang.String tag,
java.lang.String message,
java.lang.Throwable tr)
Logs an error message.
|
static void |
logInfo(java.lang.String tag,
java.lang.String message)
Logs an information message.
|
static void |
logWarning(java.lang.String tag,
java.lang.String message)
Logs a warning message.
|
void |
render(int x,
int y,
boolean hover,
java.awt.Graphics2D rd,
long l)
The painting routine for the notification goes here.
|
void |
setAction(java.awt.event.ActionListener action)
Allows to bind an action to this notification.
|
static void |
setDefaultTextOrientation(int defTextOrientation)
Sets the default text orientation to use for new notifications.
|
static void |
setDefaultTheme(NotifyTheme theme)
Sets the theme to use by default when creating notifications.
|
static void |
setLogLevel(int level)
Allows to specify the level allowed for logging messages.
|
static void |
setLogOutput(java.io.OutputStream outStream) |
void |
setTheme(NotifyTheme theme)
Allows to set a
NotifyTheme for this notification. |
void |
setTimeout(long millis)
Allows to set a timeout for this notification, in milliseconds.
|
protected void |
setVisible(boolean visible)
Used by he driver to mark this notification as visible or not.
|
protected void |
setWidth(int w) |
void |
show()
Polls the Driver in order to show this notification, so you don't have to
do it yourself.
|
static void |
showDesktopMessage(java.lang.String title,
java.lang.String message)
Creates and shows a new notification.
|
static void |
showDesktopMessage(java.lang.String title,
java.lang.String message,
int type)
Creates and shows a new notification.
|
static void |
showDesktopMessage(java.lang.String title,
java.lang.String message,
int type,
java.awt.event.ActionListener action)
Creates and shows a new notification.
|
static void |
showDesktopMessage(java.lang.String title,
java.lang.String message,
int type,
java.awt.Image icon)
Creates and shows a new notification.
|
static void |
showDesktopMessage(java.lang.String title,
java.lang.String message,
int type,
java.awt.Image icon,
java.awt.event.ActionListener action)
Creates and shows a new notification.
|
static void |
showDesktopMessage(java.lang.String title,
java.lang.String message,
int type,
java.awt.Image icon,
java.awt.event.ActionListener action,
long maxTimeMillis)
Creates and shows a new notification.
|
static void |
showDesktopMessage(java.lang.String title,
java.lang.String message,
int type,
long maxTimeMillis)
Creates and shows a new notification.
|
static void |
showDesktopMessage(java.lang.String title,
java.lang.String message,
int type,
long maxTimeMillis,
java.awt.event.ActionListener action)
Creates and shows a new notification.
|
protected void |
sortMessage()
Splits the words of the text across lines that fit inside the
notification.
|
public static final int DEFAULT
public static final int INFORMATION
public static final int WARNING
public static final int ERROR
public static final int HELP
public static final int TIP
public static final int INPUT_REQUEST
public static final int SUCCESS
public static final int FAIL
public static final int LEFT_TO_RIGHT
public static final int RIGHT_TO_LEFT
protected static int defTextOrientation
public static final int DEBUG
public static final int NONE
protected DesktopNotify(java.lang.String title, java.lang.String message, int type, int orientation, java.awt.Image icon)
showDesktopMessage()
static methods
or a NotificationBuilder
in order to create and display a
notification instead.title
- The notification title. Can be null
when the
notification isn't meant to have one.message
- The notification message. Can be null
when
the notification isn't meant to have one.orientation
- The text orientation, either LEFT_TO_RIGHT
or
RIGHT_TO_LEFT
.type
- The notification type. Check the type contans in the
class for the ones you can use.icon
- The icon to display. Can be null
when the
notification isn't meant to have one.public static void setDefaultTheme(NotifyTheme theme)
theme
- The theme to use.public static NotifyTheme getDefaultTheme()
public static int getDefaultTextOrientation()
RIGHT_TO_LEFT
,
LEFT_TO_RIGHT
public static void setDefaultTextOrientation(int defTextOrientation)
defTextOrientation
- The new text orientation.RIGHT_TO_LEFT
,
LEFT_TO_RIGHT
public static void showDesktopMessage(java.lang.String title, java.lang.String message)
title
- The title, if any.message
- The message, if any.public static void showDesktopMessage(java.lang.String title, java.lang.String message, int type)
title
- The title, if any.message
- The message, if any.type
- An int that denotes a valid message type. Invalid
values will be treated as DEFAULT.public static void showDesktopMessage(java.lang.String title, java.lang.String message, int type, java.awt.event.ActionListener action)
title
- The title, if any.message
- The message, if any.type
- An int that denotes a valid message type. Invalid
values will be treated as DEFAULT.action
- An ActionListener with the action to execute when
the user clicks the notification.public static void showDesktopMessage(java.lang.String title, java.lang.String message, int type, java.awt.Image icon, java.awt.event.ActionListener action)
title
- The title, if any.message
- The message, if any.type
- An int that denotes a valid message type. Invalid
values will be treated as DEFAULT.icon
- A custom Image to use instead of the default icon
assigned by type.action
- An ActionListener with the action to execute when
the user clicks the notification.public static void showDesktopMessage(java.lang.String title, java.lang.String message, int type, long maxTimeMillis)
title
- The title, if any.message
- The message, if any.type
- An int that denotes a valid message type. Invalid
values will be treated as DEFAULT.maxTimeMillis
- The maximum time in milliseconds that this
notification will stay on the screen. If set to 0,
the user will have to close it manually by clicking
it.public static void showDesktopMessage(java.lang.String title, java.lang.String message, int type, long maxTimeMillis, java.awt.event.ActionListener action)
title
- The title, if any.message
- The message, if any.type
- An int that denotes a valid message type. Invalid
values will be treated as DEFAULT.maxTimeMillis
- The maximum time in milliseconds that this
notification will stay on the screen. If set to 0,
the user will have to close it manually by clicking
it. Such value is recommended if you want to add an
action for it.action
- An ActionListener with the action to execute when
the user clicks the notification.public static void showDesktopMessage(java.lang.String title, java.lang.String message, int type, java.awt.Image icon)
title
- The title, if any.message
- The message, if any.type
- An int that denotes a valid message type. Invalid
values will be treated as DEFAULT.icon
- A custom Image to use instead of the default icon
assigned by type.public static void showDesktopMessage(java.lang.String title, java.lang.String message, int type, java.awt.Image icon, java.awt.event.ActionListener action, long maxTimeMillis)
title
- The title, if any.message
- The message, if any.type
- An int that denotes a valid message type. Invalid
values will be treated as DEFAULT.icon
- A custom Image to use instead of the default icon
assigned by type.maxTimeMillis
- The maximum time in milliseconds that this
notification will stay on the screen. If set to 0,
the user will have to close it manually by clicking
it. Such value recommended if you want to add an
action for it.action
- An ActionListener with the action to execute if
the user clicks the notification.public NotifyTheme getTheme()
NotifyTheme
in use for this notification.public void setTheme(NotifyTheme theme)
NotifyTheme
for this notification. One of
these defines stuff as the colors for text and background, the fonts and
even images for the default icons.theme
- The NotifyTheme
to use for this notification.public java.awt.event.ActionListener getAction()
public void setAction(java.awt.event.ActionListener action)
action
- he ActionListener to bind to this notification.public void setTimeout(long millis)
millis
- the timeout.protected long expTime()
public void show()
public void hide()
protected void setWidth(int w)
public boolean isVisible()
true
if this notification is currently being shown.protected void setVisible(boolean visible)
visible
- true
if the notification is currently visible.public void render(int x, int y, boolean hover, java.awt.Graphics2D rd, long l)
x
- Where to start painting (X)y
- Where to start painting (Y)hover
- A boolean that is true
if the user is hovering
this notification with the mouse pointer.rd
- The Graphics2D
object to use for painting.l
- The current time.protected void sortMessage()
DesktopNotifyDriver
.public static void setLogLevel(int level)
level
- The logging priority level to allow as minimum.public static int getLogLevel()
public static void setLogOutput(java.io.OutputStream outStream)
public static void logDebug(java.lang.String tag, java.lang.String message)
null
.tag
- The tag associated to this message.message
- The message to include.public static void logInfo(java.lang.String tag, java.lang.String message)
null
.tag
- The tag associated to this message.message
- The message to include.public static void logWarning(java.lang.String tag, java.lang.String message)
null
.tag
- The tag associated to this message.message
- The message to include.public static void logError(java.lang.String tag, java.lang.String message, java.lang.Throwable tr)
null
.tag
- The tag associated to this message.message
- The message to include.tr
- A Throable object (an Exception, for example), whose
message and stack trace should be logged too.