Home » openjdk-7 » javax » swing » text » html » [javadoc | source]
public class: CSS [javadoc | source]

All Implemented Interfaces:

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:

The following are modeled, but currently not rendered.

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.

Nested Class Summary:
public static final class  CSS.Attribute  Definitions to be used as a key on AttributeSet's that might hold CSS attributes. Since this is a closed set (i.e. defined exactly by the specification), it is final and cannot be extended. 
static final class  CSS.Value   
static class  CSS.CssValue  Base class to CSS values in the attribute sets. This is intended to act as a convertor to/from other attribute formats.

The CSS parser uses the parseCssValue method to convert a string to whatever format is appropriate a given key (i.e. these convertors are stored in a map using the CSS.Attribute as a key and the CssValue as the value).

The HTML to CSS conversion process first converts the HTML.Attribute to a CSS.Attribute, and then calls the parseHtmlValue method on the value of the HTML attribute to produce the corresponding CSS value.

The StyleConstants to CSS conversion process first converts the StyleConstants attribute to a CSS.Attribute, and then calls the fromStyleConstants method to convert the StyleConstants value to a CSS value.

The CSS to StyleConstants conversion process first converts the StyleConstants attribute to a CSS.Attribute, and then calls the toStyleConstants method to convert the CSS value to a StyleConstants value. 

static class  CSS.StringValue  By default CSS attributes are represented as simple strings. They also have no conversion to/from StyleConstants by default. This class represents the value as a string (via the superclass), but provides StyleConstants conversion support for the CSS attributes that are held as strings. 
class  CSS.FontSize  Represents a value for the CSS.FONT_SIZE attribute. The binary format of the value can be one of several types. If the type is Float, the value is specified in terms of point or percentage, depending upon the ending of the associated string. If the type is Integer, the value is specified in terms of a size index. 
static class  CSS.FontFamily   
static class  CSS.FontWeight   
static class  CSS.ColorValue   
static class  CSS.BorderStyle   
static class  CSS.LengthValue   
static class  CSS.BorderWidthValue  BorderWidthValue is used to model BORDER_XXX_WIDTH and adds support for the thin/medium/thick values. 
static class  CSS.CssValueMapper  Handles uniquing of CSS values, like lists, and background image repeating. 
static class  CSS.BackgroundPosition  Used for background images, to represent the position. 
static class  CSS.BackgroundImage  Used for BackgroundImages. 
static class  CSS.LengthUnit  Parses a length value, this is used internally, and never added to an AttributeSet or returned to the developer. 
static class  CSS.ShorthandFontParser  Class used to parse font property. The font property is shorthand for the other font properties. This expands the properties, placing them in the attributeset. 
static class  CSS.ShorthandBackgroundParser  Parses the background property into its intrinsic values. 
static class  CSS.ShorthandMarginParser  Used to parser margin and padding. 
static class  CSS.ShorthandBorderParser   
interface  CSS.LayoutIterator  An iterator to express the requirements to use when computing layout. 
Field Summary
static  int baseFontSizeIndex     
 public CSS() 
Method from javax.swing.text.html.CSS Summary:
addInternalCSSValue,   calculateTiledLayout,   calculateTiledRequirements,   colorToHex,   cssValueToStyleConstantsValue,   getAllAttributeKeys,   getAttribute,   getBaseFontSize,   getColor,   getCssValue,   getFont,   getFontSize,   getIndexOfSize,   getIndexOfSize,   getInternalCSSValue,   getLength,   getPointSize,   getPointSize,   getURL,   getValue,   hexToColor,   parseStrings,   setBaseFontSize,   setBaseFontSize,   stringToColor,   styleConstantsKeyToCSSKey,   styleConstantsValueToCSSValue,   translateHTMLToCSS
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.swing.text.html.CSS Detail:
  void addInternalCSSValue(MutableAttributeSet attr,
    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. 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.
 static SizeRequirements calculateTiledRequirements(LayoutIterator iter,
    SizeRequirements r) 
    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.
 static String colorToHex(Color color) 
    Converts a type Color to a hex string in the format "#RRGGBB"
 Object cssValueToStyleConstantsValue(StyleConstants key,
    Object value) 
    Converts the passed in CSS value to a StyleConstants value. key identifies the CSS attribute being mapped.
 public static Attribute[] getAllAttributeKeys() 
    Return the set of all possible CSS attribute keys.
 public static final Attribute getAttribute(String name) 
    Translates a string to a CSS.Attribute object. This will return null if there is no attribute by the given name.
 int getBaseFontSize() 
    Returns the base font size.
 Color getColor(AttributeSet a,
    Attribute key) 
    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.
 Object getCssValue(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. 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.
 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(Attribute key,
    String value) 
    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.
 float getLength(AttributeSet a,
    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. Legal HTML index sizes are 1-7.
 static URL getURL(URL base,
    String cssString) 
    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.
 static final Value getValue(String name) 
    Translates a string to a CSS.Value object. This will return null if there is no value by the given name.
 static final Color hexToColor(String value) 
    Convert a "#FFFFFF" hex string to a Color. If the color specification is bad, an attempt will be made to fix it up.
 static String[] parseStrings(String value) 
  void setBaseFontSize(int sz) 
    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.
  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.