|
NextApp Echo App Container 1.1.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object nextapp.echoservlet.ComponentStyle
A CSS style handler for a ComponentPeer
.
This class has an unusual design as it is intended to minimize the number of
CSS style definitions generated for a given HTML document. Minimizing the
number of styles is necessary as, if an independent style were to be
generated for each and every component, more complex documents would have a
ridiculous quantity of CSS code.
To create a ComponentPeer
that will render a component using a
CSS style generated by ComponentStyle
you must follow this
procedure:
ComponentStyle
for your
ComponentPeer
:
ComponentStyle style =
ComponentStyle.forComponent(this);
style.addAttribute("attribute-name",
"attribute-value");
style.addElementType(ElementNames.SPAN)
HtmlDocument
in which your component's
HTML code will be rendered (and take note of its resulting assigned
name):
String styleName = doc.addStyle(style);
spanTag.addAttribute(ElementNames.Attributes.CLASS,
styleName);
Field Summary | |
static int |
EXPLICIT_SET_ALL
A constant used in the options attribute of constructors
to explicitly determine the font, foreground, and background (based on
traversing component hierarchy) and set it using CSS. |
static int |
EXPLICIT_SET_BACKGROUND
A constant used in the options attribute of constructors
to explicitly determine the background color (based on traversing
component hierarchy) and set it using CSS. |
static int |
EXPLICIT_SET_FONT
A constant used in the options attribute of constructors
to explicitly determine the font (based on traversing
component hierarchy) and set it using CSS. |
static int |
EXPLICIT_SET_FOREGROUND
A constant used in the options attribute of constructors
to explicitly determine the foreground color (based on traversing
component hierarchy) and set it using CSS. |
static java.lang.String |
PERCENT_UNITS
A unit suffix for percent units. |
static java.lang.String |
PIXEL_UNITS
A unit suffix for pixel units. |
static java.lang.String |
POINT_UNITS
A unit suffix for point units. |
Constructor Summary | |
ComponentStyle()
|
Method Summary | |
void |
addAttribute(java.lang.String name,
int value)
Adds an integer attribute to the style. |
void |
addAttribute(java.lang.String name,
int value,
java.lang.String units)
Adds an integer attribute and units to the style. |
void |
addAttribute(java.lang.String name,
java.lang.String value)
Adds a text attribute to the style. |
void |
addElementType(java.lang.String name)
Adds an element type to the style. |
void |
addPseudoAttribute(java.lang.String pseudonym,
java.lang.String name,
int value)
Adds an integer attribute to a pseudoclass of the style. |
void |
addPseudoAttribute(java.lang.String pseudonym,
java.lang.String name,
java.lang.String value)
Adds an attribute to a pseudoclass of the style. |
boolean |
equals(java.lang.Object o)
|
static ComponentStyle |
forComponent(ComponentPeer componentPeer)
Creates and returns a ComponentStyle object for the
provided ComponentPeer . |
static ComponentStyle |
forComponent(ComponentPeer componentPeer,
boolean findBackground)
Deprecated. Use the forComponent(ComponentPeer, int)
factory method. Invoking it with an options value of
EXPLICIT_SET_BACKGROUND will have the same
effect as using this constructor with
findBackground true. |
static ComponentStyle |
forComponent(ComponentPeer componentPeer,
int options)
Creates and returns a ComponentStyle object for the
provided ComponentPeer . |
java.lang.String |
getAttribute(java.lang.String name)
Returns the value of the specified attribute. |
static java.lang.String |
getColorHexValue(nextapp.echo.Color color)
Converts a color to a seven character hexadecimal string of the form #RRGGBB |
boolean |
hasAttributes()
Returns true if the style has any attributes set. |
int |
hashCode()
|
void |
setBackground(nextapp.echo.Color background)
Sets the background color of the style. |
void |
setBackgroundImage(java.lang.String backgroundImage)
Sets the background image of the style. |
void |
setFont(nextapp.echo.Font font)
Sets the font of the style. |
void |
setForeground(nextapp.echo.Color foreground)
Sets the foreground color of the style. |
void |
setHorizontalAlignment(int horizontalAlignment)
Sets the horizontal text alignment of the style based on a value from the nextapp.echo.EchoConstants class. |
void |
setVerticalAlignment(int verticalAlignment)
Sets the vertical text alignment of the style based on a value from the nextapp.echo.EchoConstants class. |
java.lang.String |
toString()
Prints state information (for debugging use). |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String PERCENT_UNITS
public static final java.lang.String PIXEL_UNITS
public static final java.lang.String POINT_UNITS
public static final int EXPLICIT_SET_BACKGROUND
options
attribute of constructors
to explicitly determine the background color (based on traversing
component hierarchy) and set it using CSS.
public static final int EXPLICIT_SET_FOREGROUND
options
attribute of constructors
to explicitly determine the foreground color (based on traversing
component hierarchy) and set it using CSS.
public static final int EXPLICIT_SET_FONT
options
attribute of constructors
to explicitly determine the font (based on traversing
component hierarchy) and set it using CSS.
public static final int EXPLICIT_SET_ALL
options
attribute of constructors
to explicitly determine the font, foreground, and background (based on
traversing component hierarchy) and set it using CSS.
Constructor Detail |
public ComponentStyle()
Method Detail |
public static ComponentStyle forComponent(ComponentPeer componentPeer)
ComponentStyle
object for the
provided ComponentPeer
.
componentPeer
- The peer for which the style is to be generated.
ComponentStyle
instance suitable for the given
ComponentPeer
.public static ComponentStyle forComponent(ComponentPeer componentPeer, boolean findBackground)
forComponent(ComponentPeer, int)
factory method. Invoking it with an options value of
EXPLICIT_SET_BACKGROUND
will have the same
effect as using this constructor with
findBackground
true.
ComponentStyle
object for the
provided ComponentPeer
.
componentPeer
- The peer for which the style is to be generated.findBackground
- If true, the component's ancestors will be searched
upward from the specified component until a background color is
found. This background color will be explicitly specified in the
style's CSS output.
ComponentStyle
instance suitable for the given
ComponentPeer
.public static ComponentStyle forComponent(ComponentPeer componentPeer, int options)
ComponentStyle
object for the
provided ComponentPeer
.
componentPeer
- The peer for which the style is to be generated.options
- A bitmask indicating options to use when creating the
style.
ComponentStyle
instance suitable for the given
ComponentPeer
.public static java.lang.String getColorHexValue(nextapp.echo.Color color)
color
- The color to be converted.
public void addAttribute(java.lang.String name, java.lang.String value)
name
- The name of the attribute.value
- The attribute's value.public void addAttribute(java.lang.String name, int value)
name
- The name of the attribute.value
- The attribute's value.public void addAttribute(java.lang.String name, int value, java.lang.String units)
name
- The name of the attribute.value
- The attribute's value.units
- The units of the value.public void addElementType(java.lang.String name)
name
- The name of the element type to add. Common element
type names are available from the
nextapp.echoservlet.html.ElemenetNames
class.public void addPseudoAttribute(java.lang.String pseudonym, java.lang.String name, java.lang.String value)
pseudonym
- The name of the pseudoclass (e.g. hover, visited, etc).name
- The name of the attribute.value
- The attribute's value.public void addPseudoAttribute(java.lang.String pseudonym, java.lang.String name, int value)
pseudonym
- The name of the pseudoclass (e.g. hover, visited, etc).name
- The name of the attribute.value
- The attribute's value.public boolean equals(java.lang.Object o)
Object.equals(java.lang.Object)
public java.lang.String getAttribute(java.lang.String name)
name
- The name of an attribute.
public boolean hasAttributes()
public int hashCode()
Object.hashCode()
public void setBackground(nextapp.echo.Color background)
background
- The new background color.public void setBackgroundImage(java.lang.String backgroundImage)
backgroundImage
- The new background image.public void setFont(nextapp.echo.Font font)
font
- The new font.public void setHorizontalAlignment(int horizontalAlignment)
nextapp.echo.EchoConstants
class.
horizontalAlignment
- The horizontal text alignment, one of the
following values:
EchoConstants.LEFT
EchoConstants.CENTER
EchoConstants.RIGHT
public void setVerticalAlignment(int verticalAlignment)
nextapp.echo.EchoConstants
class.
verticalAlignment
- The vertical text alignment, one of the
following values:
EchoConstants.TOP
EchoConstants.CENTER
EchoConstants.BOTTOM
public void setForeground(nextapp.echo.Color foreground)
foreground
- The new foreground color.public java.lang.String toString()
Object.toString()
|
NextApp Echo App Container 1.1.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |