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 DirectedGraphBuilderImpldirectedGraphBuilderImplhold 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 LinkcreateEdge(Vertex nodeA, Vertex nodeB, double length)Create a new link instanceLinkSegmentcreateEdgeSegment(DirectedEdge parentLink, boolean directionAB)Create a new physical link segment instanceLinkcreateUniqueCopyOf(Link linkToCopy)create a shallo copy of the passed in edge, albeit with unique internal idsLinkSegmentcreateUniqueCopyOf(LinkSegment linkSegmentToCopy, DirectedEdge parentEdge)Create a unique copy of the passed in edge segment.NodecreateVertex()Create a new vertex instanceIdGroupingTokengetIdGroupingToken()Collect the id grouping token used by this buildervoidrecreateIds(Edges<? extends Link> links)recreate the ids for all passed in edgesvoidrecreateIds(EdgeSegments<? extends LinkSegment> linkSegments)recreate the ids for all passed in edge segmentsvoidrecreateIds(Vertices<? extends Node> nodes)recreate the ids for all passed in verticesvoidsetIdGroupingToken(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:
createVertexin 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:
createEdgein 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:
createEdgeSegmentin 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:
setIdGroupingTokenin 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:
getIdGroupingTokenin 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:
recreateIdsin 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:
recreateIdsin 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:
recreateIdsin 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:
createUniqueCopyOfin 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:
createUniqueCopyOfin interfaceDirectedGraphBuilder<Node,Link,LinkSegment>- Parameters:
linkSegmentToCopy- edge segment to copyparentEdge- use this as the new parent edge- Returns:
- created copy
-
-