Class Path
- All Implemented Interfaces:
Comparable<Path>
- Direct Known Subclasses:
OPath
Directions are defined for traffic along this path "to" the block, and "from" the block. Being more specific:
- The "to" direction is the direction that a train is going when it traverses this path "to" the final block.
- The "from" direction is the direction that a train is going when it traverses this path "from" the final block.
This implementation handles paths with a list of bean settings. This has been extended from the initial implementation.
The length of the path may also optionally be entered if desired. This attribute is for use in automatic running of trains. Length should be the actual length of model railroad track in the path. It is always stored here in millimeter units. A length of 0.0 indicates no entry of length by the user. If there is no entry the length of the block the path is in will be returned. An Entry is only needed when there are paths of greatly different lengths in the block.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intCounter-clockwisestatic final intClockwisestatic final intDownward, e.g. on a schematic diagram or CTC panelstatic final intEastwardstatic final intLeftward, e.g. on a schematic diagram or CTC panelstatic final intDirection not known or not specified.static final intNorthwardstatic final intNorth-Eaststatic final intNorth-Weststatic final intRightward, e.g. on a schematic diagram or CTC panelstatic final intSouthwardstatic final intSouth-Eaststatic final intSouth-Weststatic final intUpward, e.g. on a schematic diagram or CTC panelstatic final intWestward -
Constructor Summary
ConstructorsConstructorDescriptionPath()Create an object with default directions of NONE, and no setting element.Convenience constructor to set the destination/source block and directions in one call.Path(Block dest, int toBlockDirection, int fromBlockDirection, BeanSetting setting) Convenience constructor to set the destination/source block, directions and a single setting element in one call. -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanCheck that the Path can be traversed.voidintstatic intcomputeDirection(Point2D p1, Point2D p2) Compute octagonal direction of vector from p1 to p2.static StringdecodeDirection(int d) Decode the direction constants into a human-readable form.booleangetBlock()intfloatGet actual stored length.floatGet length in centimeters.floatGet length in inches.floatGet length in millimeters.intinthashCode()voidstatic intreverseDirection(int inDir) Get the reverse octagonal direction.voidvoidsetFromBlockDirection(int d) voidsetLength(float l) Set path length.voidsetToBlockDirection(int d) toString()
-
Field Details
-
NONE
Direction not known or not specified. May also represent "stopped", in the sense of not moving in any direction.- See Also:
-
NORTH
Northward- See Also:
-
SOUTH
Southward- See Also:
-
EAST
Eastward- See Also:
-
WEST
Westward- See Also:
-
NORTH_EAST
North-East- See Also:
-
SOUTH_EAST
South-East- See Also:
-
SOUTH_WEST
South-West- See Also:
-
NORTH_WEST
North-West- See Also:
-
CW
Clockwise- See Also:
-
CCW
Counter-clockwise- See Also:
-
LEFT
Leftward, e.g. on a schematic diagram or CTC panel- See Also:
-
RIGHT
Rightward, e.g. on a schematic diagram or CTC panel- See Also:
-
UP
Upward, e.g. on a schematic diagram or CTC panel- See Also:
-
DOWN
Downward, e.g. on a schematic diagram or CTC panel- See Also:
-
-
Constructor Details
-
Path
public Path()Create an object with default directions of NONE, and no setting element. -
Path
Convenience constructor to set the destination/source block and directions in one call.- Parameters:
dest- the destinationtoBlockDirection- direction to next blockfromBlockDirection- direction from prior block
-
Path
Convenience constructor to set the destination/source block, directions and a single setting element in one call.- Parameters:
dest- the destinationtoBlockDirection- direction to next blockfromBlockDirection- direction from prior blocksetting- the setting to add
-
-
Method Details
-
addSetting
-
getSettings
-
removeSetting
-
clearSettings
-
setBlock
-
getBlock
-
getToBlockDirection
-
setToBlockDirection
-
getFromBlockDirection
-
setFromBlockDirection
-
checkPathSet
Check that the Path can be traversed. This means that any path elements are set to the proper state, e.g. that the Turnouts on this path are set to the proper CLOSED or OPEN status.- Returns:
- true if the path can be traversed; always true if no path elements (BeanSettings) are defined.
-
decodeDirection
Decode the direction constants into a human-readable form.- Parameters:
d- the direction- Returns:
- the direction description
-
setLength
Set path length. Length may override the block length default.- Parameters:
l- length in millimeters
-
getLength
Get actual stored length.- Returns:
- length in millimeters or 0
-
getLengthMm
Get length in millimeters.- Returns:
- the stored length if greater than 0 or the block length
-
getLengthCm
Get length in centimeters.- Returns:
- the stored length if greater than 0 or the block length
-
getLengthIn
Get length in inches.- Returns:
- the stored length if greater than 0 or the block length
-
equals
-
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<Path>
-
hashCode
-
computeDirection
Compute octagonal direction of vector from p1 to p2.Note: the octagonal (8) directions are: North, North-East, East, South-East, South, South-West, West and North-West
- Parameters:
p1- the first pointp2- the second point- Returns:
- the octagonal direction from p1 to p2
-
reverseDirection
Get the reverse octagonal direction.- Parameters:
inDir- the direction- Returns:
- the reverse direction or 0 if inDir is not a direction
-