Class TrackSegment
PositionablePoints have 1 or 2 connection points. LayoutTurnouts have 3 or 4 (crossovers) connection points, designated A, B, C, and D. LevelXing's have 4 connection points, designated A, B, C, and D.
TrackSegments carry the connectivity information between the three types of nodes. Track Segments serve as the lines in a graph which shows layout connectivity. For the connectivity graph to be valid, all connections between nodes must be via TrackSegments.
TrackSegments carry Block information, as do LayoutTurnouts and LevelXings.
Arrows and bumpers are visual, presentation aspects handled in the View.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LayoutTrackprotected LayoutTrackprotected HitPointTypeprotected HitPointTypeFields inherited from class jmri.jmrit.display.layoutEditor.LayoutTrack
models -
Constructor Summary
ConstructorsConstructorDescriptionTrackSegment(String id, String c1Name, HitPointType t1, String c2Name, HitPointType t2, boolean main, LayoutEditor models) TrackSegment(String id, LayoutTrack c1, HitPointType t1, LayoutTrack c2, HitPointType t2, boolean main, LayoutEditor models) -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck 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 blockNamegetConnection(HitPointType connectionType) get the LayoutTrack connected at the specified connection typeprotected List<LayoutConnectivity>get the layout connectivity for this trackgetPointReferences(HitPointType type, LayoutTrack conn) getType1()getType2()Get the type of this item.booleanisActive()Get state.booleanvoidtemporary fill of abstract from abovevoidremove()Remove this object from display and persistance.booleanreplaceTrackConnection(LayoutTrack oldTrack, LayoutTrack newTrack, HitPointType newType) Replace old track connection with new track connection.voidsetAllLayoutBlocks(LayoutBlock layoutBlock) Assign all the layout blocks in this trackvoidsetConnect1(LayoutTrack o, HitPointType type) voidsetConnect2(LayoutTrack o, HitPointType type) voidsetConnection(HitPointType connectionType, LayoutTrack o, HitPointType type) set the LayoutTrack connected at the specified connection typevoidsetLayoutBlock(LayoutBlock newLayoutBlock) Set up a LayoutBlock for this Track Segment.voidsetLayoutBlockByName(String name) Set up a LayoutBlock for this Track Segment.voidsetMainline(boolean main) protected voidsetNewConnect1(LayoutTrack connectTrack, HitPointType connectionType) set a new connection 1protected voidsetNewConnect2(LayoutTrack connectTrack, HitPointType connectionType) set a new connection 2voidInitialization method.toString()Get debugging string for the TrackSegment.voidMethods inherited from class jmri.jmrit.display.layoutEditor.LayoutTrack
getId, getName, getTurnoutStateString, isDisconnected, setIdent
-
Field Details
-
connect1
-
type1
-
connect2
-
type2
-
tConnect1Name
-
tConnect2Name
-
tLayoutBlockName
-
-
Constructor Details
-
TrackSegment
public TrackSegment(@Nonnull String id, @CheckForNull LayoutTrack c1, HitPointType t1, @CheckForNull LayoutTrack c2, HitPointType t2, boolean main, @Nonnull LayoutEditor models) -
TrackSegment
public TrackSegment(@Nonnull String id, @CheckForNull String c1Name, HitPointType t1, @CheckForNull String c2Name, HitPointType t2, boolean main, @Nonnull LayoutEditor models)
-
-
Method Details
-
toString
Get debugging string for the TrackSegment. -
getBlockName
-
getType1
-
getType2
-
getConnect1
-
getConnect2
-
setNewConnect1
set a new connection 1- Parameters:
connectTrack- the track we want to connect toconnectionType- where on that track we want to be connected
-
setNewConnect2
set a new connection 2- Parameters:
connectTrack- the track we want to connect toconnectionType- where on that track we want to be connected
-
replaceTrackConnection
public boolean replaceTrackConnection(@CheckForNull LayoutTrack oldTrack, @CheckForNull LayoutTrack newTrack, HitPointType newType) Replace old track connection with new track connection.- Parameters:
oldTrack- the old track connection.newTrack- the new track connection.newType- the hit point type.- Returns:
- true if successful.
-
isMainline
- Specified by:
isMainlinein classLayoutTrack- Returns:
- true if track segment is a main line
-
setMainline
-
getLayoutBlock
-
getConnect1Name
-
getConnect2Name
-
getConnection
get the LayoutTrack connected at the specified connection typeThis implementation returns null because
getConnect1()andgetConnect2()should be used instead.- 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 typeThis implementation does nothing because
setNewConnect1(jmri.jmrit.display.layoutEditor.LayoutTrack, jmri.jmrit.display.layoutEditor.HitPointType)andsetNewConnect2(jmri.jmrit.display.layoutEditor.LayoutTrack, jmri.jmrit.display.layoutEditor.HitPointType)should be used instead.- 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
-
setConnect1
-
setConnect2
-
setLayoutBlock
Set up a LayoutBlock for this Track Segment.- Parameters:
newLayoutBlock- the LayoutBlock to set
-
setLayoutBlockByName
Set up a LayoutBlock for this Track Segment.- Parameters:
name- the name of the new LayoutBlock
-
setObjects
Initialization method. The above variables are initialized by PositionablePointXml, 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
-
updateBlockInfo
-
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.
-
getPointReferences
-
remove
Remove this object from display and persistance. -
isActive
Get state. "active" means that the object is still displayed, and should be stored.- Returns:
- true if still displayed, else false.
-
reCheckBlockBoundary
temporary fill of abstract from above- 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
-
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)
-
getTypeName
Get the type of this item.- Specified by:
getTypeNamein classLayoutTrack- Returns:
- the type
-