Class LayoutTraverser
A LayoutTraverser has a variable number of connection points, called SlotTracks. Each of these points should be connected to a TrackSegment.
Each slot gets its Block information from its connected track segment.
Each slot has a unique connection index. The connection index is set when the SlotTrack is created, and cannot be changed. This connection index is used to maintain the identity of the radiating segment to its connected Track Segment as slots are added and deleted by the user.
The length and width of the traverser is variable by the user.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intfinal List<LayoutTraverser.SlotTrack>static final intFields inherited from class jmri.jmrit.display.layoutEditor.LayoutTrack
models -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddSlotTrack(double offset, int index, String name) booleanCheck for active block boundaries.return a list of the available connections for this layout trackvoidcheck this track and its neighbors for non-contiguous blocksbooleandetermine if all the appropriate blocks have been assigned to this trackvoidcollectContiguousTracksNamesInBlockNamed(String blockName, Set<String> TrackNameSet) recursive routine to check for all contiguous tracks in this blockNamevoiddeleteTrackPair(int pairIndex) getConnection(HitPointType connectionType) get the LayoutTrack connected at the specified connection typedoubledoubleprotected List<LayoutConnectivity>get the layout connectivity for this trackintGet the number of slots on traverser.intintGet the traverser position.intgetSlotConnectIndexed(int index) Get the connection for the slot with this index.getSlotConnectOrdered(int i) Get the connection for the slot at the index in the slotList.intgetSlotIndex(int i) Get the index for the slot at this position in the slotList.doubledoublegetSlotOffsetValue(int i) Get the offset for the slot at this position in the slotList.getSlotTurnout(int i) Get the turnout for the slot at this index.getSlotTurnoutName(int i) Get the name of the turnout for the slot at this index.intgetSlotTurnoutState(int i) Get the state of the turnout for the slot at this index.getTurnoutList(Block curBlock, Block prevBlock, Block nextBlock) Gets the list of turnouts and their required states to align the traverser for a path defined by the given blocks.Get the type of this item.booleanisActive()Get if traverser is active.booleanisApproachMast(SignalMast mast) Checks if the given mast is an approach mast for any slot on this traverser.booleanbooleanbooleanisMainlineIndexed(int index) Test if slot with this index is a mainline track or not.booleanisMainlineOrdered(int i) Test if slot at this index is a mainline track or not.booleanCheck for conditions that will caused subsequent errors if the the traverser is removed or dispatcherManaged is changed from true to falsebooleanisSlotBlock(Block block) Checks if the given block is one of the slot blocks for this traverser.Check for a connected track segment, signal masts or SML.booleanisSlotDeleteAllowed(int pairIndex) Check for conditions that will caused subsequent errors if the the traverser slot is removed.booleanisSlotDisabled(int i) Get if the slot at this index is disabled.booleanisSlotDisabledWhenOccupied(int i) Get the disabled when occupied state of the slot at this index.booleanisTraverserBoundary(Block block1, Block block2) Checks if the path represented by the blocks crosses this traverser.booleanIs this traverser turnout controlled?voidmoveSlotPairDown(int pairIndex) voidmoveSlotPairUp(int pairIndex) protected voidabstract method... subclasses should implement _IF_ they need to recheck their block boundariesvoidremove()Remove this object from display and persistance.voidsetAllLayoutBlocks(LayoutBlock layoutBlock) Assign all the layout blocks in this trackvoidsetBufferSignalMast(String name) voidsetConnection(HitPointType connectionType, LayoutTrack o, HitPointType type) set the LayoutTrack connected at the specified connection typevoidsetDeckWidth(double w) voidsetDispatcherManaged(boolean managed) voidsetExitSignalMast(String name) voidsetLayoutBlock(LayoutBlock newLayoutBlock) Set up a LayoutBlock for this LayoutTraverser.voidsetLayoutBlockByName(String name) Set up a LayoutBlock for this LayoutTraverser.voidsetMainline(boolean main) Set the mainline status of the traverser bridge itself.voidInitialization method The name of each track segment connected to a slot track is initialized by by LayoutTraverserXml, then the following method is called after the entire LayoutEditor is loaded to set the specific TrackSegment objects.voidsetOrientation(int o) voidsetPosition(int index) Set traverser position to the slot with this index.voidsetSignalIconPlacement(int placement) voidsetSlotConnect(TrackSegment ts, int index) Set the connection for the slot at the index in the slotList.voidsetSlotDisabled(int i, boolean boo) Set the disabled state of the slot at this index.voidsetSlotDisabledWhenOccupied(int i, boolean boo) Set the disabled when occupied state of the slot at this index.voidsetSlotOffset(double offset) voidsetSlotTurnout(int index, String turnoutName, int state) Set the turnout and state for the slot with this index.voidsetTurnoutControlled(boolean boo) Set if this traverser is turnout controlled.toString()Get a string that represents this object.Methods inherited from class jmri.jmrit.display.layoutEditor.LayoutTrack
getId, getName, getTurnoutStateString, isDisconnected, setIdent
-
Field Details
-
HORIZONTAL
- See Also:
-
VERTICAL
- See Also:
-
slotList
-
tLayoutBlockName
-
tExitSignalMastName
-
tBufferSignalMastName
-
-
Constructor Details
-
LayoutTraverser
-
-
Method Details
-
toString
Get a string that represents this object. This should only be used for debugging. -
getSlotOffset
-
setSlotOffset
-
getDeckLength
-
getDeckWidth
-
setDeckWidth
-
getOrientation
-
setOrientation
-
isDispatcherManaged
-
setDispatcherManaged
-
getSignalIconPlacement
-
setSignalIconPlacement
-
getBufferMast
-
getBufferSignalMastName
-
setBufferSignalMast
-
getExitSignalMast
-
getExitSignalMastName
-
setExitSignalMast
-
getBlockName
- Returns:
- the layout block name
-
getLayoutBlock
- Returns:
- the layout block
-
setLayoutBlock
Set up a LayoutBlock for this LayoutTraverser.- Parameters:
newLayoutBlock- the LayoutBlock to set
-
setLayoutBlockByName
Set up a LayoutBlock for this LayoutTraverser.- Parameters:
name- the name of the new LayoutBlock
-
addSlotPair
-
addSlotTrack
-
getSlotConnectIndexed
Get the connection for the slot with this index.- Parameters:
index- the index- Returns:
- the connection for the slot with this value of getConnectionIndex
-
getSlotConnectOrdered
Get the connection for the slot at the index in the slotList.- Parameters:
i- the index in the slotList- Returns:
- the connection for the slot at that index in the slotList or null
-
setSlotConnect
Set the connection for the slot at the index in the slotList.- Parameters:
ts- the connectionindex- the index in the slotList
-
getSlotList
-
getNumberSlots
Get the number of slots on traverser.- Returns:
- the number of slots
-
getSlotIndex
Get the index for the slot at this position in the slotList.- Parameters:
i- the position in the slotList- Returns:
- the index
-
getSlotOffsetValue
Get the offset for the slot at this position in the slotList.- Parameters:
i- the position in the slotList- Returns:
- the offset
-
setSlotTurnout
Set the turnout and state for the slot with this index.- Parameters:
index- the indexturnoutName- the turnout namestate- the state
-
getSlotTurnoutName
Get the name of the turnout for the slot at this index.- Parameters:
i- the index- Returns:
- name of the turnout for the slot at this index
-
getSlotTurnout
Get the turnout for the slot at this index.- Parameters:
i- the index- Returns:
- the turnout for the slot at this index
-
getSlotTurnoutState
Get the state of the turnout for the slot at this index.- Parameters:
i- the index- Returns:
- state of the turnout for the slot at this index
-
isSlotDisabled
Get if the slot at this index is disabled.- Parameters:
i- the index- Returns:
- true if disabled
-
setSlotDisabled
Set the disabled state of the slot at this index.- Parameters:
i- the indexboo- the state
-
isSlotDisabledWhenOccupied
Get the disabled when occupied state of the slot at this index.- Parameters:
i- the index- Returns:
- the state
-
setSlotDisabledWhenOccupied
Set the disabled when occupied state of the slot at this index.- Parameters:
i- the indexboo- the state
-
getConnection
get the LayoutTrack connected at the specified connection type- Specified by:
getConnectionin classLayoutTrack- Parameters:
connectionType- where on us to get the connection- Returns:
- the LayoutTrack connected at the specified connection type
- Throws:
JmriException- - if the connectionType is invalid
-
setConnection
public void setConnection(HitPointType connectionType, @CheckForNull LayoutTrack o, HitPointType type) throws JmriException set the LayoutTrack connected at the specified connection type- Specified by:
setConnectionin classLayoutTrack- Parameters:
connectionType- where on us to set the connectiono- the LayoutTrack that is to be connectedtype- where on the LayoutTrack we are connected- Throws:
JmriException- - if connectionType or type are invalid
-
isMainlineIndexed
Test if slot with this index is a mainline track or not.Defaults to false (not mainline) if connecting track segment is missing.
- Parameters:
index- the index- Returns:
- true if connecting track segment is mainline
-
isMainlineOrdered
Test if slot at this index is a mainline track or not.Defaults to false (not mainline) if connecting track segment is missing
- Parameters:
i- the index- Returns:
- true if connecting track segment is mainline
-
isMainline
- Specified by:
isMainlinein classLayoutTrack
-
setMainline
Set the mainline status of the traverser bridge itself.- Parameters:
main- true if the bridge is mainline, false otherwise.
-
setObjects
Initialization method The name of each track segment connected to a slot track is initialized by by LayoutTraverserXml, then the following method is called after the entire LayoutEditor is loaded to set the specific TrackSegment objects.- Specified by:
setObjectsin classLayoutTrack- Parameters:
p- the layout editor
-
isTurnoutControlled
Is this traverser turnout controlled?- Returns:
- true if so
-
setTurnoutControlled
Set if this traverser is turnout controlled.- Parameters:
boo- set true if so
-
setPosition
Set traverser position to the slot with this index.- Parameters:
index- the index
-
getPosition
Get the traverser position.- Returns:
- the traverser position
-
deleteTrackPair
-
moveSlotPairUp
-
moveSlotPairDown
-
remove
Remove this object from display and persistance. -
isActive
Get if traverser is active. "active" means that the object is still displayed, and should be stored.- Returns:
- true if active, else false.
-
isApproachMast
Checks if the given mast is an approach mast for any slot on this traverser.- Parameters:
mast- The SignalMast to check.- Returns:
- true if it is an approach mast for one of the slots.
-
isSlotBlock
Checks if the given block is one of the slot blocks for this traverser.- Parameters:
block- The Block to check.- Returns:
- true if it is a block for one of the slots.
-
reCheckBlockBoundary
abstract method... subclasses should implement _IF_ they need to recheck their block boundaries- Specified by:
reCheckBlockBoundaryin classLayoutTrack
-
getLayoutConnectivity
get the layout connectivity for this track- Specified by:
getLayoutConnectivityin classLayoutTrack- Returns:
- the list of Layout Connectivity objects
-
checkForFreeConnections
return a list of the available connections for this layout track- Specified by:
checkForFreeConnectionsin classLayoutTrack- Returns:
- the list of available connections
-
checkForUnAssignedBlocks
determine if all the appropriate blocks have been assigned to this track- Specified by:
checkForUnAssignedBlocksin classLayoutTrack- Returns:
- true if all appropriate blocks have been assigned
-
isTraverserBoundary
Checks if the path represented by the blocks crosses this traverser.- Parameters:
block1- A block in the path.block2- Another block in the path.- Returns:
- true if the path crosses this traverser.
-
getTurnoutList
public List<LayoutTrackExpectedState<LayoutTurnout>> getTurnoutList(Block curBlock, Block prevBlock, Block nextBlock) Gets the list of turnouts and their required states to align the traverser for a path defined by the given blocks.- Parameters:
curBlock- The current block in the train's path.prevBlock- The previous block in the train's path.nextBlock- The next block in the train's path.- Returns:
- A list of LayoutTrackExpectedState objects for the turnouts.
-
isSlotDeleteAllowed
Check for conditions that will caused subsequent errors if the the traverser slot is removed. Both slot connections have to be clear.- Parameters:
pairIndex- The traverser slot to be deleted.- Returns:
- true if the slot can be deleted.
-
isSlotConnectionClear
Check for a connected track segment, signal masts or SML.- Parameters:
track- The A or B side of a slot.- Returns:
- an empty StringBuilder if clear or a set of messages.
-
isRemoveAllowed
Check for conditions that will caused subsequent errors if the the traverser is removed or dispatcherManaged is changed from true to false. - The exit mast is a SML source. - The buffer mast is a SML destination. - Exit, buffer or approach masts are on the panel. -
checkForNonContiguousBlocks
public void checkForNonContiguousBlocks(@Nonnull HashMap<String, List<Set<String>>> blockNamesToTrackNameSetsMap) check this track and its neighbors for non-contiguous blocksFor each (non-null) blocks of this track do: #1) If it's got an entry in the blockNamesToTrackNameSetMap then #2) If this track is not in one of the TrackNameSets for this block #3) add a new set (with this block/track) to blockNamesToTrackNameSetMap and #4) check all the connections in this block (by calling the 2nd method below)
Basically, we're maintaining contiguous track sets for each block found (in blockNamesToTrackNameSetMap)
- Specified by:
checkForNonContiguousBlocksin classLayoutTrack- Parameters:
blockNamesToTrackNameSetsMap- hashmap of key:block names to lists of track name sets for those blocks
-
collectContiguousTracksNamesInBlockNamed
public void collectContiguousTracksNamesInBlockNamed(@Nonnull String blockName, @Nonnull Set<String> TrackNameSet) recursive routine to check for all contiguous tracks in this blockName- Specified by:
collectContiguousTracksNamesInBlockNamedin classLayoutTrack- Parameters:
blockName- the block that we're checking forTrackNameSet- the set of track names in this block
-
setAllLayoutBlocks
Assign all the layout blocks in this track- Specified by:
setAllLayoutBlocksin classLayoutTrack- Parameters:
layoutBlock- to this layout block (used by the Tools menu's "Assign block to selection" item)
-
canRemove
Check for active block boundaries.If any connection point of a layout track object has attached objects, such as signal masts, signal heads or NX sensors, the layout track object cannot be deleted.
- Specified by:
canRemovein classLayoutTrack- Returns:
- true if the layout track object can be deleted.
-
getTypeName
Get the type of this item.- Specified by:
getTypeNamein classLayoutTrack- Returns:
- the type
-