Class LayoutTrack
- java.lang.Object
-
- jmri.jmrit.display.layoutEditor.LayoutTrack
-
- Direct Known Subclasses:
LayoutTurnout,LayoutTurntable,LevelXing,PositionablePoint,TrackSegment
public abstract class LayoutTrack extends java.lang.Object
Abstract base class for all layout track objects (PositionablePoint, TrackSegment, LayoutTurnout, LayoutSlip, LevelXing and LayoutTurntable)This is the connectivity/topology information for the layout; the display information, including screen geometry, is held in
LayoutTrackViewsubclasses.- One or more connections, consisting of a LayoutTrack name and
HitPointType - Mainline status
- Associated
- Blocks
- Signal heads and masts
- Sensors
- Turnout controls
-
-
Field Summary
Fields Modifier and Type Field Description protected LayoutEditormodels
-
Constructor Summary
Constructors Constructor Description LayoutTrack(java.lang.String ident, LayoutEditor models)Constructor method.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract booleancanRemove()Check for active block boundaries.abstract java.util.List<HitPointType>checkForFreeConnections()return a list of the available connections for this layout trackabstract voidcheckForNonContiguousBlocks(java.util.HashMap<java.lang.String,java.util.List<java.util.Set<java.lang.String>>> blockNamesToTrackNameSetMaps)check this track and its neighbors for non-contiguous blocksabstract booleancheckForUnAssignedBlocks()determine if all the appropriate blocks have been assigned to this trackabstract voidcollectContiguousTracksNamesInBlockNamed(java.lang.String blockName, java.util.Set<java.lang.String> TrackNameSet)recursive routine to check for all contiguous tracks in this blockNameabstract LayoutTrackgetConnection(HitPointType connectionType)get the LayoutTrack connected at the specified connection typejava.lang.StringgetId()Get the track ID.protected abstract java.util.List<LayoutConnectivity>getLayoutConnectivity()get the layout connectivity for this trackjava.lang.StringgetName()java.lang.StringgetTurnoutStateString(int turnoutState)get turnout state stringabstract java.lang.StringgetTypeName()Get the type of this item.booleanisDisconnected(HitPointType connectionType)return true if this connection type is disconnectedabstract booleanisMainline()protected abstract voidreCheckBlockBoundary()abstract method... subclasses should implement _IF_ they need to recheck their block boundariesabstract voidsetAllLayoutBlocks(LayoutBlock layoutBlock)Assign all the layout blocks in this trackabstract voidsetConnection(HitPointType connectionType, LayoutTrack o, HitPointType type)set the LayoutTrack connected at the specified connection typeprotected voidsetIdent(java.lang.String ident)abstract voidsetObjects(LayoutEditor le)Initialization method for LayoutTrack sub-classes.
-
-
-
Field Detail
-
models
protected final LayoutEditor models
-
-
Constructor Detail
-
LayoutTrack
public LayoutTrack(@Nonnull java.lang.String ident, @Nonnull LayoutEditor models)
Constructor method.- Parameters:
ident- track ID.models- main layout editor.
-
-
Method Detail
-
getTypeName
public abstract java.lang.String getTypeName()
Get the type of this item.- Returns:
- the type
-
isMainline
public abstract boolean isMainline()
-
getTurnoutStateString
public final java.lang.String getTurnoutStateString(int turnoutState)
get turnout state string- Parameters:
turnoutState- of the turnout- Returns:
- the turnout state string
-
canRemove
public abstract boolean 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.
- Returns:
- true if the layout track object can be deleted.
-
setObjects
public abstract void setObjects(@Nonnull LayoutEditor le)
Initialization method for LayoutTrack sub-classes. The following method is called for each instance after the entire LayoutEditor is loaded to set the specific objects for that instance- Parameters:
le- the layout editor
-
getConnection
public abstract LayoutTrack getConnection(HitPointType connectionType) throws JmriException
get the LayoutTrack connected at the specified connection type- 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 abstract void setConnection(HitPointType connectionType, LayoutTrack o, HitPointType type) throws JmriException
set the LayoutTrack connected at the specified connection type- 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
-
reCheckBlockBoundary
protected abstract void reCheckBlockBoundary()
abstract method... subclasses should implement _IF_ they need to recheck their block boundaries
-
getLayoutConnectivity
protected abstract java.util.List<LayoutConnectivity> getLayoutConnectivity()
get the layout connectivity for this track- Returns:
- the list of Layout Connectivity objects
-
isDisconnected
public boolean isDisconnected(HitPointType connectionType)
return true if this connection type is disconnected- Parameters:
connectionType- the connection type to test- Returns:
- true if the connection for this connection type is free
-
checkForFreeConnections
@Nonnull public abstract java.util.List<HitPointType> checkForFreeConnections()
return a list of the available connections for this layout track- Returns:
- the list of available connections
-
checkForUnAssignedBlocks
public abstract boolean checkForUnAssignedBlocks()
determine if all the appropriate blocks have been assigned to this track- Returns:
- true if all appropriate blocks have been assigned
-
checkForNonContiguousBlocks
public abstract void checkForNonContiguousBlocks(@Nonnull java.util.HashMap<java.lang.String,java.util.List<java.util.Set<java.lang.String>>> blockNamesToTrackNameSetMaps)
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)
- Parameters:
blockNamesToTrackNameSetMaps- hashmap of key:block names to lists of track name sets for those blocks
-
collectContiguousTracksNamesInBlockNamed
public abstract void collectContiguousTracksNamesInBlockNamed(@Nonnull java.lang.String blockName, @Nonnull java.util.Set<java.lang.String> TrackNameSet)
recursive routine to check for all contiguous tracks in this blockName- Parameters:
blockName- the block that we're checking forTrackNameSet- the set of track names in this block
-
setAllLayoutBlocks
public abstract void setAllLayoutBlocks(LayoutBlock layoutBlock)
Assign all the layout blocks in this track- Parameters:
layoutBlock- to this layout block (used by the Tools menu's "Assign block to selection" item)
-
-