Package jmri.jmrit.display.layoutEditor
Class PositionablePointView
- java.lang.Object
-
- jmri.jmrit.display.layoutEditor.LayoutTrackView
-
- jmri.jmrit.display.layoutEditor.PositionablePointView
-
- All Implemented Interfaces:
InlineLogixNG
public class PositionablePointView extends LayoutTrackView
MVC View component for the PositionablePoint class.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) javax.swing.JDialog
editLink
(package private) javax.swing.JComboBox<JCBHandle<LayoutEditor>>
editorCombo
(package private) javax.swing.JComboBox<java.lang.String>
linkPointsBox
protected NamedBeanHandle<SignalHead>
signalEastHeadNamed
protected NamedBeanHandle<SignalHead>
signalWestHeadNamed
java.lang.String
trackSegment1Name
java.lang.String
trackSegment2Name
(package private) int
xClick
(package private) int
yClick
-
Fields inherited from class jmri.jmrit.display.layoutEditor.LayoutTrackView
decorations, layoutEditor, NUM_ARROW_TYPES
-
-
Constructor Summary
Constructors Constructor Description PositionablePointView(PositionablePoint point, java.awt.geom.Point2D c, LayoutEditor layoutEditor)
constructor method.
-
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 blockName(package private) void
dispose()
Clean up when this object is no longer needed.protected void
draw1(java.awt.Graphics2D g2, boolean isMain, boolean isBlock)
draw one line (Ballast, ties, center or 3rd rail, block lines)protected void
draw2(java.awt.Graphics2D g2, boolean isMain, float railDisplacement)
draw two lines (rails)protected void
drawDecorations(java.awt.Graphics2D g2)
Draw track decorations.protected void
drawEditControls(java.awt.Graphics2D g2)
draw the edit controlsprotected void
drawTurnoutControls(java.awt.Graphics2D g2)
Draw the turnout controlsprotected HitPointType
findHitPointType(java.awt.geom.Point2D hitPoint, boolean useRectangles, boolean requireUnconnected)
find the hit (location) type for a pointjava.awt.geom.Rectangle2D
getBounds()
TrackSegment
getConnect1()
protected int
getConnect1Dir()
TrackSegment
getConnect2()
LayoutTrack
getConnection(HitPointType connectionType)
get the LayoutTrack connected at the specified connection typejava.awt.geom.Point2D
getCoordsForConnectionType(HitPointType connectionType)
return the coordinates for a specified connection typeSensor
getEastBoundSensor()
java.lang.String
getEastBoundSensorName()
java.lang.String
getEastBoundSignal()
SignalHead
getEastBoundSignalHead()
SignalMast
getEastBoundSignalMast()
java.lang.String
getEastBoundSignalMastName()
protected java.util.List<LayoutConnectivity>
getLayoutConnectivity()
get the layout connectivity for this trackLayoutEditor
getLinkedEditor()
java.lang.String
getLinkedEditorName()
PositionablePoint
getLinkedPoint()
java.lang.String
getLinkedPointId()
javax.swing.JPanel
getLinkPanel()
PositionablePoint
getPoint()
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()
Accessor methodsSensor
getWestBoundSensor()
java.lang.String
getWestBoundSensorName()
java.lang.String
getWestBoundSignal()
SignalHead
getWestBoundSignalHead()
SignalMast
getWestBoundSignalMast()
java.lang.String
getWestBoundSignalMastName()
protected void
highlightUnconnected(java.awt.Graphics2D g2, HitPointType specificType)
highlight unconnected connectionsprotected boolean
isActive()
boolean
isDisconnected(HitPointType connectionType)
return true if this connection type is disconnectedprotected int
maxHeight()
protected int
maxWidth()
void
mouseClicked(JmriMouseEvent e)
void
mousePressed(JmriMouseEvent e)
void
mouseReleased(JmriMouseEvent e)
void
reCheckBlockBoundary()
abstract method... subclasses should implement _IF_ they need to recheck their block boundariesvoid
removeBeanReference(NamedBean nb)
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
rotateCoords(double angleDEG)
rotate this LayoutTrack's coordinates by angleDEG'svoid
scaleCoords(double xFactor, double yFactor)
scale this LayoutTrack's coordinates by the x and y factorsvoid
setAllLayoutBlocks(LayoutBlock layoutBlock)
Assign all the layout blocks in this trackvoid
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)
(package private) void
setLink()
void
setLinkedPoint(PositionablePoint p)
boolean
setTrackConnection(TrackSegment track)
setup a connection to a trackvoid
setType(PositionablePoint.PointType newType)
void
setWestBoundSensor(java.lang.String sensorName)
void
setWestBoundSignal(java.lang.String signalName)
void
setWestBoundSignalMast(java.lang.String signalMast)
protected javax.swing.JPopupMenu
showPopup(JmriMouseEvent mouseEvent)
show the popup menu for this layout trackjava.lang.String
toString()
void
translateCoords(double xFactor, double yFactor)
translate this LayoutTrack's coordinates by the x and y factorsvoid
updateLink()
(package private) void
updatePointBox()
-
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, isHidden, loadArrowImageToJCBItem, removeInlineLogixNG, rotatePoint, setColorForTrackBlock, setColorForTrackBlock, setCoordsCenter, setDecorations, setHidden, setIdent, setLogixNG, setLogixNG_SystemName, setLogixNGPositionableMenu, setupLogixNG, showPopup, showPopup, trackControlCircleAt, trackControlCircleRectAt, trackEditControlCircleAt
-
-
-
-
Field Detail
-
signalEastHeadNamed
protected NamedBeanHandle<SignalHead> signalEastHeadNamed
-
signalWestHeadNamed
protected NamedBeanHandle<SignalHead> signalWestHeadNamed
-
trackSegment1Name
public java.lang.String trackSegment1Name
-
trackSegment2Name
public java.lang.String trackSegment2Name
-
xClick
int xClick
-
yClick
int yClick
-
editLink
javax.swing.JDialog editLink
-
linkPointsBox
javax.swing.JComboBox<java.lang.String> linkPointsBox
-
editorCombo
javax.swing.JComboBox<JCBHandle<LayoutEditor>> editorCombo
-
-
Constructor Detail
-
PositionablePointView
public PositionablePointView(@Nonnull PositionablePoint point, java.awt.geom.Point2D c, @Nonnull LayoutEditor layoutEditor)
constructor method.- Parameters:
point
- the positionable point.c
- location to display the positionable pointlayoutEditor
- for access to tools
-
-
Method Detail
-
getPoint
public PositionablePoint getPoint()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getType
public PositionablePoint.PointType getType()
Accessor methods- Returns:
- Type enum for this Positionable Point
-
setType
public void setType(PositionablePoint.PointType newType)
-
getConnect1
public TrackSegment getConnect1()
-
getConnect2
public TrackSegment getConnect2()
-
getLinkedEditorName
public java.lang.String getLinkedEditorName()
-
getLinkedEditor
public LayoutEditor getLinkedEditor()
-
getLinkedPoint
public PositionablePoint getLinkedPoint()
-
removeLinkedPoint
public void removeLinkedPoint()
-
getLinkedPointId
public java.lang.String getLinkedPointId()
-
setLinkedPoint
public void setLinkedPoint(PositionablePoint p)
-
scaleCoords
public void scaleCoords(double xFactor, double yFactor)
scale this LayoutTrack's coordinates by the x and y factors- Specified by:
scaleCoords
in classLayoutTrackView
- Parameters:
xFactor
- the amount to scale X coordinatesyFactor
- the amount to scale Y coordinates
-
translateCoords
public void translateCoords(double xFactor, double yFactor)
translate this LayoutTrack's coordinates by the x and y factors- Specified by:
translateCoords
in classLayoutTrackView
- Parameters:
xFactor
- the amount to translate X coordinatesyFactor
- the amount to translate Y coordinates
-
rotateCoords
public void rotateCoords(double angleDEG)
rotate this LayoutTrack's coordinates by angleDEG's- Specified by:
rotateCoords
in classLayoutTrackView
- Parameters:
angleDEG
- the amount to rotate in degrees
-
getBounds
public java.awt.geom.Rectangle2D getBounds()
- Specified by:
getBounds
in classLayoutTrackView
- Returns:
- the bounds of this positional point
-
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()
-
setEastBoundSignalMast
public void setEastBoundSignalMast(java.lang.String signalMast)
-
getWestBoundSignalMastName
@CheckReturnValue @Nonnull public java.lang.String getWestBoundSignalMastName()
-
getWestBoundSignalMast
@CheckReturnValue public SignalMast getWestBoundSignalMast()
-
setWestBoundSignalMast
public void setWestBoundSignalMast(java.lang.String signalMast)
-
removeBeanReference
public void removeBeanReference(NamedBean nb)
-
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)
-
maxWidth
protected int maxWidth()
-
maxHeight
protected int maxHeight()
-
mousePressed
public void mousePressed(JmriMouseEvent e)
-
mouseReleased
public void mouseReleased(JmriMouseEvent e)
-
mouseClicked
public void mouseClicked(JmriMouseEvent e)
-
showPopup
@Nonnull protected javax.swing.JPopupMenu showPopup(@Nonnull JmriMouseEvent mouseEvent)
show the popup menu for this layout track- Specified by:
showPopup
in classLayoutTrackView
- Parameters:
mouseEvent
- the mouse down event that triggered this popup- Returns:
- the popup menu for this layout track
-
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 classLayoutTrackView
- 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.
-
dispose
void dispose()
Clean up when this object is no longer needed. Should not be called while the object is still displayed; see remove()
-
isActive
protected boolean isActive()
- Returns:
- "active" true means that the object is still displayed, and should be stored.
-
getConnect1Dir
protected int getConnect1Dir()
-
setLink
void setLink()
-
getLinkPanel
public javax.swing.JPanel getLinkPanel()
-
updatePointBox
void updatePointBox()
-
updateLink
public void updateLink()
-
findHitPointType
protected HitPointType findHitPointType(java.awt.geom.Point2D hitPoint, boolean useRectangles, boolean requireUnconnected)
find the hit (location) type for a point- Specified by:
findHitPointType
in 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
public java.awt.geom.Point2D getCoordsForConnectionType(HitPointType connectionType)
return the coordinates for a specified connection type- Specified by:
getCoordsForConnectionType
in classLayoutTrackView
- Parameters:
connectionType
- the connection type- Returns:
- the coordinates for the specified connection type
-
getConnection
public LayoutTrack getConnection(HitPointType connectionType) throws JmriException
get the LayoutTrack connected at the specified connection type- Specified by:
getConnection
in 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:
setConnection
in 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
-
isDisconnected
public boolean isDisconnected(HitPointType connectionType)
return true if this connection type is disconnected- Overrides:
isDisconnected
in classLayoutTrackView
- Parameters:
connectionType
- the connection type to test- Returns:
- true if the connection for this connection type is free
-
drawDecorations
protected void drawDecorations(java.awt.Graphics2D g2)
Draw track decorations.This type of track has none, so this method is empty.
- Specified by:
drawDecorations
in classLayoutTrackView
- Parameters:
g2
- the graphics context
-
draw1
protected void draw1(java.awt.Graphics2D g2, boolean isMain, boolean isBlock)
draw one line (Ballast, ties, center or 3rd rail, block lines)- Specified by:
draw1
in classLayoutTrackView
- Parameters:
g2
- the graphics contextisMain
- true if drawing mainlinesisBlock
- true if drawing block lines
-
draw2
protected void draw2(java.awt.Graphics2D g2, boolean isMain, float railDisplacement)
draw two lines (rails)- Specified by:
draw2
in classLayoutTrackView
- Parameters:
g2
- the graphics contextisMain
- true if drawing mainlinesrailDisplacement
- the offset from center to draw the lines
-
highlightUnconnected
protected void highlightUnconnected(java.awt.Graphics2D g2, HitPointType specificType)
highlight unconnected connections- Specified by:
highlightUnconnected
in classLayoutTrackView
- Parameters:
g2
- the graphics contextspecificType
- the specific connection to draw (or NONE for all)
-
drawEditControls
protected void drawEditControls(java.awt.Graphics2D g2)
draw the edit controls- Specified by:
drawEditControls
in classLayoutTrackView
- Parameters:
g2
- the graphics context
-
drawTurnoutControls
protected void drawTurnoutControls(java.awt.Graphics2D g2)
Draw the turnout controls- Specified by:
drawTurnoutControls
in classLayoutTrackView
- Parameters:
g2
- the graphics context
-
reCheckBlockBoundary
public void reCheckBlockBoundary()
abstract method... subclasses should implement _IF_ they need to recheck their block boundaries- Specified by:
reCheckBlockBoundary
in classLayoutTrackView
-
getLayoutConnectivity
protected java.util.List<LayoutConnectivity> getLayoutConnectivity()
get the layout connectivity for this track- Specified by:
getLayoutConnectivity
in classLayoutTrackView
- 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 classLayoutTrackView
- 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 classLayoutTrackView
- 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 classLayoutTrackView
- 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 classLayoutTrackView
- 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 classLayoutTrackView
- Parameters:
layoutBlock
- to this layout block (used by the Tools menu's "Assign block to selection" item)
-
-