org.elkoserver.server.context.mods
Class StyleDesc

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

public class StyleDesc
extends Object
implements Encodable

Representation of style information for something containing text.

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


Constructor Summary
StyleDesc(OptString color, OptString backgroundColor, OptString borderColor, OptString textStyle, OptString icon)
          JSON-driven constructor.
StyleDesc(String color, String backgroundColor, String borderColor, String textStyle, String icon)
          Direct constructor.
 
Method Summary
 String backgroundColor()
          Get the background color.
 String borderColor()
          Get the border color.
 String color()
          Get the foreground (text) color.
 JSONLiteral encode(EncodeControl control)
          Encode this object for transmission or persistence.
 String icon()
          Get the icon URL.
 StyleDesc mergeStyle(StyleDesc partial)
          Merge this StyleDesc with another, partially specified StyleDesc, creating a new StyleDesc.
 String textStyle()
          Get the text style for this StyleDesc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StyleDesc

@JSONMethod(value={"color","backgroundColor","borderColor","textStyle","icon"})
public StyleDesc(OptString color,
                                 OptString backgroundColor,
                                 OptString borderColor,
                                 OptString textStyle,
                                 OptString icon)
JSON-driven constructor.

Parameters:
color - Optional foreground (text) color.
backgroundColor - Optional background color.
borderColor - Optional border color.
textStyle - Optional style string (e.g., "bold", "italic", etc.) for text.
icon - Optional URL of an icon to go with text.

StyleDesc

public StyleDesc(String color,
                 String backgroundColor,
                 String borderColor,
                 String textStyle,
                 String icon)
Direct constructor.

Parameters:
color - Foreground (text) color, or null if none.
backgroundColor - Background color, or null if none.
borderColor - Border color, or null if none.
textStyle - Style string for text (e.g, "bold", "italic", etc.), or null if none.
icon - URL of an icon to go with the text, or null if none.
Method Detail

backgroundColor

public String backgroundColor()
Get the background color.

Returns:
this style's background color, or null if there is none.

borderColor

public String borderColor()
Get the border color.

Returns:
this style's border color, or null if there is none.

color

public String color()
Get the foreground (text) color.

Returns:
this style's foreground color, or null if there is none.

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.

icon

public String icon()
Get the icon URL.

Returns:
this style's icon URL, or null if there is none.

mergeStyle

public StyleDesc mergeStyle(StyleDesc partial)
Merge this StyleDesc with another, partially specified StyleDesc, creating a new StyleDesc.

Parameters:
partial - The (partial) StyleDesc to merge with
Returns:
a new StyleDesc with the settings of 'partial' where 'partial' specifies them, and the settings of this object where 'partial' does not specify them.

textStyle

public String textStyle()
Get the text style for this StyleDesc. This is a string that specifies attributes such as typeface, bold, italic, etc.

Returns:
this style's text style string, or null if there is none.