public class StyleGroupSet extends Object implements StyleSheetListener
This class is in charge or storing all the style groups and to update them. Each time an element is added or removed the groups are updated. Each time the style sheet changes the groups are updated.
Modifier and Type | Class and Description |
---|---|
protected class |
StyleGroupSet.EdgeSet
Dummy set of edges.
|
protected class |
StyleGroupSet.ElementIterator<E extends Element>
Iterator that allows to browse all graph elements of a given kind (nodes,
edges, sprites, graphs) as if they where in a single set, whereas they
are in style groups.
|
class |
StyleGroupSet.EventSet
Set of events (meta-classes) actually active.
|
protected class |
StyleGroupSet.GraphSet |
protected class |
StyleGroupSet.NodeSet
Dummy set of nodes.
|
class |
StyleGroupSet.ShadowSet
Set of groups that cast a shadow.
|
protected class |
StyleGroupSet.SpriteSet
Dummy set of sprites.
|
class |
StyleGroupSet.ZIndex
All the style groups sorted by their Z index.
|
Modifier and Type | Field and Description |
---|---|
protected HashMap<String,String> |
byEdgeIdGroups
Allows to retrieve the group containing an edge knowing the node id.
|
protected HashMap<String,String> |
byGraphIdGroups
Allows to retrieve the group containing a graph knowing the node id.
|
protected HashMap<String,String> |
byNodeIdGroups
Allows to retrieve the group containing a node knowing the node id.
|
protected HashMap<String,String> |
bySpriteIdGroups
Allows to retrieve the group containing a sprite knowing the node id.
|
protected StyleGroupSet.EdgeSet |
edgeSet
Virtual set of edges.
|
protected StyleGroupSet.EventSet |
eventSet
The set of events actually occurring.
|
protected StyleGroupSet.GraphSet |
graphSet
Virtual set of graphs.
|
protected HashMap<String,StyleGroup> |
groups
All the groups indexed by their unique identifier.
|
protected ArrayList<StyleGroupListener> |
listeners
Set of listeners.
|
protected StyleGroupSet.NodeSet |
nodeSet
Virtual set of nodes.
|
protected boolean |
removeEmptyGroups
Remove groups if they become empty?.
|
protected StyleGroupSet.ShadowSet |
shadow
Set of groups that cast shadow.
|
protected StyleGroupSet.SpriteSet |
spriteSet
Virtual set of sprites.
|
protected StyleSheet |
stylesheet
The style sheet.
|
protected StyleGroupSet.ZIndex |
zIndex
The groups sorted by their Z index.
|
Constructor and Description |
---|
StyleGroupSet(StyleSheet stylesheet)
New empty style group set, using the given style sheet to create style
groups.
|
Modifier and Type | Method and Description |
---|---|
protected StyleGroup |
addElement_(Element element) |
StyleGroup |
addElement(Element element)
Add an element and bind it to its style group.
|
protected void |
addElementToReverseSearch(Element element,
String groupId) |
protected StyleGroup |
addGroup(String id,
ArrayList<Rule> rules,
Element firstElement) |
void |
addListener(StyleGroupListener listener)
Add a listener for element style changes.
|
boolean |
areEmptyGroupRemoved()
True if groups are removed when becoming empty.
|
void |
checkElementStyleGroup(Element element)
Check if an element need to change from a style group to another.
|
protected void |
checkForNewIdStyle(Rule newRule,
HashMap<String,String> elt2grp)
Check for a new specific style (applies only to one element).
|
protected void |
checkForNewStyle(Rule newRule)
We try to avoid at most to affect anew styles to elements and to recreate
groups, which is time consuming.
|
protected void |
checkForNewStyle(Rule newRule,
HashMap<String,String> elt2grp)
Check for a new kind or class style in a given name space (node, edge,
sprite, graph).
|
protected void |
checkZIndexAndShadow(Rule oldRule,
Rule newRule)
Check each group that may have changed, for example to rebuild the Z
index and the shadow set.
|
void |
clear()
Empties this style group set.
|
boolean |
containsEdge(String id)
True if the set contains and styles the edge whose identifier is given.
|
boolean |
containsGraph(String id)
True if the set contains and styles the graph whose identifier is given.
|
boolean |
containsNode(String id)
True if the set contains and styles the node whose identifier is given.
|
boolean |
containsSprite(String id)
True if the set contains and styles the sprite whose identifier is given.
|
Iterable<? extends Edge> |
edges()
Iterable set of edges.
|
Edge |
getEdge(String id)
Get an edge element knowing its identifier.
|
int |
getEdgeCount()
The number of edges referenced.
|
Iterator<? extends Edge> |
getEdgeIterator()
Iterator on the set of edges.
|
protected Element |
getElement(String id,
HashMap<String,String> elt2grp)
Get an element.
|
String |
getElementGroup(Element element)
Retrieve the group identifier of an element knowing the element
identifier.
|
Graph |
getGraph(String id)
Get a graph element knowing its identifier.
|
Iterator<? extends Graph> |
getGraphIterator()
Iterator on the set of graphs.
|
StyleGroup |
getGroup(String groupId)
Return a group by its unique identifier.
|
int |
getGroupCount()
Number of groups.
|
Iterator<? extends StyleGroup> |
getGroupIterator()
Iterator on the set of groups in no particular order.
|
Node |
getNode(String id)
Get a node element knowing its identifier.
|
int |
getNodeCount()
The number of nodes referenced.
|
Iterator<? extends Node> |
getNodeIterator()
Iterator on the set of nodes.
|
Iterator<StyleGroup> |
getShadowIterator()
Iterator on the style groups that cast a shadow.
|
StyleGroupSet.ShadowSet |
getShadowSet()
The set of style groups that cast a shadow.
|
GraphicSprite |
getSprite(String id)
Get a sprite element knowing its identifier.
|
int |
getSpriteCount()
The number of sprites referenced.
|
Iterator<? extends GraphicSprite> |
getSpriteIterator()
Iterator on the set of sprite.
|
StyleGroup |
getStyleFor(Edge edge)
Get the style of a given edge.
|
StyleGroup |
getStyleFor(Graph graph)
Get the style of a given graph.
|
StyleGroup |
getStyleFor(GraphicSprite sprite)
Get the style of a given sprite.
|
StyleGroup |
getStyleFor(Node node)
Get the style of a given node.
|
StyleGroup |
getStyleForElement(Element element)
Get the style of an element.
|
StyleGroupSet.ZIndex |
getZIndex()
The Z index object.
|
Iterator<HashSet<StyleGroup>> |
getZIterator()
Iterator on the Z index.
|
Iterable<? extends Graph> |
graphs()
Iterable set of graphs.
|
Iterable<? extends StyleGroup> |
groups()
Iterable set of groups elements, in no particular order.
|
Iterable<? extends Node> |
nodes()
Iterable set of nodes.
|
void |
popElementAsDynamic(Element element)
Remove the given element from the subset of elements having dynamic style
attribute values.
|
void |
popEvent(String event)
Pop a global event from the event set.
|
void |
popEventFor(Element element,
String event)
Pop an event specifically for a given element.
|
void |
pushElementAsDynamic(Element element)
Specify the given element has dynamic style attribute values.
|
void |
pushEvent(String event)
Push a global event on the event stack.
|
void |
pushEventFor(Element element,
String event)
Push an event specifically for a given element.
|
void |
release()
Release any dependency to the style sheet.
|
void |
removeElement(Element element)
Remove an element from the group set.
|
protected void |
removeElementFromReverseSearch(Element element) |
protected void |
removeGroup(StyleGroup group) |
void |
removeListener(StyleGroupListener listener)
Remove a style change listener.
|
void |
setRemoveEmptyGroups(boolean on)
Remove or keep groups that becomes empty, if true the groups are removed.
|
Iterable<StyleGroup> |
shadows()
Iterable set of groups that cast shadow.
|
Iterable<? extends GraphicSprite> |
sprites()
Iterable set of sprites.
|
void |
styleAdded(Rule oldRule,
Rule newRule)
A style was changed or added.
|
void |
styleSheetCleared()
The complete style sheet was cleared.
|
String |
toString() |
Iterable<HashSet<StyleGroup>> |
zIndex()
Iterable set of "subsets of groups" sorted by Z level.
|
protected StyleSheet stylesheet
protected HashMap<String,StyleGroup> groups
protected HashMap<String,String> byNodeIdGroups
protected HashMap<String,String> byEdgeIdGroups
protected HashMap<String,String> bySpriteIdGroups
protected HashMap<String,String> byGraphIdGroups
protected StyleGroupSet.NodeSet nodeSet
protected StyleGroupSet.EdgeSet edgeSet
protected StyleGroupSet.SpriteSet spriteSet
protected StyleGroupSet.GraphSet graphSet
protected StyleGroupSet.EventSet eventSet
protected StyleGroupSet.ZIndex zIndex
protected StyleGroupSet.ShadowSet shadow
protected boolean removeEmptyGroups
protected ArrayList<StyleGroupListener> listeners
public StyleGroupSet(StyleSheet stylesheet)
release()
.stylesheet
- The style sheet to use to create groups.public int getGroupCount()
public StyleGroup getGroup(String groupId)
groupId
- The group identifier.public Iterator<? extends StyleGroup> getGroupIterator()
public Iterable<? extends StyleGroup> groups()
public Iterator<HashSet<StyleGroup>> getZIterator()
public Iterable<HashSet<StyleGroup>> zIndex()
public Iterator<StyleGroup> getShadowIterator()
public Iterable<StyleGroup> shadows()
public boolean containsNode(String id)
id
- The node identifier.public boolean containsEdge(String id)
id
- The edge identifier.public boolean containsSprite(String id)
id
- The sprite identifier.public boolean containsGraph(String id)
id
- The graph identifier.protected Element getElement(String id, HashMap<String,String> elt2grp)
id
- The element id.elt2grp
- The kind of element.public Node getNode(String id)
id
- The node identifier.public Edge getEdge(String id)
id
- The edge identifier.public GraphicSprite getSprite(String id)
id
- The sprite identifier.public Graph getGraph(String id)
id
- The graph identifier.public int getNodeCount()
public int getEdgeCount()
public int getSpriteCount()
public Iterator<? extends Node> getNodeIterator()
public Iterator<? extends Graph> getGraphIterator()
public Iterable<? extends Graph> graphs()
public Iterator<? extends Edge> getEdgeIterator()
public Iterator<? extends GraphicSprite> getSpriteIterator()
public Iterable<? extends GraphicSprite> sprites()
public String getElementGroup(Element element)
element
- The element to search for.public StyleGroup getStyleForElement(Element element)
element
- The element to search for.public StyleGroup getStyleFor(Node node)
node
- The node to search for.public StyleGroup getStyleFor(Edge edge)
edge
- The edge to search for.public StyleGroup getStyleFor(GraphicSprite sprite)
sprite
- The node to search for.public StyleGroup getStyleFor(Graph graph)
graph
- The node to search for.public boolean areEmptyGroupRemoved()
public StyleGroupSet.ZIndex getZIndex()
public StyleGroupSet.ShadowSet getShadowSet()
public void release()
public void clear()
release()
to do that.public void setRemoveEmptyGroups(boolean on)
on
- If true the groups will be removed.protected void removeGroup(StyleGroup group)
public StyleGroup addElement(Element element)
element
- The element to add.protected StyleGroup addElement_(Element element)
public void removeElement(Element element)
areEmptyGroupRemoved()
, the group is deleted or kept. Keeping
groups allows to handle faster elements that constantly appear and
disappear.element
- The element to remove.public void checkElementStyleGroup(Element element)
When an element can have potentially changed style due to some of its attributes (ui.class for example), instead of removing it then reading it, use this method to move the element from its current style group to a potentially different style group.
Explanation of this method : checking the style of an element may be done
by removing it (removeElement(Element)
) and then re-adding it (
addElement(Element)
). This must be done by the element since it
knows when to check this. However you cannot only remove and add, since
the style group inside which the element is can have events occurring on
it, and these events must be passed from its old style to its new style.
This method does all this information passing.
element
- The element to move.protected void addElementToReverseSearch(Element element, String groupId)
protected void removeElementFromReverseSearch(Element element)
public void pushEvent(String event)
event
- The event to push.public void pushEventFor(Element element, String event)
element
- The element considered.event
- The event to push.public void popEvent(String event)
event
- The event to remove.public void popEventFor(Element element, String event)
element
- The element considered.event
- The event to pop.public void pushElementAsDynamic(Element element)
element
- The element to add to the dynamic subset.public void popElementAsDynamic(Element element)
element
- The element to remove from the dynamic subset.public void addListener(StyleGroupListener listener)
listener
- The listener to add.public void removeListener(StyleGroupListener listener)
listener
- The listener to remove.public void styleAdded(Rule oldRule, Rule newRule)
StyleSheetListener
styleAdded
in interface StyleSheetListener
oldRule
- The style that changed.newRule
- The style that was added to the style sheet.public void styleSheetCleared()
StyleSheetListener
styleSheetCleared
in interface StyleSheetListener
protected void checkZIndexAndShadow(Rule oldRule, Rule newRule)
oldRule
- The old rule that changed.newRule
- The new rule that participated in the change.protected void checkForNewStyle(Rule newRule)
protected void checkForNewIdStyle(Rule newRule, HashMap<String,String> elt2grp)
newRule
- The new style rule.elt2grp
- The name space.protected void checkForNewStyle(Rule newRule, HashMap<String,String> elt2grp)
newRule
- The new style rule.elt2grp
- The name space.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses