Class PositionablePoint
- java.lang.Object
-
- jmri.jmrit.display.layoutEditor.LayoutTrack
-
- jmri.jmrit.display.layoutEditor.PositionablePoint
-
public class PositionablePoint extends LayoutTrack
PositionablePoint is a Point defining a node in the Track that can be dragged around the inside of the enclosing LayoutEditor panel using a right-drag (drag with meta key).Three types of Positionable Point are supported: Anchor - point on track - two track connections End Bumper - end of track point - one track connection Edge Connector - This is used to link track segments between two different panels
Note that a PositionablePoint exists for specifying connectivity and drawing position only. The Track Segments connected to a PositionablePoint may belong to the same block or to different blocks. Since each Track Segment may only belong to one block, a PositionablePoint may function as a Block Boundary.
As an Edge Connector, this is a semi-transparent connection to a remote TrackSeqment via another Edge Connector object.
Signal names are saved here at a Block Boundary anchor point by the tool Set Signals at Block Boundary. PositionablePoint does nothing with these signal head names; it only serves as a place to store them.
Arrows and bumpers are visual presentation aspects handled in the View.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPositionablePoint.PointType
-
Field Summary
Fields Modifier and Type Field Description protected NamedBeanHandle<SignalHead>signalEastHeadNamedprotected NamedBeanHandle<SignalHead>signalWestHeadNamedjava.lang.StringtrackSegment1Namejava.lang.StringtrackSegment2Name-
Fields inherited from class jmri.jmrit.display.layoutEditor.LayoutTrack
models
-
-
Constructor Summary
Constructors Constructor Description PositionablePoint(java.lang.String id, PositionablePoint.PointType t, LayoutEditor models)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanRemove()Check for active block boundaries.java.util.List<HitPointType>checkForFreeConnections()return a list of the available connections for this layout trackvoidcheckForNonContiguousBlocks(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 blocksbooleancheckForUnAssignedBlocks()determine if all the appropriate blocks have been assigned to this trackvoidcollectContiguousTracksNamesInBlockNamed(java.lang.String blockName, java.util.Set<java.lang.String> TrackNameSet)recursive routine to check for all contiguous tracks in this blockNameTrackSegmentgetConnect1()Provide the destination TrackSegment of the 1st connection.protected intgetConnect1Dir()TrackSegmentgetConnect2()Provide the destination TrackSegment of the 2nd connection.TrackSegmentgetConnect2Actual()Provide the destination TrackSegment of the 2nd connection without doing the look-through present ingetConnect2()LayoutTrackgetConnection(HitPointType connectionType)get the LayoutTrack connected at the specified connection typeSensorgetEastBoundSensor()java.lang.StringgetEastBoundSensorName()java.lang.StringgetEastBoundSignal()SignalHeadgetEastBoundSignalHead()SignalMastgetEastBoundSignalMast()java.lang.StringgetEastBoundSignalMastName()NamedBeanHandle<SignalMast>getEastBoundSignalMastNamed()protected java.util.List<LayoutConnectivity>getLayoutConnectivity()get the layout connectivity for this trackprotected LayoutEditorgetLayoutEditor()LayoutEditorgetLinkedEditor()java.lang.StringgetLinkedEditorName()PositionablePointgetLinkedPoint()java.lang.StringgetLinkedPointId()java.util.ArrayList<java.lang.String>getSegmentReferences(TrackSegment ts)Build a list of sensors, signal heads, and signal masts attached to a connection point.PositionablePoint.PointTypegetType()Get the point type.java.lang.StringgetTypeName()Get the type of this item.SensorgetWestBoundSensor()java.lang.StringgetWestBoundSensorName()java.lang.StringgetWestBoundSignal()SignalHeadgetWestBoundSignalHead()SignalMastgetWestBoundSignalMast()java.lang.StringgetWestBoundSignalMastName()NamedBeanHandle<SignalMast>getWestBoundSignalMastNamed()protected booleanisActive()"active" means that the object is still displayed, and should be stored.booleanisDisconnected(HitPointType connectionType)return true if this connection type is disconnectedbooleanisMainline()voidreCheckBlockBoundary()abstract method... subclasses should implement _IF_ they need to recheck their block boundariesvoidremove()Removes this object from display and persistencevoidremoveBeanReference(NamedBean nb)(package private) voidremoveLinkedPoint()(package private) voidremoveSML(SignalMast signalMast)booleanremoveTrackConnection(TrackSegment track)remove a connection to a trackbooleanreplaceTrackConnection(TrackSegment oldTrack, TrackSegment newTrack)replace old track connection with new track connectionvoidsetAllLayoutBlocks(LayoutBlock layoutBlock)Assign all the layout blocks in this trackvoidsetConnect1(TrackSegment trk)voidsetConnect2Actual(TrackSegment trk)voidsetConnection(HitPointType connectionType, LayoutTrack o, HitPointType type)set the LayoutTrack connected at the specified connection typevoidsetEastBoundSensor(java.lang.String sensorName)voidsetEastBoundSignal(java.lang.String signalName)voidsetEastBoundSignalMast(java.lang.String signalMast)voidsetLinkedPoint(PositionablePoint p)voidsetObjects(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.booleansetTrackConnection(TrackSegment track)setup a connection to a trackvoidsetType(PositionablePoint.PointType newType)(package private) voidsetTypeAnchor()(package private) voidsetTypeEdgeConnector()(package private) voidsetTypeEndBumper()voidsetWestBoundSensor(java.lang.String sensorName)voidsetWestBoundSignal(java.lang.String signalName)voidsetWestBoundSignalMast(java.lang.String signalMast)java.lang.StringtoString()-
Methods inherited from class jmri.jmrit.display.layoutEditor.LayoutTrack
getId, getName, getTurnoutStateString, setIdent
-
-
-
-
Field Detail
-
signalEastHeadNamed
protected NamedBeanHandle<SignalHead> signalEastHeadNamed
-
signalWestHeadNamed
protected NamedBeanHandle<SignalHead> signalWestHeadNamed
-
trackSegment1Name
public java.lang.String trackSegment1Name
-
trackSegment2Name
public java.lang.String trackSegment2Name
-
-
Constructor Detail
-
PositionablePoint
public PositionablePoint(java.lang.String id, PositionablePoint.PointType t, LayoutEditor models)
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getType
public PositionablePoint.PointType getType()
Get the point type.- Returns:
- point type, i.e. ANCHOR, END_BUMPER, EDGE_CONNECTOR
-
setType
public void setType(PositionablePoint.PointType newType)
-
setTypeAnchor
void setTypeAnchor()
-
setTypeEndBumper
void setTypeEndBumper()
-
setTypeEdgeConnector
void setTypeEdgeConnector()
-
getConnect1
public TrackSegment getConnect1()
Provide the destination TrackSegment of the 1st connection.- Returns:
- destination track segment
-
setConnect1
public void setConnect1(TrackSegment trk)
-
getConnect2
public TrackSegment getConnect2()
Provide the destination TrackSegment of the 2nd connection. When this is an EDGE CONNECTOR, it looks through the linked point (if any) to the far-end track connection.- Returns:
- destination track segment
-
getConnect2Actual
public TrackSegment getConnect2Actual()
Provide the destination TrackSegment of the 2nd connection without doing the look-through present ingetConnect2()- Returns:
- destination track segment
-
setConnect2Actual
public void setConnect2Actual(TrackSegment trk)
-
getLinkedEditorName
public java.lang.String getLinkedEditorName()
-
getLinkedPoint
public PositionablePoint getLinkedPoint()
-
getLinkedPointId
public java.lang.String getLinkedPointId()
-
setLinkedPoint
public void setLinkedPoint(PositionablePoint p)
-
getLinkedEditor
@CheckReturnValue public LayoutEditor getLinkedEditor()
-
getLayoutEditor
@CheckReturnValue protected LayoutEditor getLayoutEditor()
-
getEastBoundSignal
@CheckReturnValue @Nonnull public java.lang.String getEastBoundSignal()
-
getEastBoundSignalHead
@CheckForNull @CheckReturnValue public SignalHead getEastBoundSignalHead()
-
setEastBoundSignal
public void setEastBoundSignal(java.lang.String signalName)
-
getWestBoundSignal
@CheckReturnValue @Nonnull public java.lang.String getWestBoundSignal()
-
getWestBoundSignalHead
@CheckForNull @CheckReturnValue public SignalHead getWestBoundSignalHead()
-
setWestBoundSignal
public void setWestBoundSignal(java.lang.String signalName)
-
getEastBoundSensorName
@CheckReturnValue @Nonnull public java.lang.String getEastBoundSensorName()
-
getEastBoundSensor
@CheckReturnValue public Sensor getEastBoundSensor()
-
setEastBoundSensor
public void setEastBoundSensor(java.lang.String sensorName)
-
getWestBoundSensorName
@CheckReturnValue @Nonnull public java.lang.String getWestBoundSensorName()
-
getWestBoundSensor
@CheckReturnValue public Sensor getWestBoundSensor()
-
setWestBoundSensor
public void setWestBoundSensor(java.lang.String sensorName)
-
getEastBoundSignalMastName
@CheckReturnValue @Nonnull public java.lang.String getEastBoundSignalMastName()
-
getEastBoundSignalMast
@CheckReturnValue public SignalMast getEastBoundSignalMast()
-
getEastBoundSignalMastNamed
@CheckReturnValue public NamedBeanHandle<SignalMast> getEastBoundSignalMastNamed()
-
setEastBoundSignalMast
public void setEastBoundSignalMast(java.lang.String signalMast)
-
getWestBoundSignalMastName
@CheckReturnValue @Nonnull public java.lang.String getWestBoundSignalMastName()
-
getWestBoundSignalMast
@CheckReturnValue public SignalMast getWestBoundSignalMast()
-
getWestBoundSignalMastNamed
@CheckReturnValue public NamedBeanHandle<SignalMast> getWestBoundSignalMastNamed()
-
setWestBoundSignalMast
public void setWestBoundSignalMast(java.lang.String signalMast)
-
removeBeanReference
public void removeBeanReference(NamedBean nb)
-
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:
setObjectsin classLayoutTrack- Parameters:
p- the layout editor
-
setTrackConnection
public boolean setTrackConnection(@Nonnull TrackSegment track)
setup a connection to a track- Parameters:
track- the track we want to connect to- Returns:
- true if successful
-
removeTrackConnection
public boolean removeTrackConnection(@Nonnull TrackSegment track)
remove a connection to a track- Parameters:
track- the track we want to disconnect from- Returns:
- true if successful
-
replaceTrackConnection
public boolean replaceTrackConnection(@CheckForNull TrackSegment oldTrack, @CheckForNull TrackSegment newTrack)
replace old track connection with new track connection- Parameters:
oldTrack- the old track connectionnewTrack- the new track connection- Returns:
- true if successful
-
removeSML
void removeSML(SignalMast signalMast)
-
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:
canRemovein classLayoutTrack- Returns:
- true if the layout track object can be deleted.
-
getSegmentReferences
public java.util.ArrayList<java.lang.String> getSegmentReferences(TrackSegment ts)
Build a list of sensors, signal heads, and signal masts attached to a connection point.- Parameters:
ts- The track segment to be checked.- Returns:
- a list of bean reference names.
-
removeLinkedPoint
void removeLinkedPoint()
-
remove
public void remove()
Removes this object from display and persistence
-
isActive
protected boolean isActive()
"active" means that the object is still displayed, and should be stored.- Returns:
- true if active
-
getConnect1Dir
protected int getConnect1Dir()
-
getConnection
public LayoutTrack getConnection(HitPointType connectionType) throws JmriException
get the LayoutTrack connected at the specified connection type- 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, LayoutTrack o, HitPointType type) throws JmriException
set the LayoutTrack connected at the specified connection type- 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
-
isDisconnected
public boolean isDisconnected(HitPointType connectionType)
return true if this connection type is disconnected- Overrides:
isDisconnectedin classLayoutTrack- Parameters:
connectionType- the connection type to test- Returns:
- true if the connection for this connection type is free
-
isMainline
public boolean isMainline()
- Specified by:
isMainlinein classLayoutTrack
-
reCheckBlockBoundary
public void reCheckBlockBoundary()
abstract method... subclasses should implement _IF_ they need to recheck their block boundaries- Specified by:
reCheckBlockBoundaryin classLayoutTrack
-
getLayoutConnectivity
protected java.util.List<LayoutConnectivity> getLayoutConnectivity()
get the layout connectivity for this track- Specified by:
getLayoutConnectivityin 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:
checkForFreeConnectionsin 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:
checkForUnAssignedBlocksin 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:
checkForNonContiguousBlocksin 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:
collectContiguousTracksNamesInBlockNamedin 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:
setAllLayoutBlocksin 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:
getTypeNamein classLayoutTrack- Returns:
- the type
-
-