Package jmri.jmrit.display.layoutEditor
Class LayoutShape
java.lang.Object
jmri.jmrit.display.layoutEditor.LayoutShape
A LayoutShape is a set of LayoutShapePoint used to draw a shape. Each point
can ether be a point on the shape or a control point that defines a curve
that's part of the shape. The shape can be open (end points not connected) or
closed (end points connected)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThese are the points that make up the outline of the shape.static enumenum LayoutShapePointType Straight, Curvestatic enumenum LayoutShapeType -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLayoutShape(String name, Point2D c, LayoutEditor layoutEditor) constructor method (used by LayoutEditor)LayoutShape(String name, LayoutEditor layoutEditor) constructor method (used by XML loading code)LayoutShape(String name, LayoutShape.LayoutShapeType t, LayoutEditor layoutEditor) constructor method (used by XML loading code)LayoutShape(LayoutShape layoutShape) constructor method (used by duplicate) -
Method Summary
Modifier and TypeMethodDescriptionvoidadd pointvoidadd pointvoidadd point(package private) voiddispose()Clean up when this object is no longer needed.protected voiddraw(Graphics2D g2) protected voidprotected HitPointTypefindHitPointType(Point2D hitPoint, boolean useRectangles) find the hit (location) type for a pointgetBounds() - return the bounds of this shapeget coordinates of center point of shapeintgetLevel()intintget the maximum number of pointsgetName()accessor methodsintget the number of pointsgetPoint(int idx) Get point.getType()booleanisHidden()static boolean(package private) voidremove()Removes this object from display and persistence(package private) voidvoidrotateCoords(double angleDEG) rotate this LayoutTrack's coordinates by angleDEG'svoidscaleCoords(double xFactor, double yFactor) scale this shapes coordinates by the x and y factorsvoidset center coordinatesvoidsetFillColor(Color color) voidsetHidden(boolean hidden) voidsetLevel(int l) voidsetLineColor(Color color) voidsetLineWidth(int w) voidvoidset pointvoidprotected JPopupMenushowShapePopUp(JmriMouseEvent mouseEvent, HitPointType hitPointType) toString()trackControlCircleAt(Point2D inPoint) trackEditControlCircleAt(Point2D inPoint) voidtranslateCoords(double xFactor, double yFactor) translate this shapes coordinates by the x and y factors
-
Field Details
-
MAX_LINEWIDTH
- See Also:
-
-
Constructor Details
-
LayoutShape
constructor method (used by XML loading code)- Parameters:
name- the name of the shapelayoutEditor- reference to the LayoutEditor this shape is in
-
LayoutShape
constructor method (used by XML loading code)- Parameters:
name- the name of the shapet- the layout shape type.layoutEditor- reference to the LayoutEditor this shape is in
-
LayoutShape
constructor method (used by LayoutEditor)- Parameters:
name- the name of the shapec- the Point2D for the initial pointlayoutEditor- reference to the LayoutEditor this shape is in
-
LayoutShape
constructor method (used by duplicate)- Parameters:
layoutShape- to duplicate (deep copy)
-
-
Method Details
-
toString
-
getDisplayName
-
getName
accessor methods- Returns:
- the name of this shape
-
setName
-
getType
-
setType
-
getLineWidth
-
setLineWidth
-
getLineColor
-
setLineColor
-
getFillColor
-
setFillColor
-
getLevel
-
setLevel
-
setHidden
-
isHidden
-
getLayoutEditor
-
addPoint
add point- Parameters:
p- the point to add
-
addPoint
add point- Parameters:
p- the point to addnearIndex- the index of the existing point to add it near note: "near" is defined as before or after depending on closest neighbor
-
addPoint
add point- Parameters:
t- the type of point to addp- the point to add
-
setPoint
set point- Parameters:
idx- the index of the point to addp- the point to add
-
getPoint
Get point.- Parameters:
idx- the index of the point to add.- Returns:
- the 2D point of the ID, MathUtil.zeroPoint2D if no result.
-
getPoints
-
getNumberPoints
get the number of points- Returns:
- the number of points
-
getMaxNumberPoints
get the maximum number of points- Returns:
- the maximum number of points
-
getBounds
getBounds() - return the bounds of this shape- Returns:
- Rectangle2D as bound of this shape
-
findHitPointType
find the hit (location) type for a point- Parameters:
hitPoint- the pointuseRectangles- whether to use (larger) rectangles or (smaller) circles for hit testing- Returns:
- the hit point type for the point (or NONE)
-
isShapeHitPointType
-
getCoordsCenter
get coordinates of center point of shape- Returns:
- Point2D coordinates of center point of shape
-
setCoordsCenter
set center coordinates- Parameters:
p- the coordinates to set
-
scaleCoords
scale this shapes coordinates by the x and y factors- Parameters:
xFactor- the amount to scale X coordinatesyFactor- the amount to scale Y coordinates
-
translateCoords
translate this shapes 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
-
showShapePopUp
@Nonnull protected JPopupMenu showShapePopUp(@CheckForNull JmriMouseEvent mouseEvent, HitPointType hitPointType) -
removeShape
void removeShape() -
dispose
void dispose()Clean up when this object is no longer needed. Should not be called while the object is still displayed; see remove() -
remove
void remove()Removes this object from display and persistence -
draw
-
drawEditControls
-
trackEditControlCircleAt
-
trackControlCircleAt
-