MASON-INTEREST-L Archives

March 2009

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:
Sun, 15 Mar 2009 22:06:43 -0400
MIME-version:
1.0
Reply-To:
Content-type:
text/plain; charset=ISO-8859-1; format=flowed
Subject:
From:
Sean Luke <[log in to unmask]>
In-Reply-To:
Content-transfer-encoding:
7bit
Comments:
To: MASON Multiagent Simulation Toolkit <[log in to unmask]>
Parts/Attachments:
text/plain (41 lines)
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
> 

ATOM RSS1 RSS2