|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.inet.html.css.StyleResolver
public class StyleResolver
The style resolver will handle all read operations on the current style sheets. It will fill the
temporary styles into the elements attribute sets and handle the access to these style informations.
NOTE: This class does not supervise it's internal style sheet objects! You are free to change them at any time,
but keep in mind that changing the stylesheets will not update the documents model.
Constructor Summary | |
---|---|
StyleResolver()
|
Method Summary | ||
---|---|---|
void |
clearStyles()
Clears the currently set styles table |
|
void |
fillAttributesNonLocked(javax.swing.text.Element root,
java.util.HashMap<TemporaryStyle.Attribute,java.lang.Object> parentSet)
Sets the temporary style information for an element. |
|
static
|
getAttributeValue(javax.swing.text.Element elem,
com.inet.html.finder.AttributeFinder<T> finder)
Searches the correct style for the requested attribute. |
|
static
|
getAttributeValue(javax.swing.text.Element elem,
com.inet.html.finder.AttributeFinder<T> finder,
boolean useCache)
Searches the correct style for the requested attribute. |
|
java.util.Enumeration<?> |
getStyleNames()
Fetches a list of the currently used styles. |
|
Styles |
getStyles()
Returns the current styles table |
|
Styles |
getStyleSheet(java.lang.String nm)
Returns the style with the given name. |
|
void |
handleNewCSSEntry(Selector selector)
Notifies the listener if a selector was added |
|
static boolean |
hasRelevantInlineStyles(javax.swing.text.Element element)
Checks whether this element has any (inline) attribute attached, which distinguishes it from it's parent. |
|
static boolean |
matchesAttributes(javax.swing.text.Element element,
javax.swing.text.AttributeSet requirements)
Checks, whether the given element matches the defined attributes. |
|
void |
optimize()
Creates an internal list of which styles are described by the registered stylesheets and which one will remain the default. |
|
static void |
setAttribute(javax.swing.text.AttributeSet attrs,
java.lang.Object name,
java.lang.Object value)
Adds the value to the attribute set if the value is not null. |
|
void |
setStyles(Styles styles)
Sets the current styles table. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StyleResolver()
Method Detail |
---|
public static <T> T getAttributeValue(javax.swing.text.Element elem, com.inet.html.finder.AttributeFinder<T> finder)
T
- Class type of the requested attributeelem
- the current HTML nodefinder
- Finder for the requested type of attribute
public static <T> T getAttributeValue(javax.swing.text.Element elem, com.inet.html.finder.AttributeFinder<T> finder, boolean useCache)
T
- Class type of the requested attributeelem
- the current HTML nodefinder
- Finder for the requested type of attributeuseCache
- if true, the calculated styles will be used. If false, every styles will
be calculated by the registered CSS files(Warning: VERY SLOW!), this mode will not drop the font size!
public static boolean matchesAttributes(javax.swing.text.Element element, javax.swing.text.AttributeSet requirements)
element
matches the defined attributes. It will be tested,
if any attribute defined in requirements
is set with the same value at the element.
This comparison will check for inherited values as well!
element
- The element to checkrequirements
- The required attribute settings
element
fulfills the requirementspublic void fillAttributesNonLocked(javax.swing.text.Element root, java.util.HashMap<TemporaryStyle.Attribute,java.lang.Object> parentSet)
root
element has the same value for an attribute, this attribute will not appear in the attribute set
of root
. This has nothing to do with CSS-inheritance! It's just a way to keep the attribute sets small.
root
- the element to fillparentSet
- the attribute set of the parent of root
in non-diff form. If null
these values
will be calculated locallypublic static void setAttribute(javax.swing.text.AttributeSet attrs, java.lang.Object name, java.lang.Object value)
attrs
- The attribute set to modifyname
- The name of the attributevalue
- The value of the attributepublic Styles getStyles()
public void setStyles(Styles styles)
styles
- the new stylespublic void clearStyles()
public java.util.Enumeration<?> getStyleNames()
public Styles getStyleSheet(java.lang.String nm)
nm
- the name to find
public void handleNewCSSEntry(Selector selector)
handleNewCSSEntry
in interface CSSChangeListener
selector
- the new selectorpublic static boolean hasRelevantInlineStyles(javax.swing.text.Element element)
element
might
have styles by stylesheet rules.
element
- The element to check
public void optimize()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |