public class MessageBufferUpdater
extends java.lang.Object
Buffer
instance.Modifier and Type | Field and Description |
---|---|
private Buffer |
buffer
The buffer to update.
|
private static java.lang.String[] |
COLOR_NAMES
The colors names corresponding to
colors . |
private java.awt.Color[] |
colors
Maps color index to color.
|
private CrossfireDrawextinfoListener |
crossfireDrawextinfoListener
The
CrossfireDrawextinfoListener registered to receive
drawextinfo commands. |
private CrossfireDrawinfoListener |
crossfireDrawinfoListener
The
CrossfireDrawinfoListener registered to receive drawinfo
commands. |
private CrossfireQueryListener |
crossfireQueryListener
The
CrossfireQueryListener registered to receive query commands. |
private CrossfireServerConnection |
crossfireServerConnection
The
CrossfireServerConnection to monitor. |
private java.awt.Color |
defaultColor
The color to use for invalid colors indices.
|
static int |
NUM_COLORS
The number of supported colors.
|
private Parser |
parser
The
Parser instance for parsing drawextinfo messages. |
private boolean |
printMessageTypes
Whether message types are included in the buffer output.
|
private int |
types
The types to show.
|
Constructor and Description |
---|
MessageBufferUpdater(CrossfireServerConnection crossfireServerConnection,
Buffer buffer,
java.awt.Color defaultColor)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
private java.lang.CharSequence |
addMessageTypePrefix(int type,
int subtype,
int color,
java.lang.CharSequence message)
Adds a message type prefix to a message if
printMessageTypes is
set. |
void |
dispose()
Releases resources.
|
private java.awt.Color |
findColor(int index)
Converts a Crossfire color index to a
Color instance. |
static java.lang.String |
getColorName(int index)
Returns the name of a color index.
|
private boolean |
isTypeShown(int type)
Returns whether a message type should be shown.
|
void |
setColor(int index,
java.awt.Color color)
Sets a color mapping.
|
void |
setTypes(int types)
Sets the message types to show.
|
@NotNull private final Buffer buffer
@NotNull private static final java.lang.String[] COLOR_NAMES
colors
.@NotNull private final java.awt.Color[] colors
@NotNull private final CrossfireDrawextinfoListener crossfireDrawextinfoListener
CrossfireDrawextinfoListener
registered to receive
drawextinfo commands.@NotNull private final CrossfireDrawinfoListener crossfireDrawinfoListener
CrossfireDrawinfoListener
registered to receive drawinfo
commands.@NotNull private final CrossfireQueryListener crossfireQueryListener
CrossfireQueryListener
registered to receive query commands.@NotNull private final CrossfireServerConnection crossfireServerConnection
CrossfireServerConnection
to monitor.@NotNull private final java.awt.Color defaultColor
public static final int NUM_COLORS
private boolean printMessageTypes
private int types
public MessageBufferUpdater(@NotNull CrossfireServerConnection crossfireServerConnection, @NotNull Buffer buffer, @NotNull java.awt.Color defaultColor)
crossfireServerConnection
- the connection instancebuffer
- the buffer to updatedefaultColor
- the default color to use for undefined colors
indicesprivate java.lang.CharSequence addMessageTypePrefix(int type, int subtype, int color, @NotNull java.lang.CharSequence message)
printMessageTypes
is
set.type
- the message typesubtype
- the message subtypecolor
- the message colormessage
- the messagepublic void dispose()
@NotNull private java.awt.Color findColor(int index)
Color
instance.index
- the color index to look up@NotNull public static java.lang.String getColorName(int index)
index
- the color indexprivate boolean isTypeShown(int type)
type
- the message typepublic void setColor(int index, @NotNull java.awt.Color color)
index
- the color index to changecolor
- the color to map topublic void setTypes(int types)
types
- the types to show