sim.portrayal.simple
Class ShapePortrayal2D

java.lang.Object
  extended bysim.portrayal.SimplePortrayal2D
      extended bysim.portrayal.simple.ShapePortrayal2D
All Implemented Interfaces:
Portrayal, Portrayal2D, java.io.Serializable

public class ShapePortrayal2D
extends SimplePortrayal2D

A simple portrayal for 2D visualization of java.awt.Shapes. It extends the SimplePortrayal2D and it manages the drawing and hit-testing for shapes.

See Also:
Serialized Form

Field Summary
 java.awt.Paint paint
           
 double scale
           
 java.awt.Shape shape
           
 
Constructor Summary
ShapePortrayal2D(java.awt.Shape shape)
           
ShapePortrayal2D(java.awt.Shape shape, double scale)
           
ShapePortrayal2D(java.awt.Shape shape, java.awt.Paint paint)
           
ShapePortrayal2D(java.awt.Shape shape, java.awt.Paint paint, double scale)
           
 
Method Summary
 void draw(java.lang.Object object, java.awt.Graphics2D graphics, DrawInfo2D info)
          Draw a portrayed object centered at the origin in info, and with the given scaling factors.
 boolean hitObject(java.lang.Object object, DrawInfo2D range)
          If drawing area intersects selected area, return true.
 
Methods inherited from class sim.portrayal.SimplePortrayal2D
getInspector, getName, move, 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
Constructor Detail

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)
Method Detail

draw

public void draw(java.lang.Object object,
                 java.awt.Graphics2D graphics,
                 DrawInfo2D info)
Description copied from interface: Portrayal2D
Draw a portrayed object centered at the origin in info, and with the given scaling factors. draw(...) will not be called until portray(obj) has been called on a Portrayal2D at least once. But you should have some default null drawing capability just in case.

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
If drawing area intersects selected area, return true. The default computes the intersection with the (-0.5,-0.5) to (0.5,0.5) rectangle.

Overrides:
hitObject in class SimplePortrayal2D