|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.text.html.CSS
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:
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.
StyleSheet
,
Serialized FormNested Class Summary | |
static class |
CSS.Attribute
Definitions to be used as a key on AttributeSet's that might hold CSS attributes. |
(package private) static class |
CSS.BackgroundImage
Used for BackgroundImages. |
(package private) static class |
CSS.BackgroundPosition
Used for background images, to represent the position. |
(package private) static class |
CSS.BorderStyle
|
(package private) static class |
CSS.BorderWidthValue
BorderWidthValue is used to model BORDER_XXX_WIDTH and adds support for the thin/medium/thick values. |
(package private) static class |
CSS.ColorValue
|
(package private) static class |
CSS.CssValue
Base class to CSS values in the attribute sets. |
(package private) static class |
CSS.CssValueMapper
Handles uniquing of CSS values, like lists, and background image repeating. |
(package private) static class |
CSS.FontFamily
|
(package private) class |
CSS.FontSize
Represents a value for the CSS.FONT_SIZE attribute. |
(package private) static class |
CSS.FontWeight
|
(package private) static interface |
CSS.LayoutIterator
An iterator to express the requirements to use when computing layout. |
(package private) static class |
CSS.LengthUnit
Parses a length value, this is used internally, and never added to an AttributeSet or returned to the developer. |
(package private) static class |
CSS.LengthValue
|
(package private) static class |
CSS.ShorthandBackgroundParser
Parses the background property into its intrinsic values. |
(package private) static class |
CSS.ShorthandFontParser
Class used to parse font property. |
(package private) static class |
CSS.ShorthandMarginParser
Used to parser margin and padding. |
(package private) static class |
CSS.StringValue
By default CSS attributes are represented as simple strings. |
(package private) static class |
CSS.Value
|
Field Summary | |
private static Hashtable |
attributeMap
|
private int |
baseFontSize
Size used for relative units. |
private static Hashtable |
cssValueToInternalValueMap
Maps from CSS value (string) to internal value. |
private static Hashtable |
fontMapping
Used to indicate if a font family name is valid. |
private static Object |
fontMappingLock
|
private static Hashtable |
htmlAttrToCssAttrMap
The hashtable and the static initalization block below, set up a mapping from well-known HTML attributes to CSS attributes. |
private static Hashtable |
htmlValueToCssValueMap
Maps from HTML value to a CSS value. |
(package private) static int[] |
sizeMap
The HTML/CSS size model has seven slots that one can assign sizes to. |
private static Hashtable |
styleConstantToCssMap
The hashtable and static initialization that follows sets up a translation from StyleConstants (i.e. the well known attributes) to the associated CSS attributes. |
private Hashtable |
valueConvertor
Maps from CSS key to CssValue. |
private static Hashtable |
valueMap
|
Constructor Summary | |
CSS()
|
Method Summary | |
(package private) void |
addInternalCSSValue(MutableAttributeSet attr,
CSS.Attribute key,
String value)
Parses the CSS property key with value
value placing the result in att . |
(package private) static void |
calculateTiledLayout(CSS.LayoutIterator iter,
int targetSpan)
Calculate a tiled layout for the given iterator. |
(package private) static SizeRequirements |
calculateTiledRequirements(CSS.LayoutIterator iter,
SizeRequirements r)
Calculate the requirements needed to tile the requirements given by the iterator that would be tiled. |
(package private) static String |
colorToHex(Color color)
Converts a type Color to a hex string in the format "#RRGGBB" |
(package private) Object |
cssValueToStyleConstantsValue(StyleConstants key,
Object value)
Converts the passed in CSS value to a StyleConstants value. |
static CSS.Attribute[] |
getAllAttributeKeys()
Return the set of all possible CSS attribute keys. |
static CSS.Attribute |
getAttribute(String name)
Translates a string to a CSS.Attribute object.
|
(package private) int |
getBaseFontSize()
Returns the base font size. |
(package private) Color |
getColor(AttributeSet a,
CSS.Attribute key)
Takes a set of attributes and turn it into a color specification. |
private static int |
getColorComponent(String string,
int[] index)
Returns the next integer value from string starting
at index[0] . |
private CSS.Attribute |
getCssAlignAttribute(HTML.Tag tag,
AttributeSet htmlAttrSet)
Maps HTML.Attribute.ALIGN to either: CSS.Attribute.TEXT_ALIGN CSS.Attribute.FLOAT CSS.Attribute.VERTICAL_ALIGN based on the tag associated with the attribute and the value of the attribute. |
private CSS.Attribute[] |
getCssAttribute(HTML.Attribute hAttr)
Maps an HTML.Attribute object to its appropriate CSS.Attributes. |
(package private) 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. |
(package private) Font |
getFont(StyleContext sc,
AttributeSet a,
int defaultSize)
Returns the font for the values in the passed in AttributeSet. |
(package private) static int |
getFontSize(AttributeSet attr,
int defaultSize)
|
private HTML.Tag |
getHTMLTag(AttributeSet htmlAttrSet)
Fetches the tag associated with the HTML AttributeSet. |
(package private) static int |
getIndexOfSize(float pt)
|
(package private) 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 . |
(package private) float |
getLength(AttributeSet a,
CSS.Attribute key)
Returns the length of the attribute in a with
key key . |
(package private) float |
getPointSize(int index)
Return the point size, given a size index. |
(package private) float |
getPointSize(String size)
Returns the size of a font from the passed in string. |
(package private) static URL |
getURL(URL base,
String cssString)
Returns a URL for the given CSS url string. |
(package private) static Hashtable |
getValidFontNameMapping()
Returns a hashtable whose contents are used to indicate the valid fonts. |
(package private) static CSS.Value |
getValue(String name)
Translates a string to a CSS.Value object.
|
(package private) static Color |
hexToColor(String value)
Convert a "#FFFFFF" hex string to a Color. |
private boolean |
isFloater(String alignValue)
|
private boolean |
isHTMLFontTag(HTML.Tag tag)
|
private static Color |
parseRGB(String string)
Parses a String in the format rgb(r, g, b) where
each of the Color components is either an integer, or a floating number
with a % after indicating a percentage value of 255. |
(package private) static String[] |
parseStrings(String value)
|
private void |
readObject(ObjectInputStream s)
|
(package private) void |
setBaseFontSize(int sz)
Sets the base font size. |
(package private) void |
setBaseFontSize(String size)
Sets the base font size from the passed in string. |
(package private) static Color |
stringToColor(String str)
Convert a color string such as "RED" or "#NNNNNN" or "rgb(r, g, b)" to a Color. |
(package private) CSS.Attribute |
styleConstantsKeyToCSSKey(StyleConstants sc)
Maps from a StyleConstants to a CSS Attribute. |
(package private) Object |
styleConstantsValueToCSSValue(StyleConstants sc,
Object styleValue)
Maps from a StyleConstants value to a CSS value. |
private void |
translateAttribute(HTML.Attribute key,
AttributeSet htmlAttrSet,
MutableAttributeSet cssAttrSet)
|
private void |
translateAttributes(HTML.Tag tag,
AttributeSet htmlAttrSet,
MutableAttributeSet cssAttrSet)
|
private void |
translateEmbeddedAttributes(AttributeSet htmlAttrSet,
MutableAttributeSet cssAttrSet)
|
(package private) AttributeSet |
translateHTMLToCSS(AttributeSet htmlAttrSet)
Convert a set of HTML attributes to an equivalent set of CSS attributes. |
private boolean |
validTextAlignValue(String alignValue)
|
private void |
writeObject(ObjectOutputStream s)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final Hashtable attributeMap
private static final Hashtable valueMap
static int[] sizeMap
private static final Hashtable htmlAttrToCssAttrMap
private static final Hashtable styleConstantToCssMap
private static final Hashtable htmlValueToCssValueMap
private static final Hashtable cssValueToInternalValueMap
private static Hashtable fontMapping
private static final Object fontMappingLock
private transient Hashtable valueConvertor
private int baseFontSize
Constructor Detail |
public CSS()
Method Detail |
void setBaseFontSize(int sz)
sz
is a CSS value, and is
not necessarily the point size. Use getPointSize to determine the
point size corresponding to sz
.
void setBaseFontSize(String size)
int getBaseFontSize()
void addInternalCSSValue(MutableAttributeSet attr, CSS.Attribute key, String value)
key
with value
value
placing the result in att
.
Object getInternalCSSValue(CSS.Attribute key, String value)
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.
CSS.Attribute styleConstantsKeyToCSSKey(StyleConstants sc)
Object styleConstantsValueToCSSValue(StyleConstants sc, Object styleValue)
Object cssValueToStyleConstantsValue(StyleConstants key, Object value)
key
identifies the CSS attribute being mapped.
Font getFont(StyleContext sc, AttributeSet a, int defaultSize)
sc
is the StyleContext that will be messaged to get
the font once the size, name and style have been determined.
static int getFontSize(AttributeSet attr, int defaultSize)
Color getColor(AttributeSet a, CSS.Attribute key)
key
.
key
- CSS.Attribute identifying where color is stored.a
- the set of attributes
float getPointSize(String size)
size
- CSS string describing font sizefloat getLength(AttributeSet a, CSS.Attribute key)
a
with
key key
.
AttributeSet translateHTMLToCSS(AttributeSet htmlAttrSet)
static Hashtable getValidFontNameMapping()
public static CSS.Attribute[] getAllAttributeKeys()
public static final CSS.Attribute getAttribute(String name)
CSS.Attribute
object.
This will return null
if there is no attribute
by the given name.
name
- the name of the CSS attribute to fetch the
typesafe enumeration for
CSS.Attribute
object,
or null
if the string
doesn't represent a valid attribute keystatic final CSS.Value getValue(String name)
CSS.Value
object.
This will return null
if there is no value
by the given name.
name
- the name of the CSS value to fetch the
typesafe enumeration for
CSS.Value
object,
or null
if the string
doesn't represent a valid CSS value name; this does
not mean that it doesn't represent a valid CSS valuestatic URL getURL(URL base, String cssString)
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.
static String colorToHex(Color color)
static final Color hexToColor(String value)
static Color stringToColor(String str)
private static Color parseRGB(String string)
rgb(r, g, b)
where
each of the Color components is either an integer, or a floating number
with a % after indicating a percentage value of 255. Values are
constrained to fit with 0-255. The resulting Color is returned.
private static int getColorComponent(String string, int[] index)
string
starting
at index[0]
. The value can either can an integer, or
a percentage (floating number ending with %), in which case it is
multiplied by 255.
static int getIndexOfSize(float pt)
static String[] parseStrings(String value)
value
that are separated by whitespace.float getPointSize(int index)
private void translateEmbeddedAttributes(AttributeSet htmlAttrSet, MutableAttributeSet cssAttrSet)
private void translateAttributes(HTML.Tag tag, AttributeSet htmlAttrSet, MutableAttributeSet cssAttrSet)
private void translateAttribute(HTML.Attribute key, AttributeSet htmlAttrSet, MutableAttributeSet cssAttrSet)
Object getCssValue(CSS.Attribute cssAttr, String htmlAttrValue)
private CSS.Attribute[] getCssAttribute(HTML.Attribute hAttr)
private CSS.Attribute getCssAlignAttribute(HTML.Tag tag, AttributeSet htmlAttrSet)
private HTML.Tag getHTMLTag(AttributeSet htmlAttrSet)
private boolean isHTMLFontTag(HTML.Tag tag)
private boolean isFloater(String alignValue)
private boolean validTextAlignValue(String alignValue)
static SizeRequirements calculateTiledRequirements(CSS.LayoutIterator iter, SizeRequirements r)
static void calculateTiledLayout(CSS.LayoutIterator iter, int targetSpan)
private void writeObject(ObjectOutputStream s) throws IOException
IOException
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException
ClassNotFoundException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |