Class TrackSegmentView
- All Implemented Interfaces:
InlineLogixNG
Arrows and bumpers are visual, presentation aspects handled in the View.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intMaximum length of the bumper decoration.static final intstatic final intstatic final intstatic final intintFields inherited from class jmri.jmrit.display.layoutEditor.LayoutTrackView
decorations, layoutEditor, NUM_ARROW_TYPES -
Constructor Summary
ConstructorsConstructorDescriptionTrackSegmentView(TrackSegment track, LayoutEditor layoutEditor) TrackSegmentView(TrackSegment track, LayoutEditor layoutEditor, boolean arc, boolean flip, boolean circle) constructor method. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbooleanCheck for active block boundaries.(package private) voidchangeType(int choice) 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 decorationsprotected voiddraw the edit controlsprotected voidDraw the turnout controlsprotected HitPointTypefindHitPointType(Point2D hitPoint, boolean useRectangles, boolean requireUnconnected) find the hit (location) type for a pointdoublegetAngle()intintintintArrow decoration accessor.getBezierControlPoint(int index) intintintintintdoubledoubledoubledoubledoublegetCH()doublegetConnection(HitPointType connectionType) get the LayoutTrack connected at the specified connection typeget center coordinatesgetCoordsForConnectionType(HitPointType connectionType) Get the coordinates for a specified connection type.doublegetCW()doublegetCX()doublegetCY()Get current decorationsdoubleGet the direction from end point 1 to 2.doubleGet the direction from end point 1 to 2.protected List<LayoutConnectivity>get the layout connectivity for this trackintgetPointReferences(HitPointType type, LayoutTrack conn) doubledoubleintintintgetType1()getType2()booleanbooleanvoidhideConstructionLines(int hide) Method used by LayoutEditor.protected voidhighlightUnconnected(Graphics2D g2, HitPointType selectedType) highlight unconnected connectionsbooleanisActive()Get state.booleanisArc()booleanbooleanbooleanbooleanbooleanisBezier()booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanisCircle()booleanisDashed()booleanisFlip()booleanbooleanbooleanbooleanbooleanprotected voidreCalculateTrackSegmentAngle(double x, double y) voidabstract method... subclasses should implement _IF_ they need to recheck their block boundariesvoidremove()Remove this object from display and persistance.booleanreplaceTrackConnection(LayoutTrack oldTrack, LayoutTrack newTrack, HitPointType newType) replace old track connection with new track connectionvoidrotateCoords(double angleDEG) rotate this LayoutTrack's coordinates by angleDEG'svoidscaleCoords(double xFactor, double yFactor) scale this LayoutTrack's coordinates by the x and y factorsvoidsetAllLayoutBlocks(LayoutBlock layoutBlock) Assign all the layout blocks in this trackvoidsetAngle(double x) voidsetArc(boolean boo) voidsetArrowColor(Color newVal) voidsetArrowDirIn(boolean newVal) voidsetArrowDirOut(boolean newVal) voidsetArrowEndStart(boolean newVal) voidsetArrowEndStop(boolean newVal) voidsetArrowGap(int newVal) voidsetArrowLength(int newVal) voidsetArrowLineWidth(int newVal) voidsetArrowStyle(int newVal) Set the arrow decoration.voidsetBezier(boolean bool) voidsetBezierControlPoint(Point2D p, int index) voidsetBridgeApproachWidth(int newVal) voidsetBridgeColor(Color newVal) voidsetBridgeDeckWidth(int newVal) voidsetBridgeHasEntry(boolean newVal) voidsetBridgeHasExit(boolean newVal) voidsetBridgeLineWidth(int newVal) voidsetBridgeSideLeft(boolean newVal) voidsetBridgeSideRight(boolean newVal) voidsetBumperColor(Color newVal) voidsetBumperEndStart(boolean newVal) voidsetBumperEndStop(boolean newVal) voidsetBumperFlipped(boolean newVal) voidsetBumperLength(int newVal) voidsetBumperLineWidth(int newVal) voidvoidsetCentreSegX(double x) voidsetCentreSegY(double y) voidsetCentreX(double x) voidsetCentreY(double y) voidsetCH(double CH) voidsetChordLength(double chord) voidsetCircle(boolean boo) voidsetConnection(HitPointType connectionType, LayoutTrack o, HitPointType type) set the LayoutTrack connected at the specified connection typevoidsetCoordsCenter(Point2D newCenterPoint) Set center coordinates.voidset center coordinatesvoidsetCW(double CW) voidsetCX(double CX) voidsetCY(double CY) voidsetDashed(boolean dash) voidsetDecorations(Map<String, String> decorations) Set new decorations This is a complete replacement of the decorations, not an appending.voidsetFlip(boolean boo) voidsetLayoutBlock(LayoutBlock newLayoutBlock) Set up a LayoutBlock for this Track Segment.voidsetLayoutBlockByName(String name) Set up a LayoutBlock for this Track Segment.protected voidsetNewConnect1(LayoutTrack connectTrack, HitPointType connectionType) set a new connection 1protected voidsetNewConnect2(LayoutTrack connectTrack, HitPointType connectionType) set a new connection 2voidsetStartAdj(double startAdj) voidsetTmpAngle(double a) voidvoidvoidsetTunnelColor(Color newVal) voidsetTunnelEntranceWidth(int newVal) voidsetTunnelFloorWidth(int newVal) voidsetTunnelHasEntry(boolean newVal) voidsetTunnelHasExit(boolean newVal) voidsetTunnelLineWidth(int newVal) voidsetTunnelSideLeft(boolean newVal) voidsetTunnelSideRight(boolean newVal) protected voidshowBezierPopUp(JmriMouseEvent e, HitPointType hitPointType) Display popup menu for information and editing.protected JPopupMenushowPopup(JmriMouseEvent mouseEvent) show the popup menu for this layout trackvoidsplit a track segment into two track segments with an anchor point in between.toString()Get debugging string for the TrackSegment.booleanDetermine if we need to redraw a curved piece of track.voidvoidtranslateCoords(double xFactor, double yFactor) translate this LayoutTrack's coordinates by the x and y factorsvoidMethods inherited from class jmri.jmrit.display.layoutEditor.LayoutTrackView
addCommonPopupItems, displayRemoveWarningDialog, drawHidden, drawLayoutTrackText, findHitPointType, findHitPointType, getColorForTrackBlock, getColorForTrackBlock, getCoordsCenter, getEditorName, getId, getLayoutEditor, getLayoutEditorToolBarPanel, getLayoutTrack, getLogixNG, getName, getNameString, getTurnoutStateString, getTypeName, getX, getY, highlightUnconnected, isDisconnected, isHidden, loadArrowImageToJCBItem, removeInlineLogixNG, rotatePoint, setColorForTrackBlock, setColorForTrackBlock, setHidden, setIdent, setLogixNG, setLogixNG_SystemName, setLogixNGPositionableMenu, setupLogixNG, showPopup, showPopup, trackControlCircleAt, trackControlCircleRectAt, trackEditControlCircleAt
-
Field Details
-
tConnect1Name
-
tConnect2Name
-
tLayoutBlockName
-
MAX_BUMPER_LENGTH
Maximum length of the bumper decoration.- See Also:
-
MIN_BUMPER_LENGTH
- See Also:
-
MAX_BUMPER_WIDTH
- See Also:
-
MIN_BUMPER_WIDTH
- See Also:
-
SHOWCON
- See Also:
-
HIDECON
- See Also:
-
HIDECONALL
- See Also:
-
showConstructionLine
-
-
Constructor Details
-
TrackSegmentView
-
TrackSegmentView
public TrackSegmentView(@Nonnull TrackSegment track, @Nonnull LayoutEditor layoutEditor, boolean arc, boolean flip, boolean circle) constructor method.- Parameters:
track- the track segment to viewlayoutEditor- for reference to toolsarc- specify displayflip- specify displaycircle- specify display
-
-
Method Details
-
getTrackSegment
-
toString
Get debugging string for the TrackSegment. -
getBlockName
-
getType1
-
getType2
-
getConnect1
-
getConnect2
-
setNewConnect1
set a new connection 1- Parameters:
connectTrack- the track we want to connect toconnectionType- where on that track we want to be connected
-
setNewConnect2
set a new connection 2- Parameters:
connectTrack- the track we want to connect toconnectionType- where on that track we want to be connected
-
replaceTrackConnection
public boolean replaceTrackConnection(@CheckForNull LayoutTrack oldTrack, @CheckForNull LayoutTrack newTrack, HitPointType newType) replace old track connection with new track connection- Parameters:
oldTrack- the old track connectionnewTrack- the new track connectionnewType- type of the new track connection- Returns:
- true if successful
-
isDashed
- Returns:
- true if track segment should be drawn dashed
-
setDashed
-
isArc
- Returns:
- true if track segment is an arc
-
setArc
-
isCircle
- Returns:
- true if track segment is circle
-
setCircle
-
isFlip
- Returns:
- true if track segment circle or arc should be drawn flipped
-
setFlip
-
isBezier
- Returns:
- true if track segment is a bezier curve
-
setBezier
- Parameters:
bool- Set true to turn on Bezier curve representation.
-
getAngle
-
setAngle
-
getDirectionRAD
Get the direction from end point 1 to 2.Note: Goes CW from east (0) to south (PI/2) to west (PI) to north (PI*3/2), etc.
- Returns:
- The direction (in radians)
-
getDirectionDEG
Get the direction from end point 1 to 2.Note: Goes CW from east (0) to south (90) to west (180) to north (270), etc.
- Returns:
- the direction (in degrees)
-
trackNeedsRedraw
Determine if we need to redraw a curved piece of track. Saves having to recalculate the circle details each time.- Returns:
- true means needs to be (re)drawn
-
trackRedrawn
-
getLayoutBlock
-
getConnect1Name
-
getConnect2Name
-
getConnection
Description copied from class:LayoutTrackViewget 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 typeThis implementation does nothing because
setNewConnect1(jmri.jmrit.display.layoutEditor.LayoutTrack, jmri.jmrit.display.layoutEditor.HitPointType)andsetNewConnect2(jmri.jmrit.display.layoutEditor.LayoutTrack, jmri.jmrit.display.layoutEditor.HitPointType)should be used instead.- 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
-
getNumberOfBezierControlPoints
-
getBezierControlPoint
- Parameters:
index- If negative, this is index from the end i.e. -1 is the last element- Returns:
- Reference to the indexed control point
-
setBezierControlPoint
- Parameters:
p- the location of the point to be setindex- If negative, this is index from the end i.e. -1 is the last element
-
getBezierControlPoints
-
setLayoutBlock
Set up a LayoutBlock for this Track Segment.- Parameters:
newLayoutBlock- the LayoutBlock to set
-
setLayoutBlockByName
Set up a LayoutBlock for this Track Segment.- Parameters:
name- the name of the new LayoutBlock
-
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
-
setCoordsCenter
Set center coordinates.- Overrides:
setCoordsCenterin classLayoutTrackView- Parameters:
newCenterPoint- the coordinates to set
-
updateBlockInfo
-
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)
-
getCoordsForConnectionType
Get the coordinates for a specified connection type.- 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 segment
-
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
-
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.
-
getPointReferences
-
splitTrackSegment
split a track segment into two track segments with an anchor point in between. -
showBezierPopUp
Display popup menu for information and editing.- Parameters:
e- The original event causing thishitPointType- the type of the underlying hit
-
changeType
-
dispose
Clean up when this object is no longer needed.Should not be called while the object is still displayed.
- See Also:
-
remove
Remove this object from display and persistance. -
isActive
Get state. "active" means that the object is still displayed, and should be stored.- Returns:
- true if active
-
isShowConstructionLines
- Returns:
- true if HIDECON is not set and HIDECONALL is not set
-
hideConstructionLines
Method used by LayoutEditor.If the argument is
- HIDECONALL then set HIDECONALL
- SHOWCON reset HIDECONALL is set, other wise set SHOWCON
- HIDECON or otherwise set HIDECON
- Parameters:
hide- The specification i.e. HIDECONALL, SHOWCON et al
-
hideConstructionLines
- Returns:
- true if SHOWCON is not set
-
getTmpPt1
-
getTmpPt2
-
setTmpPt1
-
setTmpPt2
-
getCX
-
setCX
-
getCY
-
setCY
-
getCW
-
setCW
-
getCH
-
setCH
-
getStartAdj
-
setStartAdj
-
getCentreSegX
-
setCentreSegX
-
getCentreSegY
-
setCentreSegY
-
getCentreSeg
- Returns:
- the location of the middle of the segment (on the segment)
-
setCentreSeg
-
getCentreX
-
setCentreX
-
getCentreY
-
setCentreY
-
getCentre
-
getTmpAngle
-
setTmpAngle
-
getCoordsCenterCircle
get center coordinates- Returns:
- the center coordinates
-
setCoordsCenterCircle
set center coordinates- Parameters:
p- the coordinates to set
-
getChordLength
-
setChordLength
-
reCalculateTrackSegmentAngle
-
calculateTrackSegmentAngle
-
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 contextselectedType- the specific connection to draw (or NONE for all)
-
drawEditControls
Description copied from class:LayoutTrackViewdraw the edit controls- Specified by:
drawEditControlsin classLayoutTrackView- Parameters:
g2- the graphics context
-
drawTurnoutControls
Description copied from class:LayoutTrackViewDraw the turnout controls- Specified by:
drawTurnoutControlsin classLayoutTrackView- Parameters:
g2- the graphics context
-
reCheckBlockBoundary
abstract method... subclasses should implement _IF_ they need to recheck their block boundaries- Specified by:
reCheckBlockBoundaryin classLayoutTrackView
-
drawDecorations
Draw track decorations- Specified by:
drawDecorationsin classLayoutTrackView- Parameters:
g2- the graphics context
-
hasDecorations
- Overrides:
hasDecorationsin classLayoutTrackView- Returns:
- true if this track segment has decorations
-
getDecorations
Get current decorations- Overrides:
getDecorationsin classLayoutTrackView- Returns:
- the decorations
-
setDecorations
Set new decorations This is a complete replacement of the decorations, not an appending.- Overrides:
setDecorationsin classLayoutTrackView- Parameters:
decorations- A map from strings ("arrow", "bridge", "bumper",..) to specific value strings ("single", "entry;right", ), perhaps including multiple values separated by semicolons.
-
getArrowStyle
Arrow decoration accessor. The 0 (none) and 1 through 5 arrow decorations are keyed to files like program:resources/icons/decorations/ArrowStyle1.png et al.- Returns:
- Style number
-
setArrowStyle
Set the arrow decoration. The 0 (none) and 1 through 5 arrow decorations are keyed to files like program:resources/icons/decorations/ArrowStyle1.png et al.- Parameters:
newVal- the new style number
-
isArrowEndStart
-
setArrowEndStart
-
isArrowEndStop
-
setArrowEndStop
-
isArrowDirIn
-
setArrowDirIn
-
isArrowDirOut
-
setArrowDirOut
-
getArrowColor
-
setArrowColor
-
getArrowLineWidth
-
setArrowLineWidth
-
getArrowLength
-
setArrowLength
-
getArrowGap
-
setArrowGap
-
isBridgeSideRight
-
setBridgeSideRight
-
isBridgeSideLeft
-
setBridgeSideLeft
-
isBridgeHasEntry
-
setBridgeHasEntry
-
isBridgeHasExit
-
setBridgeHasExit
-
getBridgeColor
-
setBridgeColor
-
getBridgeDeckWidth
-
setBridgeDeckWidth
-
getBridgeLineWidth
-
setBridgeLineWidth
-
getBridgeApproachWidth
-
setBridgeApproachWidth
-
isBumperEndStart
-
setBumperEndStart
-
isBumperEndStop
-
setBumperEndStop
-
getBumperColor
-
setBumperColor
-
getBumperLineWidth
-
setBumperLineWidth
-
getBumperLength
-
setBumperLength
-
isBumperFlipped
-
setBumperFlipped
-
isTunnelSideRight
-
setTunnelSideRight
-
isTunnelSideLeft
-
setTunnelSideLeft
-
isTunnelHasEntry
-
setTunnelHasEntry
-
isTunnelHasExit
-
setTunnelHasExit
-
getTunnelColor
-
setTunnelColor
-
getTunnelFloorWidth
-
setTunnelFloorWidth
-
getTunnelLineWidth
-
setTunnelLineWidth
-
getTunnelEntranceWidth
-
setTunnelEntranceWidth
-
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)
-