|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectJTP.SplashMessage
public class SplashMessage
Displays various "pop-up" messages. (e.g. level end message) Note: Only the most recently requested message will be displayed.
Field Summary | |
---|---|
static long |
DEFAULT
Default display length. |
static long |
LONG
Long display length. |
static long |
SHORT
Short display length. |
Constructor Summary | |
---|---|
SplashMessage(Font f,
Color bg,
Color txt,
Color bd,
int lineSpacing,
int borderSpacing,
int curvature,
float borderThickness,
ScreenFrames frames,
Images imgData,
Graphics2D g)
Constructs a new SplashMessage instance with the given
attributes. |
Method Summary | |
---|---|
void |
cancel()
Cancels any currently requested messages. |
void |
display(Rectangle drawArea,
Graphics2D g)
Draws the requested message to the screen. |
long |
getDisplayLength()
Returns lenght for which the requested message will be displayed. |
boolean |
hasForcedLength()
Returns whether a particular display length has been set or not. |
static boolean |
isValidMessage(String message)
Checks whether the given message is valid. |
void |
request(boolean p2,
long time)
Requests player start message to be displayed. |
void |
request(int p1Score,
int p2Score,
long time)
Requests player scores to be displayed. |
void |
request(String message)
Requests a text message to be displayed. |
void |
request(String message,
long time)
Requests a text message to be displayed. |
boolean |
requested()
Checks whether a message have been requested. |
protected void |
requestHelp()
Request help message (horribly hardcoded) |
void |
setDisplayLength(long time)
Sets display length for any currently requested message. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long SHORT
public static final long DEFAULT
public static final long LONG
Constructor Detail |
---|
public SplashMessage(Font f, Color bg, Color txt, Color bd, int lineSpacing, int borderSpacing, int curvature, float borderThickness, ScreenFrames frames, Images imgData, Graphics2D g) throws IllegalArgumentException, NullPointerException
SplashMessage
instance with the given
attributes. One instance can be used to display any number of splash
messages.
f
- the font to use for textbg
- background colourtxt
- text colourbd
- border colourlineSpacing
- in pixels between linesborderSpacing
- spacing between text and border (both vertical and
horizontal)curvature
- roundness of edgesborderThickness
- in pixelsframes
- provides access to screen information (e.g. to render in
the middle of the screen)imgData
- images required by some times up splash messageg
- context used to determine text size (one-off)
IllegalArgumentException
- if any of lineSpacing
,
borderSpacing
, borderThickness
or
curvature
are < 0
.
NullPointerException
- if any of f
, bg
or
txt
are null
Method Detail |
---|
public void display(Rectangle drawArea, Graphics2D g)
drawArea
- used to calculate center of screeng
- graphics context for drawingprotected void requestHelp()
public void request(boolean p2, long time) throws IllegalArgumentException
p2
- indicates for which player the message istime
- length in milliseconds to display message for
IllegalArgumentException
- if time < 1
public void request(int p1Score, int p2Score, long time) throws IllegalArgumentException
p1Score
- player one scorep2Score
- player two scoretime
- length in milliseconds to display message for
IllegalArgumentException
- if time < 1
public void request(String message, long time) throws IllegalArgumentException
message
- message to display. If this is null
then
any previous message request is cancelled.time
- length in milliseconds to display message for
IllegalArgumentException
- if time < 1
null
.public static boolean isValidMessage(String message)
message
- the string to check
false
if any of the following is true:
message
is null
message
is zeromessage
only contains whitespace characters:
[\t\n\x0B\f\r]
public void request(String message)
message
- message to display. If this is null
then
any previous message request is cancelled.public void setDisplayLength(long time) throws IllegalArgumentException
time
- length in milliseconds to display message for
IllegalArgumentException
- if time < 1
public boolean hasForcedLength()
true
if message is supposed to be displayed for a
certain length or false
, if this class it to determine the
display length (and it is o.k. to cancel display of said message at any
point).public long getDisplayLength()
public void cancel()
public boolean requested()
true
if a message has been requested
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |