Multivalent API

multivalent.std.adaptor
Class CSS

java.lang.Object
  extended by multivalent.StyleSheet
      extended by multivalent.std.adaptor.CSS
All Implemented Interfaces:
java.lang.Cloneable

public class CSS
extends StyleSheet

Cascading Style Sheet (CSS) reader, with some CSS2.

For now, minimal support. Supported: &64;import { :; } such as

                <STYLE>
                        .c1 { color:yellow; }
                        .c2 { color:red; }
                        .c3 { color:orange; }
                </STYLE>
                
Not supported: nested selectors and everything else.

CSS has many attributes, which should be carried along in the graphics context. When asked about an attribute (even for its own use), a node looks at its local attributes, then the gc's, then the default. But for now we just hardcode a couple special cases.

NOT supported: reference by LINK, contextual selectors: e.g, "OL OL", "H1.c1" pseudo classes, pseudo elements: e.g., "A:visited", "P:first-line", ... display property (which can be used to render XML directly, as it declares elements to be "block"/structural or "inline"/span) properties other than font and color

Since CSS is used by other specs, such as SVG, maybe just parse into name-value pairs and let clients put into native data types, if desired. general font/general color/underline/rest of Context properties

Version:
$Revision: 1.9 $ $Date: 2004/11/04 05:27:55 $
See Also:
CSSGeneral, CSSContext

Field Summary
protected static int BACKGROUND
           
protected static int BACKGROUND_ATTACHMENT
           
protected static int BACKGROUND_COLOR
           
protected static int BACKGROUND_IMAGE
           
protected static int BACKGROUND_POSITION
           
protected static int BACKGROUND_REPEAT
           
protected static int BORDER
           
protected static int BORDER_BOTTOM
           
protected static int BORDER_BOTTOM_WIDTH
           
protected static int BORDER_COLOR
           
protected static int BORDER_LEFT
           
protected static int BORDER_LEFT_WIDTH
           
protected static int BORDER_RIGHT
           
protected static int BORDER_RIGHT_WIDTH
           
protected static int BORDER_STYLE
           
protected static int BORDER_TOP
           
protected static int BORDER_TOP_WIDTH
           
protected static int BORDER_WIDTH
           
protected static int CLEAR
           
protected static int COLOR
           
protected static int DISPLAY
           
protected static int ELIDE
           
protected static int END_CSS
           
protected static int END_CSS2
           
protected static int FLOAT
           
protected static int FONT
           
protected static int FONT_FAMILY
           
protected static int FONT_SIZE
           
protected static int FONT_STYLE
           
protected static int FONT_VARIANT
           
protected static int FONT_WEIGHT
           
protected static int HEIGHT
           
protected static java.util.Map<java.lang.String,java.lang.Integer> keyword2int_
           
protected static int LETTER_SPACING
           
protected static int LINE_HEIGHT
           
protected static int LIST_STYLE
           
protected static int LIST_STYLE_IMAGE
           
protected static int LIST_STYLE_POSITION
           
protected static int LIST_STYLE_TYPE
           
protected static int MARGIN
           
protected static int MARGIN_BOTTOM
           
protected static int MARGIN_LEFT
           
protected static int MARGIN_RIGHT
           
protected static int MARGIN_TOP
           
protected static int PADDING
           
protected static int PADDING_BOTTOM
           
protected static int PADDING_LEFT
           
protected static int PADDING_RIGHT
           
protected static int PADDING_TOP
           
protected static int START_CSS
           
protected static int START_CSS2
           
protected static int TEXT_ALIGN
           
protected static int TEXT_DECORATION
           
protected static int TEXT_INDENT
           
protected static int TEXT_TRANSFORM
           
protected static int VERTICAL_ALIGN
           
protected static int VISIBILITY
           
protected static int WHITE_SPACE
           
protected static int WIDTH
           
protected static int WORD_SPACING
           
 
Fields inherited from class multivalent.StyleSheet
cascade_, cx_, key2cl_, name_, PRIORITY_BLOCK, PRIORITY_CLASS, PRIORITY_ELEMENT, PRIORITY_ID, PRIORITY_INLINE, TERMINAL
 
Constructor Summary
CSS()
           
 
Method Summary
 void activesAdd(java.util.List<ContextListener> actives, VObject o, Node parent)
          Add all relevant ContextListeners to Context.
 void activesRemove(java.util.List<ContextListener> actives, VObject o, Node parent)
           
protected  Context createContext()
          Create new Context matched to this StyleSheet's ContextListeners.
 int getBorderColors(java.lang.String vals)
          Returns count.
 int getBorderWidth(java.lang.String val)
           
 int getBorderWidths(java.lang.String vals)
          Returns count.
 int getLength(java.lang.String val)
           
 int getLengths(java.lang.String vals)
          Returns count.
 void parse(java.lang.String csstxt, java.net.URL base)
          Parse stylesheet to hash of selector - CSSGeneral.
 void setAttr(CSSGeneral gs, java.lang.String name, java.lang.String value)
          Convert passed attribute name and value into setting in CSSGeneral.
 void setAttrs(CSSGeneral gs, java.lang.String pairs)
          Parse list of attribute name-value pairs into settings in CSSGeneral.
 void setPriority(java.lang.String selector, CLGeneral cl)
          Compute priority of passed selector.
 
Methods inherited from class multivalent.StyleSheet
copy, eatSpace, get, get, getCascade, getCascade, getContext, getContext, getName, parse, put, put, remove, remove, setAttr, setAttrs, setCascade, setCascade, setName, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

START_CSS

protected static final int START_CSS
See Also:
Constant Field Values

FONT

protected static final int FONT
See Also:
Constant Field Values

FONT_FAMILY

protected static final int FONT_FAMILY
See Also:
Constant Field Values

FONT_STYLE

protected static final int FONT_STYLE
See Also:
Constant Field Values

FONT_VARIANT

protected static final int FONT_VARIANT
See Also:
Constant Field Values

FONT_WEIGHT

protected static final int FONT_WEIGHT
See Also:
Constant Field Values

FONT_SIZE

protected static final int FONT_SIZE
See Also:
Constant Field Values

COLOR

protected static final int COLOR
See Also:
Constant Field Values

BACKGROUND

protected static final int BACKGROUND
See Also:
Constant Field Values

BACKGROUND_COLOR

protected static final int BACKGROUND_COLOR
See Also:
Constant Field Values

BACKGROUND_IMAGE

protected static final int BACKGROUND_IMAGE
See Also:
Constant Field Values

BACKGROUND_REPEAT

protected static final int BACKGROUND_REPEAT
See Also:
Constant Field Values

BACKGROUND_ATTACHMENT

protected static final int BACKGROUND_ATTACHMENT
See Also:
Constant Field Values

BACKGROUND_POSITION

protected static final int BACKGROUND_POSITION
See Also:
Constant Field Values

WORD_SPACING

protected static final int WORD_SPACING
See Also:
Constant Field Values

LETTER_SPACING

protected static final int LETTER_SPACING
See Also:
Constant Field Values

TEXT_DECORATION

protected static final int TEXT_DECORATION
See Also:
Constant Field Values

VERTICAL_ALIGN

protected static final int VERTICAL_ALIGN
See Also:
Constant Field Values

TEXT_TRANSFORM

protected static final int TEXT_TRANSFORM
See Also:
Constant Field Values

TEXT_ALIGN

protected static final int TEXT_ALIGN
See Also:
Constant Field Values

TEXT_INDENT

protected static final int TEXT_INDENT
See Also:
Constant Field Values

LINE_HEIGHT

protected static final int LINE_HEIGHT
See Also:
Constant Field Values

MARGIN

protected static final int MARGIN
See Also:
Constant Field Values

MARGIN_TOP

protected static final int MARGIN_TOP
See Also:
Constant Field Values

MARGIN_BOTTOM

protected static final int MARGIN_BOTTOM
See Also:
Constant Field Values

MARGIN_LEFT

protected static final int MARGIN_LEFT
See Also:
Constant Field Values

MARGIN_RIGHT

protected static final int MARGIN_RIGHT
See Also:
Constant Field Values

PADDING

protected static final int PADDING
See Also:
Constant Field Values

PADDING_TOP

protected static final int PADDING_TOP
See Also:
Constant Field Values

PADDING_BOTTOM

protected static final int PADDING_BOTTOM
See Also:
Constant Field Values

PADDING_LEFT

protected static final int PADDING_LEFT
See Also:
Constant Field Values

PADDING_RIGHT

protected static final int PADDING_RIGHT
See Also:
Constant Field Values

BORDER_WIDTH

protected static final int BORDER_WIDTH
See Also:
Constant Field Values

BORDER_TOP_WIDTH

protected static final int BORDER_TOP_WIDTH
See Also:
Constant Field Values

BORDER_BOTTOM_WIDTH

protected static final int BORDER_BOTTOM_WIDTH
See Also:
Constant Field Values

BORDER_LEFT_WIDTH

protected static final int BORDER_LEFT_WIDTH
See Also:
Constant Field Values

BORDER_RIGHT_WIDTH

protected static final int BORDER_RIGHT_WIDTH
See Also:
Constant Field Values

BORDER_COLOR

protected static final int BORDER_COLOR
See Also:
Constant Field Values

BORDER_STYLE

protected static final int BORDER_STYLE
See Also:
Constant Field Values

BORDER

protected static final int BORDER
See Also:
Constant Field Values

BORDER_TOP

protected static final int BORDER_TOP
See Also:
Constant Field Values

BORDER_BOTTOM

protected static final int BORDER_BOTTOM
See Also:
Constant Field Values

BORDER_LEFT

protected static final int BORDER_LEFT
See Also:
Constant Field Values

BORDER_RIGHT

protected static final int BORDER_RIGHT
See Also:
Constant Field Values

WIDTH

protected static final int WIDTH
See Also:
Constant Field Values

HEIGHT

protected static final int HEIGHT
See Also:
Constant Field Values

FLOAT

protected static final int FLOAT
See Also:
Constant Field Values

CLEAR

protected static final int CLEAR
See Also:
Constant Field Values

DISPLAY

protected static final int DISPLAY
See Also:
Constant Field Values

WHITE_SPACE

protected static final int WHITE_SPACE
See Also:
Constant Field Values

LIST_STYLE

protected static final int LIST_STYLE
See Also:
Constant Field Values

LIST_STYLE_TYPE

protected static final int LIST_STYLE_TYPE
See Also:
Constant Field Values

LIST_STYLE_IMAGE

protected static final int LIST_STYLE_IMAGE
See Also:
Constant Field Values

LIST_STYLE_POSITION

protected static final int LIST_STYLE_POSITION
See Also:
Constant Field Values

END_CSS

protected static final int END_CSS
See Also:
Constant Field Values

START_CSS2

protected static final int START_CSS2
See Also:
Constant Field Values

VISIBILITY

protected static final int VISIBILITY
See Also:
Constant Field Values

END_CSS2

protected static final int END_CSS2
See Also:
Constant Field Values

ELIDE

protected static final int ELIDE
See Also:
Constant Field Values

keyword2int_

protected static java.util.Map<java.lang.String,java.lang.Integer> keyword2int_
Constructor Detail

CSS

public CSS()
Method Detail

createContext

protected Context createContext()
Description copied from class: StyleSheet
Create new Context matched to this StyleSheet's ContextListeners. StyleSheet subclasses should override.

Overrides:
createContext in class StyleSheet

activesAdd

public void activesAdd(java.util.List<ContextListener> actives,
                       VObject o,
                       Node parent)
Description copied from class: StyleSheet
Add all relevant ContextListeners to Context. After invoking parent cascade, this simple implementation tries VObject's name and handle as selectors. Called directly by Leaf, indirectly by INode through paintBefore.

Overrides:
activesAdd in class StyleSheet

activesRemove

public void activesRemove(java.util.List<ContextListener> actives,
                          VObject o,
                          Node parent)
Overrides:
activesRemove in class StyleSheet

getLength

public int getLength(java.lang.String val)

getLengths

public int getLengths(java.lang.String vals)
Returns count.


getBorderWidth

public int getBorderWidth(java.lang.String val)

getBorderWidths

public int getBorderWidths(java.lang.String vals)
Returns count.


getBorderColors

public int getBorderColors(java.lang.String vals)
Returns count.


setAttr

public void setAttr(CSSGeneral gs,
                    java.lang.String name,
                    java.lang.String value)
Convert passed attribute name and value into setting in CSSGeneral. CSSGeneral has space overhead, but have limited number of style sheet specs per document. Method also used to process STYLE attribute in arbitrary tags (which means that all HTML tags must be Generic*). Subclass CSSGeneral to handle CSS2.


setAttrs

public void setAttrs(CSSGeneral gs,
                     java.lang.String pairs)
Parse list of attribute name-value pairs into settings in CSSGeneral.


setPriority

public void setPriority(java.lang.String selector,
                        CLGeneral cl)
Description copied from class: StyleSheet
Compute priority of passed selector.

Overrides:
setPriority in class StyleSheet

parse

public void parse(java.lang.String csstxt,
                  java.net.URL base)
Parse stylesheet to hash of selector - CSSGeneral.

Overrides:
parse in class StyleSheet

Multivalent API