Package sim.portrayal.simple
Class RectanglePortrayal2D
java.lang.Object
sim.portrayal.SimplePortrayal2D
sim.portrayal.simple.AbstractShapePortrayal2D
sim.portrayal.simple.RectanglePortrayal2D
- All Implemented Interfaces:
Serializable
,Portrayal
,Portrayal2D
- Direct Known Subclasses:
ImagePortrayal2D
,ValuePortrayal2D
A simple portrayal for 2D visualization of rectangles. It extends the SimplePortrayal2D and
it manages the drawing and hit-testing for rectangular shapes.
- See Also:
-
Field Summary
Fields inherited from class sim.portrayal.simple.AbstractShapePortrayal2D
defaultStroke, filled, fillPaint, paint, scale, stroke, strokePaint
Fields inherited from class sim.portrayal.SimplePortrayal2D
TYPE_HIT_OBJECT, TYPE_SELECTED_OBJECT
-
Constructor Summary
ConstructorDescriptionRectanglePortrayal2D
(double scale) RectanglePortrayal2D
(double scale, boolean filled) RectanglePortrayal2D
(Paint paint) RectanglePortrayal2D
(Paint paint, boolean filled) RectanglePortrayal2D
(Paint paint, double scale) RectanglePortrayal2D
(Paint paint, double scale, boolean filled) RectanglePortrayal2D
(Paint fillPaint, Paint strokePaint, double strokeWidth, double scale) New-style constructors.RectanglePortrayal2D
(Paint fillPaint, Paint strokePaint, Stroke stroke, double scale) New-style constructors. -
Method Summary
Modifier and TypeMethodDescriptionvoid
draw
(Object object, Graphics2D graphics, DrawInfo2D info) Draw a the given object with an origin at (info.draw.x, info.draw.y), and with the coordinate system scaled by so that 1 unit is in the x and y directions are equal to info.draw.width and info.draw.height respectively in pixels.boolean
hitObject
(Object object, DrawInfo2D range) If drawing area intersects selected area, add last portrayed object to the bagvoid
setStroke
(double width) void
Methods inherited from class sim.portrayal.SimplePortrayal2D
getInspector, getName, getStatus, handleMouseEvent, setSelected
-
Constructor Details
-
RectanglePortrayal2D
public RectanglePortrayal2D() -
RectanglePortrayal2D
-
RectanglePortrayal2D
public RectanglePortrayal2D(double scale) -
RectanglePortrayal2D
-
RectanglePortrayal2D
-
RectanglePortrayal2D
public RectanglePortrayal2D(double scale, boolean filled) -
RectanglePortrayal2D
-
RectanglePortrayal2D
New-style constructors. Rather than having a "filled" flag which determines whether we stroke versus fill, we can do BOTH. We do this by specifying a fill paint and a stroke paint, either of which can be NULL. We also provide a stroke width and a scale. -
RectanglePortrayal2D
New-style constructors. Rather than having a "filled" flag which determines whether we stroke versus fill, we can do BOTH. We do this by specifying a fill paint and a stroke paint, either of which can be NULL. We also provide a stroke and a scale.
-
-
Method Details
-
hitObject
If drawing area intersects selected area, add last portrayed object to the bag- Overrides:
hitObject
in classSimplePortrayal2D
-
draw
Description copied from interface:Portrayal2D
Draw a the given object with an origin at (info.draw.x, info.draw.y), and with the coordinate system scaled by so that 1 unit is in the x and y directions are equal to info.draw.width and info.draw.height respectively in pixels. The rectangle given by info.clip specifies the only region in which it is necessary to draw. If info.precise is true, try to draw using real-valued high-resolution drawing rather than faster integer drawing. It is possible that object is null. The location of the object in the field may (and may not) be stored in info.location. The form of that location varies depending on the kind of field used.- Specified by:
draw
in interfacePortrayal2D
- Overrides:
draw
in classSimplePortrayal2D
-
setStroke
-
setStroke
public void setStroke(double width)
-