Class TrackSegmentView
- java.lang.Object
-
- jmri.jmrit.display.layoutEditor.LayoutTrackView
-
- jmri.jmrit.display.layoutEditor.TrackSegmentView
-
- All Implemented Interfaces:
InlineLogixNG
public class TrackSegmentView extends LayoutTrackView
MVC View component for the TrackSegment class.Arrows and bumpers are visual, presentation aspects handled in the View.
-
-
Field Summary
Fields Modifier and Type Field Description static int
HIDECON
static int
HIDECONALL
static int
MAX_BUMPER_LENGTH
Maximum length of the bumper decoration.static int
MAX_BUMPER_WIDTH
static int
MIN_BUMPER_LENGTH
static int
MIN_BUMPER_WIDTH
static int
SHOWCON
int
showConstructionLine
java.lang.String
tConnect1Name
java.lang.String
tConnect2Name
java.lang.String
tLayoutBlockName
-
Fields inherited from class jmri.jmrit.display.layoutEditor.LayoutTrackView
decorations, layoutEditor, NUM_ARROW_TYPES
-
-
Constructor Summary
Constructors Constructor Description TrackSegmentView(TrackSegment track, LayoutEditor layoutEditor)
TrackSegmentView(TrackSegment track, LayoutEditor layoutEditor, boolean arc, boolean flip, boolean circle)
constructor method.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
calculateTrackSegmentAngle()
boolean
canRemove()
Check for active block boundaries.(package private) void
changeType(int choice)
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 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 decorationsprotected 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 pointdouble
getAngle()
java.awt.Color
getArrowColor()
int
getArrowGap()
int
getArrowLength()
int
getArrowLineWidth()
int
getArrowStyle()
Arrow decoration accessor.java.awt.geom.Point2D
getBezierControlPoint(int index)
java.util.ArrayList<java.awt.geom.Point2D>
getBezierControlPoints()
java.lang.String
getBlockName()
java.awt.geom.Rectangle2D
getBounds()
int
getBridgeApproachWidth()
java.awt.Color
getBridgeColor()
int
getBridgeDeckWidth()
int
getBridgeLineWidth()
java.awt.Color
getBumperColor()
int
getBumperLength()
int
getBumperLineWidth()
java.awt.geom.Point2D
getCentre()
java.awt.geom.Point2D
getCentreSeg()
double
getCentreSegX()
double
getCentreSegY()
double
getCentreX()
double
getCentreY()
double
getCH()
double
getChordLength()
LayoutTrack
getConnect1()
java.lang.String
getConnect1Name()
LayoutTrack
getConnect2()
java.lang.String
getConnect2Name()
LayoutTrack
getConnection(HitPointType connectionType)
get the LayoutTrack connected at the specified connection typejava.awt.geom.Point2D
getCoordsCenterCircle()
get center coordinatesjava.awt.geom.Point2D
getCoordsForConnectionType(HitPointType connectionType)
Get the coordinates for a specified connection type.double
getCW()
double
getCX()
double
getCY()
java.util.Map<java.lang.String,java.lang.String>
getDecorations()
Get current decorationsdouble
getDirectionDEG()
Get the direction from end point 1 to 2.double
getDirectionRAD()
Get the direction from end point 1 to 2.LayoutBlock
getLayoutBlock()
protected java.util.List<LayoutConnectivity>
getLayoutConnectivity()
get the layout connectivity for this trackint
getNumberOfBezierControlPoints()
java.util.ArrayList<java.lang.String>
getPointReferences(HitPointType type, LayoutTrack conn)
double
getStartAdj()
double
getTmpAngle()
java.awt.geom.Point2D
getTmpPt1()
java.awt.geom.Point2D
getTmpPt2()
TrackSegment
getTrackSegment()
java.awt.Color
getTunnelColor()
int
getTunnelEntranceWidth()
int
getTunnelFloorWidth()
int
getTunnelLineWidth()
HitPointType
getType1()
HitPointType
getType2()
boolean
hasDecorations()
boolean
hideConstructionLines()
void
hideConstructionLines(int hide)
Method used by LayoutEditor.protected void
highlightUnconnected(java.awt.Graphics2D g2, HitPointType selectedType)
highlight unconnected connectionsboolean
isActive()
Get state.boolean
isArc()
boolean
isArrowDirIn()
boolean
isArrowDirOut()
boolean
isArrowEndStart()
boolean
isArrowEndStop()
boolean
isBezier()
boolean
isBridgeHasEntry()
boolean
isBridgeHasExit()
boolean
isBridgeSideLeft()
boolean
isBridgeSideRight()
boolean
isBumperEndStart()
boolean
isBumperEndStop()
boolean
isBumperFlipped()
boolean
isCircle()
boolean
isDashed()
boolean
isFlip()
boolean
isShowConstructionLines()
boolean
isTunnelHasEntry()
boolean
isTunnelHasExit()
boolean
isTunnelSideLeft()
boolean
isTunnelSideRight()
protected void
reCalculateTrackSegmentAngle(double x, double y)
void
reCheckBlockBoundary()
abstract method... subclasses should implement _IF_ they need to recheck their block boundariesvoid
remove()
Remove this object from display and persistance.boolean
replaceTrackConnection(LayoutTrack oldTrack, LayoutTrack newTrack, HitPointType newType)
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
setAngle(double x)
void
setArc(boolean boo)
void
setArrowColor(java.awt.Color newVal)
void
setArrowDirIn(boolean newVal)
void
setArrowDirOut(boolean newVal)
void
setArrowEndStart(boolean newVal)
void
setArrowEndStop(boolean newVal)
void
setArrowGap(int newVal)
void
setArrowLength(int newVal)
void
setArrowLineWidth(int newVal)
void
setArrowStyle(int newVal)
Set the arrow decoration.void
setBezier(boolean bool)
void
setBezierControlPoint(java.awt.geom.Point2D p, int index)
void
setBridgeApproachWidth(int newVal)
void
setBridgeColor(java.awt.Color newVal)
void
setBridgeDeckWidth(int newVal)
void
setBridgeHasEntry(boolean newVal)
void
setBridgeHasExit(boolean newVal)
void
setBridgeLineWidth(int newVal)
void
setBridgeSideLeft(boolean newVal)
void
setBridgeSideRight(boolean newVal)
void
setBumperColor(java.awt.Color newVal)
void
setBumperEndStart(boolean newVal)
void
setBumperEndStop(boolean newVal)
void
setBumperFlipped(boolean newVal)
void
setBumperLength(int newVal)
void
setBumperLineWidth(int newVal)
void
setCentreSeg(java.awt.geom.Point2D p)
void
setCentreSegX(double x)
void
setCentreSegY(double y)
void
setCentreX(double x)
void
setCentreY(double y)
void
setCH(double CH)
void
setChordLength(double chord)
void
setCircle(boolean boo)
void
setConnection(HitPointType connectionType, LayoutTrack o, HitPointType type)
set the LayoutTrack connected at the specified connection typevoid
setCoordsCenter(java.awt.geom.Point2D newCenterPoint)
Set center coordinates.void
setCoordsCenterCircle(java.awt.geom.Point2D p)
set center coordinatesvoid
setCW(double CW)
void
setCX(double CX)
void
setCY(double CY)
void
setDashed(boolean dash)
void
setDecorations(java.util.Map<java.lang.String,java.lang.String> decorations)
Set new decorations This is a complete replacement of the decorations, not an appending.void
setFlip(boolean boo)
void
setLayoutBlock(LayoutBlock newLayoutBlock)
Set up a LayoutBlock for this Track Segment.void
setLayoutBlockByName(java.lang.String name)
Set up a LayoutBlock for this Track Segment.protected void
setNewConnect1(LayoutTrack connectTrack, HitPointType connectionType)
set a new connection 1protected void
setNewConnect2(LayoutTrack connectTrack, HitPointType connectionType)
set a new connection 2void
setStartAdj(double startAdj)
void
setTmpAngle(double a)
void
setTmpPt1(java.awt.geom.Point2D Pt1)
void
setTmpPt2(java.awt.geom.Point2D Pt2)
void
setTunnelColor(java.awt.Color newVal)
void
setTunnelEntranceWidth(int newVal)
void
setTunnelFloorWidth(int newVal)
void
setTunnelHasEntry(boolean newVal)
void
setTunnelHasExit(boolean newVal)
void
setTunnelLineWidth(int newVal)
void
setTunnelSideLeft(boolean newVal)
void
setTunnelSideRight(boolean newVal)
protected void
showBezierPopUp(JmriMouseEvent e, HitPointType hitPointType)
Display popup menu for information and editing.protected javax.swing.JPopupMenu
showPopup(JmriMouseEvent mouseEvent)
show the popup menu for this layout trackvoid
splitTrackSegment()
split a track segment into two track segments with an anchor point in between.java.lang.String
toString()
Get debugging string for the TrackSegment.boolean
trackNeedsRedraw()
Determine if we need to redraw a curved piece of track.void
trackRedrawn()
void
translateCoords(double xFactor, double yFactor)
translate this LayoutTrack's coordinates by the x and y factorsvoid
updateBlockInfo()
-
Methods 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 Detail
-
tConnect1Name
public java.lang.String tConnect1Name
-
tConnect2Name
public java.lang.String tConnect2Name
-
tLayoutBlockName
public java.lang.String tLayoutBlockName
-
MAX_BUMPER_LENGTH
public static final int MAX_BUMPER_LENGTH
Maximum length of the bumper decoration.- See Also:
- Constant Field Values
-
MIN_BUMPER_LENGTH
public static final int MIN_BUMPER_LENGTH
- See Also:
- Constant Field Values
-
MAX_BUMPER_WIDTH
public static final int MAX_BUMPER_WIDTH
- See Also:
- Constant Field Values
-
MIN_BUMPER_WIDTH
public static final int MIN_BUMPER_WIDTH
- See Also:
- Constant Field Values
-
SHOWCON
public static final int SHOWCON
- See Also:
- Constant Field Values
-
HIDECON
public static final int HIDECON
- See Also:
- Constant Field Values
-
HIDECONALL
public static final int HIDECONALL
- See Also:
- Constant Field Values
-
showConstructionLine
public int showConstructionLine
-
-
Constructor Detail
-
TrackSegmentView
public TrackSegmentView(@Nonnull TrackSegment track, @Nonnull LayoutEditor layoutEditor)
-
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 Detail
-
getTrackSegment
@Nonnull public TrackSegment getTrackSegment()
-
toString
public java.lang.String toString()
Get debugging string for the TrackSegment.- Overrides:
toString
in classjava.lang.Object
- Returns:
- text showing id and connections of this segment
-
getBlockName
@Nonnull public java.lang.String getBlockName()
-
getType1
public HitPointType getType1()
-
getType2
public HitPointType getType2()
-
getConnect1
public LayoutTrack getConnect1()
-
getConnect2
public LayoutTrack getConnect2()
-
setNewConnect1
protected void setNewConnect1(@CheckForNull LayoutTrack connectTrack, HitPointType connectionType)
set a new connection 1- Parameters:
connectTrack
- the track we want to connect toconnectionType
- where on that track we want to be connected
-
setNewConnect2
protected void setNewConnect2(@CheckForNull LayoutTrack connectTrack, HitPointType connectionType)
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
public boolean isDashed()
- Returns:
- true if track segment should be drawn dashed
-
setDashed
public void setDashed(boolean dash)
-
isArc
public boolean isArc()
- Returns:
- true if track segment is an arc
-
setArc
public void setArc(boolean boo)
-
isCircle
public boolean isCircle()
- Returns:
- true if track segment is circle
-
setCircle
public void setCircle(boolean boo)
-
isFlip
public boolean isFlip()
- Returns:
- true if track segment circle or arc should be drawn flipped
-
setFlip
public void setFlip(boolean boo)
-
isBezier
public boolean isBezier()
- Returns:
- true if track segment is a bezier curve
-
setBezier
public void setBezier(boolean bool)
- Parameters:
bool
- Set true to turn on Bezier curve representation.
-
getAngle
public double getAngle()
-
setAngle
public void setAngle(double x)
-
getDirectionRAD
public double 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
public double 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
public boolean 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
public void trackRedrawn()
-
getLayoutBlock
public LayoutBlock getLayoutBlock()
-
getConnect1Name
public java.lang.String getConnect1Name()
-
getConnect2Name
public java.lang.String getConnect2Name()
-
getConnection
public LayoutTrack getConnection(HitPointType connectionType) throws JmriException
Description copied from class:LayoutTrackView
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, @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:
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
-
getNumberOfBezierControlPoints
public int getNumberOfBezierControlPoints()
-
getBezierControlPoint
public java.awt.geom.Point2D getBezierControlPoint(int index)
- 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
public void setBezierControlPoint(@CheckForNull java.awt.geom.Point2D p, int index)
- 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
@Nonnull public java.util.ArrayList<java.awt.geom.Point2D> getBezierControlPoints()
-
setLayoutBlock
public void setLayoutBlock(@CheckForNull LayoutBlock newLayoutBlock)
Set up a LayoutBlock for this Track Segment.- Parameters:
newLayoutBlock
- the LayoutBlock to set
-
setLayoutBlockByName
public void setLayoutBlockByName(@CheckForNull java.lang.String name)
Set up a LayoutBlock for this Track Segment.- Parameters:
name
- the name of the new LayoutBlock
-
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
-
setCoordsCenter
public void setCoordsCenter(@Nonnull java.awt.geom.Point2D newCenterPoint)
Set center coordinates.- Overrides:
setCoordsCenter
in classLayoutTrackView
- Parameters:
newCenterPoint
- the coordinates to set
-
updateBlockInfo
public void updateBlockInfo()
-
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)
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 track segment
-
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.
-
getPointReferences
public java.util.ArrayList<java.lang.String> getPointReferences(HitPointType type, LayoutTrack conn)
-
splitTrackSegment
public void splitTrackSegment()
split a track segment into two track segments with an anchor point in between.
-
showBezierPopUp
protected void showBezierPopUp(JmriMouseEvent e, HitPointType hitPointType)
Display popup menu for information and editing.- Parameters:
e
- The original event causing thishitPointType
- the type of the underlying hit
-
changeType
void changeType(int choice)
-
dispose
public void dispose()
Clean up when this object is no longer needed.Should not be called while the object is still displayed.
- See Also:
remove()
-
remove
public void remove()
Remove this object from display and persistance.
-
isActive
public boolean isActive()
Get state. "active" means that the object is still displayed, and should be stored.- Returns:
- true if active
-
isShowConstructionLines
public boolean isShowConstructionLines()
- Returns:
- true if HIDECON is not set and HIDECONALL is not set
-
hideConstructionLines
public void hideConstructionLines(int hide)
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
public boolean hideConstructionLines()
- Returns:
- true if SHOWCON is not set
-
getTmpPt1
public java.awt.geom.Point2D getTmpPt1()
-
getTmpPt2
public java.awt.geom.Point2D getTmpPt2()
-
setTmpPt1
public void setTmpPt1(java.awt.geom.Point2D Pt1)
-
setTmpPt2
public void setTmpPt2(java.awt.geom.Point2D Pt2)
-
getCX
public double getCX()
-
setCX
public void setCX(double CX)
-
getCY
public double getCY()
-
setCY
public void setCY(double CY)
-
getCW
public double getCW()
-
setCW
public void setCW(double CW)
-
getCH
public double getCH()
-
setCH
public void setCH(double CH)
-
getStartAdj
public double getStartAdj()
-
setStartAdj
public void setStartAdj(double startAdj)
-
getCentreSegX
public double getCentreSegX()
-
setCentreSegX
public void setCentreSegX(double x)
-
getCentreSegY
public double getCentreSegY()
-
setCentreSegY
public void setCentreSegY(double y)
-
getCentreSeg
public java.awt.geom.Point2D getCentreSeg()
- Returns:
- the location of the middle of the segment (on the segment)
-
setCentreSeg
public void setCentreSeg(java.awt.geom.Point2D p)
-
getCentreX
public double getCentreX()
-
setCentreX
public void setCentreX(double x)
-
getCentreY
public double getCentreY()
-
setCentreY
public void setCentreY(double y)
-
getCentre
public java.awt.geom.Point2D getCentre()
-
getTmpAngle
public double getTmpAngle()
-
setTmpAngle
public void setTmpAngle(double a)
-
getCoordsCenterCircle
public java.awt.geom.Point2D getCoordsCenterCircle()
get center coordinates- Returns:
- the center coordinates
-
setCoordsCenterCircle
public void setCoordsCenterCircle(java.awt.geom.Point2D p)
set center coordinates- Parameters:
p
- the coordinates to set
-
getChordLength
public double getChordLength()
-
setChordLength
public void setChordLength(double chord)
-
reCalculateTrackSegmentAngle
protected void reCalculateTrackSegmentAngle(double x, double y)
-
calculateTrackSegmentAngle
protected void calculateTrackSegmentAngle()
-
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 selectedType)
highlight unconnected connections- Specified by:
highlightUnconnected
in classLayoutTrackView
- Parameters:
g2
- the graphics contextselectedType
- 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()
abstract method... subclasses should implement _IF_ they need to recheck their block boundaries- Specified by:
reCheckBlockBoundary
in classLayoutTrackView
-
drawDecorations
protected void drawDecorations(java.awt.Graphics2D g2)
Draw track decorations- Specified by:
drawDecorations
in classLayoutTrackView
- Parameters:
g2
- the graphics context
-
hasDecorations
public boolean hasDecorations()
- Overrides:
hasDecorations
in classLayoutTrackView
- Returns:
- true if this track segment has decorations
-
getDecorations
public java.util.Map<java.lang.String,java.lang.String> getDecorations()
Get current decorations- Overrides:
getDecorations
in classLayoutTrackView
- Returns:
- the decorations
-
setDecorations
public void setDecorations(@Nonnull java.util.Map<java.lang.String,java.lang.String> decorations)
Set new decorations This is a complete replacement of the decorations, not an appending.- Overrides:
setDecorations
in 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
public int 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
public void setArrowStyle(int newVal)
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
public boolean isArrowEndStart()
-
setArrowEndStart
public void setArrowEndStart(boolean newVal)
-
isArrowEndStop
public boolean isArrowEndStop()
-
setArrowEndStop
public void setArrowEndStop(boolean newVal)
-
isArrowDirIn
public boolean isArrowDirIn()
-
setArrowDirIn
public void setArrowDirIn(boolean newVal)
-
isArrowDirOut
public boolean isArrowDirOut()
-
setArrowDirOut
public void setArrowDirOut(boolean newVal)
-
getArrowColor
public java.awt.Color getArrowColor()
-
setArrowColor
public void setArrowColor(java.awt.Color newVal)
-
getArrowLineWidth
public int getArrowLineWidth()
-
setArrowLineWidth
public void setArrowLineWidth(int newVal)
-
getArrowLength
public int getArrowLength()
-
setArrowLength
public void setArrowLength(int newVal)
-
getArrowGap
public int getArrowGap()
-
setArrowGap
public void setArrowGap(int newVal)
-
isBridgeSideRight
public boolean isBridgeSideRight()
-
setBridgeSideRight
public void setBridgeSideRight(boolean newVal)
-
isBridgeSideLeft
public boolean isBridgeSideLeft()
-
setBridgeSideLeft
public void setBridgeSideLeft(boolean newVal)
-
isBridgeHasEntry
public boolean isBridgeHasEntry()
-
setBridgeHasEntry
public void setBridgeHasEntry(boolean newVal)
-
isBridgeHasExit
public boolean isBridgeHasExit()
-
setBridgeHasExit
public void setBridgeHasExit(boolean newVal)
-
getBridgeColor
public java.awt.Color getBridgeColor()
-
setBridgeColor
public void setBridgeColor(java.awt.Color newVal)
-
getBridgeDeckWidth
public int getBridgeDeckWidth()
-
setBridgeDeckWidth
public void setBridgeDeckWidth(int newVal)
-
getBridgeLineWidth
public int getBridgeLineWidth()
-
setBridgeLineWidth
public void setBridgeLineWidth(int newVal)
-
getBridgeApproachWidth
public int getBridgeApproachWidth()
-
setBridgeApproachWidth
public void setBridgeApproachWidth(int newVal)
-
isBumperEndStart
public boolean isBumperEndStart()
-
setBumperEndStart
public void setBumperEndStart(boolean newVal)
-
isBumperEndStop
public boolean isBumperEndStop()
-
setBumperEndStop
public void setBumperEndStop(boolean newVal)
-
getBumperColor
public java.awt.Color getBumperColor()
-
setBumperColor
public void setBumperColor(java.awt.Color newVal)
-
getBumperLineWidth
public int getBumperLineWidth()
-
setBumperLineWidth
public void setBumperLineWidth(int newVal)
-
getBumperLength
public int getBumperLength()
-
setBumperLength
public void setBumperLength(int newVal)
-
isBumperFlipped
public boolean isBumperFlipped()
-
setBumperFlipped
public void setBumperFlipped(boolean newVal)
-
isTunnelSideRight
public boolean isTunnelSideRight()
-
setTunnelSideRight
public void setTunnelSideRight(boolean newVal)
-
isTunnelSideLeft
public boolean isTunnelSideLeft()
-
setTunnelSideLeft
public void setTunnelSideLeft(boolean newVal)
-
isTunnelHasEntry
public boolean isTunnelHasEntry()
-
setTunnelHasEntry
public void setTunnelHasEntry(boolean newVal)
-
isTunnelHasExit
public boolean isTunnelHasExit()
-
setTunnelHasExit
public void setTunnelHasExit(boolean newVal)
-
getTunnelColor
public java.awt.Color getTunnelColor()
-
setTunnelColor
public void setTunnelColor(java.awt.Color newVal)
-
getTunnelFloorWidth
public int getTunnelFloorWidth()
-
setTunnelFloorWidth
public void setTunnelFloorWidth(int newVal)
-
getTunnelLineWidth
public int getTunnelLineWidth()
-
setTunnelLineWidth
public void setTunnelLineWidth(int newVal)
-
getTunnelEntranceWidth
public int getTunnelEntranceWidth()
-
setTunnelEntranceWidth
public void setTunnelEntranceWidth(int newVal)
-
getLayoutConnectivity
@Nonnull 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
@Nonnull 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)
-
-