Class LayoutTurnoutView
- All Implemented Interfaces:
InlineLogixNG
- Direct Known Subclasses:
LayoutLHTurnoutView,LayoutRHTurnoutView,LayoutSlipView,LayoutWyeView,LayoutXOverView
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LayoutTurnoutEditorstatic final intprotected NamedBeanHandle<LayoutBlock>protected NamedBeanHandle<LayoutBlock>protected NamedBeanHandle<LayoutBlock>protected NamedBeanHandle<LayoutBlock>protected NamedBeanHandle<Turnout>protected NamedBeanHandle<Turnout>booleanprotected NamedBeanHandle<SignalHead>protected NamedBeanHandle<SignalHead>protected NamedBeanHandle<SignalHead>protected NamedBeanHandle<SignalHead>protected NamedBeanHandle<SignalHead>protected NamedBeanHandle<SignalHead>protected NamedBeanHandle<SignalHead>protected NamedBeanHandle<SignalHead>protected NamedBeanHandle<SignalHead>static final intstatic final intstatic final intstatic final intstatic final doublestatic final doublestatic final doublestatic final intstatic final doublestatic final doublestatic final doubleFields inherited from class jmri.jmrit.display.layoutEditor.LayoutTrackView
decorations, layoutEditor, NUM_ARROW_TYPES -
Constructor Summary
ConstructorsConstructorDescriptionLayoutTurnoutView(LayoutTurnout turnout, Point2D c, double rot, double xFactor, double yFactor, LayoutEditor layoutEditor) Constructor method.LayoutTurnoutView(LayoutTurnout turnout, Point2D c, double rot, LayoutEditor layoutEditor) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEditPopUpMenu(JMenuItem menu) voidaddViewPopUpMenu(JMenuItem menu) booleanCheck 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 blockNamevoiddispose()Clean up when this object is no longer needed.protected voiddraw1(Graphics2D g2, boolean isMain, boolean isBlock) draw one line (Ballast, ties, center or 3rd rail, block lines)protected voiddraw2(Graphics2D g2, boolean isMain, float railDisplacement) draw two lines (rails)protected voidDraw track decorations.protected voiddraw the edit controlsprotected voidDraw the turnout controlsprotected HitPointTypefindHitPointType(Point2D hitPoint, boolean useRectangles, boolean requireUnconnected) find the hit (location) type for a pointgetBeanReferences(String pointName) Build a list of sensors, signal heads, and signal masts attached to a turnout point.String[]getConnection(HitPointType connectionType) get the LayoutTrack connected at the specified connection typeprotected intgetConnectivityStateForLayoutBlocks(LayoutBlock currLayoutBlock, LayoutBlock prevLayoutBlock, LayoutBlock nextLayoutBlock, boolean suppress) intgetCoordsForConnectionType(HitPointType connectionType) return the coordinates for a specified connection type (abstract: should be overridden by ALL subclasses)protected List<LayoutConnectivity>get the layout connectivity for this trackfinal LayoutTurnoutgetProtectedBlocks(NamedBean bean) doublebooleanintgetState()Get the LayoutTurnout stateintbooleanReturns true if this has double track on the entrance end (crossover or slip)static booleanReturns true if this has double track on the entrance end (crossover or slip)booleanReturns true if this has a single-track entrance end.static booleanReturns true if this has a single-track entrance end.protected voidhighlightUnconnected(Graphics2D g2, HitPointType specificType) highlight unconnected connectionsbooleanisActive()"active" means that the object is still displayed, and should be stored.booleanbooleanbooleanbooleanTest if turnout legs are mainline track or not.booleanbooleanbooleanbooleanReturns true if this is a slipstatic booleanReturns true if this is a slipbooleanReturns true if this is a turnout (not a crossover or slip)static booleanReturns true if this is a turnout (not a crossover or slip)booleanReturns true if this is a crossoverstatic booleanReturns true if this is a crossover(package private) voidvoidabstract method... subclasses should implement _IF_ they need to recheck their block boundariesvoidremove()Remove this object from display and persistance.voidprotected voidremoveSML(SignalMast signalMast) voidrotateCoords(double angleDEG) rotate this LayoutTrack's coordinates by angleDEG'svoidscaleCoords(double xFactor, double yFactor) scale this LayoutTrack's coordinates by the x and y factorsvoidvoidvoidsetAllLayoutBlocks(LayoutBlock layoutBlock) Assign all the layout blocks in this trackvoidsetConnectA(LayoutTrack o, HitPointType type) voidsetConnectB(LayoutTrack o, HitPointType type) voidsetConnectC(LayoutTrack o, HitPointType type) voidsetConnectD(LayoutTrack o, HitPointType type) voidsetConnection(HitPointType connectionType, LayoutTrack o, HitPointType type) set the LayoutTrack connected at the specified connection typevoidsetContinuingSense(int sense) voidvoidvoidvoidSet center coordinates.voidvoidsetDisabled(boolean state) voidsetDisableWhenOccupied(boolean state) voidsetLayoutBlock(LayoutBlock newLayoutBlock) Set up Layout Block(s) for this Turnout.voidsetLayoutBlockB(LayoutBlock newLayoutBlock) voidsetLayoutBlockBByName(String name) voidsetLayoutBlockByName(String name) voidsetLayoutBlockC(LayoutBlock newLayoutBlock) voidsetLayoutBlockCByName(String name) voidsetLayoutBlockD(LayoutBlock newLayoutBlock) voidsetLayoutBlockDByName(String name) voidvoidvoidsetSecondTurnout(String tName) voidsetSecondTurnoutInverted(boolean inverted) voidsetSensorA(String sensorName) voidsetSensorB(String sensorName) voidsetSensorC(String sensorName) voidsetSensorD(String sensorName) voidsetShowUnknown(boolean show) voidsetSignalA1Name(String signalHead) voidsetSignalA2Name(String signalHead) voidsetSignalA3Name(String signalHead) voidsetSignalAMast(String signalMast) voidsetSignalB1Name(String signalHead) voidsetSignalB2Name(String signalHead) voidsetSignalBMast(String signalMast) voidsetSignalC1Name(String signalHead) voidsetSignalC2Name(String signalHead) voidsetSignalCMast(String signalMast) voidsetSignalD1Name(String signalHead) voidsetSignalD2Name(String signalHead) voidsetSignalDMast(String signalMast) voidsetState(int state) Set the LayoutTurnout state.(package private) voidsetTrackSegmentBlock(HitPointType pointType, boolean isAutomatic) Update the block for a track segment that provides a (graphically) short connection between a turnout and another object, normally another turnout.(package private) voidCheck each connection point and update the block value for very short track segments.voidsetTurnout(String tName) protected voidSet default size parameters to correspond to this turnout's size.voidsetVersion(int v) protected JPopupMenushowPopup(JmriMouseEvent mouseEvent) show the popup menu for this layout trackvoidToggle turnout if clicked on, physical turnout exists, and not disabled.toString()voidtranslateCoords(double xFactor, double yFactor) translate this LayoutTrack's coordinates by the x and y factorsvoidbooleanMethods inherited from class jmri.jmrit.display.layoutEditor.LayoutTrackView
addCommonPopupItems, displayRemoveWarningDialog, drawHidden, drawLayoutTrackText, findHitPointType, findHitPointType, getColorForTrackBlock, getColorForTrackBlock, getCoordsCenter, getDecorations, getEditorName, getId, getLayoutEditor, getLayoutEditorToolBarPanel, getLayoutTrack, getLogixNG, getName, getNameString, getTurnoutStateString, getTypeName, getX, getY, hasDecorations, highlightUnconnected, isDisconnected, isHidden, loadArrowImageToJCBItem, removeInlineLogixNG, rotatePoint, setColorForTrackBlock, setColorForTrackBlock, setDecorations, setHidden, setIdent, setLogixNG, setLogixNG_SystemName, setLogixNGPositionableMenu, setupLogixNG, showPopup, showPopup, trackControlCircleAt, trackControlCircleRectAt, trackEditControlCircleAt
-
Field Details
-
UNKNOWN
- See Also:
-
INCONSISTENT
- See Also:
-
STATE_AC
- See Also:
-
STATE_BD
- See Also:
-
STATE_AD
- See Also:
-
STATE_BC
- See Also:
-
turnoutBXDefault
- See Also:
-
turnoutCXDefault
- See Also:
-
turnoutWidDefault
- See Also:
-
xOverLongDefault
- See Also:
-
xOverHWidDefault
- See Also:
-
xOverShortDefault
- See Also:
-
namedTurnout
-
secondNamedTurnout
-
namedLayoutBlockA
-
namedLayoutBlockB
-
namedLayoutBlockC
-
namedLayoutBlockD
-
signalA1HeadNamed
-
signalA2HeadNamed
-
signalA3HeadNamed
-
signalB1HeadNamed
-
signalB2HeadNamed
-
signalC1HeadNamed
-
signalC2HeadNamed
-
signalD1HeadNamed
-
signalD2HeadNamed
-
dispB
-
dispA
-
pointA
-
pointB
-
pointC
-
pointD
-
showUnknown
-
editor
-
connectAName
-
connectBName
-
connectCName
-
connectDName
-
tBlockAName
-
tBlockBName
-
tBlockCName
-
tBlockDName
-
editAdditionalMenu
-
viewAdditionalMenu
-
-
Constructor Details
-
LayoutTurnoutView
public LayoutTurnoutView(@Nonnull LayoutTurnout turnout, @Nonnull Point2D c, double rot, @Nonnull LayoutEditor layoutEditor) -
LayoutTurnoutView
public LayoutTurnoutView(@Nonnull LayoutTurnout turnout, @Nonnull Point2D c, double rot, double xFactor, double yFactor, @Nonnull LayoutEditor layoutEditor) Constructor method.- Parameters:
turnout- the layout turnout to create the view for.c- where to put itrot- for displayxFactor- for displayyFactor- for displaylayoutEditor- what layout editor panel to put it in
-
-
Method Details
-
isTurnoutTypeTurnout
Returns true if this is a turnout (not a crossover or slip)- Parameters:
type- the turnout type- Returns:
- boolean true if this is a turnout
-
isTurnoutTypeTurnout
Returns true if this is a turnout (not a crossover or slip)- Returns:
- boolean true if this is a turnout
-
isTurnoutTypeXover
Returns true if this is a crossover- Parameters:
type- the turnout type- Returns:
- boolean true if this is a crossover
-
isTurnoutTypeXover
Returns true if this is a crossover- Returns:
- boolean true if this is a crossover
-
isTurnoutTypeSlip
Returns true if this is a slip- Parameters:
type- the turnout type- Returns:
- boolean true if this is a slip
-
isTurnoutTypeSlip
Returns true if this is a slip- Returns:
- boolean true if this is a slip
-
hasEnteringSingleTrack
Returns true if this has a single-track entrance end. (turnout or wye)- Parameters:
type- the turnout type- Returns:
- boolean true if single track entrance
-
hasEnteringSingleTrack
Returns true if this has a single-track entrance end. (turnout or wye)- Returns:
- boolean true if single track entrance
-
hasEnteringDoubleTrack
Returns true if this has double track on the entrance end (crossover or slip)- Parameters:
type- the turnout type- Returns:
- boolean true if double track entrance
-
hasEnteringDoubleTrack
Returns true if this has double track on the entrance end (crossover or slip)- Returns:
- boolean true if double track entrance
-
getLayoutTurnout
-
toString
-
getVersion
-
setVersion
-
useBlockSpeed
-
getTurnoutName
-
getSecondTurnoutName
-
getBlockName
-
getBlockBName
-
getBlockCName
-
getBlockDName
-
getSignalHead
-
getSignalA1
-
getSignalA1Name
-
setSignalA1Name
-
getSignalA2
-
getSignalA2Name
-
setSignalA2Name
-
getSignalA3
-
getSignalA3Name
-
setSignalA3Name
-
getSignalB1
-
getSignalB1Name
-
setSignalB1Name
-
getSignalB2
-
getSignalB2Name
-
setSignalB2Name
-
getSignalC1
-
getSignalC1Name
-
setSignalC1Name
-
getSignalC2
-
getSignalC2Name
-
setSignalC2Name
-
getSignalD1
-
getSignalD1Name
-
setSignalD1Name
-
getSignalD2
-
getSignalD2Name
-
setSignalD2Name
-
removeBeanReference
-
setShowUnknown
-
getShowUnknown
-
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 classLayoutTrackView- Returns:
- true if the layout track object can be deleted.
-
getBeanReferences
Build a list of sensors, signal heads, and signal masts attached to a turnout point.- Parameters:
pointName- Specify the point (A-D) or all (All) points.- Returns:
- a list of bean reference names.
-
getSignalAMastName
-
getSignalAMast
-
setSignalAMast
-
getSignalBMastName
-
getSignalBMast
-
setSignalBMast
-
getSignalCMastName
-
getSignalCMast
-
setSignalCMast
-
getSignalDMastName
-
getSignalDMast
-
setSignalDMast
-
getSensorAName
-
getSensorA
-
setSensorA
-
getSensorBName
-
getSensorB
-
setSensorB
-
getSensorCName
-
getSensorC
-
setSensorC
-
getSensorDName
-
getSensorD
-
setSensorD
-
getLinkedTurnoutName
-
setLinkedTurnoutName
-
getLinkType
-
setLinkType
-
getTurnoutType
-
getConnectA
-
getConnectB
-
getConnectC
-
getConnectD
-
getTurnout
- Returns:
- null if no turnout set // temporary? Might want to run all calls through this class; but this is getModel equiv
-
getContinuingSense
-
isInContinuingSenseState
- Returns:
- true is the continuingSense matches the known state
-
setTurnout
-
getSecondTurnout
-
setSecondTurnout
-
setSecondTurnoutInverted
-
setContinuingSense
-
setDisabled
-
isDisabled
-
setDisableWhenOccupied
-
isDisabledWhenOccupied
-
getConnection
get the LayoutTrack connected at the specified connection type- Specified by:
getConnectionin classLayoutTrackView- 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 type- Specified by:
setConnectionin classLayoutTrackView- 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
-
setConnectA
-
setConnectB
-
setConnectC
-
setConnectD
-
getLayoutBlock
-
getLayoutBlockB
-
getLayoutBlockC
-
getLayoutBlockD
-
getCoordsA
-
getCoordsB
-
getCoordsC
-
getCoordsD
-
getCoordsForConnectionType
return the coordinates for a specified connection type (abstract: should be overridden by ALL subclasses)- Specified by:
getCoordsForConnectionTypein classLayoutTrackView- Parameters:
connectionType- the connection type- Returns:
- the coordinates for the specified connection type
-
getBounds
- Specified by:
getBoundsin classLayoutTrackView- Returns:
- the bounds of this track
-
updateBlockInfo
-
setUpDefaultSize
Set default size parameters to correspond to this turnout's size.note: only protected so LayoutTurnoutTest can call it
-
setLayoutBlock
Set up Layout Block(s) for this Turnout.- Parameters:
newLayoutBlock- SeeLayoutTurnout.setLayoutBlock(jmri.jmrit.display.layoutEditor.LayoutBlock)for definition
-
setLayoutBlockB
-
setLayoutBlockC
-
setLayoutBlockD
-
setLayoutBlockByName
-
setLayoutBlockBByName
-
setLayoutBlockCByName
-
setLayoutBlockDByName
-
setTrackSegmentBlocks
void setTrackSegmentBlocks()Check each connection point and update the block value for very short track segments.- Since:
- 4.11.6
-
setTrackSegmentBlock
Update the block for a track segment that provides a (graphically) short connection between a turnout and another object, normally another turnout. These are hard to see and are frequently missed.Skip block changes if signal heads, masts or sensors have been assigned. Only track segments with a length less than the turnout circle radius will be changed.
- Parameters:
pointType- The point type which indicates which turnout connection.isAutomatic- True for the automatically generated track segment created by the drag-n-drop process. False for existing connections which require a track segment length calculation.- Since:
- 4.11.6
-
isMainlineA
Test if turnout legs are mainline track or not.- Returns:
- true if connecting track segment is mainline; Defaults to not mainline if connecting track segment is missing
-
isMainlineB
-
isMainlineC
-
isMainlineD
-
findHitPointType
protected HitPointType findHitPointType(@Nonnull Point2D hitPoint, boolean useRectangles, boolean requireUnconnected) find the hit (location) type for a point- Specified by:
findHitPointTypein classLayoutTrackView- Parameters:
hitPoint- the pointuseRectangles- whether to use (larger) rectangles or (smaller) circles for hit testingrequireUnconnected- whether to only return hit types for free connections- Returns:
- the location type for the point (or NONE)
-
setCoordsCenter
Set center coordinates.Some subtypes may reimplement this is "center" is a more complicated idea, i.e. for Bezier curves
- Overrides:
setCoordsCenterin classLayoutTrackView- Parameters:
p- the coordinates to set
-
reCalculateCenter
void reCalculateCenter() -
setCoordsA
-
setCoordsB
-
setCoordsC
-
setCoordsD
-
scaleCoords
scale this LayoutTrack's coordinates by the x and y factors- Specified by:
scaleCoordsin classLayoutTrackView- Parameters:
xFactor- the amount to scale X coordinatesyFactor- the amount to scale Y coordinates
-
translateCoords
translate this LayoutTrack's coordinates by the x and y factors- Specified by:
translateCoordsin classLayoutTrackView- Parameters:
xFactor- the amount to translate X coordinatesyFactor- the amount to translate Y coordinates
-
rotateCoords
rotate this LayoutTrack's coordinates by angleDEG's- Specified by:
rotateCoordsin classLayoutTrackView- Parameters:
angleDEG- the amount to rotate in degrees
-
getRotationDEG
-
toggleTurnout
Toggle turnout if clicked on, physical turnout exists, and not disabled. -
setState
Set the LayoutTurnout state. Used for sending the toggle command Checks not disabled, disable when occupied Also sets secondary Turnout commanded state- Parameters:
state- New state to set, eg Turnout.CLOSED
-
getState
Get the LayoutTurnout stateEnsures the secondary Turnout state matches the primary
- Returns:
- the state, eg Turnout.CLOSED or Turnout.INCONSISTENT
-
showPopup
show the popup menu for this layout track- Specified by:
showPopupin classLayoutTrackView- Parameters:
mouseEvent- the mouse down event that triggered this popup- Returns:
- the popup menu for this layout track
-
getBlockBoundaries
-
getProtectedBlocks
-
removeSML
-
dispose
Clean up when this object is no longer needed. Should not be called while the object is still displayed; seeremove() -
remove
Remove this object from display and persistance. -
isActive
"active" means that the object is still displayed, and should be stored.- Returns:
- true if active
-
addEditPopUpMenu
-
addViewPopUpMenu
-
setAdditionalEditPopUpMenu
-
setAdditionalViewPopUpMenu
-
drawDecorations
Draw track decorations.This type of track has none, so this method is empty.
- Specified by:
drawDecorationsin classLayoutTrackView- Parameters:
g2- the graphics context
-
draw1
draw one line (Ballast, ties, center or 3rd rail, block lines)- Specified by:
draw1in classLayoutTrackView- Parameters:
g2- the graphics contextisMain- true if drawing mainlinesisBlock- true if drawing block lines
-
draw2
draw two lines (rails)- Specified by:
draw2in classLayoutTrackView- Parameters:
g2- the graphics contextisMain- true if drawing mainlinesrailDisplacement- the offset from center to draw the lines
-
highlightUnconnected
highlight unconnected connections- Specified by:
highlightUnconnectedin classLayoutTrackView- Parameters:
g2- the graphics contextspecificType- the specific connection to draw (or NONE for all)
-
drawTurnoutControls
Draw the turnout controls- Specified by:
drawTurnoutControlsin classLayoutTrackView- Parameters:
g2- the graphics context
-
drawEditControls
draw the edit controls- Specified by:
drawEditControlsin classLayoutTrackView- Parameters:
g2- the graphics context
-
getConnectivityStateForLayoutBlocks
protected int getConnectivityStateForLayoutBlocks(LayoutBlock currLayoutBlock, LayoutBlock prevLayoutBlock, LayoutBlock nextLayoutBlock, boolean suppress) -
reCheckBlockBoundary
abstract method... subclasses should implement _IF_ they need to recheck their block boundaries- Specified by:
reCheckBlockBoundaryin classLayoutTrackView
-
getLayoutConnectivity
get the layout connectivity for this track- Specified by:
getLayoutConnectivityin classLayoutTrackView- Returns:
- the list of Layout Connectivity objects
-
checkForFreeConnections
return a list of the available connections for this layout track- Specified by:
checkForFreeConnectionsin classLayoutTrackView- Returns:
- the list of available connections
-
checkForUnAssignedBlocks
determine if all the appropriate blocks have been assigned to this track- Specified by:
checkForUnAssignedBlocksin classLayoutTrackView- 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 classLayoutTrackView- 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 classLayoutTrackView- 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 classLayoutTrackView- Parameters:
layoutBlock- to this layout block (used by the Tools menu's "Assign block to selection" item)
-