org.elkoserver.server.context.mods
Class StyleOptions

java.lang.Object
  extended by org.elkoserver.server.context.mods.StyleOptions
All Implemented Interfaces:
Encodable

public class StyleOptions
extends Object
implements Encodable

Representation of permissible text style information in a context that can contain text.

Note: this is not a mod. StyleOptions objects are used by the NoteMaker and TalkOptions mods.


Constructor Summary
StyleOptions(String[] colors, String[] backgroundColors, String[] borderColors, String[] textStyles, String[] icons, OptInteger iconWidth, OptInteger iconHeight)
          JSON-driven constructor.
 
Method Summary
 boolean allowedStyle(StyleDesc style)
          Test if a particular StyleDesc is permissible according to this object's settings.
 String[] backgroundColors()
          Get the permissible background colors.
 String[] borderColors()
          Get the permissible border colors.
 String[] colors()
          Get the permissible foreground (text) colors.
 JSONLiteral encode(EncodeControl control)
          Encode this object for transmission or persistence.
 int iconHeight()
          Get the height of the icons.
 String[] icons()
          Get the permissible icon URLs.
 int iconWidth()
          Get the width of the icons.
 StyleDesc mergeStyle(StyleDesc style)
          Produce a new StyleDesc object given another, partially specified, StyleDesc object.
 String[] textStyles()
          Get the permissible text styles.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StyleOptions

@JSONMethod(value={"colors","backgroundColors","borderColors","textStyles","icons","iconWidth","iconHeight"})
public StyleOptions(String[] colors,
                                    String[] backgroundColors,
                                    String[] borderColors,
                                    String[] textStyles,
                                    String[] icons,
                                    OptInteger iconWidth,
                                    OptInteger iconHeight)
JSON-driven constructor.

Parameters:
colors - Permissible foreground (text) colors.
backgroundColors - Permissible background colors.
borderColors - Permissible border colors.
textStyles - Permissible text styles.
icons - Permissible icon URLs.
iconWidth - Common width of icons, or -1 if not relevant.
iconHeight - Common height of icons, or -1 if not relevant.
Method Detail

allowedStyle

public boolean allowedStyle(StyleDesc style)
Test if a particular StyleDesc is permissible according to this object's settings.

Parameters:
style - The StyleDesc to test.
Returns:
true if 'style' is acceptable to this object, false if not.

backgroundColors

public String[] backgroundColors()
Get the permissible background colors.

Returns:
an array of the permissible background colors.

borderColors

public String[] borderColors()
Get the permissible border colors.

Returns:
an array of the permissible border colors.

colors

public String[] colors()
Get the permissible foreground (text) colors.

Returns:
an array of the permissible foreground colors.

encode

public JSONLiteral encode(EncodeControl control)
Encode this object for transmission or persistence.

Specified by:
encode in interface Encodable
Parameters:
control - Encode control determining what flavor of encoding should be done.
Returns:
a JSON literal representing this object.

icons

public String[] icons()
Get the permissible icon URLs.

Returns:
an array of the permissible icon URLs.

iconHeight

public int iconHeight()
Get the height of the icons.

Returns:
the (common) height of the icons, or -1 if they do not have a common height.

iconWidth

public int iconWidth()
Get the width of the icons.

Returns:
the (common) width of the icons, or -1 if they do not have a common width.

mergeStyle

public StyleDesc mergeStyle(StyleDesc style)
Produce a new StyleDesc object given another, partially specified, StyleDesc object.

Parameters:
style - The StyleDesc to start from.
Returns:
a new StyleDesc object that is a copy of 'style' with additional attributes according to the defaults contained in this object, or null if one of the attributes specified by 'style' is not permitted by this object's settings.

textStyles

public String[] textStyles()
Get the permissible text styles.

Returns:
an array of the permissible text styles.