public class StyleSheet
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
StyleSheet.NameSpace
A name space is a tuple (default rule, id rule set, class rule set).
|
Modifier and Type | Field and Description |
---|---|
Rule |
defaultRule
The top-level default rule.
|
StyleSheet.NameSpace |
edgeRules
The default, id and class rules for edges.
|
StyleSheet.NameSpace |
graphRules
The default, id and class rules for graphs.
|
java.util.ArrayList<StyleSheetListener> |
listeners
Set of listeners.
|
StyleSheet.NameSpace |
nodeRules
The default, id and class rules for nodes.
|
StyleSheet.NameSpace |
spriteRules
The default, id and class rules for sprites.
|
Constructor and Description |
---|
StyleSheet()
New style sheet initialised to defaults.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(StyleSheetListener listener)
Add a listener for style events.
|
void |
addRule(Rule newRule)
Add a new rule with its style.
|
void |
clear()
Clear all specific rules and initialise the default rules.
|
Rule |
getDefaultEdgeRule()
The default rule for edges.
|
Style |
getDefaultEdgeStyle()
The default style for edges.
|
Rule |
getDefaultGraphRule()
The default rule for graphs.
|
Style |
getDefaultGraphStyle()
The default style for graphs.
|
Rule |
getDefaultNodeRule()
The default rule for nodes.
|
Style |
getDefaultNodeStyle()
The default style for nodes.
|
Rule |
getDefaultSpriteRule()
The default rule for sprites.
|
Style |
getDefaultSpriteStyle()
The default style for sprites.
|
StyleSheet.NameSpace |
getEdgeStyleNameSpace()
All the rules (default, specific and class) that apply to edges.
|
StyleSheet.NameSpace |
getGraphStyleNameSpace()
All the rules (default, specific and class) that apply to graphs.
|
StyleSheet.NameSpace |
getNodeStyleNameSpace()
All the rules (default, specific and class) that apply to nodes.
|
java.util.ArrayList<Rule> |
getRulesFor(Element element)
Get the rules that match a given element.
|
StyleSheet.NameSpace |
getSpriteStyleNameSpace()
All the rules (default, specific and class) that apply to sprites.
|
java.lang.String |
getStyleGroupIdFor(Element element,
java.util.ArrayList<Rule> rules)
Compute the name of the style group and element will pertain to knowing its
styling rules.
|
void |
load(java.lang.String styleSheetValue)
Load a style sheet from an attribute value, the value can either be the
contents of the whole style sheet, or begin by "url".
|
void |
parseFromFile(java.lang.String fileName)
Parse a style sheet from a file.
|
void |
parseFromString(java.lang.String styleSheet)
Parse a style sheet from a string.
|
void |
parseFromURL(java.lang.String url)
Parse a style sheet from an URL.
|
void |
parseStyleFromString(Selector select,
java.lang.String styleString)
Parse only one style, create a rule with the given selector, and add this
rule.
|
void |
removeListener(StyleSheetListener listener)
Remove a previously registered listener.
|
java.lang.String |
toString() |
public Rule defaultRule
public StyleSheet.NameSpace graphRules
public StyleSheet.NameSpace nodeRules
public StyleSheet.NameSpace edgeRules
public StyleSheet.NameSpace spriteRules
public java.util.ArrayList<StyleSheetListener> listeners
public Rule getDefaultGraphRule()
public Rule getDefaultNodeRule()
public Rule getDefaultEdgeRule()
public Rule getDefaultSpriteRule()
public Style getDefaultGraphStyle()
public Style getDefaultNodeStyle()
public Style getDefaultEdgeStyle()
public Style getDefaultSpriteStyle()
public StyleSheet.NameSpace getGraphStyleNameSpace()
public StyleSheet.NameSpace getNodeStyleNameSpace()
public StyleSheet.NameSpace getEdgeStyleNameSpace()
public StyleSheet.NameSpace getSpriteStyleNameSpace()
public java.util.ArrayList<Rule> getRulesFor(Element element)
element
- The element a rules are searched for.public java.lang.String getStyleGroupIdFor(Element element, java.util.ArrayList<Rule> rules)
element
- The element.rules
- The styling rules.getRulesFor(Element)
public void addListener(StyleSheetListener listener)
listener
- The new listener.public void removeListener(StyleSheetListener listener)
listener
- The listener to remove.public void clear()
public void parseFromFile(java.lang.String fileName) throws java.io.IOException
fileName
- Name of the file containing the style sheet.java.io.IOException
- For any kind of I/O error or parse error.public void parseFromURL(java.lang.String url) throws java.io.IOException
url
- Name of the file containing the style sheet.java.io.IOException
- For any kind of I/O error or parse error.public void parseFromString(java.lang.String styleSheet) throws java.io.IOException
styleSheet
- The string containing the whole style sheet.java.io.IOException
- For any kind of I/O error or parse error.public void parseStyleFromString(Selector select, java.lang.String styleString) throws java.io.IOException
select
- The elements for which this style must apply.styleString
- The style string to parse.java.io.IOException
public void load(java.lang.String styleSheetValue) throws java.io.IOException
url('file:///some/path/on/the/file/system')Or
url('http://some/web/url')The loaded style sheet will be merged with the styles already present in the style sheet.
styleSheetValue
- The style sheet name of content.java.io.IOException
- If the loading or parsing of the style sheet failed.public void addRule(Rule newRule)
newRule
- The new rule.public java.lang.String toString()
toString
in class java.lang.Object