MASON-INTEREST-L Archives

August 2012

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Thu, 2 Aug 2012 05:48:32 +0900
MIME-version:
1.0 (Apple Message framework v1084)
Reply-To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Content-type:
text/plain; charset=iso-8859-1
Subject:
From:
Sean Luke <[log in to unmask]>
In-Reply-To:
Content-Transfer-Encoding:
8bit
Parts/Attachments:
text/plain (28 lines)
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.

Sean

ATOM RSS1 RSS2