Print

Print


> I think we're missing some context here.  I've created a draw() for a
> sub-class of SparseGridPortrayal2D in which I try to do exactly that,
> not a subclass of, say, OvalPortrayal2D.  Alas, 'object' in my context
> is the entire sparse grid and not the individual object.
> 
> It might be nice if there existed an over-ridable 'drawObject(Object)'
> which is, in turn, called by draw() for the grid level objects.
> (I.e., sort of a Visitor design pattern for grid portrayals.)  Then I
> could do something like the above each time the object is rendered.
> 
> It seems that your draw() is for a sub-class of a simple object
> portrayal?  And, if so, that my object should subclass from that?
> Which is icky because now I'm mixing in rendering state into an object
> when it's not necessarily going to be be used in a graphics context.
> (I.e. not run from a GUI.)

Mark, I think there is some confusion here.  It'd be a pretty rare 
event, if ever, to override SparseGridPortrayal2D.

SparseGridPortrayal2D goes through each of the sparse objects and, one 
by one, calls forth a simple portrayal to draw those objects.  It's that 
simple portrayal you want to override and specify.

1. Create a simple portrayal as discussed.

2. Register the simple portrayal to draw objects in your 
SparseGridPortrayal2D.  There are lots of registration options: have it 
registered to draw a specific object; to draw objects from a given 
Class; to draw all objects; etc.  See the class documentation for 
FieldPortrayals:
	http://cs.gmu.edu/~eclab/projects/mason/docs/classdocs/sim/portrayal/FieldPortrayal.html

I suggest setPortrayalForAll(...)

Sean