|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectilog.views.util.styling.IlvMutableStyleSheet
public class IlvMutableStyleSheet
This is a mutable style sheet. It is designed to be used in memory. It is possible to add, change and remove rules of the style sheet. The stylable that uses this mutable style sheet is automatically notified of any change. In order to set the style sheet, use for example:
IlvMutableStyleSheet styleSheet = new IlvMutableStyleSheet(stylable);
...
stylable.setStyleSheets(new String[] { styleSheet.toString() });
...
styleSheet.setDeclaration(selector, property, value);
...
styleSheet.removeDeclaration(selector, property);
...
styleSheet.removeRule(selector);
...
In order to visit the entire contents of the style sheet, you need to
iterate first over the rule selectors and then over the declared properties,
for example:
IlvMutableStyleSheet styleSheet = ...
...
Iterator iterator1 = styleSheet.getRuleSelectors();
while (iterator1.hasNext()) {
String selector = (String)iterator1.next();
Iterator iterator2 = styleSheet.getDeclaredProperties(selector);
while (iterator2.hasNext()) {
String property = (String)iterator2.next();
String value = styleSheet.getDeclaration(selector, property);
...
}
}
IlvStylable.setStyleSheets(java.lang.String[])| Constructor Summary | |
|---|---|
IlvMutableStyleSheet(IlvStylable stylable)
Creates a new mutable style sheet. |
|
| Method Summary | |
|---|---|
boolean |
containsDeclaration(String selector,
String property)
Returns true if the style sheet contains a rule with
the specified selector that contains a declaration for the specified
property. |
boolean |
containsRule(String selector)
Returns true if the style sheet contains a rule with
the specified selector. |
String |
getDeclaration(String selector,
String property)
Returns the value of a declaration of a rule. |
Iterator |
getDeclaredProperties(String selector)
Returns all properties in declarations of the specified rule in the style sheet. |
Iterator |
getRuleSelectors()
Returns all rule selectors stored in the style sheet. |
IlvStylable |
getStylable()
Returns the stylable of this mutable style sheet. |
protected String[] |
getUpdatedStyleSheets()
Return the updated set of style sheets. |
boolean |
isAdjusting()
Returns true if the adjusting mode is enabled. |
protected void |
propertyChanged()
Notifies the stylable that the style sheet has changed. |
void |
readStyleSheet(String styleSheet)
Fills this style sheet with all declarations of the input style sheet. |
void |
removeAllRules()
Removes all rules. |
void |
removeDeclaration(String selector,
String property)
Removes a declaration in a rule. |
void |
removeRule(String selector)
Removes a rule. |
void |
setAdjusting(boolean adjusting)
Enables or disables the adjusting mode. |
void |
setDeclaration(String selector,
String property,
String value)
Sets a declaration in a rule. |
String |
toString()
Returns the string representation of the style sheet. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public IlvMutableStyleSheet(IlvStylable stylable)
stylable - The stylable that should use this style sheet.| Method Detail |
|---|
public IlvStylable getStylable()
public void readStyleSheet(String styleSheet)
public void setDeclaration(String selector,
String property,
String value)
selector - The selector of the rule.property - The property name.value - The property value.setAdjusting(boolean)
public String getDeclaration(String selector,
String property)
null if no rule matches the selector, or if
the property is not declared in the matching rule in the
mutable style sheet.
The returned string omits the optional leading and trailing quote
character.
selector - The selector of the rule.property - The property name.
public boolean containsDeclaration(String selector,
String property)
true if the style sheet contains a rule with
the specified selector that contains a declaration for the specified
property.
selector - The selector of the rule.property - The property name.
public void removeDeclaration(String selector,
String property)
Note: don't remove a declaration while iterating over the declarations
via getDeclaredProperties(java.lang.String) or over the rule selectors
via getRuleSelectors(). This may mess up the iteration.
To remove all declarations of a rule, use removeRule(java.lang.String).
selector - The selector of the rule.property - The property name.setAdjusting(boolean),
removeRule(java.lang.String)public boolean containsRule(String selector)
true if the style sheet contains a rule with
the specified selector.
selector - The selector of the rule.
public void removeRule(String selector)
Note: don't remove a rule while iterating over the rule selectors
via getRuleSelectors(). This may mess up the iteration.
To remove all rules of the style sheet, use removeAllRules().
selector - The selector of the rule.setAdjusting(boolean),
removeAllRules()public void removeAllRules()
Note: don't remove a rule while iterating over the rule selectors
via getRuleSelectors(). This may mess up the iteration.
public Iterator getRuleSelectors()
String values.
Note that the rule selector strings are normalized according to
the CSS syntax.
getDeclaredProperties(java.lang.String)public Iterator getDeclaredProperties(String selector)
String values.
This method searches for a rule that matches the selector.
If such a rule does not exist, it returns an empty iteration.
If such a rule exists, it returns all properties that are set
by this rule.
selector - The selector of the rule.
getDeclaration(java.lang.String, java.lang.String)public void setAdjusting(boolean adjusting)
styleSheet.setAdjusting(true);
try {
// the following settings become not immediately effective
styleSheet.setDeclaration(...);
styleSheet.setDeclaration(...);
styleSheet.setDeclaration(...);
...
} finally {
// now, the previous settings become effective
styleSheet.setAdjusting(false);
}
isAdjusting()public boolean isAdjusting()
true if the adjusting mode is enabled.
setAdjusting(boolean)protected String[] getUpdatedStyleSheets()
protected void propertyChanged()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||