Package sim.portrayal.simple
Class ShapePortrayal2D
java.lang.Object
sim.portrayal.SimplePortrayal2D
sim.portrayal.simple.AbstractShapePortrayal2D
sim.portrayal.simple.ShapePortrayal2D
- All Implemented Interfaces:
Serializable
,Portrayal
,Portrayal2D
- Direct Known Subclasses:
HexagonalPortrayal2D
A simple portrayal for 2D visualization of java.awt.Shapes and java.awt.Polygons. It extends the SimplePortrayal2D and
it manages the drawing and hit-testing for shapes. Various X and Y point arrays for constructing
different default shapes are also provided.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final Area
static final Shape
static final Area
static final Area
static final Area
static final Shape
static final Area
static final Shape
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
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
ConstructorDescriptionShapePortrayal2D
(double[] xpoints, double[] ypoints) ShapePortrayal2D
(double[] xpoints, double[] ypoints, boolean filled) ShapePortrayal2D
(double[] xpoints, double[] ypoints, double scale) ShapePortrayal2D
(double[] xpoints, double[] ypoints, double scale, boolean filled) ShapePortrayal2D
(double[] xpoints, double[] ypoints, Paint paint) ShapePortrayal2D
(double[] xpoints, double[] ypoints, Paint paint, boolean filled) ShapePortrayal2D
(double[] xpoints, double[] ypoints, Paint paint, double scale) ShapePortrayal2D
(double[] xpoints, double[] ypoints, Paint paint, double scale, boolean filled) ShapePortrayal2D
(double[] xpoints, double[] ypoints, Paint fillPaint, Paint strokePaint, double strokeWidth, double scale) New-style constructors.ShapePortrayal2D
(double[] xpoints, double[] ypoints, Paint fillPaint, Paint strokePaint, Stroke stroke, double scale) New-style constructors.ShapePortrayal2D
(int polygon, Paint fillPaint, Paint strokePaint, double strokeWidth, double scale) New-style constructors.ShapePortrayal2D
(int polygon, Paint fillPaint, Paint strokePaint, Stroke stroke, double scale) New-style constructors.ShapePortrayal2D
(Shape shape) ShapePortrayal2D
(Shape shape, boolean filled) ShapePortrayal2D
(Shape shape, double scale) ShapePortrayal2D
(Shape shape, double scale, boolean filled) ShapePortrayal2D
(Shape shape, Paint paint) ShapePortrayal2D
(Shape shape, Paint paint, boolean filled) ShapePortrayal2D
(Shape shape, Paint paint, double scale) ShapePortrayal2D
(Shape shape, Paint paint, double scale, boolean filled) ShapePortrayal2D
(Shape shape, Paint fillPaint, Paint strokePaint, double strokeWidth, double scale) New-style constructors.ShapePortrayal2D
(Shape shape, 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) Return true if the given object, when drawn, intersects with a provided rectangle, for hit testing purposes.void
setShape
(double[] xpoints, double[] ypoints) void
void
setStroke
(double width) void
Methods inherited from class sim.portrayal.SimplePortrayal2D
getInspector, getName, getStatus, handleMouseEvent, setSelected
-
Field Details
-
shape
-
X_POINTS_TRIANGLE_DOWN
public static final double[] X_POINTS_TRIANGLE_DOWN -
Y_POINTS_TRIANGLE_DOWN
public static final double[] Y_POINTS_TRIANGLE_DOWN -
X_POINTS_TRIANGLE_UP
public static final double[] X_POINTS_TRIANGLE_UP -
Y_POINTS_TRIANGLE_UP
public static final double[] Y_POINTS_TRIANGLE_UP -
X_POINTS_TRIANGLE_RIGHT
public static final double[] X_POINTS_TRIANGLE_RIGHT -
Y_POINTS_TRIANGLE_RIGHT
public static final double[] Y_POINTS_TRIANGLE_RIGHT -
X_POINTS_TRIANGLE_LEFT
public static final double[] X_POINTS_TRIANGLE_LEFT -
Y_POINTS_TRIANGLE_LEFT
public static final double[] Y_POINTS_TRIANGLE_LEFT -
X_POINTS_POINTER_RIGHT
public static final double[] X_POINTS_POINTER_RIGHT -
Y_POINTS_POINTER_RIGHT
public static final double[] Y_POINTS_POINTER_RIGHT -
X_POINTS_POINTER_LEFT
public static final double[] X_POINTS_POINTER_LEFT -
Y_POINTS_POINTER_LEFT
public static final double[] Y_POINTS_POINTER_LEFT -
X_POINTS_POINTER_DOWN
public static final double[] X_POINTS_POINTER_DOWN -
Y_POINTS_POINTER_DOWN
public static final double[] Y_POINTS_POINTER_DOWN -
X_POINTS_POINTER_UP
public static final double[] X_POINTS_POINTER_UP -
Y_POINTS_POINTER_UP
public static final double[] Y_POINTS_POINTER_UP -
X_POINTS_DIAMOND
public static final double[] X_POINTS_DIAMOND -
Y_POINTS_DIAMOND
public static final double[] Y_POINTS_DIAMOND -
X_POINTS_SQUARE
public static final double[] X_POINTS_SQUARE -
Y_POINTS_SQUARE
public static final double[] Y_POINTS_SQUARE -
X_POINTS_BOWTIE
public static final double[] X_POINTS_BOWTIE -
Y_POINTS_BOWTIE
public static final double[] Y_POINTS_BOWTIE -
X_POINTS_HOURGLASS
public static final double[] X_POINTS_HOURGLASS -
Y_POINTS_HOURGLASS
public static final double[] Y_POINTS_HOURGLASS -
X_POINTS_COMPASS
public static final double[] X_POINTS_COMPASS -
Y_POINTS_COMPASS
public static final double[] Y_POINTS_COMPASS -
X_POINTS_STAR
public static final double[] X_POINTS_STAR -
Y_POINTS_STAR
public static final double[] Y_POINTS_STAR -
X_POINTS_PARALLELOGRAM
public static final double[] X_POINTS_PARALLELOGRAM -
Y_POINTS_PARALLELOGRAM
public static final double[] Y_POINTS_PARALLELOGRAM -
X_POINTS_OCTAGON
public static final double[] X_POINTS_OCTAGON -
Y_POINTS_OCTAGON
public static final double[] Y_POINTS_OCTAGON -
X_POINTS_HEXAGON
public static final double[] X_POINTS_HEXAGON -
Y_POINTS_HEXAGON
public static final double[] Y_POINTS_HEXAGON -
X_POINTS_HEXAGON_ROTATED
public static final double[] X_POINTS_HEXAGON_ROTATED -
Y_POINTS_HEXAGON_ROTATED
public static final double[] Y_POINTS_HEXAGON_ROTATED -
POLY_TRIANGLE_UP
public static final int POLY_TRIANGLE_UP- See Also:
-
POLY_TRIANGLE_DOWN
public static final int POLY_TRIANGLE_DOWN- See Also:
-
POLY_TRIANGLE_LEFT
public static final int POLY_TRIANGLE_LEFT- See Also:
-
POLY_TRIANGLE_RIGHT
public static final int POLY_TRIANGLE_RIGHT- See Also:
-
POLY_POINTER_UP
public static final int POLY_POINTER_UP- See Also:
-
POLY_POINTER_DOWN
public static final int POLY_POINTER_DOWN- See Also:
-
POLY_POINTER_LEFT
public static final int POLY_POINTER_LEFT- See Also:
-
POLY_POINTER_RIGHT
public static final int POLY_POINTER_RIGHT- See Also:
-
POLY_DIAMOND
public static final int POLY_DIAMOND- See Also:
-
POLY_SQUARE
public static final int POLY_SQUARE- See Also:
-
POLY_BOWTIE
public static final int POLY_BOWTIE- See Also:
-
POLY_HOURGLASS
public static final int POLY_HOURGLASS- See Also:
-
POLY_COMPASS
public static final int POLY_COMPASS- See Also:
-
POLY_STAR
public static final int POLY_STAR- See Also:
-
POLY_PARALLELOGRAM
public static final int POLY_PARALLELOGRAM- See Also:
-
POLY_OCTAGON
public static final int POLY_OCTAGON- See Also:
-
POLY_HEXAGON
public static final int POLY_HEXAGON- See Also:
-
POLY_HEXAGON_ROTATED
public static final int POLY_HEXAGON_ROTATED- See Also:
-
SHAPE_CIRCLE
-
SHAPE_ROUND_SQUARE
-
SHAPE_VERY_ROUND_SQUARE
-
SHAPE_DELAY
-
SHAPE_REVERSE_DELAY
-
SHAPE_CHOMP
-
SHAPE_PILL
-
SHAPE_STORAGE
-
-
Constructor Details
-
ShapePortrayal2D
public ShapePortrayal2D(double[] xpoints, double[] ypoints) -
ShapePortrayal2D
-
ShapePortrayal2D
public ShapePortrayal2D(double[] xpoints, double[] ypoints, double scale) -
ShapePortrayal2D
-
ShapePortrayal2D
public ShapePortrayal2D(double[] xpoints, double[] ypoints, boolean filled) -
ShapePortrayal2D
-
ShapePortrayal2D
public ShapePortrayal2D(double[] xpoints, double[] ypoints, double scale, boolean filled) -
ShapePortrayal2D
public ShapePortrayal2D(double[] xpoints, double[] ypoints, Paint paint, double scale, boolean filled) -
ShapePortrayal2D
-
ShapePortrayal2D
-
ShapePortrayal2D
-
ShapePortrayal2D
-
ShapePortrayal2D
-
ShapePortrayal2D
-
ShapePortrayal2D
-
ShapePortrayal2D
-
ShapePortrayal2D
public ShapePortrayal2D(double[] xpoints, double[] ypoints, Paint fillPaint, Paint strokePaint, double strokeWidth, double scale) 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. -
ShapePortrayal2D
public ShapePortrayal2D(double[] xpoints, double[] ypoints, Paint fillPaint, Paint strokePaint, Stroke stroke, double scale) 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. -
ShapePortrayal2D
public ShapePortrayal2D(int polygon, Paint fillPaint, Paint strokePaint, double strokeWidth, double scale) 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. -
ShapePortrayal2D
public ShapePortrayal2D(int polygon, Paint fillPaint, Paint strokePaint, Stroke stroke, double scale) 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. -
ShapePortrayal2D
public ShapePortrayal2D(Shape shape, Paint fillPaint, Paint strokePaint, double strokeWidth, double scale) 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. -
ShapePortrayal2D
public ShapePortrayal2D(Shape shape, Paint fillPaint, Paint strokePaint, Stroke stroke, double scale) 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
-
setShape
-
setShape
public void setShape(double[] xpoints, double[] ypoints) -
setStroke
-
setStroke
public void setStroke(double width) -
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
-
hitObject
Description copied from class:SimplePortrayal2D
Return true if the given object, when drawn, intersects with a provided rectangle, for hit testing purposes. The object is drawn 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 region to do hit testing in; often this region is actually of 0 width or height, which might represent a single point. 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.- Overrides:
hitObject
in classSimplePortrayal2D
-