|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.text.StyleContext
javax.swing.text.html.StyleSheet
public class StyleSheet
This class adds support for defining the visual characteristics of HTML views being rendered. This enables views to be customized by a look-and-feel, mulitple views over the same model can be rendered differently. Each EditorPane has its own StyleSheet, but by default one sheet will be shared by all of the HTMLEditorKit instances. An HTMLDocument can also have a StyleSheet, which holds specific CSS specs. 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. Since the StyleSheet may be used by views over multiple documents the HTML attributes don't effect the selector being used. The rules are stored as named styles, and other information is stored to translate the context of an element to a rule.
Nested Class Summary | |
---|---|
static class |
StyleSheet.BoxPainter
This class carries out some of the duties of CSS formatting. |
static class |
StyleSheet.ListPainter
This class carries out some of the CSS list formatting duties. |
Nested classes/interfaces inherited from class javax.swing.text.StyleContext |
---|
StyleContext.NamedStyle, StyleContext.SmallAttributeSet |
Field Summary |
---|
Fields inherited from class javax.swing.text.StyleContext |
---|
DEFAULT_STYLE |
Constructor Summary | |
---|---|
StyleSheet()
Constructs a StyleSheet. |
Method Summary | |
---|---|
AttributeSet |
addAttribute(AttributeSet old,
Object key,
Object value)
Adds an attribute to the given set and returns a new set. |
AttributeSet |
addAttributes(AttributeSet old,
AttributeSet attr)
Adds a set of attributes to the element. |
void |
addCSSAttribute(MutableAttributeSet attr,
CSS.Attribute key,
String value)
Adds a CSS attribute to the given set. |
boolean |
addCSSAttributeFromHTML(MutableAttributeSet attr,
CSS.Attribute key,
String value)
Adds a CSS attribute to the given set. |
void |
addRule(String rule)
Adds a set of rules to the sheet. |
void |
addStyleSheet(StyleSheet ss)
Adds the rules from ss to those of the receiver. ss's rules will override the old rules. |
protected MutableAttributeSet |
createLargeAttributeSet(AttributeSet a)
Creates a large set of attributes. |
protected StyleContext.SmallAttributeSet |
createSmallAttributeSet(AttributeSet a)
Creates a compact set of attributes that might be shared. |
Color |
getBackground(AttributeSet a)
Takes a set of attributes and turns it into a background color specification. |
URL |
getBase()
Gets the base url. |
StyleSheet.BoxPainter |
getBoxPainter(AttributeSet a)
Gets the box formatter to use for the given set of CSS attributes. |
AttributeSet |
getDeclaration(String decl)
Translates a CSS declaration into an AttributeSet. |
Font |
getFont(AttributeSet a)
Gets the font to use for the given set. |
Color |
getForeground(AttributeSet a)
Takes a set of attributes and turns it into a foreground color specification. |
static int |
getIndexOfSize(float pt)
TODO |
StyleSheet.ListPainter |
getListPainter(AttributeSet a)
Gets the list formatter to use for the given set of CSS attributes. |
float |
getPointSize(int index)
Gets the point size, given a size index. |
float |
getPointSize(String size)
Given the string of the size, returns the point size value. |
Style |
getRule(HTML.Tag t,
Element e)
Gets the style used to render the given tag. |
Style |
getRule(String selector)
Gets the rule that best matches the selector. selector is a space separated String of element names. |
StyleSheet[] |
getStyleSheets()
Returns an array of the linked StyleSheets. |
AttributeSet |
getViewAttributes(View v)
Gets a set of attributes to use in the view. |
void |
importStyleSheet(URL url)
Imports a style sheet from the url. |
void |
loadRules(Reader in,
URL ref)
Loads a set of rules that have been specified in terms of CSS grammar. |
AttributeSet |
removeAttribute(AttributeSet old,
Object key)
Removes an attribute from the set. |
AttributeSet |
removeAttributes(AttributeSet old,
AttributeSet attrs)
Removes an attribute from the set. |
AttributeSet |
removeAttributes(AttributeSet old,
Enumeration<?> names)
Removes a set of attributes for the element. |
void |
removeStyle(String nm)
Removes a style previously added. |
void |
removeStyleSheet(StyleSheet ss)
Removes ss from those of the receiver |
void |
setBase(URL base)
Sets the base url. |
void |
setBaseFontSize(int sz)
Sets the base font size between 1 and 7. |
void |
setBaseFontSize(String size)
Sets the base font size from the String. |
Color |
stringToColor(String colorName)
Convert the color string represenation into java.awt.Color. |
AttributeSet |
translateHTMLToCSS(AttributeSet htmlAttrSet)
Converts a set of HTML attributes to an equivalent set of CSS attributes. |
Methods inherited from class javax.swing.text.StyleContext |
---|
addChangeListener, addStyle, getChangeListeners, getCompressionThreshold, getDefaultStyleContext, getEmptySet, getFont, getFontMetrics, getStaticAttribute, getStaticAttributeKey, getStyle, getStyleNames, readAttributes, readAttributeSet, reclaim, registerStaticAttributeKey, removeChangeListener, 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 tag to translate to visual attributese
- - the element representing the tag
public Style getRule(String selector)
selector
- - the element names separated by spaces
public void addRule(String rule)