Class LayoutTurntableView
- All Implemented Interfaces:
InlineLogixNG
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class jmri.jmrit.display.layoutEditor.LayoutTrackView
decorations, layoutEditor, NUM_ARROW_TYPES -
Constructor Summary
ConstructorsConstructorDescriptionLayoutTurntableView(LayoutTurntable turntable, Point2D c, LayoutEditor layoutEditor) Constructor method. -
Method Summary
Modifier and TypeMethodDescriptionaddRay(double angle) Add a ray at the specified angle.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 blockNamevoiddeleteRay(LayoutTurntable.RayTrack rayTrack) Delete this ray track.voiddispose()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 this turntable's edit controls.protected voidDraw this turntable's controls.protected HitPointTypefindHitPointType(Point2D hitPoint, boolean useRectangles, boolean requireUnconnected) find the hit (location) type for a pointgetConnection(HitPointType connectionType) get the LayoutTrack connected at the specified connection typegetCoordsForConnectionType(HitPointType connectionType) Get the coordinates for a specified connection type.protected List<LayoutConnectivity>get the layout connectivity for this trackintGet the number of rays on turntable.intGet the turntable position.doubleGet the radius for this turntable.doublegetRayAngle(int i) Get the angle for the ray at this position in the rayTrackList.getRayConnectIndexed(int index) Get the connection for the ray with this index.getRayConnectOrdered(int i) Get the connection for the ray at the index in the rayTrackList.getRayCoordsIndexed(int index) Get the coordinates for the ray with this index.getRayCoordsOrdered(int i) Get the coordinates for the ray at this index.intgetRayIndex(int i) Get the index for the ray at this position in the rayTrackList.getRayTurnout(int i) Get the turnout for the ray at this index.getRayTurnoutName(int i) Get the name of the turnout for the ray at this index.intgetRayTurnoutState(int i) Get the state of the turnout for the ray at this index.final LayoutTurntableprotected voidhighlightUnconnected(Graphics2D g2, HitPointType specificType) highlight unconnected connectionsbooleanisActive()booleanisMainlineIndexed(int index) Test if ray with this index is a mainline track or not.booleanisMainlineOrdered(int i) Test if ray at this index is a mainline track or not.booleanisRayDisabled(int i) Get if the ray at this index is disabled.booleanisRayDisabledWhenOccupied(int i) Get the disabled when occupied state of the ray at this index.booleanIs this turntable turnout controlled?protected voidabstract method... subclasses should implement _IF_ they need to recheck their block boundariesvoidremove()Remove this object from display and persistance.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 factors.voidsetAllLayoutBlocks(LayoutBlock layoutBlock) Assign all the layout blocks in this trackvoidsetConnection(HitPointType connectionType, LayoutTrack o, HitPointType type) set the LayoutTrack connected at the specified connection typevoidsetLayoutBlock(LayoutBlock newLayoutBlock) Set up a LayoutBlock for this LayoutTurntable.voidsetLayoutBlockByName(String name) Set up a LayoutBlock for this LayoutTurntable.voidsetPosition(int index) Set turntable position to the ray with this index.voidsetRadius(double r) Set the radius for this turntable.voidsetRayConnect(TrackSegment ts, int index) Set the connection for the ray at the index in the rayTrackList.voidsetRayCoordsIndexed(double x, double y, int index) Set the coordinates for the ray at this index.voidsetRayCoordsIndexed(Point2D point, int index) Set the coordinates for the ray at this index.voidsetRayDisabled(int i, boolean boo) Set the disabled state of the ray at this index.voidsetRayDisabledWhenOccupied(int i, boolean boo) Set the disabled when occupied state of the ray at this index.voidsetRayTurnout(int index, String turnoutName, int state) Set the turnout and state for the ray with this index.voidsetTurnoutControlled(boolean boo) Set if this turntable is turnout controlled.protected JPopupMenushowPopup(JmriMouseEvent mouseEvent) show the popup menu for this layout trackprotected voidshowRayPopUp(JmriMouseEvent e, int index) toString()Get a string that represents this object.voidtranslateCoords(double xFactor, double yFactor) Translate (2D move) this LayoutTrack's coordinates by the x and y factors.Methods 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, setCoordsCenter, setDecorations, setHidden, setIdent, setLogixNG, setLogixNG_SystemName, setLogixNGPositionableMenu, setupLogixNG, showPopup, showPopup, trackControlCircleAt, trackControlCircleRectAt, trackEditControlCircleAt
-
Field Details
-
tLayoutBlockName
-
-
Constructor Details
-
LayoutTurntableView
public LayoutTurntableView(@Nonnull LayoutTurntable turntable, @Nonnull Point2D c, @Nonnull LayoutEditor layoutEditor) Constructor method.- Parameters:
turntable- the layout turntable to create view for.c- where to put itlayoutEditor- what layout editor panel to put it in
-
-
Method Details
-
getTurntable
-
toString
Get a string that represents this object. This should only be used for debugging. -
getRadius
Get the radius for this turntable.- Returns:
- the radius for this turntable
-
setRadius
Set the radius for this turntable.- Parameters:
r- the radius for this turntable
-
getBlockName
- Returns:
- the layout block name
-
getLayoutBlock
- Returns:
- the layout block
-
setLayoutBlock
Set up a LayoutBlock for this LayoutTurntable.- Parameters:
newLayoutBlock- the LayoutBlock to set
-
setLayoutBlockByName
Set up a LayoutBlock for this LayoutTurntable.- Parameters:
name- the name of the new LayoutBlock
-
getBounds
- Specified by:
getBoundsin classLayoutTrackView- Returns:
- the bounds of this turntable.
-
addRay
Add a ray at the specified angle.- Parameters:
angle- the angle- Returns:
- the RayTrack
-
getRayConnectIndexed
Get the connection for the ray with this index.- Parameters:
index- the index- Returns:
- the connection for the ray with this value of getConnectionIndex
-
getRayConnectOrdered
Get the connection for the ray at the index in the rayTrackList.- Parameters:
i- the index in the rayTrackList- Returns:
- the connection for the ray at that index in the rayTrackList or null
-
setRayConnect
Set the connection for the ray at the index in the rayTrackList.- Parameters:
ts- the connectionindex- the index in the rayTrackList
-
getRayTrackList
-
getNumberRays
Get the number of rays on turntable.- Returns:
- the number of rays
-
getRayIndex
Get the index for the ray at this position in the rayTrackList.- Parameters:
i- the position in the rayTrackList- Returns:
- the index
-
getRayAngle
Get the angle for the ray at this position in the rayTrackList.- Parameters:
i- the position in the rayTrackList- Returns:
- the angle
-
setRayTurnout
Set the turnout and state for the ray with this index.- Parameters:
index- the indexturnoutName- the turnout namestate- the state
-
getRayTurnoutName
Get the name of the turnout for the ray at this index.- Parameters:
i- the index- Returns:
- name of the turnout for the ray at this index
-
getRayTurnout
Get the turnout for the ray at this index.- Parameters:
i- the index- Returns:
- the turnout for the ray at this index
-
getRayTurnoutState
Get the state of the turnout for the ray at this index.- Parameters:
i- the index- Returns:
- state of the turnout for the ray at this index
-
isRayDisabled
Get if the ray at this index is disabled.- Parameters:
i- the index- Returns:
- true if disabled
-
setRayDisabled
Set the disabled state of the ray at this index.- Parameters:
i- the indexboo- the state
-
isRayDisabledWhenOccupied
Get the disabled when occupied state of the ray at this index.- Parameters:
i- the index- Returns:
- the state
-
setRayDisabledWhenOccupied
Set the disabled when occupied state of the ray at this index.- Parameters:
i- the indexboo- the state
-
getRayCoordsIndexed
Get the coordinates for the ray with this index.- Parameters:
index- the index- Returns:
- the coordinates
-
getRayCoordsOrdered
Get the coordinates for the ray at this index.- Parameters:
i- the index; zero point returned if this is out of range- Returns:
- the coordinates
-
setRayCoordsIndexed
Set the coordinates for the ray at this index.- Parameters:
x- the x coordinatesy- the y coordinatesindex- the index
-
setRayCoordsIndexed
Set the coordinates for the ray at this index.- Parameters:
point- the new coordinatesindex- the index
-
getCoordsForConnectionType
Get the coordinates for a specified connection type.- Specified by:
getCoordsForConnectionTypein classLayoutTrackView- Parameters:
connectionType- the connection type- Returns:
- the coordinates
-
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, 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
-
isMainlineIndexed
Test if ray with this index is a mainline track or not.Defaults to false (not mainline) if connecting track segment is missing.
- Parameters:
index- the index- Returns:
- true if connecting track segment is mainline
-
isMainlineOrdered
Test if ray at this index is a mainline track or not.Defaults to false (not mainline) if connecting track segment is missing
- Parameters:
i- the index- Returns:
- true if connecting track segment is mainline
-
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 (2D move) 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
-
findHitPointType
protected HitPointType findHitPointType(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)
-
isTurnoutControlled
Is this turntable turnout controlled?- Returns:
- true if so
-
setTurnoutControlled
Set if this turntable is turnout controlled.- Parameters:
boo- set true if so
-
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
-
showRayPopUp
-
setPosition
Set turntable position to the ray with this index.- Parameters:
index- the index
-
getPosition
Get the turntable position.- Returns:
- the turntable position
-
deleteRay
Delete this ray track.- Parameters:
rayTrack- the ray track
-
dispose
Clean up when this object is no longer needed. Should not be called while the object is still displayed; see remove(). -
remove
Remove this object from display and persistance. -
isActive
- Returns:
- "active" true means that the object is still displayed, and should be stored.
-
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 this turntable's controls.- Specified by:
drawTurnoutControlsin classLayoutTrackView- Parameters:
g2- the graphics port to draw to
-
drawEditControls
Draw this turntable's edit controls.- Specified by:
drawEditControlsin classLayoutTrackView- Parameters:
g2- the graphics port to draw to
-
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)
-
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.
-