| java.lang.Object javax.swing.text.html.CSS
CSS | public class CSS implements Serializable(Code) | | Defines a set of
CSS attributes
as a typesafe enumeration. The HTML View implementations use
CSS attributes to determine how they will render. This also defines
methods to map between CSS/HTML/StyleConstants. Any shorthand
properties, such as font, are mapped to the intrinsic properties.
The following describes the CSS properties that are suppored by the
rendering engine:
- font-family
- font-style
- font-size (supports relative units)
- font-weight
- font
- color
- background-color (with the exception of transparent)
- background-image
- background-repeat
- background-position
- background
- background-repeat
- text-decoration (with the exception of blink and overline)
- vertical-align (only sup and super)
- text-align (justify is treated as center)
- margin-top
- margin-right
- margin-bottom
- margin-left
- margin
- padding-top
- padding-right
- padding-bottom
- padding-left
- border-style (only supports inset, outset and none)
- list-style-type
- list-style-position
The following are modeled, but currently not rendered.
- font-variant
- background-attachment (background always treated as scroll)
- word-spacing
- letter-spacing
- text-indent
- text-transform
- line-height
- border-top-width (this is used to indicate if a border should be used)
- border-right-width
- border-bottom-width
- border-left-width
- border-width
- border-top
- border-right
- border-bottom
- border-left
- border
- width
- height
- float
- clear
- display
- white-space
- list-style
Note: for the time being we do not fully support relative units,
unless noted, so that
p { margin-top: 10% } will be treated as if no margin-top was specified.
author: Timothy Prinzing author: Scott Violet version: 1.74 05/05/07 See Also: StyleSheet |
Inner Class :final public static class Attribute | |
Inner Class :final static class Value | |
Inner Class :static class StringValue extends CssValue | |
Inner Class :class FontSize extends CssValue | |
Inner Class :static class FontFamily extends CssValue | |
Inner Class :static class FontWeight extends CssValue | |
Inner Class :static class ColorValue extends CssValue | |
Inner Class :static class BorderStyle extends CssValue | |
Inner Class :static class LengthValue extends CssValue | |
Inner Class :static class BorderWidthValue extends LengthValue | |
Inner Class :static class CssValueMapper extends CssValue | |
Inner Class :static class BackgroundPosition extends CssValue | |
Inner Class :static class BackgroundImage extends CssValue | |
Inner Class :static class LengthUnit implements Serializable | |
Inner Class :static class ShorthandFontParser | |
Inner Class :static class ShorthandBackgroundParser | |
Inner Class :static class ShorthandMarginParser | |
Inner Class :interface LayoutIterator | |
Constructor Summary | |
public | CSS() |
Method Summary | |
void | addInternalCSSValue(MutableAttributeSet attr, CSS.Attribute key, String value) Parses the CSS property key with value
value placing the result in att . | static void | calculateTiledLayout(LayoutIterator iter, int targetSpan) Calculate a tiled layout for the given iterator. | static SizeRequirements | calculateTiledRequirements(LayoutIterator iter, SizeRequirements r) Calculate the requirements needed to tile the requirements
given by the iterator that would be tiled. | static String | colorToHex(Color color) | Object | cssValueToStyleConstantsValue(StyleConstants key, Object value) Converts the passed in CSS value to a StyleConstants value. | public static Attribute[] | getAllAttributeKeys() Return the set of all possible CSS attribute keys. | final public static Attribute | getAttribute(String name) Translates a string to a CSS.Attribute object. | int | getBaseFontSize() Returns the base font size. | Color | getColor(AttributeSet a, CSS.Attribute key) Takes a set of attributes and turn it into a color
specification. | Object | getCssValue(CSS.Attribute cssAttr, String htmlAttrValue) Given a CSS.Attribute object and its corresponding HTML.Attribute's
value, this method returns a CssValue object to associate with the
CSS attribute. | Font | getFont(StyleContext sc, AttributeSet a, int defaultSize, StyleSheet ss) Returns the font for the values in the passed in AttributeSet. | static int | getFontSize(AttributeSet attr, int defaultSize, StyleSheet ss) | static int | getIndexOfSize(float pt, int[] sizeMap) | static int | getIndexOfSize(float pt, StyleSheet ss) | Object | getInternalCSSValue(CSS.Attribute key, String value) Gets the internal CSS representation of value which is
a CSS value of the CSS attribute named key . | float | getLength(AttributeSet a, CSS.Attribute key, StyleSheet ss) Returns the length of the attribute in a with
key key . | float | getPointSize(String size, StyleSheet ss) Returns the size of a font from the passed in string. | float | getPointSize(int index, StyleSheet ss) Return the point size, given a size index. | static URL | getURL(URL base, String cssString) Returns a URL for the given CSS url string. | final static Value | getValue(String name) Translates a string to a CSS.Value object. | final static Color | hexToColor(String value) Convert a "#FFFFFF" hex string to a Color. | static String[] | parseStrings(String value) | void | setBaseFontSize(int sz) Sets the base font size. | void | setBaseFontSize(String size) Sets the base font size from the passed in string. | static Color | stringToColor(String str) Convert a color string such as "RED" or "#NNNNNN" or "rgb(r, g, b)"
to a Color. | Attribute | styleConstantsKeyToCSSKey(StyleConstants sc) Maps from a StyleConstants to a CSS Attribute. | Object | styleConstantsValueToCSSValue(StyleConstants sc, Object styleValue) Maps from a StyleConstants value to a CSS value. | AttributeSet | translateHTMLToCSS(AttributeSet htmlAttrSet) Convert a set of HTML attributes to an equivalent
set of CSS attributes.
Parameters: AttributeSet - containing the HTML attributes. |
baseFontSizeIndex | static int baseFontSizeIndex(Code) | | |
calculateTiledLayout | static void calculateTiledLayout(LayoutIterator iter, int targetSpan)(Code) | | Calculate a tiled layout for the given iterator.
This should be done collapsing the neighboring
margins to be a total of the maximum of the two
neighboring margin areas as described in the CSS spec.
|
calculateTiledRequirements | static SizeRequirements calculateTiledRequirements(LayoutIterator iter, SizeRequirements r)(Code) | | Calculate the requirements needed to tile the requirements
given by the iterator that would be tiled. The calculation
takes into consideration margin and border spacing.
|
colorToHex | static String colorToHex(Color color)(Code) | | Converts a type Color to a hex string
in the format "#RRGGBB"
|
cssValueToStyleConstantsValue | Object cssValueToStyleConstantsValue(StyleConstants key, Object value)(Code) | | Converts the passed in CSS value to a StyleConstants value.
key identifies the CSS attribute being mapped.
|
getAllAttributeKeys | public static Attribute[] getAllAttributeKeys()(Code) | | Return the set of all possible CSS attribute keys.
|
getAttribute | final public static Attribute getAttribute(String name)(Code) | | Translates a string to a CSS.Attribute object.
This will return null if there is no attribute
by the given name.
Parameters: name - the name of the CSS attribute to fetch thetypesafe enumeration for the CSS.Attribute object,or null if the stringdoesn't represent a valid attribute key |
getBaseFontSize | int getBaseFontSize()(Code) | | Returns the base font size.
|
getColor | Color getColor(AttributeSet a, CSS.Attribute key)(Code) | | Takes a set of attributes and turn it into a color
specification. This might be used to specify things
like brighter, more hue, etc.
This will return null if there is no value for key .
Parameters: key - CSS.Attribute identifying where color is stored. Parameters: a - the set of attributes the color |
getCssValue | Object getCssValue(CSS.Attribute cssAttr, String htmlAttrValue)(Code) | | Given a CSS.Attribute object and its corresponding HTML.Attribute's
value, this method returns a CssValue object to associate with the
CSS attribute.
Parameters: the - CSS.Attribute Parameters: a - String containing the value associated HTML.Attribtue. |
getFont | Font getFont(StyleContext sc, AttributeSet a, int defaultSize, StyleSheet ss)(Code) | | Returns the font for the values in the passed in AttributeSet.
It is assumed the keys will be CSS.Attribute keys.
sc is the StyleContext that will be messaged to get
the font once the size, name and style have been determined.
|
getIndexOfSize | static int getIndexOfSize(float pt, int[] sizeMap)(Code) | | |
getInternalCSSValue | Object getInternalCSSValue(CSS.Attribute key, String value)(Code) | | Gets the internal CSS representation of value which is
a CSS value of the CSS attribute named key . The receiver
should not modify value , and the first count
strings are valid.
|
getPointSize | float getPointSize(String size, StyleSheet ss)(Code) | | Returns the size of a font from the passed in string.
Parameters: size - CSS string describing font size Parameters: baseFontSize - size to use for relative units. |
getPointSize | float getPointSize(int index, StyleSheet ss)(Code) | | Return the point size, given a size index. Legal HTML index sizes
are 1-7.
|
getURL | static URL getURL(URL base, String cssString)(Code) | | Returns a URL for the given CSS url string. If relative,
base is used as the parent. If a valid URL can not
be found, this will not throw a MalformedURLException, instead
null will be returned.
|
getValue | final static Value getValue(String name)(Code) | | Translates a string to a CSS.Value object.
This will return null if there is no value
by the given name.
Parameters: name - the name of the CSS value to fetch thetypesafe enumeration for the CSS.Value object, or null if the stringdoesn't represent a valid CSS value name; this doesnot mean that it doesn't represent a valid CSS value |
hexToColor | final static Color hexToColor(String value)(Code) | | Convert a "#FFFFFF" hex string to a Color.
If the color specification is bad, an attempt
will be made to fix it up.
|
parseStrings | static String[] parseStrings(String value)(Code) | | an array of all the strings in value that are separated by whitespace. |
setBaseFontSize | void setBaseFontSize(int sz)(Code) | | Sets the base font size. sz is a CSS value, and is
not necessarily the point size. Use getPointSize to determine the
point size corresponding to sz .
|
setBaseFontSize | void setBaseFontSize(String size)(Code) | | Sets the base font size from the passed in string.
|
stringToColor | static Color stringToColor(String str)(Code) | | Convert a color string such as "RED" or "#NNNNNN" or "rgb(r, g, b)"
to a Color.
|
styleConstantsKeyToCSSKey | Attribute styleConstantsKeyToCSSKey(StyleConstants sc)(Code) | | Maps from a StyleConstants to a CSS Attribute.
|
translateHTMLToCSS | AttributeSet translateHTMLToCSS(AttributeSet htmlAttrSet)(Code) | | Convert a set of HTML attributes to an equivalent
set of CSS attributes.
Parameters: AttributeSet - containing the HTML attributes. AttributeSet containing the corresponding CSS attributes.The AttributeSet will be empty if there are no mappingCSS attributes. |
|
|