|
NextApp Echo App Container 1.0.5 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnextapp.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 | |
private java.util.Map |
attributes
|
private nextapp.echo.Color |
background
|
private java.lang.String |
backgroundImage
|
private java.util.Set |
elements
|
private nextapp.echo.Font |
font
|
private nextapp.echo.Color |
foreground
|
private ComponentStyle |
forwardingStyle
|
private int |
id
|
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. |
private java.util.Map |
pseudonyms
|
private static java.lang.String |
STYLE_PREFIX
A prefix which will be appended to all style names. |
| 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. |
(package private) void |
addElementTypesOfStyle(ComponentStyle style)
Adds all element types that are present in another 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)
Creates and returns a ComponentStyle object for the
provided ComponentPeer, optionally searching its ancestors
to find a background color if it does not provide one. |
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 |
(package private) java.lang.String |
getName()
Returns the name of the style. |
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. |
(package private) void |
setId(int id)
Sets the identifier of the style. |
void |
setVerticalAlignment(int verticalAlignment)
Sets the vertical text alignment of the style based on a value from the nextapp.echo.EchoConstants class. |
(package private) Style |
toStyle()
Renders a CSS representation of the style. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static final java.lang.String STYLE_PREFIX
Id.
public static final java.lang.String PERCENT_UNITS
public static final java.lang.String PIXEL_UNITS
public static final java.lang.String POINT_UNITS
private nextapp.echo.Font font
private nextapp.echo.Color foreground
private nextapp.echo.Color background
private java.lang.String backgroundImage
private java.util.Set elements
private java.util.Map attributes
private java.util.Map pseudonyms
private int id
private ComponentStyle forwardingStyle
| 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)
ComponentStyle object for the
provided ComponentPeer, optionally searching its ancestors
to find a background color if it does not provide one. The handling
of background colors is a special case because most of the time
styles will only specify a background color if a component explicitly
has its own background color set. This is necessary for proper
aesthetics.
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 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.void addElementTypesOfStyle(ComponentStyle style)
style - The style whose element types are to be retrieved and
added to this style's list of element types.
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.
java.lang.String getName()
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.LEFTEchoConstants.CENTEREchoConstants.RIGHTpublic void setVerticalAlignment(int verticalAlignment)
nextapp.echo.EchoConstants class.
verticalAlignment - The vertical text alignment, one of the
following values:
EchoConstants.TOPEchoConstants.CENTEREchoConstants.BOTTOMpublic void setForeground(nextapp.echo.Color foreground)
foreground - The new foreground color.void setId(int id)
Style toStyle()
|
NextApp Echo App Container 1.0.5 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||