Package org.goplanit.graph.directed
Class DirectedEdgeImpl<V extends DirectedVertex,ES extends EdgeSegment>
- java.lang.Object
-
- org.goplanit.utils.id.IdAbleImpl
-
- org.goplanit.utils.id.ExternalIdAbleImpl
-
- org.goplanit.graph.GraphEntityImpl
-
- org.goplanit.graph.EdgeImpl<V>
-
- org.goplanit.graph.directed.DirectedEdgeImpl<V,ES>
-
- All Implemented Interfaces:
Serializable
,Comparable<IdAble>
,DirectedEdge
,Edge
,GraphEntity
,ExternalIdAble
,IdAble
,ManagedId
- Direct Known Subclasses:
ConjugateDirectedEdgeImpl
,ConjugateLinkImpl
,ConnectoidEdgeImpl
,LinkImpl
,ServiceLegImpl
public class DirectedEdgeImpl<V extends DirectedVertex,ES extends EdgeSegment> extends EdgeImpl<V> implements DirectedEdge
Edge class connecting two vertices via some geometry. Each edge has one or two underlying edge segments in a particular direction which may carry additional information for each particular direction of the edge.- Author:
- markr
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.goplanit.graph.EdgeImpl
inputProperties, lengthInKm, lineGeometry, name
-
Fields inherited from interface org.goplanit.utils.graph.Edge
EDGE_ID_CLASS
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DirectedEdgeImpl(DirectedEdgeImpl<V,ES> directedEdgeImpl, boolean deepCopy)
Copy Constructor.protected
DirectedEdgeImpl(IdGroupingToken groupId, V vertexA, V vertexB)
Constructor which injects link lengths directlyprotected
DirectedEdgeImpl(IdGroupingToken groupId, V vertexA, V vertexB, double lengthKm)
Constructor which injects link lengths directly
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DirectedEdgeImpl<V,ES>
deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call.ES
getEdgeSegmentAb()
Edge segment in the direction from A to BES
getEdgeSegmentBa()
Edge segment in the direction from B to AES
registerEdgeSegment(EdgeSegment edgeSegment, boolean directionAB, boolean force)
Register EdgeSegment.ES
removeEdgeSegmentAb()
Remove edge segmentAb from this edge.ES
removeEdgeSegmentBa()
Remove edge segmentAb from this edge.void
replace(EdgeSegment edgeSegmentToReplace, EdgeSegment edgeSegmentToReplaceWith)
replace passed in edge segment (if present) with the passed in onevoid
setEdgeSegmentAb(ES edgeSegmentAb)
set edge segment from A to Bvoid
setEdgeSegmentBa(ES edgeSegmentBa)
set edge segment from B to ADirectedEdgeImpl<V,ES>
shallowClone()
Create a shallow copy of this entity-
Methods inherited from class org.goplanit.graph.EdgeImpl
addInputProperty, getGeometry, getInputProperty, getLengthKm, getName, getVertexA, getVertexB, removeVertex, removeVertexA, removeVertexB, replace, setGeometry, setLengthKm, setName, setVertexA, setVertexB, validate
-
Methods inherited from class org.goplanit.graph.GraphEntityImpl
generateAndSetId, generateId, recreateManagedIds, toString
-
Methods inherited from class org.goplanit.utils.id.ExternalIdAbleImpl
getExternalId, getXmlId, setExternalId, setXmlId
-
Methods inherited from class org.goplanit.utils.id.IdAbleImpl
equals, generateAndSetId, getId, hashCode, setId
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.graph.directed.DirectedEdge
forEachSegment, getEdgeSegment, getEdgeSegments, getVertexA, getVertexB, hasEdgeSegment, hasEdgeSegmentAb, hasEdgeSegmentBa, registerEdgeSegment, removeEdgeSegment, removeEdgeSegments
-
Methods inherited from interface org.goplanit.utils.graph.Edge
addInputProperty, createEnvelope, getGeometry, getIdClass, getInputProperty, getLengthKm, getName, hasGeometry, hasName, hasVertex, hasVertexA, hasVertexB, hasVertices, isGeometryInAbDirection, isGeometryInAbDirection, isVertexA, populateBasicGeometry, removeVertex, replace, setGeometry, setLengthKm, setName, transformGeometry, updateGeometryInjectCoordinateAtProjectedLocation, validate
-
Methods inherited from interface org.goplanit.utils.id.ExternalIdAble
appendExternalId, appendExternalId, getExternalId, getIdsAsString, getSplitExternalId, getSplitExternalId, getXmlId, hasExternalId, hasXmlId, setExternalId, setXmlId, setXmlId
-
Methods inherited from interface org.goplanit.utils.id.IdAble
compareTo, getId, idEquals, idHashCode
-
Methods inherited from interface org.goplanit.utils.id.ManagedId
recreateManagedIds, resetChildManagedIdEntities
-
-
-
-
Constructor Detail
-
DirectedEdgeImpl
protected DirectedEdgeImpl(IdGroupingToken groupId, V vertexA, V vertexB)
Constructor which injects link lengths directly- Parameters:
groupId
- , contiguous id generation within this group for instances of this classvertexA
- first vertex in the linkvertexB
- second vertex in the link
-
DirectedEdgeImpl
protected DirectedEdgeImpl(IdGroupingToken groupId, V vertexA, V vertexB, double lengthKm)
Constructor which injects link lengths directly- Parameters:
groupId
- , contiguous id generation within this group for instances of this classvertexA
- first vertex in the linkvertexB
- second vertex in the linklengthKm
- length of the link in km
-
DirectedEdgeImpl
protected DirectedEdgeImpl(DirectedEdgeImpl<V,ES> directedEdgeImpl, boolean deepCopy)
Copy Constructor. Edge segments are shallow copied and point to the passed in edge as their parent So additional effort is needed to make the new edge usable- Parameters:
directedEdgeImpl
- to copydeepCopy
- when true, create a deep copy, shallow copy otherwise
-
-
Method Detail
-
setEdgeSegmentBa
public void setEdgeSegmentBa(ES edgeSegmentBa)
set edge segment from B to A- Parameters:
edgeSegmentBa
- to set
-
setEdgeSegmentAb
public void setEdgeSegmentAb(ES edgeSegmentAb)
set edge segment from A to B- Parameters:
edgeSegmentAb
- to set
-
registerEdgeSegment
public ES registerEdgeSegment(EdgeSegment edgeSegment, boolean directionAB, boolean force)
Register EdgeSegment. If there already exists an edgeSegment for that direction it is replaced and returned. If the edge segment has no parent edge, this edge is set. If there is a discrepancy between the edge segment's parent edge and this edge a warning is issued and the edge segment is not registered- Specified by:
registerEdgeSegment
in interfaceDirectedEdge
- Parameters:
edgeSegment
- the edgeSegment to be registereddirectionAB
- direction of travelforce
- when true the provided edge segment is always set (even if null or inconsistent, without warning)- Returns:
- replaced egeSegment (if any)
-
getEdgeSegmentAb
public ES getEdgeSegmentAb()
Edge segment in the direction from A to B- Specified by:
getEdgeSegmentAb
in interfaceDirectedEdge
- Returns:
- edge segment AB
-
getEdgeSegmentBa
public ES getEdgeSegmentBa()
Edge segment in the direction from B to A- Specified by:
getEdgeSegmentBa
in interfaceDirectedEdge
- Returns:
- edge segment BA
-
shallowClone
public DirectedEdgeImpl<V,ES> shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceDirectedEdge
- Specified by:
shallowClone
in interfaceEdge
- Specified by:
shallowClone
in interfaceGraphEntity
- Specified by:
shallowClone
in interfaceIdAble
- Overrides:
shallowClone
in classEdgeImpl<V extends DirectedVertex>
- Returns:
- shallow copy of entity
-
deepClone
public DirectedEdgeImpl<V,ES> deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call. To be used with caution if not called by managed id container related code- Specified by:
deepClone
in interfaceDirectedEdge
- Specified by:
deepClone
in interfaceEdge
- Specified by:
deepClone
in interfaceGraphEntity
- Specified by:
deepClone
in interfaceIdAble
- Overrides:
deepClone
in classEdgeImpl<V extends DirectedVertex>
- Returns:
- deep copy of entity
-
replace
public void replace(EdgeSegment edgeSegmentToReplace, EdgeSegment edgeSegmentToReplaceWith)
replace passed in edge segment (if present) with the passed in one- Specified by:
replace
in interfaceDirectedEdge
- Parameters:
edgeSegmentToReplace
- the one to replaceedgeSegmentToReplaceWith
- the one to replace it with
-
removeEdgeSegmentAb
public ES removeEdgeSegmentAb()
Remove edge segmentAb from this edge. Be careful doing this as it because it might affect the contiguous ids if the edge segment is garbage collected- Specified by:
removeEdgeSegmentAb
in interfaceDirectedEdge
- Returns:
- removed edge segment
-
removeEdgeSegmentBa
public ES removeEdgeSegmentBa()
Remove edge segmentAb from this edge. Be careful doing this as it because it might affect the contiguous ids if the edge segment is garbage collected- Specified by:
removeEdgeSegmentBa
in interfaceDirectedEdge
- Returns:
- removed edge segment
-
-