Print

Print


Absolutely: it's straightforward to do this.  There are several 
portrayals which change their color etc. based on the current 'value' of 
the object (by calling a method to query it).  You can use those 
depending on the kind of field portrayal you're using.  Or you could 
just make a custom version of an existing portrayal.  Most 2D portrayals 
have an instance variable called paint which is used to set the graphics 
color.  So you could do this:

public MyPortrayal extends RectanglePortrayal2D
	{
     	public void draw(Object object,
			Graphics2D graphics, DrawInfo2D info)
		{
		MyObject obj = (MyObject)object;
		paint = obj.theColorIWant();
		super.draw(object, graphics, info);
		}
	}

You could also have your objects act as their own portrayal, which gives 
you complete control over drawing.

I oughta add something like this into the FAQ now that I think of it.

Sean

Mike King wrote:
> Hello!
> 
> We using MASON to try and simulate a traffic scenario where cars and 
> traffic lights are agents, and we would like to be able to update the 
> color of the traffic lights during the simulation.  Is there any way to 
> update the portrayal as the simulation is running?  Or perhaps add and 
> remove agents as the simulation is running?  We would really like to use 
> setupPortrayals() to setup the initial portrayal and then update the 
> portrayal each step.
> 
> Thanks very much!
> Mike
>