public class StyleGroupSet extends java.lang.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 |
---|---|
class |
StyleGroupSet.EventSet
Set of events (meta-classes) actually active.
|
class |
StyleGroupSet.ShadowSet
Set of groups that cast a shadow.
|
class |
StyleGroupSet.ZIndex
All the style 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 |
---|---|
StyleGroup |
addElement(Element element)
Add an element and bind it to its style group.
|
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.
|
void |
clear()
Empties this style group set.
|
boolean |
containsEdge(java.lang.String id)
True if the set contains and styles the edge whose identifier is given.
|
boolean |
containsGraph(java.lang.String id)
True if the set contains and styles the graph whose identifier is given.
|
boolean |
containsNode(java.lang.String id)
True if the set contains and styles the node whose identifier is given.
|
boolean |
containsSprite(java.lang.String id)
True if the set contains and styles the sprite whose identifier is given.
|
java.util.stream.Stream<Edge> |
edges() |
Edge |
getEdge(java.lang.String id)
Get an edge element knowing its identifier.
|
int |
getEdgeCount()
The number of edges referenced.
|
java.util.Iterator<? extends Edge> |
getEdgeIterator()
Iterator on the set of edges.
|
java.lang.String |
getElementGroup(Element element)
Retrieve the group identifier of an element knowing the element identifier.
|
Graph |
getGraph(java.lang.String id)
Get a graph element knowing its identifier.
|
java.util.Iterator<? extends Graph> |
getGraphIterator()
Iterator on the set of graphs.
|
StyleGroup |
getGroup(java.lang.String groupId)
Return a group by its unique identifier.
|
int |
getGroupCount()
Number of groups.
|
java.util.Iterator<? extends StyleGroup> |
getGroupIterator()
Iterator on the set of groups in no particular order.
|
Node |
getNode(java.lang.String id)
Get a node element knowing its identifier.
|
int |
getNodeCount()
The number of nodes referenced.
|
java.util.Iterator<? extends Node> |
getNodeIterator()
Iterator on the set of nodes.
|
java.util.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(java.lang.String id)
Get a sprite element knowing its identifier.
|
int |
getSpriteCount()
The number of sprites referenced.
|
java.util.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.
|
java.util.Iterator<java.util.HashSet<StyleGroup>> |
getZIterator()
Iterator on the Z index.
|
java.lang.Iterable<? extends Graph> |
graphs()
Iterable set of graphs.
|
java.lang.Iterable<? extends StyleGroup> |
groups()
Iterable set of groups elements, in no particular order.
|
java.util.stream.Stream<Node> |
nodes() |
void |
popElementAsDynamic(Element element)
Remove the given element from the subset of elements having dynamic style
attribute values.
|
void |
popEvent(java.lang.String event)
Pop a global event from the event set.
|
void |
popEventFor(Element element,
java.lang.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(java.lang.String event)
Push a global event on the event stack.
|
void |
pushEventFor(Element element,
java.lang.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.
|
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.
|
java.lang.Iterable<StyleGroup> |
shadows()
Iterable set of groups that cast shadow.
|
java.util.stream.Stream<GraphicSprite> |
sprites() |
void |
styleAdded(Rule oldRule,
Rule newRule)
A style was changed or added.
|
void |
styleSheetCleared()
The complete style sheet was cleared.
|
java.lang.String |
toString() |
java.lang.Iterable<java.util.HashSet<StyleGroup>> |
zIndex()
Iterable set of "subsets of groups" sorted by Z level.
|
public StyleGroupSet(StyleSheet stylesheet)
release()
.stylesheet
- The style sheet to use to create groups.public int getGroupCount()
public StyleGroup getGroup(java.lang.String groupId)
groupId
- The group identifier.public java.util.Iterator<? extends StyleGroup> getGroupIterator()
public java.lang.Iterable<? extends StyleGroup> groups()
public java.util.Iterator<java.util.HashSet<StyleGroup>> getZIterator()
public java.lang.Iterable<java.util.HashSet<StyleGroup>> zIndex()
public java.util.Iterator<StyleGroup> getShadowIterator()
public java.lang.Iterable<StyleGroup> shadows()
public boolean containsNode(java.lang.String id)
id
- The node identifier.public boolean containsEdge(java.lang.String id)
id
- The edge identifier.public boolean containsSprite(java.lang.String id)
id
- The sprite identifier.public boolean containsGraph(java.lang.String id)
id
- The graph identifier.public Node getNode(java.lang.String id)
id
- The node identifier.public Edge getEdge(java.lang.String id)
id
- The edge identifier.public GraphicSprite getSprite(java.lang.String id)
id
- The sprite identifier.public Graph getGraph(java.lang.String id)
id
- The graph identifier.public int getNodeCount()
public int getEdgeCount()
public int getSpriteCount()
public java.util.Iterator<? extends Node> getNodeIterator()
public java.util.Iterator<? extends Graph> getGraphIterator()
public java.util.stream.Stream<Node> nodes()
public java.util.stream.Stream<Edge> edges()
public java.util.stream.Stream<GraphicSprite> sprites()
public java.lang.Iterable<? extends Graph> graphs()
public java.util.Iterator<? extends Edge> getEdgeIterator()
public java.util.Iterator<? extends GraphicSprite> getSpriteIterator()
public java.lang.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.public StyleGroup addElement(Element element)
element
- The element to add.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.public void pushEvent(java.lang.String event)
event
- The event to push.public void pushEventFor(Element element, java.lang.String event)
element
- The element considered.event
- The event to push.public void popEvent(java.lang.String event)
event
- The event to remove.public void popEventFor(Element element, java.lang.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
public java.lang.String toString()
toString
in class java.lang.Object