com.realtime.crossfire.jxclient.gui.log
Class MessageBufferUpdater

java.lang.Object
  extended by com.realtime.crossfire.jxclient.gui.log.MessageBufferUpdater

public class MessageBufferUpdater
extends java.lang.Object

Adds drawinfo, drawextinfo, and query messages to a Buffer instance.


Field Summary
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 Summary
MessageBufferUpdater(CrossfireServerConnection crossfireServerConnection, Buffer buffer, java.awt.Color defaultColor)
          Creates a new instance.
 
Method Summary
private  java.lang.CharSequence addMessageTypePrefix(int type, int subtype, java.lang.String 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

@NotNull
private final Buffer buffer
The buffer to update.


COLOR_NAMES

@NotNull
private static final java.lang.String[] COLOR_NAMES
The colors names corresponding to colors.


colors

@NotNull
private final java.awt.Color[] colors
Maps color index to color.


crossfireDrawextinfoListener

@NotNull
private final CrossfireDrawextinfoListener crossfireDrawextinfoListener
The CrossfireDrawextinfoListener registered to receive drawextinfo commands.


crossfireDrawinfoListener

@NotNull
private final CrossfireDrawinfoListener crossfireDrawinfoListener
The CrossfireDrawinfoListener registered to receive drawinfo commands.


crossfireQueryListener

@NotNull
private final CrossfireQueryListener crossfireQueryListener
The CrossfireQueryListener registered to receive query commands.


crossfireServerConnection

@NotNull
private final CrossfireServerConnection crossfireServerConnection
The CrossfireServerConnection to monitor.


defaultColor

@NotNull
private final java.awt.Color defaultColor
The color to use for invalid colors indices.


NUM_COLORS

public static final int NUM_COLORS
The number of supported colors.

See Also:
Constant Field Values

parser

@NotNull
private final Parser parser
The Parser instance for parsing drawextinfo messages.


printMessageTypes

private boolean printMessageTypes
Whether message types are included in the buffer output.


types

private int types
The types to show.

Constructor Detail

MessageBufferUpdater

public MessageBufferUpdater(@NotNull
                            CrossfireServerConnection crossfireServerConnection,
                            @NotNull
                            Buffer buffer,
                            @NotNull
                            java.awt.Color defaultColor)
Creates a new instance.

Parameters:
crossfireServerConnection - the connection instance
buffer - the buffer to update
defaultColor - the default color to use for undefined colors indices
Method Detail

addMessageTypePrefix

private java.lang.CharSequence addMessageTypePrefix(int type,
                                                    int subtype,
                                                    @NotNull
                                                    java.lang.String message)
Adds a message type prefix to a message if printMessageTypes is set.

Parameters:
type - the message type
subtype - the message subtype
message - the message
Returns:
the message with prefix

dispose

public void dispose()
Releases resources.


findColor

@NotNull
private java.awt.Color findColor(int index)
Converts a Crossfire color index to a Color instance.

Parameters:
index - the color index to look up
Returns:
the color

getColorName

@NotNull
public static java.lang.String getColorName(int index)
Returns the name of a color index.

Parameters:
index - the color index
Returns:
the color name

isTypeShown

private boolean isTypeShown(int type)
Returns whether a message type should be shown.

Parameters:
type - the message type
Returns:
whether the message type should be shown

setColor

public void setColor(int index,
                     @NotNull
                     java.awt.Color color)
Sets a color mapping.

Parameters:
index - the color index to change
color - the color to map to

setTypes

public void setTypes(int types)
Sets the message types to show.

Parameters:
types - the types to show