On Sep 13, 2010, at 12:27 PM, Stuart Rossiter wrote:
> My understanding has always been that the draw.width and draw.height
> of the DrawInfo2D passed to an object for portrayal represent the
> unit width
> and height in the "true" coordinate space (i.e., those you use when
> drawing objects such as a Rectangle). As such, I'd expect these to
> be the
> same for all drawn objects, since the grid sizing has to be
> (To be clear, my nodes might be on a 100x100 grid. The draw.width
> represents the number of what-you-actually-draw x coordinate units
> corresponding to 1 unit on the x axis of this grid.)
> For the most part they are, and everything renders OK. However, on
> occasions, I get *different* unit widths or heights for different
> (Specifically, I had a different unit width (8.0) for the first
> node drawn,
> compared to all the others (7.0).)
I'm not sure what's happening in your code to cause this, but
SparseGrid2D uses the exact same DrawInfo2D object for all of your
simple portrayals. Is it possible that you are modifying DrawInfo2D's
rectangles or retaining them during portrayal when you shouldn't be?
As a reminder, since DrawInfo2D is a bit opaque:
DrawInfo2D.draw is a Rectangle2D.Double which defines the following:
DrawInfo2D.draw.x and y
The origin of your object as drawn in your Graphics2D
DrawInfo2D.draw.width and height
How many pixels wide 1 unit is in your model world.
Typicall objects are drawn centered at their origin, and about 1 unit
high and wide each.
DrawInfo2D.clip is a Rectangle2D.Double which defines the rectangle on-
screen which is presently visible to the user. You shouldn't bother
drawing anything which lies outside the clip.
DrawInfo2D.selected indicates if the object is presently selected
DrawInfo2D.precise indicates that you ought to draw using high quality
floating-point graphics routines, not discrete AWT-style ones (it's
probably being drawn to PDF)
DrawInfo2D.location tells you where the object is located in the
Field. This is an auxillary variable and may not be used in all
Fields or Portrayals. You are free to ignore it.