sim.portrayal
Class DrawInfo2D

java.lang.Object
  extended bysim.portrayal.DrawInfo2D
Direct Known Subclasses:
EdgeDrawInfo2D, HexaDrawInfo2D

public class DrawInfo2D
extends java.lang.Object

The DrawInfo2D class provides two Rectangles which define a simple drawing situation.

The draw rectangle describes a box which should be considered to define the coordinates and scale for the object being drawn. That is, the object should imagine that it's located at the origin [the box's coordinate], and is being drawn relative to the scale [the box's values]. While continuous objects will probably center themselves on the origin, Discrete 2D objects typically will draw themselves to fill the box (the box effectively defines the [0,0] to [1,1] range). You may assume that the coordinates will never be fipped or zeroed (that is, the width and height will not be negative or 0).

Why is this rectangle being provided instead of just using an affine transform on the grahics object to scale and translate the space? Two reasons. First, affine transforms are expensive in Java2D. Second, if you need to draw auxillary information (like readable text), the text would also get transformed (scaled), which is not what we want. Line thickness is also likewise transformed, which might or might not be desirable.

The clip rectangle describes a box defining a region that must be drawn. This region will always intersect at least partially with the draw rectangle.

Why provide this clip rectangle? Because to my knowledge there's no standard way to tell objects that only part of them needs to be updated in Java2D and Swing -- a failure of the system design.


Field Summary
 java.awt.geom.Rectangle2D.Double clip
           
 java.awt.geom.Rectangle2D.Double draw
           
 
Constructor Summary
DrawInfo2D(java.awt.geom.Rectangle2D.Double draw, java.awt.geom.Rectangle2D.Double clip)
           
DrawInfo2D(java.awt.Rectangle draw, java.awt.Rectangle clip)
           
DrawInfo2D(java.awt.geom.RectangularShape draw, java.awt.geom.RectangularShape clip)
           
 
Method Summary
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

draw

public java.awt.geom.Rectangle2D.Double draw

clip

public java.awt.geom.Rectangle2D.Double clip
Constructor Detail

DrawInfo2D

public DrawInfo2D(java.awt.geom.Rectangle2D.Double draw,
                  java.awt.geom.Rectangle2D.Double clip)

DrawInfo2D

public DrawInfo2D(java.awt.Rectangle draw,
                  java.awt.Rectangle clip)

DrawInfo2D

public DrawInfo2D(java.awt.geom.RectangularShape draw,
                  java.awt.geom.RectangularShape clip)
Method Detail

toString

public java.lang.String toString()