Package com.amalgamasimulation.trains
Class RailDestination
java.lang.Object
com.amalgamasimulation.trains.RailDestination
Class representing a combination of a specific graph position and information
about which side of the train should arrive at the destination. A position
can point to point on graph arc at certain offset from arc's beginning only.
Pointing to a node is not allowed.
If it is specified that the train should end with its tail, then the train
will pass through the specified position and stop when its tail is at the
specified position if there is enough space on the specified arch for this,
otherwise an exception will be thrown.
- Author:
- Andrey Korotin
-
Constructor Summary
ConstructorsConstructorDescriptionRailDestination(GeometricGraphPosition<RailNode, RailArc> geometricGraphPosition) Creates a new instance of the rail destination by the specifiedGeometricGraphPosition.RailDestination(GeometricGraphPosition<RailNode, RailArc> geometricGraphPosition, TrainsEnvironment.TrainDirection movementEndTrainDirection) Creates a new instance of the rail destination by the specifiedGeometricGraphPositionand information about which side of the train should arrive at the destination. -
Method Summary
Modifier and TypeMethodDescriptionbooleangetGeometricGraphPosition(double trainLength) Returns an instance ofGeometricGraphPositionwhich represents this position in the underlying rail graph considering which side of the train should arrive at the destination.Return the side of the train should arrive at the destinationgetTrack()Returns the track which this position points to.inthashCode()static RailDestinationCreates a new instance of the rail destination by the specified arc and offset.static RailDestinationof(Graph<RailNode, RailArc>.Arc arc, double arcAbsOffset, TrainsEnvironment.TrainDirection movementEndTrainDirection) Creates a new instance of the rail destination by the specifiedGeometricGraphPositionand information about which side of the train should arrive at the destination.static RailDestinationof(GeometricGraphPosition<RailNode, RailArc> geometricGraphPosition) Creates a new instance of the rail destination by the specifiedGeometricGraphPosition.static RailDestinationof(GeometricGraphPosition<RailNode, RailArc> geometricGraphPosition, TrainsEnvironment.TrainDirection movementEndTrainDirection) Creates a new instance of the rail destination by the specifiedGeometricGraphPositionand information about which side of the train should arrive at the destination.toString()
-
Constructor Details
-
RailDestination
public RailDestination(GeometricGraphPosition<RailNode, RailArc> geometricGraphPosition, TrainsEnvironment.TrainDirection movementEndTrainDirection) Creates a new instance of the rail destination by the specifiedGeometricGraphPositionand information about which side of the train should arrive at the destination.- Parameters:
geometricGraphPosition- specified positionmovementEndTrainDirection- which side of the train should arrive at the destination
-
RailDestination
Creates a new instance of the rail destination by the specifiedGeometricGraphPosition. The train direction (i.e. whether train's head or tail should arrive first) is not specified.- Parameters:
geometricGraphPosition- specified position
-
-
Method Details
-
of
public static RailDestination of(GeometricGraphPosition<RailNode, RailArc> geometricGraphPosition, TrainsEnvironment.TrainDirection movementEndTrainDirection) Creates a new instance of the rail destination by the specifiedGeometricGraphPositionand information about which side of the train should arrive at the destination.- Parameters:
geometricGraphPosition- specified positionmovementEndTrainDirection- which side of the train should arrive at the destination
-
of
Creates a new instance of the rail destination by the specifiedGeometricGraphPosition. The train direction (i.e. whether train's head or tail should arrive first) is not specified.- Parameters:
geometricGraphPosition- specified position
-
of
public static RailDestination of(Graph<RailNode, RailArc>.Arc arc, double arcAbsOffset, TrainsEnvironment.TrainDirection movementEndTrainDirection) Creates a new instance of the rail destination by the specifiedGeometricGraphPositionand information about which side of the train should arrive at the destination.- Parameters:
arc- specified arc, must not benullarcAbsOffset- specified absolute offset on the arcmovementEndTrainDirection- which side of the train should arrive at the destination
-
of
Creates a new instance of the rail destination by the specified arc and offset. The train direction (i.e. whether train's head or tail should arrive first) is not specified.- Parameters:
arc- specified arc, must not benullarcAbsOffset- specified absolute offset on the arc
-
getGeometricGraphPosition
Returns an instance ofGeometricGraphPositionwhich represents this position in the underlying rail graph considering which side of the train should arrive at the destination.- Parameters:
trainLength- train length- Returns:
- instance of
GeometricGraphPositionwhich represents this position in the underlying rail graph considering which side of the train should arrive at the destination - See Also:
-
getMovementEndTrainDirection
Return the side of the train should arrive at the destination- Returns:
- the side of the train should arrive at the destination
-
getTrack
Returns the track which this position points to.- Returns:
- track which this position points to
-
hashCode
public int hashCode() -
equals
-
toString
-