sim.portrayal.simple
Class ShapePortrayal2D

java.lang.Object
  extended by sim.portrayal.SimplePortrayal2D
      extended by sim.portrayal.simple.ShapePortrayal2D
All Implemented Interfaces:
java.io.Serializable, Portrayal, Portrayal2D
Direct Known Subclasses:
HexagonalPortrayal2D

public class ShapePortrayal2D
extends SimplePortrayal2D

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.

See Also:
Serialized Form

Field Summary
 boolean filled
           
 java.awt.Paint paint
           
 double scale
           
 java.awt.Shape shape
           
 java.awt.Stroke stroke
           
 
Fields inherited from class sim.portrayal.SimplePortrayal2D
TYPE_HIT_OBJECT, TYPE_SELECTED_OBJECT
 
Constructor Summary
ShapePortrayal2D(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, java.awt.Paint paint)
           
ShapePortrayal2D(double[] xpoints, double[] ypoints, java.awt.Paint paint, boolean filled)
           
ShapePortrayal2D(double[] xpoints, double[] ypoints, java.awt.Paint paint, double scale)
           
ShapePortrayal2D(double[] xpoints, double[] ypoints, java.awt.Paint paint, double scale, boolean filled)
           
ShapePortrayal2D(java.awt.Shape shape)
           
ShapePortrayal2D(java.awt.Shape shape, boolean filled)
           
ShapePortrayal2D(java.awt.Shape shape, double scale)
           
ShapePortrayal2D(java.awt.Shape shape, double scale, boolean filled)
           
ShapePortrayal2D(java.awt.Shape shape, java.awt.Paint paint)
           
ShapePortrayal2D(java.awt.Shape shape, java.awt.Paint paint, boolean filled)
           
ShapePortrayal2D(java.awt.Shape shape, java.awt.Paint paint, double scale)
           
ShapePortrayal2D(java.awt.Shape shape, java.awt.Paint paint, double scale, boolean filled)
           
 
Method Summary
 void draw(java.lang.Object object, java.awt.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(java.lang.Object object, DrawInfo2D range)
          Return true if the given object, when drawn, intersects with a provided rectangle, for hit testing purposes.
 void setStroke(java.awt.Stroke s)
           
 
Methods inherited from class sim.portrayal.SimplePortrayal2D
getInspector, getName, getStatus, handleMouseEvent, setSelected
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

paint

public java.awt.Paint paint

scale

public double scale

shape

public java.awt.Shape shape

stroke

public java.awt.Stroke stroke

filled

public boolean filled
Constructor Detail

ShapePortrayal2D

public ShapePortrayal2D(double[] xpoints,
                        double[] ypoints)

ShapePortrayal2D

public ShapePortrayal2D(double[] xpoints,
                        double[] ypoints,
                        java.awt.Paint paint)

ShapePortrayal2D

public ShapePortrayal2D(double[] xpoints,
                        double[] ypoints,
                        double scale)

ShapePortrayal2D

public ShapePortrayal2D(double[] xpoints,
                        double[] ypoints,
                        java.awt.Paint paint,
                        double scale)

ShapePortrayal2D

public ShapePortrayal2D(double[] xpoints,
                        double[] ypoints,
                        boolean filled)

ShapePortrayal2D

public ShapePortrayal2D(double[] xpoints,
                        double[] ypoints,
                        java.awt.Paint paint,
                        boolean filled)

ShapePortrayal2D

public ShapePortrayal2D(double[] xpoints,
                        double[] ypoints,
                        double scale,
                        boolean filled)

ShapePortrayal2D

public ShapePortrayal2D(double[] xpoints,
                        double[] ypoints,
                        java.awt.Paint paint,
                        double scale,
                        boolean filled)

ShapePortrayal2D

public ShapePortrayal2D(java.awt.Shape shape)

ShapePortrayal2D

public ShapePortrayal2D(java.awt.Shape shape,
                        java.awt.Paint paint)

ShapePortrayal2D

public ShapePortrayal2D(java.awt.Shape shape,
                        double scale)

ShapePortrayal2D

public ShapePortrayal2D(java.awt.Shape shape,
                        java.awt.Paint paint,
                        double scale)

ShapePortrayal2D

public ShapePortrayal2D(java.awt.Shape shape,
                        boolean filled)

ShapePortrayal2D

public ShapePortrayal2D(java.awt.Shape shape,
                        java.awt.Paint paint,
                        boolean filled)

ShapePortrayal2D

public ShapePortrayal2D(java.awt.Shape shape,
                        double scale,
                        boolean filled)

ShapePortrayal2D

public ShapePortrayal2D(java.awt.Shape shape,
                        java.awt.Paint paint,
                        double scale,
                        boolean filled)
Method Detail

setStroke

public void setStroke(java.awt.Stroke s)

draw

public void draw(java.lang.Object object,
                 java.awt.Graphics2D graphics,
                 DrawInfo2D info)
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 interface Portrayal2D
Overrides:
draw in class SimplePortrayal2D

hitObject

public boolean hitObject(java.lang.Object object,
                         DrawInfo2D range)
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 class SimplePortrayal2D