com.threerings.chat
Class ChatLogic

java.lang.Object
  extended by com.threerings.chat.ChatLogic

public abstract class ChatLogic
extends Object

Contains all of the routines that might (or must) be customized by a system that makes use of the comic chat system.


Field Summary
static int ATTENTION
          Our internal code for attention system messages.
protected static Color ATTENTION_COLOR
           
static int BROADCAST
          Type place code for broadcast chat type.
protected static Color BROADCAST_COLOR
           
static int CONTINUATION
          Our internal code for any type of chat that is continued in a subtitle.
static int DEFAULT_CHAT_DECAY
          The default chat decay parameter.
protected static Font DEFAULT_FONT
          Our default chat font.
protected static long[][] DISPLAY_DURATION_PARAMS
          Times to display chat: { (time per character), (min time), (max time) } Groups 0/1/2 are short/medium/long for chat bubbles, and groups 1/2/3 are short/medium/long for subtitles.
static int EMOTE
          Type mode code for emote chat type.
static int FEEDBACK
          Our internal code for feedback system messages.
protected static Color FEEDBACK_COLOR
           
static int IGNORECHAT
          Our internal code for a chat type we will ignore.
static int INFO
          Our internal code for info system messges.
protected static Color INFO_COLOR
           
static int PAD
          The padding in each direction around the text to the edges of a chat 'bubble'.
static int PLACE
          Type place code for default place chat (cluster, scene).
static int SHOUT
          Type mode code for shout chat type.
static int SPEAK
          Type mode code for default chat type (speaking).
static int SPECIALIZED
          Type code for a chat type that was used in some special context, like in a negotiation.
static int TELL
          Our internal code for tell chat.
protected static Color TELL_COLOR
           
static int TELLFEEDBACK
          Our internal code for tell feedback chat.
protected static Color TELLFEEDBACK_COLOR
           
static int THINK
          Type mode code for think chat type.
 
Constructor Summary
ChatLogic()
           
 
Method Summary
 int adjustTypeByMode(int mode, int type)
          Adjust the chat type based on the mode of the chat message.
 Label createLabel(String text)
          Creates a label for the specified text.
 Tuple<String,Boolean> decodeFormat(int type, String format)
          Determines the format string and whether to use quotes based on the chat type.
 int decodeType(String localtype)
          Decodes the main chat type given the supplied localtype provided by the chat system.
abstract  String getDefaultMessageBundle()
          Returns the message bundle used to translate default messages.
protected  int getDisplayDurationIndex()
          Get the current display duration parameters: 0 = fast, 1 = medium, 2 = long.
 long[] getDisplayDurations(int indexOffset)
          Returns metrics on how long chat messages should be displayed.
 Font getFont(int type)
          Get the font to use for the given bubble type.
 Color getOutlineColor(int type)
          Computes the chat glyph outline color from the chat message type.
 Shape getPlaceSubtitleShape(int type, Rectangle r)
          A helper function for getSubtitleShape(int, java.awt.Rectangle, java.awt.Rectangle).
 Shape getSubtitleShape(int type, Rectangle r, Rectangle b)
          Get the appropriate shape for the specified type of chat.
 int getSubtitleSpacing(int type)
          Get the spacing, in pixels, between the latest subtitle of the specified type and the previous subtitle.
protected static int modeOf(int type)
          Extracts the mode constant from the type value.
protected static int placeOf(int type)
          Extract the place constant from the type value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CHAT_DECAY

public static final int DEFAULT_CHAT_DECAY
The default chat decay parameter. See getDisplayDurationIndex().

See Also:
Constant Field Values

PAD

public static final int PAD
The padding in each direction around the text to the edges of a chat 'bubble'.

See Also:
Constant Field Values

SPEAK

public static final int SPEAK
Type mode code for default chat type (speaking).

See Also:
Constant Field Values

SHOUT

public static final int SHOUT
Type mode code for shout chat type.

See Also:
Constant Field Values

EMOTE

public static final int EMOTE
Type mode code for emote chat type.

See Also:
Constant Field Values

THINK

public static final int THINK
Type mode code for think chat type.

See Also:
Constant Field Values

PLACE

public static final int PLACE
Type place code for default place chat (cluster, scene).

See Also:
Constant Field Values

SPECIALIZED

public static final int SPECIALIZED
Type code for a chat type that was used in some special context, like in a negotiation.

See Also:
Constant Field Values

TELL

public static final int TELL
Our internal code for tell chat.

See Also:
Constant Field Values

TELLFEEDBACK

public static final int TELLFEEDBACK
Our internal code for tell feedback chat.

See Also:
Constant Field Values

INFO

public static final int INFO
Our internal code for info system messges.

See Also:
Constant Field Values

FEEDBACK

public static final int FEEDBACK
Our internal code for feedback system messages.

See Also:
Constant Field Values

ATTENTION

public static final int ATTENTION
Our internal code for attention system messages.

See Also:
Constant Field Values

CONTINUATION

public static final int CONTINUATION
Our internal code for any type of chat that is continued in a subtitle.

See Also:
Constant Field Values

BROADCAST

public static final int BROADCAST
Type place code for broadcast chat type.

See Also:
Constant Field Values

IGNORECHAT

public static final int IGNORECHAT
Our internal code for a chat type we will ignore.

See Also:
Constant Field Values

DISPLAY_DURATION_PARAMS

protected static final long[][] DISPLAY_DURATION_PARAMS
Times to display chat: { (time per character), (min time), (max time) } Groups 0/1/2 are short/medium/long for chat bubbles, and groups 1/2/3 are short/medium/long for subtitles.


BROADCAST_COLOR

protected static final Color BROADCAST_COLOR

FEEDBACK_COLOR

protected static final Color FEEDBACK_COLOR

TELL_COLOR

protected static final Color TELL_COLOR

TELLFEEDBACK_COLOR

protected static final Color TELLFEEDBACK_COLOR

INFO_COLOR

protected static final Color INFO_COLOR

ATTENTION_COLOR

protected static final Color ATTENTION_COLOR

DEFAULT_FONT

protected static final Font DEFAULT_FONT
Our default chat font.

Constructor Detail

ChatLogic

public ChatLogic()
Method Detail

getDefaultMessageBundle

public abstract String getDefaultMessageBundle()
Returns the message bundle used to translate default messages.


decodeFormat

public Tuple<String,Boolean> decodeFormat(int type,
                                          String format)
Determines the format string and whether to use quotes based on the chat type.


decodeType

public int decodeType(String localtype)
Decodes the main chat type given the supplied localtype provided by the chat system.


adjustTypeByMode

public int adjustTypeByMode(int mode,
                            int type)
Adjust the chat type based on the mode of the chat message.


getFont

public Font getFont(int type)
Get the font to use for the given bubble type.


createLabel

public Label createLabel(String text)
Creates a label for the specified text. Derived classes may wish to use specialized labels.


getOutlineColor

public Color getOutlineColor(int type)
Computes the chat glyph outline color from the chat message type.


getSubtitleShape

public Shape getSubtitleShape(int type,
                              Rectangle r,
                              Rectangle b)
Get the appropriate shape for the specified type of chat.

Parameters:
r - the rectangle bounding the chat label.
b - the rectangle bounding the chat label and icon.

getSubtitleSpacing

public int getSubtitleSpacing(int type)
Get the spacing, in pixels, between the latest subtitle of the specified type and the previous subtitle.


getPlaceSubtitleShape

public Shape getPlaceSubtitleShape(int type,
                                   Rectangle r)
A helper function for getSubtitleShape(int, java.awt.Rectangle, java.awt.Rectangle).


getDisplayDurations

public long[] getDisplayDurations(int indexOffset)
Returns metrics on how long chat messages should be displayed.


getDisplayDurationIndex

protected int getDisplayDurationIndex()
Get the current display duration parameters: 0 = fast, 1 = medium, 2 = long. See DISPLAY_DURATION_PARAMS.


modeOf

protected static int modeOf(int type)
Extracts the mode constant from the type value.


placeOf

protected static int placeOf(int type)
Extract the place constant from the type value.