Class TLcdPartitionedGraph<N,E>
java.lang.Object
com.luciad.network.graph.partition.TLcdLimitedEditablePartitionedGraph<N,E>
com.luciad.network.graph.partition.TLcdPartitionedGraph<N,E>
- All Implemented Interfaces:
ILcdEditableGraph<N,
,E> ILcdGraph<N,
,E> ILcdLimitedEditablePartitionedGraph<N,
,E> ILcdPartitionedGraph<N,
E>
public class TLcdPartitionedGraph<N,E>
extends TLcdLimitedEditablePartitionedGraph<N,E>
implements ILcdEditableGraph<N,E>
An implementation of
ILcdLimitedEditablePartitionedGraph
that is
also an ILcdEditableGraph
. This means the graph can be used wherever
a TLcdGraph can be used. The addNode
method uses an implementation-specific
node assignment policy to decide in which of its partitions the new node will
be added. This method can be overwritten to implement an editable graph with
a another assignment policy.- Since:
- 5.1
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an edge to this graph, connecting the two given nodes.void
Adds a node to this graph.boolean
canAddEdge
(E aEdge, N aStartNode, N aEndNode) Returnstrue
if the given edge can be added to this graph,false
otherwise.boolean
canAddNode
(N aNode) Returnstrue
if the given node can be added to this graph,false
otherwise.boolean
canAddPartition
(ILcdGraph<N, E> aPartition) Returnstrue
if the given partition can be added to this partitioned graph,false
otherwise.boolean
canRemoveEdge
(E aEdge) Returnstrue
if the given edge can be removed from this graph,false
otherwise.boolean
canRemoveNode
(N aNode) Returnstrue
if the given node can be removed from this graph,false
otherwise.void
clear
(int aFireEventMode) Clears the graph; all edges and nodes are removed.void
edgeChanged
(E aEdge, int aEventMode) This method should be called when the given edge has changed.void
edgesChanged
(Vector<E> aEdges, int aEventMode) This method should be called when the given edges have changed.void
Fires all the collected graph changes, i.e., all graph events that have been generated using the ILcdFireEventMode.FIRE_LATER mode, after the previous call tofireCollectedGraphChanges()
.void
nodeChanged
(N aNode, int aEventMode) This method should be called when the given node has changed.void
nodesChanged
(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.void
removeEdges
(int aFireEventMode) Removes all edges from this graph - nodes will remain in the graph.removeNode
(N aNode, int aFireEventMode) Removes a node from this graph.Methods inherited from class com.luciad.network.graph.partition.TLcdLimitedEditablePartitionedGraph
addBoundaryEdge, addGraphListener, addPartition, addPartitionedGraphListener, boundaryEdgeChanged, boundaryEdgesChanged, canAddBoundaryEdge, canRemoveBoundaryEdge, canRemoveBoundaryEdges, canRemovePartition, clear, clearBoundaryGraph, containsEdge, containsNode, containsPartition, fireCollectedPartitionedGraphChanges, getBoundaryEdges, getBoundaryGraph, getBoundaryNodes, getEdges, getEdges, getEndNode, getNodes, getOppositeNode, getPartitionForEdge, getPartitionForNode, getPartitions, getStartNode, isConnected, removeBoundaryEdge, removeBoundaryEdges, removeGraphListener, removePartition, removePartitionedGraphListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.network.graph.ILcdGraph
addGraphListener, containsEdge, containsNode, getEdges, getEdges, getEndNode, getNodes, getOppositeNode, getStartNode, isConnected, removeGraphListener
-
Constructor Details
-
TLcdPartitionedGraph
public TLcdPartitionedGraph()Constructs a new, emptyTLcdPartitionedGraph
.
-
-
Method Details
-
canAddPartition
Returnstrue
if the given partition can be added to this partitioned graph,false
otherwise. More specifically, a partition can be added to this graph if the following conditions are met:- the partition is not
null
- the partition is not yet part of this graph
- the partition contains no nodes or edges that are already part of this graph
- the partition is editable (implements the
ILcdEditableGraph
interface.
- Specified by:
canAddPartition
in interfaceILcdLimitedEditablePartitionedGraph<N,
E> - Overrides:
canAddPartition
in classTLcdLimitedEditablePartitionedGraph<N,
E> - Parameters:
aPartition
- the partition to be verified.- Returns:
true
if the partition can be added to this graph,false
otherwise.
- the partition is not
-
canAddNode
Returnstrue
if the given node can be added to this graph,false
otherwise. 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
- there are already partitions contained in this graph.
- the node satisfies all additional implementation-specific requirements (see the documentation of the implementing class).
- Specified by:
canAddNode
in interfaceILcdEditableGraph<N,
E> - Parameters:
aNode
- the node to be verified.- Returns:
true
if the node can be added to this graph,false
otherwise.
- the node is not
-
addNode
Adds a node to this graph. The node will be added to the first partition that is returned by thegetPartitions()
method. This method can be overwritten by subclasses that implement a specific policy in combination with theaddNode(ILcdGraph aPartition, Object aNode)
method, e.g. add the nodes to partitions according to their geographical position.- Specified by:
addNode
in interfaceILcdEditableGraph<N,
E> - Parameters:
aNode
- the node to be added to this graph.- Preconditions:
canAddNode(aNode)
- Note: this validation is potentially expensive, and should be avoided whenever possible.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:ILcdEditableGraph
Returnstrue
if the given node can be removed from this graph,false
otherwise. 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:
canRemoveNode
in interfaceILcdEditableGraph<N,
E> - Parameters:
aNode
- the node to be verified.- Returns:
true
if the node can be removed from this graph,false
otherwise.
- the node is not
-
removeNode
Description copied from interface:ILcdEditableGraph
Removes a node from this graph.- Specified by:
removeNode
in 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:ILcdEditableGraph
Returnstrue
if the given edge can be added to this graph,false
otherwise. 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:
canAddEdge
in 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:
true
if the edge can be added to this graph,false
otherwise.
- none of the arguments is
-
addEdge
Description copied from interface:ILcdEditableGraph
Adds an edge to this graph, connecting the two given nodes.- Specified by:
addEdge
in 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:ILcdEditableGraph
Returnstrue
if the given edge can be removed from this graph,false
otherwise. 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:
canRemoveEdge
in interfaceILcdEditableGraph<N,
E> - Parameters:
aEdge
- the edge to be verified.- Returns:
true
if the edge can be removed from this graph,false
otherwise.
- the edge is not
-
removeEdge
Description copied from interface:ILcdEditableGraph
Removes an edge from this graph.- Specified by:
removeEdge
in 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:ILcdEditableGraph
Removes all edges from this graph - nodes will remain in the graph.- Specified by:
removeEdges
in 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:ILcdEditableGraph
Clears the graph; all edges and nodes are removed.- Specified by:
clear
in 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
.
-
nodeChanged
Description copied from interface:ILcdEditableGraph
This 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:
nodeChanged
in 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:ILcdEditableGraph
This method should be called when the given nodes have changed.- Specified by:
nodesChanged
in 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
node
object 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:ILcdEditableGraph
This method should be called when the given edge has changed.- Specified by:
edgeChanged
in 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:ILcdEditableGraph
This method should be called when the given edges have changed.- Specified by:
edgesChanged
in 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
edge
object in the given vector should hold that:containsBoundaryEdge(edge)
- Note: this validation is potentially expensive, and should be avoided whenever possible.
-
fireCollectedGraphChanges
public void fireCollectedGraphChanges()Description copied from interface:ILcdLimitedEditablePartitionedGraph
Fires all the collected graph changes, i.e., all graph events that have been generated using 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:
fireCollectedGraphChanges
in interfaceILcdEditableGraph<N,
E> - Specified by:
fireCollectedGraphChanges
in interfaceILcdLimitedEditablePartitionedGraph<N,
E> - Overrides:
fireCollectedGraphChanges
in classTLcdLimitedEditablePartitionedGraph<N,
E>
-