Class LayoutTrackView
- All Implemented Interfaces:
InlineLogixNG
- Direct Known Subclasses:
LayoutTurnoutView,LayoutTurntableView,LevelXingView,PositionablePointView,TrackSegmentView
This contains the display information, including screen geometry, for a
LayoutEditor panel. The geometry/connectivity information is held in
LayoutTrack subclasses.
- Position(s) of the screen icons and its parts, typically the center; scaling and translation; size and bounds
- Line colors
- Flipped status; drawing details like bezier curve points
- Various decorations: arrows, tunnels, bridges
- Hidden status
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLayoutTrackView(LayoutTrack track, Point2D c, LayoutEditor layoutEditor) constructor methodLayoutTrackView(LayoutTrack track, LayoutEditor layoutEditor) Constructor method. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCommonPopupItems(JmriMouseEvent mouseEvent, JPopupMenu popup) Att items to the popup menu that's common to all implementing classes.abstract booleanCheck for active block boundaries.abstract List<HitPointType>return a list of the available connections for this layout trackabstract voidcheck this track and its neighbors for non-contiguous blocksabstract booleandetermine if all the appropriate blocks have been assigned to this trackabstract voidcollectContiguousTracksNamesInBlockNamed(String blockName, Set<String> TrackNameSet) recursive routine to check for all contiguous tracks in this blockNamefinal voiddisplayRemoveWarningDialog(List<String> itemList, String typeKey) Display the attached items that prevent removing the layout track item.protected abstract voiddraw1(Graphics2D g2, boolean isMain, boolean isBlock) draw one line (Ballast, ties, center or 3rd rail, block lines)protected abstract voiddraw2(Graphics2D g2, boolean isMain, float railDisplacement) draw two lines (rails)protected abstract voidDraw track decorationsprotected abstract voiddraw the edit controlsprotected final voiddrawHidden(Graphics2D g2) draw hidden trackprotected final voiddraw the text for this layout trackprotected abstract voidDraw the turnout controlsprotected final HitPointTypeprotected final HitPointTypefindHitPointType(Point2D p, boolean useRectangles) protected abstract HitPointTypefindHitPointType(Point2D hitPoint, boolean useRectangles, boolean requireUnconnected) find the hit (location) type for a pointabstract Rectangle2Dprotected final Colorprotected final ColorgetColorForTrackBlock(LayoutBlock layoutBlock, boolean forceBlockTrackColor) abstract LayoutTrackgetConnection(HitPointType connectionType) get the LayoutTrack connected at the specified connection typeSet center coordinatesabstract Point2DgetCoordsForConnectionType(HitPointType connectionType) return the coordinates for a specified connection type (abstract: should be overridden by ALL subclasses)Get current decorationsGet the LogixNG of this InlineLogixNG.final StringgetId()protected abstract List<LayoutConnectivity>get the layout connectivity for this trackfinal LayoutEditorToolBarPanelconvenience method for accessing...Get the LogixNG of this Positionable.final StringgetName()Get the name of this InlineLogixNG.final StringgetTurnoutStateString(int turnoutState) get turnout state stringGet the type of item of this InlineLogixNG.intgetX()Get the X position of this InlineLogixNG.intgetY()Get the Y position of this InlineLogixNG.booleanprotected final voidprotected abstract voidhighlightUnconnected(Graphics2D g2, HitPointType specificType) highlight unconnected connectionsbooleanisDisconnected(HitPointType connectionType) return true if this connection type is disconnectedfinal booleanisHidden()Get the hidden state of the track element.loadArrowImageToJCBItem(int n, JMenu arrowsCountMenu) Load a file for a specific arrow ending.protected abstract voidabstract method... subclasses should implement _IF_ they need to recheck their block boundariesprotected booleanabstract voidrotateCoords(double angleDEG) rotate this LayoutTrack's coordinates by angleDEG'sprotected final Point2DrotatePoint(Point2D p, double sineRot, double cosineRot) abstract voidscaleCoords(double xFactor, double yFactor) scale this LayoutTrack's coordinates by the x and y factorsabstract voidsetAllLayoutBlocks(LayoutBlock layoutBlock) Assign all the layout blocks in this trackprotected final Colorprotected final ColorsetColorForTrackBlock(Graphics2D g2, LayoutBlock layoutBlock, boolean forceBlockTrackColor) abstract voidsetConnection(HitPointType connectionType, LayoutTrack o, HitPointType type) set the LayoutTrack connected at the specified connection typevoidSet center coordinates.voidsetDecorations(Map<String, String> decorations) Set new decorations This is a complete replacement of the decorations, not an appending.final voidsetHidden(boolean hide) protected final voidvoidsetLogixNG(LogixNG logixNG) Set the LogixNG of this Positionable.voidsetLogixNG_SystemName(String systemName) Set the system name for the LogixNG of this InlineLogixNG.voidAdd a menu entry to edit Id of the Positionable itemvoidSetup the LogixNG of this InlineLogixNG.protected final JPopupMenushow the popup menu for this layout trackprotected final JPopupMenushow the popup menu for this layout trackprotected abstract JPopupMenushowPopup(JmriMouseEvent mouseEvent) show the popup menu for this layout trackfinal Ellipse2DtrackControlCircleAt(Point2D inPoint) final Rectangle2DtrackControlCircleRectAt(Point2D inPoint) final Ellipse2DtrackEditControlCircleAt(Point2D inPoint) abstract voidtranslateCoords(double xFactor, double yFactor) translate this LayoutTrack's coordinates by the x and y factors
-
Field Details
-
layoutEditor
-
decorations
-
NUM_ARROW_TYPES
- See Also:
-
-
Constructor Details
-
LayoutTrackView
Constructor method.- Parameters:
track- the layout track to viewlayoutEditor- the panel in which to place the view
-
LayoutTrackView
public LayoutTrackView(@Nonnull LayoutTrack track, @Nonnull Point2D c, @Nonnull LayoutEditor layoutEditor) constructor method- Parameters:
track- the track to viewc- display locationlayoutEditor- for reference to tools
-
-
Method Details
-
getId
-
getName
-
getLayoutEditor
-
setIdent
-
getLayoutTrack
-
getCoordsCenter
Set center coordinates- Returns:
- The center coordinates
-
setCoordsCenter
Set center coordinates.Some subtypes may reimplement this is "center" is a more complicated idea, i.e. for Bezier curves
- Parameters:
p- the coordinates to set
-
hasDecorations
- Returns:
- true if this track segment has decorations
-
getDecorations
Get current decorations- Returns:
- the decorations
-
setDecorations
Set new decorations This is a complete replacement of the decorations, not an appending.- Parameters:
decorations- A map from strings ("arrow", "bridge", "bumper",..) to specific value strings ("single", "entry;right", ), perhaps including multiple values separated by semicolons.
-
getLayoutEditorToolBarPanel
convenience method for accessing...- Returns:
- the layout editor's toolbar panel
-
trackEditControlCircleAt
-
trackControlCircleAt
-
trackControlCircleRectAt
-
getColorForTrackBlock
protected final Color getColorForTrackBlock(@CheckForNull LayoutBlock layoutBlock, boolean forceBlockTrackColor) -
getColorForTrackBlock
-
setColorForTrackBlock
protected final Color setColorForTrackBlock(Graphics2D g2, @CheckForNull LayoutBlock layoutBlock, boolean forceBlockTrackColor) -
setColorForTrackBlock
-
draw1
draw one line (Ballast, ties, center or 3rd rail, block lines)- Parameters:
g2- the graphics contextisMain- true if drawing mainlinesisBlock- true if drawing block lines
-
draw2
draw two lines (rails)- Parameters:
g2- the graphics contextisMain- true if drawing mainlinesrailDisplacement- the offset from center to draw the lines
-
drawHidden
draw hidden track- Parameters:
g2- the graphics context
-
drawLayoutTrackText
draw the text for this layout track- Parameters:
g- note: currently can't override (final); change this if you need to
-
loadArrowImageToJCBItem
Load a file for a specific arrow ending.- Parameters:
n- The arrow type as a numberarrowsCountMenu- menu containing the arrows to set visible selection- Returns:
- An item for the arrow menu
-
highlightUnconnected
highlight unconnected connections- Parameters:
g2- the graphics contextspecificType- the specific connection to draw (or NONE for all)
-
highlightUnconnected
-
drawEditControls
draw the edit controls- Parameters:
g2- the graphics context
-
drawTurnoutControls
Draw the turnout controls- Parameters:
g2- the graphics context
-
drawDecorations
Draw track decorations- Parameters:
g2- the graphics context
-
isHidden
Get the hidden state of the track element.- Returns:
- true if hidden; false otherwise
-
setHidden
-
getTurnoutStateString
get turnout state string- Parameters:
turnoutState- of the turnout- Returns:
- the turnout state string
-
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.
- Returns:
- true if the layout track object can be deleted.
-
displayRemoveWarningDialog
Display the attached items that prevent removing the layout track item.- Parameters:
itemList- A list of the attached heads, masts and/or sensors.typeKey- The object type such as Turnout, Level Crossing, etc.
-
scaleCoords
scale this LayoutTrack's coordinates by the x and y factors- 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- Parameters:
xFactor- the amount to translate X coordinatesyFactor- the amount to translate Y coordinates
-
rotateCoords
rotate this LayoutTrack's coordinates by angleDEG's- Parameters:
angleDEG- the amount to rotate in degrees
-
rotatePoint
-
findHitPointType
protected abstract HitPointType findHitPointType(@Nonnull Point2D hitPoint, boolean useRectangles, boolean requireUnconnected) find the hit (location) type for a point- 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)
- Since:
- 7.4.3
-
findHitPointType
-
findHitPointType
-
getCoordsForConnectionType
return the coordinates for a specified connection type (abstract: should be overridden by ALL subclasses)- Parameters:
connectionType- the connection type- Returns:
- the coordinates for the specified connection type
-
getBounds
- Returns:
- the bounds of this track
-
showPopup
show the popup menu for this layout track- Parameters:
mouseEvent- the mouse down event that triggered this popup- Returns:
- the popup menu for this layout track
-
addCommonPopupItems
Att items to the popup menu that's common to all implementing classes.- Parameters:
mouseEvent- the mouse down event that triggered this popuppopup- the popup menu
-
getNameString
Description copied from interface:InlineLogixNGGet the name of this InlineLogixNG.- Specified by:
getNameStringin interfaceInlineLogixNG- Returns:
- the name
-
getEditorName
Description copied from interface:InlineLogixNGGet the LogixNG of this InlineLogixNG.- Specified by:
getEditorNamein interfaceInlineLogixNG- Returns:
- the LogixNG or null if it has no LogixNG
-
getX
Description copied from interface:InlineLogixNGGet the X position of this InlineLogixNG.- Specified by:
getXin interfaceInlineLogixNG- Returns:
- the X position
-
getY
Description copied from interface:InlineLogixNGGet the Y position of this InlineLogixNG.- Specified by:
getYin interfaceInlineLogixNG- Returns:
- the Y position
-
getTypeName
Description copied from interface:InlineLogixNGGet the type of item of this InlineLogixNG.- Specified by:
getTypeNamein interfaceInlineLogixNG- Returns:
- the type
-
setLogixNGPositionableMenu
Add a menu entry to edit Id of the Positionable item- Parameters:
popup- the menu to add the entry to
-
getLogixNG
Get the LogixNG of this Positionable.- Specified by:
getLogixNGin interfaceInlineLogixNG- Returns:
- the LogixNG or null if it has no LogixNG
-
setLogixNG
Set the LogixNG of this Positionable.- Specified by:
setLogixNGin interfaceInlineLogixNG- Parameters:
logixNG- the LogixNG or null if remove the LogixNG from the Positionable
-
setLogixNG_SystemName
Description copied from interface:InlineLogixNGSet the system name for the LogixNG of this InlineLogixNG.- Specified by:
setLogixNG_SystemNamein interfaceInlineLogixNG- Parameters:
systemName- the system name
-
setupLogixNG
Description copied from interface:InlineLogixNGSetup the LogixNG of this InlineLogixNG.- Specified by:
setupLogixNGin interfaceInlineLogixNG
-
showPopup
show the popup menu for this layout track- Parameters:
where- to show the popup- Returns:
- the popup menu for this layout track
-
showPopup
show the popup menu for this layout track- Returns:
- the popup menu for this layout track
-
getConnection
get the LayoutTrack connected at the specified connection type- 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 abstract void setConnection(HitPointType connectionType, LayoutTrack o, HitPointType type) throws JmriException set the LayoutTrack connected at the specified connection type- 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
-
reCheckBlockBoundary
abstract method... subclasses should implement _IF_ they need to recheck their block boundaries -
getLayoutConnectivity
get the layout connectivity for this track- Returns:
- the list of Layout Connectivity objects
-
isDisconnected
return true if this connection type is disconnected- Parameters:
connectionType- the connection type to test- Returns:
- true if the connection for this connection type is free
-
checkForFreeConnections
return a list of the available connections for this layout track- Returns:
- the list of available connections
-
checkForUnAssignedBlocks
determine if all the appropriate blocks have been assigned to this track- Returns:
- true if all appropriate blocks have been assigned
-
checkForNonContiguousBlocks
public abstract void checkForNonContiguousBlocks(@Nonnull HashMap<String, List<Set<String>>> blockNamesToTrackNameSetMaps) 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)
- Parameters:
blockNamesToTrackNameSetMaps- hashmap of key:block names to lists of track name sets for those blocks
-
collectContiguousTracksNamesInBlockNamed
public abstract void collectContiguousTracksNamesInBlockNamed(@Nonnull String blockName, @Nonnull Set<String> TrackNameSet) recursive routine to check for all contiguous tracks in this blockName- 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- Parameters:
layoutBlock- to this layout block (used by the Tools menu's "Assign block to selection" item)
-
removeInlineLogixNG
-