Package jmri.jmrit.display.layoutEditor
Class LevelXingView
- java.lang.Object
-
- jmri.jmrit.display.layoutEditor.LayoutTrackView
-
- jmri.jmrit.display.layoutEditor.LevelXingView
-
- All Implemented Interfaces:
InlineLogixNG
public class LevelXingView extends LayoutTrackView
MVC View component for the LevelXing class
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.ArrayList<javax.swing.JMenuItem>
editAdditionalMenu
Remove this object from display and persistance.(package private) javax.swing.JPopupMenu
popup
(package private) java.util.ArrayList<javax.swing.JMenuItem>
viewAdditionalMenu
-
Fields inherited from class jmri.jmrit.display.layoutEditor.LayoutTrackView
decorations, layoutEditor, NUM_ARROW_TYPES
-
-
Constructor Summary
Constructors Constructor Description LevelXingView(LevelXing xing, java.awt.geom.Point2D c, LayoutEditor layoutEditor)
constructor methodLevelXingView(LevelXing xing, LayoutEditor layoutEditor)
Constructor method.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEditPopUpMenu(javax.swing.JMenuItem menu)
void
addViewPopUpMenu(javax.swing.JMenuItem menu)
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 blockNamevoid
dispose()
Clean up when this object is no longer needed.protected void
draw1(java.awt.Graphics2D g2, boolean isMain, boolean isBlock)
Draw this level crossing.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.lang.String
getBlockNameAC()
java.lang.String
getBlockNameBD()
java.awt.geom.Rectangle2D
getBounds()
LayoutTrack
getConnectA()
LayoutTrack
getConnectB()
LayoutTrack
getConnectC()
LayoutTrack
getConnectD()
LayoutTrack
getConnection(HitPointType connectionType)
get the LayoutTrack connected at the specified connection typejava.awt.geom.Point2D
getCoordsA()
java.awt.geom.Point2D
getCoordsB()
java.awt.geom.Point2D
getCoordsC()
java.awt.geom.Point2D
getCoordsD()
java.awt.geom.Point2D
getCoordsForConnectionType(HitPointType connectionType)
Get the coordinates for a specified connection type.LayoutBlock
getLayoutBlockAC()
LayoutBlock
getLayoutBlockBD()
protected java.util.ArrayList<LayoutConnectivity>
getLayoutConnectivity()
get the layout connectivity for this trackLevelXing
getLevelXing()
Sensor
getSensor(LevelXing.Geometry loc)
Sensor
getSensorA()
java.lang.String
getSensorAName()
Sensor
getSensorB()
java.lang.String
getSensorBName()
Sensor
getSensorC()
java.lang.String
getSensorCName()
Sensor
getSensorD()
java.lang.String
getSensorDName()
SignalMast
getSignalAMast()
java.lang.String
getSignalAMastName()
java.lang.String
getSignalAName()
SignalMast
getSignalBMast()
java.lang.String
getSignalBMastName()
java.lang.String
getSignalBName()
SignalMast
getSignalCMast()
java.lang.String
getSignalCMastName()
java.lang.String
getSignalCName()
SignalMast
getSignalDMast()
java.lang.String
getSignalDMastName()
java.lang.String
getSignalDName()
SignalHead
getSignalHead(LevelXing.Geometry loc)
SignalMast
getSignalMast(LevelXing.Geometry loc)
protected void
highlightUnconnected(java.awt.Graphics2D g2, HitPointType specificType)
highlight unconnected connectionsboolean
isMainlineAC()
Test if mainline track or not.boolean
isMainlineBD()
void
reCheckBlockBoundary()
abstract method... subclasses should implement _IF_ they need to recheck their block boundariesvoid
removeBeanReference(NamedBean nb)
void
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
setAdditionalEditPopUpMenu(javax.swing.JPopupMenu popup)
void
setAdditionalViewPopUpMenu(javax.swing.JPopupMenu popup)
void
setAllLayoutBlocks(LayoutBlock layoutBlock)
Assign all the layout blocks in this trackvoid
setConnectA(LayoutTrack o, HitPointType type)
void
setConnectB(LayoutTrack o, HitPointType type)
void
setConnectC(LayoutTrack o, HitPointType type)
void
setConnectD(LayoutTrack o, HitPointType type)
void
setConnection(HitPointType connectionType, LayoutTrack o, HitPointType type)
set the LayoutTrack connected at the specified connection typevoid
setCoordsA(java.awt.geom.Point2D p)
void
setCoordsB(java.awt.geom.Point2D p)
void
setCoordsC(java.awt.geom.Point2D p)
void
setCoordsD(java.awt.geom.Point2D p)
void
setSensorAName(java.lang.String sensorName)
void
setSensorBName(java.lang.String sensorName)
void
setSensorCName(java.lang.String sensorName)
void
setSensorDName(java.lang.String sensorName)
void
setSignalAMast(java.lang.String signalMast)
void
setSignalAName(java.lang.String signalHead)
void
setSignalBMast(java.lang.String signalMast)
void
setSignalBName(java.lang.String signalHead)
void
setSignalCMast(java.lang.String signalMast)
void
setSignalCName(java.lang.String signalHead)
void
setSignalDMast(java.lang.String signalMast)
void
setSignalDName(java.lang.String signalHead)
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 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 Detail
-
popup
javax.swing.JPopupMenu popup
-
editAdditionalMenu
java.util.ArrayList<javax.swing.JMenuItem> editAdditionalMenu
Remove this object from display and persistance.
-
viewAdditionalMenu
java.util.ArrayList<javax.swing.JMenuItem> viewAdditionalMenu
-
-
Constructor Detail
-
LevelXingView
public LevelXingView(@Nonnull LevelXing xing, @Nonnull LayoutEditor layoutEditor)
Constructor method.- Parameters:
xing
- the level crossing.layoutEditor
- for access to tools
-
LevelXingView
public LevelXingView(@Nonnull LevelXing xing, @Nonnull java.awt.geom.Point2D c, @Nonnull LayoutEditor layoutEditor)
constructor method- Parameters:
xing
- the level crossing.c
- display locationlayoutEditor
- for access to tools
-
-
Method Detail
-
getLevelXing
@Nonnull public LevelXing getLevelXing()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getBlockNameAC
@Nonnull public java.lang.String getBlockNameAC()
-
getBlockNameBD
@Nonnull public java.lang.String getBlockNameBD()
-
getSignalHead
public SignalHead getSignalHead(LevelXing.Geometry loc)
-
getSignalMast
public SignalMast getSignalMast(LevelXing.Geometry loc)
-
getSensor
public Sensor getSensor(LevelXing.Geometry loc)
-
getSignalAName
@Nonnull public java.lang.String getSignalAName()
-
setSignalAName
public void setSignalAName(java.lang.String signalHead)
-
getSignalBName
@Nonnull public java.lang.String getSignalBName()
-
setSignalBName
public void setSignalBName(java.lang.String signalHead)
-
getSignalCName
@Nonnull public java.lang.String getSignalCName()
-
setSignalCName
public void setSignalCName(java.lang.String signalHead)
-
getSignalDName
@Nonnull public java.lang.String getSignalDName()
-
setSignalDName
public void setSignalDName(java.lang.String signalHead)
-
removeBeanReference
public void removeBeanReference(NamedBean nb)
-
getSignalAMastName
public java.lang.String getSignalAMastName()
-
getSignalAMast
public SignalMast getSignalAMast()
-
setSignalAMast
public void setSignalAMast(java.lang.String signalMast)
-
getSignalBMastName
public java.lang.String getSignalBMastName()
-
getSignalBMast
public SignalMast getSignalBMast()
-
setSignalBMast
public void setSignalBMast(java.lang.String signalMast)
-
getSignalCMastName
public java.lang.String getSignalCMastName()
-
getSignalCMast
public SignalMast getSignalCMast()
-
setSignalCMast
public void setSignalCMast(java.lang.String signalMast)
-
getSignalDMastName
public java.lang.String getSignalDMastName()
-
getSignalDMast
public SignalMast getSignalDMast()
-
setSignalDMast
public void setSignalDMast(java.lang.String signalMast)
-
getSensorAName
public java.lang.String getSensorAName()
-
getSensorA
public Sensor getSensorA()
-
setSensorAName
public void setSensorAName(java.lang.String sensorName)
-
getSensorBName
public java.lang.String getSensorBName()
-
getSensorB
public Sensor getSensorB()
-
setSensorBName
public void setSensorBName(java.lang.String sensorName)
-
getSensorCName
public java.lang.String getSensorCName()
-
getSensorC
public Sensor getSensorC()
-
setSensorCName
public void setSensorCName(java.lang.String sensorName)
-
getSensorDName
public java.lang.String getSensorDName()
-
getSensorD
public Sensor getSensorD()
-
setSensorDName
public void setSensorDName(java.lang.String sensorName)
-
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
-
getConnectA
public LayoutTrack getConnectA()
-
getConnectB
public LayoutTrack getConnectB()
-
getConnectC
public LayoutTrack getConnectC()
-
getConnectD
public LayoutTrack getConnectD()
-
setConnectA
public void setConnectA(LayoutTrack o, HitPointType type)
-
setConnectB
public void setConnectB(LayoutTrack o, HitPointType type)
-
setConnectC
public void setConnectC(LayoutTrack o, HitPointType type)
-
setConnectD
public void setConnectD(LayoutTrack o, HitPointType type)
-
getLayoutBlockAC
public LayoutBlock getLayoutBlockAC()
-
getLayoutBlockBD
public LayoutBlock getLayoutBlockBD()
-
getCoordsA
public java.awt.geom.Point2D getCoordsA()
-
getCoordsB
public java.awt.geom.Point2D getCoordsB()
-
getCoordsC
public java.awt.geom.Point2D getCoordsC()
-
getCoordsD
public java.awt.geom.Point2D getCoordsD()
-
getCoordsForConnectionType
public java.awt.geom.Point2D getCoordsForConnectionType(HitPointType connectionType)
Get 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
-
getBounds
public java.awt.geom.Rectangle2D getBounds()
- Specified by:
getBounds
in classLayoutTrackView
- Returns:
- the bounds of this crossing
-
isMainlineAC
public boolean isMainlineAC()
Test if mainline track or not.- Returns:
- true if either connecting track segment is mainline; Defaults to not mainline if connecting track segments are missing
-
isMainlineBD
public boolean isMainlineBD()
-
setCoordsA
public void setCoordsA(java.awt.geom.Point2D p)
-
setCoordsB
public void setCoordsB(java.awt.geom.Point2D p)
-
setCoordsC
public void setCoordsC(java.awt.geom.Point2D p)
-
setCoordsD
public void setCoordsD(java.awt.geom.Point2D 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
-
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)
-
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.
-
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
-
dispose
public void dispose()
Clean up when this object is no longer needed. Should not be called while the object is still displayed; see remove().
-
addEditPopUpMenu
public void addEditPopUpMenu(javax.swing.JMenuItem menu)
-
addViewPopUpMenu
public void addViewPopUpMenu(javax.swing.JMenuItem menu)
-
setAdditionalEditPopUpMenu
public void setAdditionalEditPopUpMenu(javax.swing.JPopupMenu popup)
-
setAdditionalViewPopUpMenu
public void setAdditionalViewPopUpMenu(javax.swing.JPopupMenu popup)
-
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 this level crossing.- Specified by:
draw1
in classLayoutTrackView
- Parameters:
g2
- the graphics port to draw toisMain
- 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)
Description copied from class:LayoutTrackView
draw the edit controls- Specified by:
drawEditControls
in classLayoutTrackView
- Parameters:
g2
- the graphics context
-
drawTurnoutControls
protected void drawTurnoutControls(java.awt.Graphics2D g2)
Description copied from class:LayoutTrackView
Draw the turnout controls- Specified by:
drawTurnoutControls
in classLayoutTrackView
- Parameters:
g2
- the graphics context
-
reCheckBlockBoundary
public void reCheckBlockBoundary()
Description copied from class:LayoutTrackView
abstract method... subclasses should implement _IF_ they need to recheck their block boundaries- Specified by:
reCheckBlockBoundary
in classLayoutTrackView
-
getLayoutConnectivity
protected java.util.ArrayList<LayoutConnectivity> getLayoutConnectivity()
Description copied from class:LayoutTrackView
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)
-
-