public class StateNode extends Object
| Constructor and Description |
|---|
StateNode(int id,
StateTree tree)
Creates a new state node.
|
| Modifier and Type | Method and Description |
|---|---|
elemental.events.EventRemover |
addDomNodeSetListener(Function<StateNode,Boolean> listener)
Adds a listener to get a notification when the DOM Node is set for this
StateNode. |
elemental.events.EventRemover |
addUnregisterListener(NodeUnregisterListener listener)
Adds a listener that will be notified when this node is unregistered.
|
<T> void |
clearNodeData(T object)
Removes the
object from the stored data. |
void |
forEachFeature(JsMap.ForEachCallback<Double,NodeFeature> callback)
Iterates all features in this node.
|
elemental.json.JsonObject |
getDebugJson()
Gets a JSON object representing the contents of this node.
|
elemental.dom.Node |
getDomNode()
Gets the DOM node associated with this state node.
|
int |
getId()
Gets the id of this state node.
|
NodeList |
getList(int id)
Gets the node list with the given id.
|
NodeMap |
getMap(int id)
Gets the node map with the given id.
|
<T> T |
getNodeData(Class<T> clazz)
Gets the object previously stored by the
setNodeData(Object) by
its type. |
StateNode |
getParent()
Get the parent
StateNode if set. |
StateTree |
getTree()
Gets the state tree that this node belongs to.
|
boolean |
hasFeature(int id)
Checks whether this node has a feature with the given id.
|
boolean |
isUnregistered()
Checks whether this node has been unregistered.
|
void |
setDomNode(elemental.dom.Node node)
Sets the DOM node associated with this state node.
|
<T> void |
setNodeData(T object)
Stores the
object in the StateNode instance. |
void |
setParent(StateNode parent)
Set the parent
StateNode for this node. |
void |
unregister()
Unregisters this node, causing all registered node unregister listeners
to be notified.
|
public StateNode(int id,
StateTree tree)
id - the id of the nodetree - the state tree that the node belongs topublic StateTree getTree()
public int getId()
public NodeList getList(int id)
id - the id of the listpublic NodeMap getMap(int id)
id - the id of the mappublic boolean hasFeature(int id)
id - the id of the featuretrue if this node has the given feature; otherwise
falsepublic void forEachFeature(JsMap.ForEachCallback<Double,NodeFeature> callback)
callback - the callback to invoke for each featurepublic elemental.json.JsonObject getDebugJson()
public boolean isUnregistered()
true if this node has been unregistered;
false if the node is still registeredStateTree.unregisterNode(StateNode)public void unregister()
public elemental.events.EventRemover addUnregisterListener(NodeUnregisterListener listener)
listener - the node unregister listener to addpublic elemental.dom.Node getDomNode()
null if no DOM node has been
associated with this state nodepublic void setDomNode(elemental.dom.Node node)
node - the associated DOM nodepublic elemental.events.EventRemover addDomNodeSetListener(Function<StateNode,Boolean> listener)
StateNode.
The listener return value is used to decide whether the listener should
be removed immediately if it returns true.
listener - listener to addpublic void setParent(StateNode parent)
StateNode for this node.parent - the parent state nodepublic <T> void setNodeData(T object)
object in the StateNode instance.
The object may represent any kind of data. This data can be
retrieved later on via the getNodeData(Class) providing the
class of the object. So make sure you are using some custom type for your
data to avoid clash with other types.
T - the type of the node data to setobject - the object to storegetNodeData(Class)public <T> T getNodeData(Class<T> clazz)
setNodeData(Object) by
its type.
If there is no stored object with the given type then the method returns
null.
T - the type of the node data to getclazz - the type of the object to getclazzpublic <T> void clearNodeData(T object)
object from the stored data.T - the type of the object to removeobject - the object to removeCopyright © 2000–2020 Vaadin Ltd. All rights reserved.