Class 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 LayoutTrackView subclasses.

    • One or more connections, consisting of a LayoutTrack name and HitPointType
    • Mainline status
    • Associated
      • Blocks
      • Signal heads and masts
      • Sensors
      • Turnout controls
    • Method Detail

      • getId

        public final java.lang.String getId()
        Get the track ID.
        track ident.
      • getTypeName

        public abstract java.lang.String getTypeName()
        Get the type of this item.
        the type
      • isMainline

        public abstract boolean isMainline()
      • getTurnoutStateString

        public final java.lang.String getTurnoutStateString​(int turnoutState)
        get turnout state string
        turnoutState - of the turnout
        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.

        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
        le - the layout editor
      • getConnection

        public abstract LayoutTrack getConnection​(HitPointType connectionType)
                                           throws JmriException
        get the LayoutTrack connected at the specified connection type
        connectionType - where on us to get the connection
        the LayoutTrack connected at the specified connection type
        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
        connectionType - where on us to set the connection
        o - the LayoutTrack that is to be connected
        type - where on the LayoutTrack we are connected
        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<LayoutConnectivitygetLayoutConnectivity()
        get the layout connectivity for this track
        the list of Layout Connectivity objects
      • isDisconnected

        public boolean isDisconnected​(HitPointType connectionType)
        return true if this connection type is disconnected
        connectionType - the connection type to test
        true if the connection for this connection type is free
      • checkForFreeConnections

        public abstract java.util.List<HitPointTypecheckForFreeConnections()
        return a list of the available connections for this layout track
        the list of available connections
      • checkForUnAssignedBlocks

        public abstract boolean checkForUnAssignedBlocks()
        determine if all the appropriate blocks have been assigned to this track
        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 blocks

        For 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)

        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,
                                                                      java.util.Set<java.lang.String> TrackNameSet)
        recursive routine to check for all contiguous tracks in this blockName
        blockName - the block that we're checking for
        TrackNameSet - the set of track names in this block
      • setAllLayoutBlocks

        public abstract void setAllLayoutBlocks​(LayoutBlock layoutBlock)
        Assign all the layout blocks in this track
        layoutBlock - to this layout block (used by the Tools menu's "Assign block to selection" item)