Package org.planit.graph
Class EdgeImpl
- java.lang.Object
-
- org.planit.graph.EdgeImpl
-
- All Implemented Interfaces:
Serializable,Comparable<Edge>,Edge
- Direct Known Subclasses:
ConnectoidImpl,LinkImpl
public class EdgeImpl extends Object implements Edge
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 Modifier and Type Field Description protected EdgeSegmentedgeSegmentABEdge segment A to B directionprotected EdgeSegmentedgeSegmentBAEdge segment B to A directionprotected longidUnique internal identifierprotected Map<String,Object>inputPropertiesGeneric input property storageprotected doublelengthLength of edgeprotected StringnameName of the edgeprotected VertexvertexAVertex Aprotected VertexvertexBVertex B
-
Constructor Summary
Constructors Modifier Constructor Description protectedEdgeImpl(IdGroupingToken groupId, Vertex vertexA, Vertex vertexB, double length)Constructor which injects link lengths directly
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInputProperty(String key, Object value)Add a property from the original input that is not part of the readily available link membersintcompareTo(Edge o)protected static longgenerateEdgeId(IdGroupingToken groupId)Generate edge idEdgeSegmentgetEdgeSegmentAB()Edge segment in the direction from A to BEdgeSegmentgetEdgeSegmentBA()Edge segment in the direction from B to AlonggetId()Return id of this instance.ObjectgetInputProperty(String key)Get input property by its keydoublegetLength()Return length of this edge in kmStringgetName()collect the name of the edgeVertexgetVertexA()Vertex A of the edgeVertexgetVertexB()Vertex B of the edgeprotected EdgeSegmentregisterEdgeSegment(EdgeSegment edgeSegment, boolean directionAB)Register EdgeSegment.voidsetName(String name)set the name of this edge
-
-
-
Field Detail
-
id
protected final long id
Unique internal identifier
-
name
protected String name
Name of the edge
-
vertexA
protected Vertex vertexA
Vertex A
-
vertexB
protected Vertex vertexB
Vertex B
-
length
protected double length
Length of edge
-
edgeSegmentAB
protected EdgeSegment edgeSegmentAB
Edge segment A to B direction
-
edgeSegmentBA
protected EdgeSegment edgeSegmentBA
Edge segment B to A direction
-
-
Constructor Detail
-
EdgeImpl
protected EdgeImpl(IdGroupingToken groupId, Vertex vertexA, Vertex vertexB, double length) throws PlanItException
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 linklength- length of the link- Throws:
PlanItException- thrown if there is an error
-
-
Method Detail
-
generateEdgeId
protected static long generateEdgeId(IdGroupingToken groupId)
Generate edge id- Parameters:
groupId- , contiguous id generation within this group for instances of this class- Returns:
- id of this Edge object
-
registerEdgeSegment
protected EdgeSegment registerEdgeSegment(EdgeSegment edgeSegment, boolean directionAB) throws PlanItException
Register EdgeSegment. If there already exists an edgeSegment for that direction it is replaced and returned- Parameters:
edgeSegment- EdgeSegment to be registereddirectionAB- direction of travel- Returns:
- replaced LinkSegment
- Throws:
PlanItException- thrown if there is an error
-
addInputProperty
public void addInputProperty(String key, Object value)
Add a property from the original input that is not part of the readily available link members- Specified by:
addInputPropertyin interfaceEdge- Parameters:
key- key (name) of input propertyvalue- value of input property
-
getInputProperty
public Object getInputProperty(String key)
Get input property by its key- Specified by:
getInputPropertyin interfaceEdge- Parameters:
key- key of input property- Returns:
- value retrieved value of input property
-
getLength
public double getLength()
Return length of this edge in km
-
getId
public long getId()
Return id of this instance. This id is expected to be generated using the org.planit.utils.misc.IdGenerator
-
getVertexA
public Vertex getVertexA()
Vertex A of the edge- Specified by:
getVertexAin interfaceEdge- Returns:
- vertex A
-
getVertexB
public Vertex getVertexB()
Vertex B of the edge- Specified by:
getVertexBin interfaceEdge- Returns:
- vertex B
-
getName
public String getName()
collect the name of the edge
-
setName
public void setName(String name)
set the name of this edge- Parameters:
name- the name of this edge
-
getEdgeSegmentAB
public EdgeSegment getEdgeSegmentAB()
Edge segment in the direction from A to B- Specified by:
getEdgeSegmentABin interfaceEdge- Returns:
- edge segment AB
-
getEdgeSegmentBA
public EdgeSegment getEdgeSegmentBA()
Edge segment in the direction from B to A- Specified by:
getEdgeSegmentBAin interfaceEdge- Returns:
- edge segment BA
-
compareTo
public int compareTo(Edge o)
- Specified by:
compareToin interfaceComparable<Edge>
-
-