Class LayoutTrack

java.lang.Object
jmri.jmrit.display.layoutEditor.LayoutTrack
Direct Known Subclasses:
LayoutTurnout, LayoutTurntable, LevelXing, PositionablePoint, TrackSegment

public abstract class LayoutTrack extends 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
  • Field Details

  • Constructor Details

  • Method Details

    • getId

      @Nonnull public final String getId()
      Get the track ID.
      Returns:
      track ident.
    • getName

      @Nonnull public final String getName()
    • getTypeName

      public abstract String getTypeName()
      Get the type of this item.
      Returns:
      the type
    • setIdent

      protected final void setIdent(@Nonnull String ident)
    • isMainline

      public abstract boolean isMainline()
    • getTurnoutStateString

      public final 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 connection
      o - the LayoutTrack that is to be connected
      type - 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

      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

      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 HashMap<String,List<Set<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)

      Parameters:
      blockNamesToTrackNameSetMaps - hashmap of key:block names to lists of track name sets for those blocks
    • collectContiguousTracksNamesInBlockNamed

      public abstract void collectContiguousTracksNamesInBlockNamed(@Nonnull String blockName, @Nonnull Set<String> TrackNameSet)
      recursive routine to check for all contiguous tracks in this blockName
      Parameters:
      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
      Parameters:
      layoutBlock - to this layout block (used by the Tools menu's "Assign block to selection" item)