Package com.luciad.network.graph
Class TLcdGraph<N,E>
java.lang.Object
com.luciad.network.graph.TLcdGraph<N,E>
- All Implemented Interfaces:
ILcdEditableGraph<N,,E> ILcdGraph<N,E>
Implementation of
ILcdGraph.
This implementation uses equals() and hashCode() to identify the nodes and edges
it contains - a correct implementation of both methods is thus required for all
edges and nodes contained in this graph.- Since:
- 5.1
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an edge to this graph, connecting the two given nodes.voidaddGraphListener(ILcdGraphListener<N, E> aGraphListener) Registers the givenILcdGraphListenerwith this graph.voidAdds a node to this graph.booleancanAddEdge(E aEdge, N aStartNode, N aEndNode) Returnstrueif the given edge can be added to this graph,falseotherwise.booleancanAddNode(N aNode) Returnstrueif the given node can be added to this graph,falseotherwise.booleancanRemoveEdge(E aEdge) Returnstrueif the given edge can be removed from this graph,falseotherwise.booleancanRemoveNode(N aNode) Returnstrueif the given node can be removed from this graph,falseotherwise.voidclear(int aFireEventMode) Clears the graph; all edges and nodes are removed.booleancontainsEdge(E aEdge) Returns true ifaEdgeis contained in this graph, false otherwise.booleancontainsNode(N aNode) Returns true ifaNodeis part of this graph, false otherwise.voidedgeChanged(E aEdge, int aEventMode) This method should be called when the given edge has changed.voidedgesChanged(Vector<E> aEdges, int aEventMode) This method should be called when the given edges have changed.voidFires all the collected graph changes, i.e., all graph events that have been generated using the the ILcdFireEventMode.FIRE_LATER mode, after the previous call tofireCollectedGraphChanges().getEdges()Returns an Enumeration containing all edges in this graph.Returns an Enumeration containing all edges connected to the given node.getEndNode(E aEdge) Returns the end node of the given edge in this graph.getNodes()Returns an Enumeration containing all nodes in this graph.getOppositeNode(E aEdge, N aNode) IfaNodeis one of the two nodes connected by the given edge in this graph, returns the other node, otherwise throwsIllegalArgumentException.getStartNode(E aEdge) Returns the start node of the given edge in this graph.booleanisConnected(E aEdge, N aNode) Returns true ifaNodeis one the nodes to which this edge is connected.voidnodeChanged(N aNode, int aEventMode) This method should be called when the given node has changed.voidnodesChanged(Vector<N> aNodes, int aEventMode) This method should be called when the given nodes have changed.removeEdge(E aEdge, int aFireEventMode) Removes an edge from this graph.voidremoveEdges(int aFireEventMode) Removes all edges from this graph - nodes will remain in the graph.voidremoveGraphListener(ILcdGraphListener<N, E> aGraphListener) Unregisters the givenILcdGraphListenerfrom this graph.removeNode(N aNode, int aFireEventMode) Removes a node from this graph.toString()Returns a general description of this graph, containing the number of nodes and edges contained in this graph.
-
Constructor Details
-
TLcdGraph
public TLcdGraph()Constructs a new, empty graph.
-
-
Method Details
-
containsNode
Description copied from interface:ILcdGraphReturns true ifaNodeis part of this graph, false otherwise.- Specified by:
containsNodein interfaceILcdGraph<N,E> - Parameters:
aNode- the node to be checked.- Returns:
trueifaNodeis part of the graph,falseotherwise.
-
getNodes
Description copied from interface:ILcdGraphReturns an Enumeration containing all nodes in this graph. -
containsEdge
Description copied from interface:ILcdGraphReturns true ifaEdgeis contained in this graph, false otherwise.- Specified by:
containsEdgein interfaceILcdGraph<N,E> - Parameters:
aEdge- the edge to be checked- Returns:
trueifaEdgeis part of the graph,falseotherwise.
-
getEdges
Description copied from interface:ILcdGraphReturns an Enumeration containing all edges in this graph. -
getEdges
Description copied from interface:ILcdGraphReturns an Enumeration containing all edges connected to the given node. -
getStartNode
Description copied from interface:ILcdGraphReturns the start node of the given edge in this graph.- Specified by:
getStartNodein interfaceILcdGraph<N,E> - Parameters:
aEdge- the edge whose start node should be returned.- Returns:
- the start node.
-
getEndNode
Description copied from interface:ILcdGraphReturns the end node of the given edge in this graph.- Specified by:
getEndNodein interfaceILcdGraph<N,E> - Parameters:
aEdge- the edge whose end node should be returned.- Returns:
- the end node.
-
getOppositeNode
Description copied from interface:ILcdGraphIfaNodeis one of the two nodes connected by the given edge in this graph, returns the other node, otherwise throwsIllegalArgumentException.- Specified by:
getOppositeNodein interfaceILcdGraph<N,E> - Parameters:
aEdge- the edge whose opposite node should be returned.aNode- one of the twoObject's connected by the given edge.- Returns:
- if
aNodeis one of the two nodes connected by this edge, returns the other node connected by this edge.
-
isConnected
Description copied from interface:ILcdGraphReturns true ifaNodeis one the nodes to which this edge is connected.- Specified by:
isConnectedin interfaceILcdGraph<N,E> - Parameters:
aEdge- the edge whose connectivity should be checked.aNode- the node whose connectivity should be checked.- Returns:
- true if
aNodeis one the nodes to which this edge is connected.
-
addGraphListener
Description copied from interface:ILcdGraphRegisters the givenILcdGraphListenerwith this graph. All events generated by this graph afterwards will be sent to the given listener, until it is removed from this graph.- Specified by:
addGraphListenerin interfaceILcdGraph<N,E> - Parameters:
aGraphListener- the graph listener to be registered with this graph.
-
removeGraphListener
Description copied from interface:ILcdGraphUnregisters the givenILcdGraphListenerfrom this graph. After it has been unregistered, no events generated by this graph will be sent to the given listener anymore.- Specified by:
removeGraphListenerin interfaceILcdGraph<N,E> - Parameters:
aGraphListener- the graph listener to be unregistered from this graph.
-
canAddNode
Description copied from interface:ILcdEditableGraphReturnstrueif the given node can be added to this graph,falseotherwise. More specifically, a node can be added to this graph if the following conditions are met:- the node is not
null - the node is not yet part of this graph
- the node satisfies all additional implementation-specific requirements (see the documentation of the implementing class).
- Specified by:
canAddNodein interfaceILcdEditableGraph<N,E> - Parameters:
aNode- the node to be verified.- Returns:
trueif the node can be added to this graph,falseotherwise.
- the node is not
-
addNode
Description copied from interface:ILcdEditableGraphAdds a node to this graph.- Specified by:
addNodein interfaceILcdEditableGraph<N,E> - Parameters:
aNode- the node to be added to this graph.aFireEventMode- the mode for sending out the TLcdGraphChangedEvent. This can be one ofILcdFireEventMode.FIRE_NOW, ILcdFireEventMode.FIRE_LATER or ILcdFireEventMode.NO_EVENT.- Preconditions:
canAddNode(aNode)- Note: this validation is potentially expensive, and should be avoided whenever possible.
-
canRemoveNode
Description copied from interface:ILcdEditableGraphReturnstrueif the given node can be removed from this graph,falseotherwise. More specifically, a node can be remove from this graph if the following conditions are met:- the node is not
null - the node is part of this graph
- there are no edges in this graph, connected to the node
- Specified by:
canRemoveNodein interfaceILcdEditableGraph<N,E> - Parameters:
aNode- the node to be verified.- Returns:
trueif the node can be removed from this graph,falseotherwise.
- the node is not
-
removeNode
Description copied from interface:ILcdEditableGraphRemoves a node from this graph.- Specified by:
removeNodein interfaceILcdEditableGraph<N,E> - Parameters:
aNode- the node to be removed from this graph.aFireEventMode- the mode for sending out the TLcdGraphChangedEvent. This can be one ofILcdFireEventMode.FIRE_NOW, ILcdFireEventMode.FIRE_LATER or ILcdFireEventMode.NO_EVENT.- Preconditions:
canRemoveNode(aNode)- Note: this validation is potentially expensive, and should be avoided whenever possible.- Returns:
- the node that was removed from the graph.
-
canAddEdge
Description copied from interface:ILcdEditableGraphReturnstrueif the given edge can be added to this graph,falseotherwise. More specifically, an edge can be added to this graph if the following conditions are met:- none of the arguments is
null - the edge is not yet part of this graph
- both nodes are part of this graph
- the edge satisfies all additional implementation-specific requirements (see the documentation of the implementing class).
- Specified by:
canAddEdgein interfaceILcdEditableGraph<N,E> - Parameters:
aEdge- the edge to be verified.aStartNode- the first node that should be connected by the given edge.aEndNode- the second node that should be connected by the given edge.- Returns:
trueif the edge can be added to this graph,falseotherwise.
- none of the arguments is
-
addEdge
Description copied from interface:ILcdEditableGraphAdds an edge to this graph, connecting the two given nodes.- Specified by:
addEdgein interfaceILcdEditableGraph<N,E> - Parameters:
aEdge- the edge to be added to this graph.aStartNode- the first node that should be connected by the given edge.aEndNode- the second node that should be connected by the given edge.aFireEventMode- the mode for sending out the TLcdGraphChangedEvent. This can be one ofILcdFireEventMode.FIRE_NOW, ILcdFireEventMode.FIRE_LATER or ILcdFireEventMode.NO_EVENT.- Preconditions:
canAddEdge(aEdge, aStartNode, aEndNode)- Note: this validation is potentially expensive, and should be avoided whenever possible.
-
canRemoveEdge
Description copied from interface:ILcdEditableGraphReturnstrueif the given edge can be removed from this graph,falseotherwise. More specifically, a edge can be remove from this graph if the following conditions are met:- the edge is not
null - the edge is part of this graph
- Specified by:
canRemoveEdgein interfaceILcdEditableGraph<N,E> - Parameters:
aEdge- the edge to be verified.- Returns:
trueif the edge can be removed from this graph,falseotherwise.
- the edge is not
-
removeEdge
Description copied from interface:ILcdEditableGraphRemoves an edge from this graph.- Specified by:
removeEdgein interfaceILcdEditableGraph<N,E> - Parameters:
aEdge- the edge to be removed from this graph.aFireEventMode- the mode for sending out the TLcdGraphChangedEvent. This can be one ofILcdFireEventMode.FIRE_NOW, ILcdFireEventMode.FIRE_LATER or ILcdFireEventMode.NO_EVENT.- Preconditions:
canRemoveEdge(aEdge)- Note: this validation is potentially expensive, and should be avoided whenever possible.- Returns:
- the edge which was removed from the graph.
-
removeEdges
public void removeEdges(int aFireEventMode) Description copied from interface:ILcdEditableGraphRemoves all edges from this graph - nodes will remain in the graph.- Specified by:
removeEdgesin interfaceILcdEditableGraph<N,E> - Parameters:
aFireEventMode- the mode for sending out the TLcdGraphChangedEvent. This can be one ofILcdFireEventMode.FIRE_NOW, ILcdFireEventMode.FIRE_LATER or ILcdFireEventMode.NO_EVENT.
-
clear
public void clear(int aFireEventMode) Description copied from interface:ILcdEditableGraphClears the graph; all edges and nodes are removed.- Specified by:
clearin interfaceILcdEditableGraph<N,E> - Parameters:
aFireEventMode- the mode for sending out the TLcdGraphChangedEvent. This can be one ofILcdFireEventMode.FIRE_NOW, ILcdFireEventMode.FIRE_LATER or ILcdFireEventMode.NO_EVENT.
-
fireCollectedGraphChanges
public void fireCollectedGraphChanges()Description copied from interface:ILcdEditableGraphFires all the collected graph changes, i.e., all graph events that have been generated using the the ILcdFireEventMode.FIRE_LATER mode, after the previous call tofireCollectedGraphChanges(). Note that afireCollectedGraphChanges()call is made whenever a graph event is generated in theILcdFireEventMode.FIRE_NOW, to guarantee the correct order of the events.- Specified by:
fireCollectedGraphChangesin interfaceILcdEditableGraph<N,E>
-
nodeChanged
Description copied from interface:ILcdEditableGraphThis method should be called when the given node has changed.- Preconditions:
containsPartition(aNode)- Note: this validation is potentially expensive, and should be avoided whenever possible.- Specified by:
nodeChangedin interfaceILcdEditableGraph<N,E> - Parameters:
aNode- the node that has changed.aEventMode- the mode for sending out the TLcdGraphChangedEvent. This can be one ofILcdFireEventMode.FIRE_NOW, ILcdFireEventMode.FIRE_LATER or ILcdFireEventMode.NO_EVENT.
-
nodesChanged
Description copied from interface:ILcdEditableGraphThis method should be called when the given nodes have changed.- Specified by:
nodesChangedin interfaceILcdEditableGraph<N,E> - Parameters:
aNodes- a vector containing the nodes that have changed.aEventMode- the mode for sending out the TLcdGraphChangedEvent. This can be one ofILcdFireEventMode.FIRE_NOW, ILcdFireEventMode.FIRE_LATER or ILcdFireEventMode.NO_EVENT.- Preconditions:
- for each
nodeobject in the given vector should hold that:containsPartition(node)- Note: this validation is potentially expensive, and should be avoided whenever possible.
-
edgeChanged
Description copied from interface:ILcdEditableGraphThis method should be called when the given edge has changed.- Specified by:
edgeChangedin interfaceILcdEditableGraph<N,E> - Parameters:
aEdge- the edge that has changed.aEventMode- the mode for sending out the TLcdGraphChangedEvent. This can be one ofILcdFireEventMode.FIRE_NOW, ILcdFireEventMode.FIRE_LATER or ILcdFireEventMode.NO_EVENT.- Preconditions:
containsBoundaryEdge(aEdge)- Note: this validation is potentially expensive, and should be avoided whenever possible.
-
edgesChanged
Description copied from interface:ILcdEditableGraphThis method should be called when the given edges have changed.- Specified by:
edgesChangedin interfaceILcdEditableGraph<N,E> - Parameters:
aEdges- a vector containing the edges that have changed.aEventMode- the mode for sending out the TLcdGraphChangedEvent. This can be one ofILcdFireEventMode.FIRE_NOW, ILcdFireEventMode.FIRE_LATER or ILcdFireEventMode.NO_EVENT.- Preconditions:
- for each
edgeobject in the given vector should hold that:containsBoundaryEdge(edge)- Note: this validation is potentially expensive, and should be avoided whenever possible.
-
toString
Returns a general description of this graph, containing the number of nodes and edges contained in this graph. The exact details of the representation are unspecified and are subject to change.
-