|
Java Platform 1.2 Beta 4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.java.swing.text.StyleContext | +--com.sun.java.swing.text.html.StyleSheet
toString
method is required
to return a string representation of css value.
The primary entry point for HTML View implementations to get their attributes is the getRule method. This should be implemented to establish the desired policy used to associate attributes with the view. Each HTMLEditorKit (i.e. and therefore each associated JEditorPane) can have its own StyleSheet, but by default one sheet will be shared by all of the HTMLEditorKit instances. HTMLDocument instance can also have a StyleSheet, which holds the document-specific css specifications.
In order for Views to store less state and therefore be more lightweight, the StyleSheet can act as a factory for painters that handle some of the rendering tasks. This allows implementations to determine what they want to cache and have the sharing potentially at the level that a selector is common to multiple views. Since the StyleSheet may be used by views over multiple documents and typically the html attributes don't effect the selector being used, the potential for sharing is significant.
Inner Class Summary | |
static | StyleSheet.BoxPainter
Class to carry out some of the duties of css formatting. |
static | StyleSheet.ListPainter
class to carry out some of the duties of css list formatting. |
Inner classes inherited from class com.sun.java.swing.text.StyleContext | |
StyleContext.NamedStyle |
Fields inherited from class com.sun.java.swing.text.StyleContext | |
DEFAULT_STYLE |
Constructor Summary | |
StyleSheet()
Construct a StyleSheet |
Method Summary | |
void | addRule(String rule)
Add a set of rules to the sheet. |
Color | getBackground(AttributeSet a)
Takes a set of attributes and turn it into a background color specification. |
StyleSheet.BoxPainter | getBoxPainter(AttributeSet a)
Fetch the box formatter to use for the given set of css attributes. |
AttributeSet | getDeclaration(String decl)
Translate a CSS declaration to an AttributeSet that represents the CSS declaration. |
Font | getFont(AttributeSet a)
Fetch the font to use for the given set of attributes. |
Color | getForeground(AttributeSet a)
Takes a set of attributes and turn it into a foreground color specification. |
static int | getIndexOfSize(float pt)
|
StyleSheet.ListPainter | getListPainter(AttributeSet a)
Fetch the list formatter to use for the given set of css attributes. |
float | getPointSize(int index)
Return the point size, given a size index. |
float | getPointSize(String size)
Given a string "+2" |
Style | getRule(HTML.Tag t,
Element e)
Fetch the style to use to render the given type of html tag. |
Style | getRule(String selector)
Fetch the rule that best matches the selector given in string form. |
AttributeSet | getViewAttributes(View v)
Fetch a set of attributes to use in the view for displaying. |
void | loadRules(Reader in,
URL ref)
Load a set of rules that have been specified in terms of CSS1 grammar. |
void | setBaseFontSize(int sz)
|
void | setBaseFontSize(String size)
|
Color | stringToColor(String str)
Convert a color string "RED" or "#NNNNNN" to a Color. |
AttributeSet | translateHTMLToCSS(AttributeSet htmlAttrSet)
Convert a set of html attributes to an equivalent set of css attributes. |
Methods inherited from class com.sun.java.swing.text.StyleContext | |
addAttribute , addAttributes , addChangeListener , addStyle , getCompressionThreshold , getDefaultStyleContext , getEmptySet , getFont , getFontMetrics , getStyle , getStyleNames , readAttributes , readAttributeSet , reclaim , registerStaticAttributeKey , removeAttribute , removeAttributes , removeAttributes , removeChangeListener , removeStyle , toString , writeAttributes , writeAttributeSet |
Methods inherited from class java.lang.Object | |
clone , equals , finalize , getClass , hashCode , notify , notifyAll , wait , wait , wait |
Constructor Detail |
public StyleSheet()
Method Detail |
public Style getRule(HTML.Tag t, Element e)
t
- the type to translate to visual attributes.
e
- the element representing the tag. The element
can be used to determine the nesting for situations where
the attributes will differ if nested inside of other
elements.public Style getRule(String selector)
public void addRule(String rule)
public AttributeSet getDeclaration(String decl)
public void loadRules(Reader in, URL ref) throws IOException
in
- the stream to read the css grammar from.
ref
- the reference url. This value represents the
location of the stream and may be null. All relative
urls specified in the stream will be based upon this
parameter.public AttributeSet getViewAttributes(View v)
public Font getFont(AttributeSet a)
public Color getForeground(AttributeSet a)
a
- the set of attributespublic Color getBackground(AttributeSet a)
attr
- the set of attributespublic StyleSheet.BoxPainter getBoxPainter(AttributeSet a)
public StyleSheet.ListPainter getListPainter(AttributeSet a)
public Color stringToColor(String str)
public void setBaseFontSize(int sz)
public void setBaseFontSize(String size)
public static int getIndexOfSize(float pt)
public float getPointSize(int index)
public float getPointSize(String size)
public AttributeSet translateHTMLToCSS(AttributeSet htmlAttrSet)
AttributeSet
- containing the HTML attributes.
AttributeSet
- containing the corresponding CSS attributes.
The AttributeSet will be empty if there are no mapping
CSS attributes.
|
Java Platform 1.2 Beta 4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |