Package org.planit.network.physical
Class PhysicalNetworkBuilderImpl
- java.lang.Object
-
- org.planit.network.physical.PhysicalNetworkBuilderImpl
-
- All Implemented Interfaces:
DirectedGraphBuilder<Node,Link,LinkSegment>
,GraphBuilder<Node,Link>
,PhysicalNetworkBuilder<Node,Link,LinkSegment>
public class PhysicalNetworkBuilderImpl extends Object implements PhysicalNetworkBuilder<Node,Link,LinkSegment>
Create network entities for a physical network simulation model- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description protected DirectedGraphBuilderImpl
directedGraphBuilderImpl
hold an implementation of directed graph builder to use its overlapping functionality
-
Constructor Summary
Constructors Constructor Description PhysicalNetworkBuilderImpl(IdGroupingToken groupId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Link
createEdge(Vertex nodeA, Vertex nodeB, double length)
Create a new link instanceLinkSegment
createEdgeSegment(DirectedEdge parentLink, boolean directionAB)
Create a new physical link segment instanceLink
createUniqueCopyOf(Link linkToCopy)
create a shallo copy of the passed in edge, albeit with unique internal idsLinkSegment
createUniqueCopyOf(LinkSegment linkSegmentToCopy, DirectedEdge parentEdge)
Create a unique copy of the passed in edge segment.Node
createVertex()
Create a new vertex instanceIdGroupingToken
getIdGroupingToken()
Collect the id grouping token used by this buildervoid
recreateIds(Edges<? extends Link> links)
recreate the ids for all passed in edgesvoid
recreateIds(EdgeSegments<? extends LinkSegment> linkSegments)
recreate the ids for all passed in edge segmentsvoid
recreateIds(Vertices<? extends Node> nodes)
recreate the ids for all passed in verticesvoid
setIdGroupingToken(IdGroupingToken groupToken)
Each builder needs a group if token to allow all underlying factory methods to generated ids uniquely tied to the group the entities belong to
-
-
-
Field Detail
-
directedGraphBuilderImpl
protected DirectedGraphBuilderImpl directedGraphBuilderImpl
hold an implementation of directed graph builder to use its overlapping functionality
-
-
Constructor Detail
-
PhysicalNetworkBuilderImpl
public PhysicalNetworkBuilderImpl(IdGroupingToken groupId)
-
-
Method Detail
-
createVertex
public Node createVertex()
Create a new vertex instance- Specified by:
createVertex
in interfaceGraphBuilder<Node,Link>
- Returns:
- created vertex
-
createEdge
public Link createEdge(Vertex nodeA, Vertex nodeB, double length) throws PlanItException
Create a new link instance- Specified by:
createEdge
in interfaceGraphBuilder<Node,Link>
- Parameters:
nodeA
- the first vertex in this edgenodeB
- the second vertex in this edgelength
- the length (in km)- Returns:
- created edge
- Throws:
PlanItException
- thrown if there is an error
-
createEdgeSegment
public LinkSegment createEdgeSegment(DirectedEdge parentLink, boolean directionAB) throws PlanItException
Create a new physical link segment instance- Specified by:
createEdgeSegment
in interfaceDirectedGraphBuilder<Node,Link,LinkSegment>
- Parameters:
parentLink
- the parent edge of the edge segmentdirectionAB
- direction of travel- Returns:
- edgeSegment the created edge segment
- Throws:
PlanItException
- thrown if error
-
setIdGroupingToken
public void setIdGroupingToken(IdGroupingToken groupToken)
Each builder needs a group if token to allow all underlying factory methods to generated ids uniquely tied to the group the entities belong to- Specified by:
setIdGroupingToken
in interfaceGraphBuilder<Node,Link>
- Parameters:
groupToken
- , contiguous id generation within this group for instances created with the factory methods
-
getIdGroupingToken
public IdGroupingToken getIdGroupingToken()
Collect the id grouping token used by this builder- Specified by:
getIdGroupingToken
in interfaceGraphBuilder<Node,Link>
- Returns:
- idGroupingToken the id grouping token used by this builder
-
recreateIds
public void recreateIds(EdgeSegments<? extends LinkSegment> linkSegments)
recreate the ids for all passed in edge segments- Specified by:
recreateIds
in interfaceDirectedGraphBuilder<Node,Link,LinkSegment>
- Parameters:
linkSegments
- to recreate ids for
-
recreateIds
public void recreateIds(Edges<? extends Link> links)
recreate the ids for all passed in edges- Specified by:
recreateIds
in interfaceGraphBuilder<Node,Link>
- Parameters:
links
- to recreate ids for
-
recreateIds
public void recreateIds(Vertices<? extends Node> nodes)
recreate the ids for all passed in vertices- Specified by:
recreateIds
in interfaceGraphBuilder<Node,Link>
- Parameters:
nodes
- to recreate ids for
-
createUniqueCopyOf
public Link createUniqueCopyOf(Link linkToCopy)
create a shallo copy of the passed in edge, albeit with unique internal ids- Specified by:
createUniqueCopyOf
in interfaceGraphBuilder<Node,Link>
- Parameters:
linkToCopy
- the edge to copy- Returns:
- new edge based on passed in edge
-
createUniqueCopyOf
public LinkSegment createUniqueCopyOf(LinkSegment linkSegmentToCopy, DirectedEdge parentEdge)
Create a unique copy of the passed in edge segment. All members are copied as is, except for its ids which are created uniquely created so it remains identifiable, also the parent edge is updated if required- Specified by:
createUniqueCopyOf
in interfaceDirectedGraphBuilder<Node,Link,LinkSegment>
- Parameters:
linkSegmentToCopy
- edge segment to copyparentEdge
- use this as the new parent edge- Returns:
- created copy
-
-