On Aug 2, 2012, at 5:19 AM, Luís de Sousa wrote:
> I have a SparseGrid harbouring objects of assorted classes. I'd like
> to portray one of these classes with a ColourMap, like it is made with
> ValueGrid. This way each object would be portrayed with a different
> colour gradient depending on a particular attribute. Is this possible
> to do? How?
SparseGrid does not support color maps directly. But it's easy enough to do it. Choose or create a SimplePortrayal to display your object. Let's say it's OvalPortrayal2D. Then you can say:
final SimpleColorMap map = new SimpleColorMap( ....... ); // set it up like you'd like
OvalPortrayal2D oval = new OvalPortrayal2D()
public void draw(Object object, Graphics2D graphics, DrawInfo2D info)
MyObjectClass obj = (MyObjectClass) object;
double val = obj.getMyAttribute();
paint = new Color(map.getColor(val));
super.draw(object, graphics, info);
Then just use 'oval' as your portrayal.