org.eobjects.metamodel.data
Class StyleBuilder

java.lang.Object
  extended by org.eobjects.metamodel.data.StyleBuilder

public final class StyleBuilder
extends Object

Builder class for Style and related objects, like Style.Color.

Author:
Kasper Sørensen

Constructor Summary
StyleBuilder()
          Constructs a new StyleBuilder with the default foreground and background colors.
StyleBuilder(Style.Color defaultForegroundColor, Style.Color defaultBackgroundColor)
          Constructs a new StyleBuilder with a specified default foreground and background colors.
 
Method Summary
 StyleBuilder background(int r, int g, int b)
          Sets the background (fill) color of the style
 StyleBuilder background(short[] rgb)
          Sets the background (fill) color of the style
 StyleBuilder background(String rgbColorCode)
          Sets the background (fill) color of the style
 StyleBuilder background(Style.Color color)
          Sets the background (fill) color of the style
 StyleBuilder bold()
          Sets the font weight to bold
 StyleBuilder centerAligned()
          Sets the text alignment to center
 Style create()
          Creates a Style object based on the build characteristics.
static Style.Color createColor(int r, int g, int b)
          Creates a color based on 3 RGB components, represented as ints
static Style.Color createColor(short r, short g, short b)
          Creates a color based on 3 RGB components, represented as shorts
static Style.Color createColor(String rgbColorCode)
          Creates a Color based on a 6-letter RGB hex color code string, eg
 StyleBuilder fontSize(int fontSize, Style.SizeUnit sizeUnit)
          Sets the font size of the style
 StyleBuilder foreground(int r, int g, int b)
          Sets the foreground (text) color of the style
 StyleBuilder foreground(short[] rgb)
          Sets the foreground (text) color of the style
 StyleBuilder foreground(String rgbColorCode)
          Sets the foreground (text) color of the style
 StyleBuilder foreground(Style.Color color)
          Sets the foreground (text) color of the style
 StyleBuilder italic()
          Sets the font style to italic
 StyleBuilder justifyAligned()
          Sets the text alignment to justify
 StyleBuilder leftAligned()
          Sets the text alignment to left
 void reset()
          Resets the state of the built style, which will conceptually match it with Style.NO_STYLE.
 StyleBuilder rightAligned()
          Sets the text alignment to right
 StyleBuilder underline()
          Sets the text decoration to underlined
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StyleBuilder

public StyleBuilder()
Constructs a new StyleBuilder with the default foreground and background colors.


StyleBuilder

public StyleBuilder(Style.Color defaultForegroundColor,
                    Style.Color defaultBackgroundColor)
Constructs a new StyleBuilder with a specified default foreground and background colors. These colors will be disregarded, if posted to the foreground and background methods.

Parameters:
defaultForegroundColor -
defaultBackgroundColor -
Method Detail

reset

public void reset()
Resets the state of the built style, which will conceptually match it with Style.NO_STYLE.


create

public Style create()
Creates a Style object based on the build characteristics.

Returns:
a Style object based on the build characteristics.

bold

public StyleBuilder bold()
Sets the font weight to bold

Returns:
the StyleBuilder self (for cascading method calls)

italic

public StyleBuilder italic()
Sets the font style to italic

Returns:
the StyleBuilder self (for cascading method calls)

underline

public StyleBuilder underline()
Sets the text decoration to underlined

Returns:
the StyleBuilder self (for cascading method calls)

createColor

public static Style.Color createColor(String rgbColorCode)
Creates a Color based on a 6-letter RGB hex color code string, eg. "000000" for black and "FFFFFF" for white.

Parameters:
rgbColorCode - a 6-letter RGB hex color code string
Returns:
a color representing this color code

createColor

public static Style.Color createColor(int r,
                                      int g,
                                      int b)
Creates a color based on 3 RGB components, represented as ints

Parameters:
r -
g -
b -
Returns:
a color representing the RGB code

createColor

public static Style.Color createColor(short r,
                                      short g,
                                      short b)
Creates a color based on 3 RGB components, represented as shorts

Parameters:
r -
g -
b -
Returns:
a color representing the RGB code

foreground

public StyleBuilder foreground(String rgbColorCode)
Sets the foreground (text) color of the style

Parameters:
rgbColorCode - a 6-letter hex RGB color code, such as FF0000 (red).
Returns:
the StyleBuilder self (for cascading method calls)

foreground

public StyleBuilder foreground(short[] rgb)
Sets the foreground (text) color of the style

Parameters:
rgb - a triplet array of shorts
Returns:
the StyleBuilder self (for cascading method calls)

foreground

public StyleBuilder foreground(int r,
                               int g,
                               int b)
Sets the foreground (text) color of the style

Parameters:
r - red amount (0-255)
g - green amount (0-255)
b - blue amount (0-255)
Returns:
the StyleBuilder self (for cascading method calls)

foreground

public StyleBuilder foreground(Style.Color color)
Sets the foreground (text) color of the style

Parameters:
color - the color to use
Returns:
the StyleBuilder self (for cascading method calls)

background

public StyleBuilder background(String rgbColorCode)
Sets the background (fill) color of the style

Parameters:
rgbColorCode - a 6-letter hex RGB color code, such as FF0000 (red).
Returns:
the StyleBuilder self (for cascading method calls)

background

public StyleBuilder background(short[] rgb)
Sets the background (fill) color of the style

Parameters:
rgb - a triplet array of shorts
Returns:
the StyleBuilder self (for cascading method calls)

background

public StyleBuilder background(int r,
                               int g,
                               int b)
Sets the background (fill) color of the style

Parameters:
r - red amount (0-255)
g - green amount (0-255)
b - blue amount (0-255)
Returns:
the StyleBuilder self (for cascading method calls)

background

public StyleBuilder background(Style.Color color)
Sets the background (fill) color of the style

Parameters:
color - the color to use
Returns:
the StyleBuilder self (for cascading method calls)

fontSize

public StyleBuilder fontSize(int fontSize,
                             Style.SizeUnit sizeUnit)
Sets the font size of the style

Parameters:
fontSize - the font size
sizeUnit - the font size unit
Returns:
the StyleBuilder self (for cascading method calls)

centerAligned

public StyleBuilder centerAligned()
Sets the text alignment to center

Returns:
the StyleBuilder self (for cascading method calls)

leftAligned

public StyleBuilder leftAligned()
Sets the text alignment to left

Returns:
the StyleBuilder self (for cascading method calls)

rightAligned

public StyleBuilder rightAligned()
Sets the text alignment to right

Returns:
the StyleBuilder self (for cascading method calls)

justifyAligned

public StyleBuilder justifyAligned()
Sets the text alignment to justify

Returns:
the StyleBuilder self (for cascading method calls)


Copyright © 2007-2013. All Rights Reserved.