|
Préférences
Moteurs de recherche
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.6.0
javax.swing.text.html
|
Nested Class Summary | |
---|---|
static class |
StyleSheet.BoxPainter
Class to carry out some of the duties of CSS formatting. |
static class |
StyleSheet.ListPainter
Class to carry out some of the duties of CSS list formatting. |
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()
Construct a StyleSheet |
Method Summary | |
---|---|
AttributeSet |
addAttribute(AttributeSet old,
Object key,
Object value)
Adds an attribute to the given set, and returns the new representative 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 the StyleSheet ss to those of
the receiver. |
protected MutableAttributeSet |
createLargeAttributeSet(AttributeSet a)
Creates a large set of attributes that should trade off space for time. |
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 turn it into a background color specification. |
URL |
getBase()
Returns the base. |
StyleSheet.BoxPainter |
getBoxPainter(AttributeSet a)
Fetches the box formatter to use for the given set of CSS attributes. |
AttributeSet |
getDeclaration(String decl)
Translates a CSS declaration to an AttributeSet that represents the CSS declaration. |
Font |
getFont(AttributeSet a)
Fetches 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)
Fetches the list formatter to use for the given set of CSS attributes. |
float |
getPointSize(int index)
Returns the point size, given a size index. |
float |
getPointSize(String size)
Given a string such as "+2", "-2", or "2", returns a point size value. |
Style |
getRule(HTML.Tag t,
Element e)
Fetches the style to use to render the given type of HTML tag. |
Style |
getRule(String selector)
Fetches the rule that best matches the selector given in string form. |
StyleSheet[] |
getStyleSheets()
Returns an array of the linked StyleSheets. |
AttributeSet |
getViewAttributes(View v)
Fetches a set of attributes to use in the view for displaying. |
void |
importStyleSheet(URL url)
Imports a style sheet from url . |
void |
loadRules(Reader in,
URL ref)
Loads a set of rules that have been specified in terms of CSS1 grammar. |
AttributeSet |
removeAttribute(AttributeSet old,
Object key)
Removes an attribute from the set. |
AttributeSet |
removeAttributes(AttributeSet old,
AttributeSet attrs)
Removes a set of attributes. |
AttributeSet |
removeAttributes(AttributeSet old,
Enumeration<?> names)
Removes a set of attributes for the element. |
void |
removeStyle(String nm)
Removes a named style previously added to the document. |
void |
removeStyleSheet(StyleSheet ss)
Removes the StyleSheet ss from those of the receiver. |
void |
setBase(URL base)
Sets the base. |
void |
setBaseFontSize(int sz)
Sets the base font size, with valid values between 1 and 7. |
void |
setBaseFontSize(String size)
Sets the base font size from the passed in String. |
Color |
stringToColor(String string)
Converts a color string such as "RED" or "#NNNNNN" to a 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 type to translate to visual attributese
- 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)
selector
is a space separated
String of the element names. For example, selector
might be 'html body tr td''The attributes of the returned Style will change as rules are added and removed. That is if you to ask for a rule with a selector "table p" and a new rule was added with a selector of "p" the returned Style would include the new attributes from the rule "p".
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 fromref
- 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.
IOException
public AttributeSet getViewAttributes(View v)
public void removeStyle(String nm)
removeStyle
in class StyleContext
nm
- the name of the style to removepublic void addStyleSheet(StyleSheet ss)
ss
to those of
the receiver. ss's
rules will override the rules of
any previously added style sheets. An added StyleSheet will never
override the rules of the receiving style sheet.
public void removeStyleSheet(StyleSheet ss)
ss
from those of the receiver.
public StyleSheet[] getStyleSheets()
public void importStyleSheet(URL url)
url
. The resulting rules
are directly added to the receiver. If you do not want the rules
to become part of the receiver, create a new StyleSheet and use
addStyleSheet to link it in.
public void setBase(URL base)
base
.
public URL getBase()
public void addCSSAttribute(MutableAttributeSet attr, CSS.Attribute key, String value)
public boolean addCSSAttributeFromHTML(MutableAttributeSet attr, CSS.Attribute key, String value)
public AttributeSet translateHTMLToCSS(AttributeSet htmlAttrSet)
htmlAttrSet
- AttributeSet containing the HTML attributes.public AttributeSet addAttribute(AttributeSet old, Object key, Object value)
addAttribute
in interface AbstractDocument.AttributeContext
addAttribute
in class StyleContext
old
- the old attribute setkey
- the non-null attribute keyvalue
- the attribute value
MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object)
public AttributeSet addAttributes(AttributeSet old, AttributeSet attr)
addAttributes
in interface AbstractDocument.AttributeContext
addAttributes
in class StyleContext
old
- the old attribute setattr
- the attributes to add
MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object)
public AttributeSet removeAttribute(AttributeSet old, Object key)
removeAttribute
in interface AbstractDocument.AttributeContext
removeAttribute
in class StyleContext
old
- the old set of attributeskey
- the non-null attribute name
MutableAttributeSet.removeAttribute(java.lang.Object)
public AttributeSet removeAttributes(AttributeSet old, Enumeration<?> names)
removeAttributes
in interface AbstractDocument.AttributeContext
removeAttributes
in class StyleContext
old
- the old attribute setnames
- the attribute names
MutableAttributeSet.removeAttributes(java.util.Enumeration>)
public AttributeSet removeAttributes(AttributeSet old, AttributeSet attrs)
removeAttributes
in interface AbstractDocument.AttributeContext
removeAttributes
in class StyleContext
old
- the old attribute setattrs
- the attributes
MutableAttributeSet.removeAttributes(java.util.Enumeration>)
protected StyleContext.SmallAttributeSet createSmallAttributeSet(AttributeSet a)
createSmallAttributeSet
in class StyleContext
a
- The set of attributes to be represented in the
the compact form.protected MutableAttributeSet createLargeAttributeSet(AttributeSet a)
createLargeAttributeSet
in class StyleContext
a
- The set of attributes to be represented in the
the larger form.public Font getFont(AttributeSet a)
getFont
in class StyleContext
a
- the attribute set
public Color getForeground(AttributeSet a)
getForeground
in class StyleContext
a
- the set of attributes
public Color getBackground(AttributeSet a)
getBackground
in class StyleContext
a
- the set of attributes
public StyleSheet.BoxPainter getBoxPainter(AttributeSet a)
public StyleSheet.ListPainter getListPainter(AttributeSet a)
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 Color stringToColor(String string)