com.kuka.nav.fleet.graph
Class TopologyGraph

java.lang.Object
  extended by com.kuka.graph.impl.AbstractGraph<N,E>
      extended by com.kuka.graph.impl.AbstractBaseGraph<N,E>
          extended by com.kuka.graph.impl.AbstractBaseListenableGraph<TopologyNode,TopologyEdge>
              extended by com.kuka.nav.fleet.graph.TopologyGraph
All Implemented Interfaces:
com.kuka.graph.Graph<TopologyNode,TopologyEdge>, com.kuka.graph.ListenableGraph<TopologyNode,TopologyEdge>, Serializable, Cloneable, Iterable<TopologyNode>

public class TopologyGraph
extends com.kuka.graph.impl.AbstractBaseListenableGraph<TopologyNode,TopologyEdge>

Represents a graph containing TopologyNodes and TopologyEdges.

See Also:
Serialized Form

Nested Class Summary
protected static class TopologyGraph.ListenerContainer
          Contains a collection of listeners.
 
Field Summary
static String GRAPH_TRANSITION
          Key used for registering graph transition custom actions.
static int INVALID_ID
          Invalid node and graph id.
 
Constructor Summary
TopologyGraph()
          Creates a new topology graph.
 
Method Summary
 boolean addEdge(TopologyEdge edge)
           
 boolean addNode(TopologyNode node)
           
 void addTopologyGraphListener(TopologyGraphListener listener)
          Adds the given listener to this graph.
protected  void checkLegalNodeAddition(TopologyGraph g, TopologyNode n)
          Checks whether the node may be added to the given topology graph.
 TopologyEdge createEdge(TopologyNode source, TopologyNode target)
           
 TopologyNode createNode()
           Additionally an id is generated for the new node.
 TopologyNode createNode(int id)
          Creates a new node with the given id, adds it to this graph and returns the created node.
protected  void fireEdgeChanged(TopologyEdge edge)
          Fires an edge changed event.
protected  void fireEdgePropertyAdded(TopologyEdge edge, Property property)
          Fires a property added event.
protected  void fireEdgePropertyChanged(TopologyEdge edge, Property property)
          Fires a property changed event.
protected  void fireEdgePropertyRemoved(TopologyEdge edge, Property property)
          Deprecated. use instead
protected  void fireEdgePropertyRemoved(TopologyEdge edge, Property property, Integer robotTypeId)
          Fires a property removed event.
protected  void fireNodeChanged(TopologyNode node)
          Fires a node changed event.
protected  void fireNodePropertyAdded(TopologyNode node, Property property)
          Fires a property added event.
protected  void fireNodePropertyChanged(TopologyNode node, Property property)
          Fires a property changed event.
protected  void fireNodePropertyRemoved(TopologyNode node, Property property)
          Deprecated. use instead
protected  void fireNodePropertyRemoved(TopologyNode node, Property property, Integer robotTypeId)
          Fires a property removed event.
 TopologyEdge getEdge(int sourceNodeID, int targetNodeID)
          Retrieves an edge by its node IDs or null if no such edge exists.
 TopologyEdge getEdge(TopologyEdge e)
          Retrieves an edge by edge reference, e.g., to map input parameters to 'real' edges.
 int getId()
          Gets the graph ID.
 int getMapId()
          Gets the ID of the map the graph is configured on.
 String getName()
          Gets the name of the graph or null if no name is set.
 int getNextFreeNodeId()
          Finds the smallest unused node id that is bigger than 0.
 TopologyNode getNode(int id)
          Retrieves a node by its id.
 TopologyNode getNode(String name)
          Retrieves a node by its name.
 TopologyNode getNode(TopologyNodeId node)
          Retrieves a node by a node reference, e.g. to map an input parameter to a 'real' topology graph node.
 TopologyGraph getSubgraphOf(TopologyNodeId node)
          Returns the subgraph of this topology graph which contains the given node.
 Collection<TopologyGraph> getSubgraphs()
          Returns all contained subgraphs.
 com.kuka.nav.provider.util.ObjectMap<String> getTags()
          Gets the tags of the graph.
protected  Collection<TopologyGraphListener> getTopologyGraphListeners()
          Returns all contained listeners.
 boolean hasName()
          Checks if the graph has a name assigned.
 boolean removeEdge(TopologyEdge edge)
           
 boolean removeNode(TopologyNode node)
           
 void removeTopologyGraphListener(TopologyGraphListener listener)
          Removes the given listener from this graph.
 void setGraphId(int id)
          Recursively sets graph ID to graph and all contained elements.
 String toString()
           
static TopologyGraph withId(int id)
          Creates a new topology graph instance with given ID.
static TopologyGraph withName(String name)
          Creates a new topology graph instance with given name.
 
Methods inherited from class com.kuka.graph.impl.AbstractBaseListenableGraph
addListener, hasListeners, removeListener
 
Methods inherited from class com.kuka.graph.impl.AbstractBaseGraph
clone, containsEdge, containsNode, edges, getEdge, incomingEdges, neighbors, nodes, outgoingEdges
 
Methods inherited from class com.kuka.graph.impl.AbstractGraph
addAllEdges, addAllNodes, clear, containsAllEdges, containsAllNodes, containsEdge, edges, edgeSize, isEmpty, iterator, nodes, nodeSize, removeAllEdges, removeAllNodes, removeEdge, retainAllEdges, retainAllNodes
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.kuka.graph.Graph
addAllEdges, addAllNodes, clear, containsAllEdges, containsAllNodes, containsEdge, containsEdge, containsNode, edges, edges, edgeSize, getEdge, incomingEdges, isEmpty, neighbors, nodes, nodes, nodeSize, outgoingEdges, removeAllEdges, removeAllNodes, removeEdge, retainAllEdges, retainAllNodes
 
Methods inherited from interface java.lang.Iterable
iterator
 

Field Detail

INVALID_ID

public static final int INVALID_ID
Invalid node and graph id.

See Also:
Constant Field Values

GRAPH_TRANSITION

public static final String GRAPH_TRANSITION
Key used for registering graph transition custom actions. Must not be used for registering other custom actions.

See Also:
Constant Field Values
Constructor Detail

TopologyGraph

public TopologyGraph()
Creates a new topology graph.

Method Detail

withId

public static TopologyGraph withId(int id)
Creates a new topology graph instance with given ID.

Note that the object created with this static factory method is only an identifier and does not reflect the state of the corresponding element in the data source, i.e. most of the getters will fail.

A TopologyNode returned by this method can be used to parameterize a GraphMotion#GraphMotion(TopologyGraph, TopologyNode).

Parameters:
id - the topology element ID
Returns:
topology graph with given ID
See Also:
GraphMotion#GraphMotion(TopologyGraph, TopologyNode)

withName

public static TopologyGraph withName(String name)
Creates a new topology graph instance with given name.

Note that the object created with this static factory method is only an identifier and does not reflect the state of the corresponding element in the data source, i.e. most of the getters will fail.

A TopologyNode returned by this method can be used to parameterize a GraphMotion#GraphMotion(TopologyGraph, TopologyNode).

Parameters:
name - the graph name
Returns:
topology graph with given name
See Also:
GraphMotion#GraphMotion(TopologyGraph, TopologyNode)

getTags

public com.kuka.nav.provider.util.ObjectMap<String> getTags()
Gets the tags of the graph.

Returns:
the tags

createNode

public TopologyNode createNode()

Additionally an id is generated for the new node. It will be the first free id found starting from 1.

See Also:
createNode(int)

createNode

public TopologyNode createNode(int id)
Creates a new node with the given id, adds it to this graph and returns the created node.

Parameters:
id - the id of the new node
Returns:
the created node

createEdge

public TopologyEdge createEdge(TopologyNode source,
                               TopologyNode target)

getId

public int getId()
Gets the graph ID.

Returns:
the graph ID

getMapId

public int getMapId()
Gets the ID of the map the graph is configured on.

Returns:
the map ID

hasName

public boolean hasName()
Checks if the graph has a name assigned.

Returns:
true if graph is named, false if not

getName

public String getName()
Gets the name of the graph or null if no name is set. The method hasName() checks if a name is assigned.

Returns:
the name

getNode

public TopologyNode getNode(int id)
Retrieves a node by its id. Return null if that node doesn't exist.

Parameters:
id - id of the node
Returns:
the node

getNode

public TopologyNode getNode(String name)
Retrieves a node by its name. Return null if that node doesn't exist.

Parameters:
name - name of the node
Returns:
the node

getEdge

public TopologyEdge getEdge(TopologyEdge e)
Retrieves an edge by edge reference, e.g., to map input parameters to 'real' edges.

Parameters:
e - the edge reference
Returns:
the real representation of the corresponding edge in this topology graph or null if no such edge exists.

getNode

public TopologyNode getNode(TopologyNodeId node)
Retrieves a node by a node reference, e.g. to map an input parameter to a 'real' topology graph node. Return null if that node doesn't exist.

Parameters:
node - the reference node
Returns:
the topology graph node

getEdge

public TopologyEdge getEdge(int sourceNodeID,
                            int targetNodeID)
Retrieves an edge by its node IDs or null if no such edge exists.

Parameters:
sourceNodeID - the source node ID
targetNodeID - the target node ID
Returns:
the edge or null if nodes or edge between nodes does not exist in graph

toString

public String toString()
Overrides:
toString in class com.kuka.graph.impl.AbstractGraph<TopologyNode,TopologyEdge>

addNode

public boolean addNode(TopologyNode node)
Specified by:
addNode in interface com.kuka.graph.Graph<TopologyNode,TopologyEdge>
Overrides:
addNode in class com.kuka.graph.impl.AbstractBaseListenableGraph<TopologyNode,TopologyEdge>

addEdge

public boolean addEdge(TopologyEdge edge)
Specified by:
addEdge in interface com.kuka.graph.Graph<TopologyNode,TopologyEdge>
Overrides:
addEdge in class com.kuka.graph.impl.AbstractBaseListenableGraph<TopologyNode,TopologyEdge>

removeNode

public boolean removeNode(TopologyNode node)
Specified by:
removeNode in interface com.kuka.graph.Graph<TopologyNode,TopologyEdge>
Overrides:
removeNode in class com.kuka.graph.impl.AbstractBaseListenableGraph<TopologyNode,TopologyEdge>

removeEdge

public boolean removeEdge(TopologyEdge edge)
Specified by:
removeEdge in interface com.kuka.graph.Graph<TopologyNode,TopologyEdge>
Overrides:
removeEdge in class com.kuka.graph.impl.AbstractBaseListenableGraph<TopologyNode,TopologyEdge>

setGraphId

public void setGraphId(int id)
Recursively sets graph ID to graph and all contained elements.

Parameters:
id - the graph ID

getSubgraphs

public Collection<TopologyGraph> getSubgraphs()
Returns all contained subgraphs.

This topology graph itself is not considered to be its own subgraph, hence, it is not contained in the returned collection.

Returns:
a collection containing all subgraphs

getSubgraphOf

public TopologyGraph getSubgraphOf(TopologyNodeId node)
Returns the subgraph of this topology graph which contains the given node. If no subgraph contains the given node null is returned.

This topology graph itself is not considered to be its own subgraph, hence, if the given node is contained in this graph null is returned.

Parameters:
node - the node to get the corresponding subgraph for
Returns:
the subgraph or null

addTopologyGraphListener

public void addTopologyGraphListener(TopologyGraphListener listener)
Adds the given listener to this graph.

Parameters:
listener - the listener to add

removeTopologyGraphListener

public void removeTopologyGraphListener(TopologyGraphListener listener)
Removes the given listener from this graph.

Parameters:
listener - the listener to remove

getTopologyGraphListeners

protected Collection<TopologyGraphListener> getTopologyGraphListeners()
Returns all contained listeners.

Returns:
all contained listeners

fireNodeChanged

protected void fireNodeChanged(TopologyNode node)
Fires a node changed event.

Parameters:
node - the node that has been changed

fireNodePropertyAdded

protected void fireNodePropertyAdded(TopologyNode node,
                                     Property property)
Fires a property added event.

Parameters:
node - the node that contains the property
property - the property that has been added

fireNodePropertyRemoved

@Deprecated
protected void fireNodePropertyRemoved(TopologyNode node,
                                                  Property property)
Deprecated. use instead

Fires a property removed event.

Parameters:
node - the node that contains the property
property - the property that has been removed

fireNodePropertyRemoved

protected void fireNodePropertyRemoved(TopologyNode node,
                                       Property property,
                                       Integer robotTypeId)
Fires a property removed event.

Parameters:
node - the node that contains the property
property - the property that has been removed
robotTypeId - the corresponding robot type to the removed property

fireNodePropertyChanged

protected void fireNodePropertyChanged(TopologyNode node,
                                       Property property)
Fires a property changed event.

Parameters:
node - the node that contains the property
property - the property that has been changed

fireEdgeChanged

protected void fireEdgeChanged(TopologyEdge edge)
Fires an edge changed event.

Parameters:
edge - the edge that has been changed

fireEdgePropertyAdded

protected void fireEdgePropertyAdded(TopologyEdge edge,
                                     Property property)
Fires a property added event.

Parameters:
edge - the edge that contains the property
property - the property that has been added

fireEdgePropertyRemoved

@Deprecated
protected void fireEdgePropertyRemoved(TopologyEdge edge,
                                                  Property property)
Deprecated. use instead

Fires a property removed event.

Parameters:
edge - the edge that contains the property
property - the property that has been removed

fireEdgePropertyRemoved

protected void fireEdgePropertyRemoved(TopologyEdge edge,
                                       Property property,
                                       Integer robotTypeId)
Fires a property removed event.

Parameters:
edge - the edge that contains the property
property - the property that has been removed
robotTypeId - the corresponding robot type to the removed property

fireEdgePropertyChanged

protected void fireEdgePropertyChanged(TopologyEdge edge,
                                       Property property)
Fires a property changed event.

Parameters:
edge - the edge that contains the property
property - the property that has been changed

checkLegalNodeAddition

protected void checkLegalNodeAddition(TopologyGraph g,
                                      TopologyNode n)
Checks whether the node may be added to the given topology graph.

Parameters:
n - the node to be added.
g - the graph to which the node shall be added.

getNextFreeNodeId

public int getNextFreeNodeId()
Finds the smallest unused node id that is bigger than 0.

Returns:
the smallest unused node id > 0


Copyright © 2019. All rights reserved.