ymsg.support
Class MessageDecoderSettings

Object
  extended byMessageDecoderSettings

public class MessageDecoderSettings
extends Object

This class acts in tandem with the MessageDecoder, to give control over how the translated output is styled. Rather than set these preferences inside the decoder object itself, this independent object allows for a single set of preferences to be shared between multiple decoders, and immediately updated across all.

The font/text settings fall into two categories. 'Default' determines the initial state of the decoder, while 'overridden' determines the settings to use to override those specified in each message.

For example, setting a default font will effect the way text is rendered for messages which do not set their fonts explicity. (Not setting this will mean that the decoder will use the default style provided by Swing.) Setting an overriding font will effect the way text is rendered for messages which carry their own font details - your overriding font will always be used in preference to the message's choosen font. (Not setting this will mean that the message fonts will be respected.)

To force all font faces to be Courier, for example, one would set both the default and the overriding font faces. This will ensure that all messages without font data will be rendered using Courier (thanks to 'default') and all messages *with* font data will also be rendered using Courier (thanks to 'override').

Setting a field to null or -1 will have the effect of disabling that style attribute. It is therefore quite possible to override message font faces, while not overriding their font size. Or to set a maximum font size for messages, but no minimum.

Fade and alt are two ways of creating highly coloured text. Fade provides a transitional effect evenly between an array of colours across a message. Alt also takes an array of colours, but instead of gradually fading from colour to colour across a message, the colours are simply alternated over and over, one per character.

Displaying highly coloured text like fade and alt can use excessive resources, so it is recommended software provides a way to switch off fade and alt decoding. (See the 'respect' methods provided.)

Since:
1.0

Constructor Summary
MessageDecoderSettings()
           
 
Method Summary
 String getDefaultFontFace()
          Returns default font face name, if set.
 int getDefaultFontSize()
          Returns default font size, if set.
 Color getDefaultForeground()
          Returns default text colour, if set.
 EmoticonLoader getEmoticonLoader()
          Returns emoticon loader object, if set.
 boolean getEmoticonsDecoded()
          Returns whether emoticons will be translated to icons.
 String getOverrideFontFace()
          Returns overriding font face name, if set.
 Color getOverrideForeground()
          Returns overriding text colour, if set.
 int getOverrideMaxFontSize()
          Returns overriding maximum font size, if set.
 int getOverrideMinFontSize()
          Returns overriding minimum font size, if set.
 boolean getRespectTextAlt()
          Returns whether alt message components are respected.
 boolean getRespectTextFade()
          Returns whether fade message components are respected.
 void setDefaultFont(String face, int sz, Color fgCol)
          Convenience method for setting all default font settings at once.
 void setDefaultFontFace(String s)
          Set the default (starting) font face.
 void setDefaultFontSize(int sz)
          Set the default (starting) font point size.
 void setDefaultForeground(Color col)
          Set the default (starting) text colour.
 void setEmoticonLoader(EmoticonLoader l)
          Set an emoticon loader instance.
 void setEmoticonsDecoded(boolean b)
          Set whether emoticons should be decoded as images, or left as text.
 void setOverrideFont(String face, int min, int max, Color fgCol)
          Convenience method for setting all overriding font settings at once.
 void setOverrideFontFace(String s)
          Set the overriding font face.
 void setOverrideForeground(Color col)
          Set the overriding text colour.
 void setOverrideMaxFontSize(int sz)
          Set the overriding maximum font point size.
 void setOverrideMinFontSize(int sz)
          Set the overriding minimum font point size.
 void setRespectTextAlt(boolean b)
          Determines whether ALT message components will be ignored.
 void setRespectTextFade(boolean b)
          Determines whether FADE message components will be ignored.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageDecoderSettings

public MessageDecoderSettings()
Method Detail

setEmoticonsDecoded

public void setEmoticonsDecoded(boolean b)
Set whether emoticons should be decoded as images, or left as text.

Parameters:
b - true=translate, false=leave
Since:
1.0

setEmoticonLoader

public void setEmoticonLoader(EmoticonLoader l)
Set an emoticon loader instance. This can be used to intergrate bespoke emoticon images into the decoder. See EmoticonLoader for more details. Setting this property to null disables it.

Parameters:
l - class of type EmoticonLoader, or null
Since:
1.0

setDefaultFontFace

public void setDefaultFontFace(String s)
Set the default (starting) font face. Setting this property to null disables it.

Parameters:
s - name of default font, or null
Since:
1.0

setDefaultFontSize

public void setDefaultFontSize(int sz)
Set the default (starting) font point size. Setting this property to -1 disables it.

Parameters:
sz - size of default font, or -1
Since:
1.0

setDefaultForeground

public void setDefaultForeground(Color col)
Set the default (starting) text colour. Setting this property to null disables it.

Parameters:
col - AWT Color of default text, or null
Since:
1.0

setOverrideFontFace

public void setOverrideFontFace(String s)
Set the overriding font face. Any message attempting to change the font face will be superceeded by this setting. Setting this property to null disables it.

Parameters:
s - name of overriding font, or null
Since:
1.0

setOverrideMaxFontSize

public void setOverrideMaxFontSize(int sz)
Set the overriding maximum font point size. Any message attempting to set a font larger than this will be superceeded by this setting. Setting this property to -1 disables it.

Parameters:
sz - max size of overriding font, or -1
Since:
1.0

setOverrideMinFontSize

public void setOverrideMinFontSize(int sz)
Set the overriding minimum font point size. Any message attempting to set a font smaller than this will be superceeded by this setting. Setting this property to -1 disables it.

Parameters:
sz - min size of overriding font, or -1
Since:
1.0

setOverrideForeground

public void setOverrideForeground(Color col)
Set the overriding text colour. Any message attempting to change the text colour will be superceeded by this setting. Setting this property to null disables it.

Parameters:
col - AWT Color of overriding text, or null
Since:
1.0

setDefaultFont

public void setDefaultFont(String face,
                           int sz,
                           Color fgCol)
Convenience method for setting all default font settings at once. Setting these properties to null or -1 disables them.

Parameters:
face - name of default font, or null
sz - size of default font, or -1
fgCol - AWT Color of default text, or null
Since:
1.0

setOverrideFont

public void setOverrideFont(String face,
                            int min,
                            int max,
                            Color fgCol)
Convenience method for setting all overriding font settings at once. Setting these properties to null or -1 disables them.

Parameters:
face - name of overriding font, or null
min - min size of overriding font, or -1
max - max size of overriding font, or -1
fgCol - AWT Color of overriding text, or null
Since:
1.0

setRespectTextFade

public void setRespectTextFade(boolean b)
Determines whether FADE message components will be ignored. True will signal to decoders that transitional text colour sections in a message are to be respected when possible. Default is false.

(Note: highly coloured text like this might greatly increase the resources required to process and display said messages in UI components.)

Parameters:
b - true if fade is to be respected
Since:
1.0

setRespectTextAlt

public void setRespectTextAlt(boolean b)
Determines whether ALT message components will be ignored. True will signal to decoders that alternating text colour sections in a message are to be respected when possible. Default is false.

(Note: highly coloured text like this might greatly increase the resources required to process and display said messages in UI components.)

Parameters:
b - true if alt is to be respected
Since:
1.0

getEmoticonsDecoded

public boolean getEmoticonsDecoded()
Returns whether emoticons will be translated to icons.

Returns:
true=translate, false=leave
Since:
1.0

getEmoticonLoader

public EmoticonLoader getEmoticonLoader()
Returns emoticon loader object, if set.

Returns:
emoticon loader, or null
Since:
1.0

getDefaultFontFace

public String getDefaultFontFace()
Returns default font face name, if set.

Returns:
string, or null
Since:
1.0

getDefaultFontSize

public int getDefaultFontSize()
Returns default font size, if set.

Returns:
size, or -1
Since:
1.0

getDefaultForeground

public Color getDefaultForeground()
Returns default text colour, if set.

Returns:
AWT Color, or null
Since:
1.0

getOverrideFontFace

public String getOverrideFontFace()
Returns overriding font face name, if set.

Returns:
string, or null
Since:
1.0

getOverrideMaxFontSize

public int getOverrideMaxFontSize()
Returns overriding maximum font size, if set.

Returns:
size, or -1
Since:
1.0

getOverrideMinFontSize

public int getOverrideMinFontSize()
Returns overriding minimum font size, if set.

Returns:
size, or -1
Since:
1.0

getOverrideForeground

public Color getOverrideForeground()
Returns overriding text colour, if set.

Returns:
AWT Color, or null
Since:
1.0

getRespectTextFade

public boolean getRespectTextFade()
Returns whether fade message components are respected.

Returns:
true if FADE is respected, otherwise false
Since:
1.0

getRespectTextAlt

public boolean getRespectTextAlt()
Returns whether alt message components are respected.

Returns:
true if ALT is respected, otherwise false
Since:
1.0