Package org.planit.graph
Class EdgeSegmentImpl
- java.lang.Object
-
- org.planit.graph.EdgeSegmentImpl
-
- All Implemented Interfaces:
Serializable,Comparable<Idable>,EdgeSegment,ExternalIdable,Idable
- Direct Known Subclasses:
ConnectoidSegmentImpl,LinkSegmentImpl
public class EdgeSegmentImpl extends Object implements EdgeSegment
EdgeSegment represents an edge in a particular (single) direction. Each edge has either one or two edge segments where each edge segment may have a more detailed geography than its parent link (which represents both directions via a centreline) This class is now abstract. It is extended by LinkSegment (physical links) and Connectoid (virtual links).- Author:
- markr
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedEdgeSegmentImpl(EdgeSegmentImpl edgeSegmentImpl)Copy constructorprotectedEdgeSegmentImpl(IdGroupingToken groupId, DirectedEdge parentEdge, boolean directionAB)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description EdgeSegmentclone()Clone the edge segmentbooleanequals(Object obj)protected static longgenerateEdgeSegmentId(IdGroupingToken groupId)Generate unique edge segment idDirectedVertexgetDownstreamVertex()Get the segment's downstream vertexStringgetExternalId()get external id of the entitylonggetId()collect id of the entityDirectedEdgegetParentEdge()Collect the parent edge of the segmentDirectedVertexgetUpstreamVertex()Get the segment's upstream vertexStringgetXmlId()the id exposed to users as the "normal" id in the PLANit native xml formatinthashCode()booleanisDirectionAb()check if edge segment runs from vertex a to b or b to abooleanremove(DirectedVertex vertex)Remove the vertex from the edge segment if it is either the up or downstream vertexvoidremoveParentEdge()remove the parent edge from this edge segmentvoidsetDownstreamVertex(DirectedVertex downstreamVertex)Set another downstream vertex.voidsetExternalId(String externalId)set the external idprotected voidsetId(Long id)set id of edge segmentvoidsetParentEdge(DirectedEdge parentEdge)Set the parent edgevoidsetUpstreamVertex(DirectedVertex upstreamVertex)Set another upstream vertex.voidsetXmlId(String xmlId)set the external idbooleanvalidate()validate the contents of this edge segment-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.planit.utils.graph.EdgeSegment
replace
-
Methods inherited from interface org.planit.utils.id.ExternalIdable
hasExternalId, hasXmlId
-
Methods inherited from interface org.planit.utils.id.Idable
compareTo, idEquals, idHashCode
-
-
-
-
Field Detail
-
xmlId
protected String xmlId
Xml Id of the edge segment
-
-
Constructor Detail
-
EdgeSegmentImpl
protected EdgeSegmentImpl(IdGroupingToken groupId, DirectedEdge parentEdge, boolean directionAB) throws PlanItException
Constructor- Parameters:
groupId- contiguous id generation within this group for instances of this classparentEdge- parent edge of segmentdirectionAB- direction of travel- Throws:
PlanItException- thrown when parent edge's vertices are incompatible with directional edge segments
-
EdgeSegmentImpl
protected EdgeSegmentImpl(EdgeSegmentImpl edgeSegmentImpl)
Copy constructor- Parameters:
edgeSegmentImpl- to copy
-
-
Method Detail
-
generateEdgeSegmentId
protected static long generateEdgeSegmentId(IdGroupingToken groupId)
Generate unique edge segment id- Parameters:
groupId- contiguous id generation within this group for instances of this class- Returns:
- id id of this EdgeSegment
-
setId
protected void setId(Long id)
set id of edge segment- Parameters:
id- to set
-
remove
public boolean remove(DirectedVertex vertex)
Remove the vertex from the edge segment if it is either the up or downstream vertex- Specified by:
removein interfaceEdgeSegment- Parameters:
vertex- to remove- Returns:
- true when successful, false otherwise
-
setDownstreamVertex
public void setDownstreamVertex(DirectedVertex downstreamVertex)
Set another downstream vertex.- Specified by:
setDownstreamVertexin interfaceEdgeSegment- Parameters:
downstreamVertex- to use
-
setUpstreamVertex
public void setUpstreamVertex(DirectedVertex upstreamVertex)
Set another upstream vertex.- Specified by:
setUpstreamVertexin interfaceEdgeSegment- Parameters:
upstreamVertex- to use
-
getUpstreamVertex
public DirectedVertex getUpstreamVertex()
Get the segment's upstream vertex- Specified by:
getUpstreamVertexin interfaceEdgeSegment- Returns:
- upstream vertex
-
getDownstreamVertex
public DirectedVertex getDownstreamVertex()
Get the segment's downstream vertex- Specified by:
getDownstreamVertexin interfaceEdgeSegment- Returns:
- downstream vertex
-
isDirectionAb
public boolean isDirectionAb()
check if edge segment runs from vertex a to b or b to a- Specified by:
isDirectionAbin interfaceEdgeSegment- Returns:
- true when running from a to b, otherwise false
-
getId
public long getId()
collect id of the entity
-
getParentEdge
public DirectedEdge getParentEdge()
Collect the parent edge of the segment- Specified by:
getParentEdgein interfaceEdgeSegment- Returns:
- parentEdge
-
setParentEdge
public void setParentEdge(DirectedEdge parentEdge)
Set the parent edge- Specified by:
setParentEdgein interfaceEdgeSegment- Parameters:
parentEdge- to set
-
removeParentEdge
public void removeParentEdge()
remove the parent edge from this edge segment- Specified by:
removeParentEdgein interfaceEdgeSegment
-
clone
public EdgeSegment clone()
Clone the edge segment- Specified by:
clonein interfaceEdgeSegment- Overrides:
clonein classObject- Returns:
- copy of this instance
-
validate
public boolean validate()
validate the contents of this edge segment- Specified by:
validatein interfaceEdgeSegment- Returns:
- true when valid, false otherwise
-
getExternalId
public String getExternalId()
get external id of the entity- Specified by:
getExternalIdin interfaceExternalIdable- Returns:
- external id
-
setExternalId
public void setExternalId(String externalId)
set the external id- Specified by:
setExternalIdin interfaceExternalIdable- Parameters:
externalId- to set
-
getXmlId
public String getXmlId()
the id exposed to users as the "normal" id in the PLANit native xml format- Specified by:
getXmlIdin interfaceExternalIdable- Returns:
- xmlId
-
setXmlId
public void setXmlId(String xmlId)
set the external id- Specified by:
setXmlIdin interfaceExternalIdable- Parameters:
xmlId- to set
-
-