Class LevelXing
- java.lang.Object
-
- jmri.jmrit.display.layoutEditor.LayoutTrack
-
- jmri.jmrit.display.layoutEditor.LevelXing
-
public class LevelXing extends LayoutTrack
A LevelXing is two track segment on a layout that cross at an angle.A LevelXing has four connection points, designated A, B, C, and D. At the crossing, A-C and B-D are straight segments. A train proceeds through the crossing on either of these segments.
A D \\ // X // \\ B C
Each straight segment carries Block information. A-C and B-D may be in the same or different Layout Blocks.For drawing purposes, each LevelXing carries a center point and displacements for A and B. The displacements for C = - the displacement for A, and the displacement for D = - the displacement for B. The center point and these displacements may be adjusted by the user when in edit mode.
When LevelXings are first created, there are no connections. Block information and connections are added when available.
Signal Head names are saved here to keep track of where signals are. LevelXing only serves as a storage place for signal head names. The names are placed here by Set Signals at Level Crossing in Tools menu.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LevelXing.Geometry
-
Field Summary
Fields Modifier and Type Field Description (package private) boolean
active
java.lang.String
connectAName
java.lang.String
connectBName
java.lang.String
connectCName
java.lang.String
connectDName
protected NamedBeanHandle<SignalHead>
signalAHeadNamed
protected NamedBeanHandle<SignalMast>
signalAMastNamed
protected NamedBeanHandle<SignalHead>
signalBHeadNamed
protected NamedBeanHandle<SignalMast>
signalBMastNamed
protected NamedBeanHandle<SignalHead>
signalCHeadNamed
protected NamedBeanHandle<SignalMast>
signalCMastNamed
protected NamedBeanHandle<SignalHead>
signalDHeadNamed
protected NamedBeanHandle<SignalMast>
signalDMastNamed
(package private) java.util.ArrayList<SignalMast>
sml
java.lang.String
tLayoutBlockNameAC
java.lang.String
tLayoutBlockNameBD
-
Fields inherited from class jmri.jmrit.display.layoutEditor.LayoutTrack
models
-
-
Constructor Summary
Constructors Constructor Description LevelXing(java.lang.String id, LayoutEditor models)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSignalMastLogic(SignalMast sm)
boolean
canRemove()
Check for active block boundaries.java.util.List<HitPointType>
checkForFreeConnections()
return a list of the available connections for this layout trackvoid
checkForNonContiguousBlocks(java.util.HashMap<java.lang.String,java.util.List<java.util.Set<java.lang.String>>> blockNamesToTrackNameSetsMap)
check this track and its neighbors for non-contiguous blocksboolean
checkForUnAssignedBlocks()
determine if all the appropriate blocks have been assigned to this trackvoid
collectContiguousTracksNamesInBlockNamed(java.lang.String blockName, java.util.Set<java.lang.String> TrackNameSet)
recursive routine to check for all contiguous tracks in this blockNamejava.util.ArrayList<java.lang.String>
getBeanReferences(java.lang.String pointName)
Build a list of sensors, signal heads, and signal masts attached to a level crossing point.java.lang.String[]
getBlockBoundaries()
java.lang.String
getBlockNameAC()
java.lang.String
getBlockNameBD()
LayoutTrack
getConnectA()
LayoutTrack
getConnectB()
LayoutTrack
getConnectC()
LayoutTrack
getConnectD()
LayoutTrack
getConnection(HitPointType connectionType)
get the LayoutTrack connected at the specified connection typeLayoutBlock
getLayoutBlockAC()
LayoutBlock
getLayoutBlockBD()
protected java.util.ArrayList<LayoutConnectivity>
getLayoutConnectivity()
get the layout connectivity for this trackSensor
getSensor(LevelXing.Geometry loc)
Sensor
getSensorA()
java.lang.String
getSensorAName()
Sensor
getSensorB()
java.lang.String
getSensorBName()
Sensor
getSensorC()
java.lang.String
getSensorCName()
Sensor
getSensorD()
java.lang.String
getSensorDName()
SignalMast
getSignalAMast()
java.lang.String
getSignalAMastName()
java.lang.String
getSignalAName()
SignalMast
getSignalBMast()
java.lang.String
getSignalBMastName()
java.lang.String
getSignalBName()
SignalMast
getSignalCMast()
java.lang.String
getSignalCMastName()
java.lang.String
getSignalCName()
SignalMast
getSignalDMast()
java.lang.String
getSignalDMastName()
java.lang.String
getSignalDName()
SignalHead
getSignalHead(LevelXing.Geometry loc)
SignalMast
getSignalMast(LevelXing.Geometry loc)
java.lang.String
getTypeName()
Get the type of this item.boolean
isActive()
Get if active.boolean
isMainline()
boolean
isMainlineAC()
Test if mainline track or not.boolean
isMainlineBD()
void
reCheckBlockBoundary()
abstract method... subclasses should implement _IF_ they need to recheck their block boundariesvoid
remove()
Remove this object from display and persistance.void
removeBeanReference(NamedBean nb)
void
removeSignalMastLogic(SignalMast sm)
(package private) void
removeSML(SignalMast signalMast)
void
setAllLayoutBlocks(LayoutBlock layoutBlock)
Assign all the layout blocks in this trackvoid
setConnectA(LayoutTrack o, HitPointType type)
void
setConnectB(LayoutTrack o, HitPointType type)
void
setConnectC(LayoutTrack o, HitPointType type)
void
setConnectD(LayoutTrack o, HitPointType type)
void
setConnection(HitPointType connectionType, LayoutTrack o, HitPointType type)
set the LayoutTrack connected at the specified connection typevoid
setLayoutBlockAC(LayoutBlock newLayoutBlock)
Add Layout Blocks.void
setLayoutBlockBD(LayoutBlock newLayoutBlock)
void
setObjects(LayoutEditor p)
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.void
setSensorAName(java.lang.String sensorName)
void
setSensorBName(java.lang.String sensorName)
void
setSensorCName(java.lang.String sensorName)
void
setSensorDName(java.lang.String sensorName)
void
setSignalAMast(java.lang.String signalMast)
void
setSignalAName(java.lang.String signalHead)
void
setSignalBMast(java.lang.String signalMast)
void
setSignalBName(java.lang.String signalHead)
void
setSignalCMast(java.lang.String signalMast)
void
setSignalCName(java.lang.String signalHead)
void
setSignalDMast(java.lang.String signalMast)
void
setSignalDName(java.lang.String signalHead)
java.lang.String
toString()
void
updateBlockInfo()
-
Methods inherited from class jmri.jmrit.display.layoutEditor.LayoutTrack
getId, getName, getTurnoutStateString, isDisconnected, setIdent
-
-
-
-
Field Detail
-
signalAHeadNamed
protected NamedBeanHandle<SignalHead> signalAHeadNamed
-
signalBHeadNamed
protected NamedBeanHandle<SignalHead> signalBHeadNamed
-
signalCHeadNamed
protected NamedBeanHandle<SignalHead> signalCHeadNamed
-
signalDHeadNamed
protected NamedBeanHandle<SignalHead> signalDHeadNamed
-
signalAMastNamed
protected NamedBeanHandle<SignalMast> signalAMastNamed
-
signalBMastNamed
protected NamedBeanHandle<SignalMast> signalBMastNamed
-
signalCMastNamed
protected NamedBeanHandle<SignalMast> signalCMastNamed
-
signalDMastNamed
protected NamedBeanHandle<SignalMast> signalDMastNamed
-
connectAName
public java.lang.String connectAName
-
connectBName
public java.lang.String connectBName
-
connectCName
public java.lang.String connectCName
-
connectDName
public java.lang.String connectDName
-
tLayoutBlockNameAC
public java.lang.String tLayoutBlockNameAC
-
tLayoutBlockNameBD
public java.lang.String tLayoutBlockNameBD
-
active
boolean active
-
sml
java.util.ArrayList<SignalMast> sml
-
-
Constructor Detail
-
LevelXing
public LevelXing(java.lang.String id, LayoutEditor models)
Constructor.- Parameters:
id
- ID string.models
- the main layout editor.
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getBlockNameAC
@Nonnull public java.lang.String getBlockNameAC()
-
getBlockNameBD
@Nonnull public java.lang.String getBlockNameBD()
-
getSignalHead
public SignalHead getSignalHead(LevelXing.Geometry loc)
-
getSignalMast
public SignalMast getSignalMast(LevelXing.Geometry loc)
-
getSensor
public Sensor getSensor(LevelXing.Geometry loc)
-
getSignalAName
@Nonnull public java.lang.String getSignalAName()
-
setSignalAName
public void setSignalAName(java.lang.String signalHead)
-
getSignalBName
@Nonnull public java.lang.String getSignalBName()
-
setSignalBName
public void setSignalBName(java.lang.String signalHead)
-
getSignalCName
@Nonnull public java.lang.String getSignalCName()
-
setSignalCName
public void setSignalCName(java.lang.String signalHead)
-
getSignalDName
@Nonnull public java.lang.String getSignalDName()
-
setSignalDName
public void setSignalDName(java.lang.String signalHead)
-
removeBeanReference
public void removeBeanReference(NamedBean nb)
-
getSignalAMastName
public java.lang.String getSignalAMastName()
-
getSignalAMast
public SignalMast getSignalAMast()
-
setSignalAMast
public void setSignalAMast(java.lang.String signalMast)
-
getSignalBMastName
public java.lang.String getSignalBMastName()
-
getSignalBMast
public SignalMast getSignalBMast()
-
setSignalBMast
public void setSignalBMast(java.lang.String signalMast)
-
getSignalCMastName
public java.lang.String getSignalCMastName()
-
getSignalCMast
public SignalMast getSignalCMast()
-
setSignalCMast
public void setSignalCMast(java.lang.String signalMast)
-
getSignalDMastName
public java.lang.String getSignalDMastName()
-
getSignalDMast
public SignalMast getSignalDMast()
-
setSignalDMast
public void setSignalDMast(java.lang.String signalMast)
-
getSensorAName
public java.lang.String getSensorAName()
-
getSensorA
public Sensor getSensorA()
-
setSensorAName
public void setSensorAName(java.lang.String sensorName)
-
getSensorBName
public java.lang.String getSensorBName()
-
getSensorB
public Sensor getSensorB()
-
setSensorBName
public void setSensorBName(java.lang.String sensorName)
-
getSensorCName
public java.lang.String getSensorCName()
-
getSensorC
public Sensor getSensorC()
-
setSensorCName
public void setSensorCName(java.lang.String sensorName)
-
getSensorDName
public java.lang.String getSensorDName()
-
getSensorD
public Sensor getSensorD()
-
setSensorDName
public void setSensorDName(java.lang.String sensorName)
-
getConnection
public LayoutTrack getConnection(HitPointType connectionType) throws JmriException
get the LayoutTrack connected at the specified connection type- Specified by:
getConnection
in 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, LayoutTrack o, HitPointType type) throws JmriException
set the LayoutTrack connected at the specified connection type- Specified by:
setConnection
in 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
-
getConnectA
public LayoutTrack getConnectA()
-
getConnectB
public LayoutTrack getConnectB()
-
getConnectC
public LayoutTrack getConnectC()
-
getConnectD
public LayoutTrack getConnectD()
-
setConnectA
public void setConnectA(LayoutTrack o, HitPointType type)
-
setConnectB
public void setConnectB(LayoutTrack o, HitPointType type)
-
setConnectC
public void setConnectC(LayoutTrack o, HitPointType type)
-
setConnectD
public void setConnectD(LayoutTrack o, HitPointType type)
-
getLayoutBlockAC
public LayoutBlock getLayoutBlockAC()
-
getLayoutBlockBD
public LayoutBlock getLayoutBlockBD()
-
setLayoutBlockAC
public void setLayoutBlockAC(LayoutBlock newLayoutBlock)
Add Layout Blocks.- Parameters:
newLayoutBlock
- the layout block to add.
-
setLayoutBlockBD
public void setLayoutBlockBD(LayoutBlock newLayoutBlock)
-
updateBlockInfo
public void updateBlockInfo()
-
removeSML
void removeSML(SignalMast signalMast)
-
isMainlineAC
public boolean isMainlineAC()
Test if mainline track or not.- Returns:
- true if either connecting track segment is mainline; Defaults to not mainline if connecting track segments are missing
-
isMainlineBD
public boolean isMainlineBD()
-
isMainline
public boolean isMainline()
- Specified by:
isMainline
in classLayoutTrack
-
setObjects
public void setObjects(LayoutEditor p)
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:
setObjects
in classLayoutTrack
- Parameters:
p
- the layout editor
-
canRemove
public 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.
- Specified by:
canRemove
in classLayoutTrack
- Returns:
- true if the layout track object can be deleted.
-
getBeanReferences
public java.util.ArrayList<java.lang.String> getBeanReferences(java.lang.String pointName)
Build a list of sensors, signal heads, and signal masts attached to a level crossing point.- Parameters:
pointName
- Specify the point (A-D) or all (All) points.- Returns:
- a list of bean reference names.
-
getBlockBoundaries
public java.lang.String[] getBlockBoundaries()
-
remove
public void remove()
Remove this object from display and persistance.
-
isActive
public boolean isActive()
Get if active. "active" means that the object is still displayed, and should be stored.- Returns:
- true if still displayed, else false.
-
addSignalMastLogic
public void addSignalMastLogic(SignalMast sm)
-
removeSignalMastLogic
public void removeSignalMastLogic(SignalMast sm)
-
reCheckBlockBoundary
public void reCheckBlockBoundary()
Description copied from class:LayoutTrack
abstract method... subclasses should implement _IF_ they need to recheck their block boundaries- Specified by:
reCheckBlockBoundary
in classLayoutTrack
-
getLayoutConnectivity
protected java.util.ArrayList<LayoutConnectivity> getLayoutConnectivity()
Description copied from class:LayoutTrack
get the layout connectivity for this track- Specified by:
getLayoutConnectivity
in classLayoutTrack
- Returns:
- the list of Layout Connectivity objects
-
checkForFreeConnections
public java.util.List<HitPointType> checkForFreeConnections()
return a list of the available connections for this layout track- Specified by:
checkForFreeConnections
in classLayoutTrack
- Returns:
- the list of available connections
-
checkForUnAssignedBlocks
public boolean checkForUnAssignedBlocks()
determine if all the appropriate blocks have been assigned to this track- Specified by:
checkForUnAssignedBlocks
in classLayoutTrack
- Returns:
- true if all appropriate blocks have been assigned
-
checkForNonContiguousBlocks
public void checkForNonContiguousBlocks(@Nonnull java.util.HashMap<java.lang.String,java.util.List<java.util.Set<java.lang.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:
checkForNonContiguousBlocks
in classLayoutTrack
- Parameters:
blockNamesToTrackNameSetsMap
- hashmap of key:block names to lists of track name sets for those blocks
-
collectContiguousTracksNamesInBlockNamed
public 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- Specified by:
collectContiguousTracksNamesInBlockNamed
in classLayoutTrack
- Parameters:
blockName
- the block that we're checking forTrackNameSet
- the set of track names in this block
-
setAllLayoutBlocks
public void setAllLayoutBlocks(LayoutBlock layoutBlock)
Assign all the layout blocks in this track- Specified by:
setAllLayoutBlocks
in classLayoutTrack
- Parameters:
layoutBlock
- to this layout block (used by the Tools menu's "Assign block to selection" item)
-
getTypeName
public java.lang.String getTypeName()
Get the type of this item.- Specified by:
getTypeName
in classLayoutTrack
- Returns:
- the type
-
-