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 class
PositionablePoint.PointType
-
Field Summary
Fields Modifier and Type Field Description protected NamedBeanHandle<SignalHead>
signalEastHeadNamed
protected NamedBeanHandle<SignalHead>
signalWestHeadNamed
java.lang.String
trackSegment1Name
java.lang.String
trackSegment2Name
-
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 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 blockNameTrackSegment
getConnect1()
Provide the destination TrackSegment of the 1st connection.protected int
getConnect1Dir()
TrackSegment
getConnect2()
Provide the destination TrackSegment of the 2nd connection.TrackSegment
getConnect2Actual()
Provide the destination TrackSegment of the 2nd connection without doing the look-through present ingetConnect2()
LayoutTrack
getConnection(HitPointType connectionType)
get the LayoutTrack connected at the specified connection typeSensor
getEastBoundSensor()
java.lang.String
getEastBoundSensorName()
java.lang.String
getEastBoundSignal()
SignalHead
getEastBoundSignalHead()
SignalMast
getEastBoundSignalMast()
java.lang.String
getEastBoundSignalMastName()
NamedBeanHandle<SignalMast>
getEastBoundSignalMastNamed()
protected java.util.List<LayoutConnectivity>
getLayoutConnectivity()
get the layout connectivity for this trackprotected LayoutEditor
getLayoutEditor()
LayoutEditor
getLinkedEditor()
java.lang.String
getLinkedEditorName()
PositionablePoint
getLinkedPoint()
java.lang.String
getLinkedPointId()
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.PointType
getType()
Get the point type.java.lang.String
getTypeName()
Get the type of this item.Sensor
getWestBoundSensor()
java.lang.String
getWestBoundSensorName()
java.lang.String
getWestBoundSignal()
SignalHead
getWestBoundSignalHead()
SignalMast
getWestBoundSignalMast()
java.lang.String
getWestBoundSignalMastName()
NamedBeanHandle<SignalMast>
getWestBoundSignalMastNamed()
protected boolean
isActive()
"active" means that the object is still displayed, and should be stored.boolean
isDisconnected(HitPointType connectionType)
return true if this connection type is disconnectedboolean
isMainline()
void
reCheckBlockBoundary()
abstract method... subclasses should implement _IF_ they need to recheck their block boundariesvoid
remove()
Removes this object from display and persistencevoid
removeBeanReference(NamedBean nb)
(package private) void
removeLinkedPoint()
(package private) void
removeSML(SignalMast signalMast)
boolean
removeTrackConnection(TrackSegment track)
remove a connection to a trackboolean
replaceTrackConnection(TrackSegment oldTrack, TrackSegment newTrack)
replace old track connection with new track connectionvoid
setAllLayoutBlocks(LayoutBlock layoutBlock)
Assign all the layout blocks in this trackvoid
setConnect1(TrackSegment trk)
void
setConnect2Actual(TrackSegment trk)
void
setConnection(HitPointType connectionType, LayoutTrack o, HitPointType type)
set the LayoutTrack connected at the specified connection typevoid
setEastBoundSensor(java.lang.String sensorName)
void
setEastBoundSignal(java.lang.String signalName)
void
setEastBoundSignalMast(java.lang.String signalMast)
void
setLinkedPoint(PositionablePoint p)
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.boolean
setTrackConnection(TrackSegment track)
setup a connection to a trackvoid
setType(PositionablePoint.PointType newType)
(package private) void
setTypeAnchor()
(package private) void
setTypeEdgeConnector()
(package private) void
setTypeEndBumper()
void
setWestBoundSensor(java.lang.String sensorName)
void
setWestBoundSignal(java.lang.String signalName)
void
setWestBoundSignalMast(java.lang.String signalMast)
java.lang.String
toString()
-
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:
toString
in 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:
setObjects
in 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:
canRemove
in 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:
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
-
isDisconnected
public boolean isDisconnected(HitPointType connectionType)
return true if this connection type is disconnected- Overrides:
isDisconnected
in 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:
isMainline
in classLayoutTrack
-
reCheckBlockBoundary
public void reCheckBlockBoundary()
abstract method... subclasses should implement _IF_ they need to recheck their block boundaries- Specified by:
reCheckBlockBoundary
in classLayoutTrack
-
getLayoutConnectivity
protected java.util.List<LayoutConnectivity> getLayoutConnectivity()
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
-
-