Print

Print


I belive you want Method 2: interpolation:

public SimpleColorMap(double minLevel, double maxLevel, Color minColor, Color maxColor)

what you're doing is Method 1: color table.

public SimpleColorMap(Color[] colorTable)

Here's the relevant part of the javadoc comment for the SimpleColorMap
class:

<li> Method 1: a color table.  The user can provide an array of Colors;
if the numerical value, cast into an integer, is between 0 and (the
length of this array - 1), then the appropriate Color is returned.

<li> Method 2: color interpolation.  The user can provide a min-level,
min-Color, max-level, and max-Color. If the numerical value is below
min-level, then minColor is provided. If it's above max-level, then
max-Color is provided.  If it's between min-level and max-level, then a
linear interpolation between min-Color and max-Color is provided.

BTW, you can also mix them.
Good luck,
Gabriel

On Sat, 4 Apr 2009, MASON-INTEREST-L automatic digest system wrote:

> There is 1 message totalling 49 lines in this issue.
>
> Topics of the day:
>
>   1. Problem displaying FastObjectGridPortrayal2D
>
> ----------------------------------------------------------------------
>
> Date:    Fri, 3 Apr 2009 19:19:38 -0400
> From:    Mark Coletti <[log in to unmask]>
> Subject: Problem displaying FastObjectGridPortrayal2D
>
> I have a FastObjectGridPortrayal2D of objects.  Each cell in the grid
> should change colors depending on a property of their respective
> objects.  However, the simulation does not change colors during runs
> as it should.
>
> I'm doing the following:
>
> - the objects stored in each FastObjectGridPortrayal2D cell is a
> Valuable and so declares a doubleValue() that returns a uniformly
> random (0,1]
>
> - where I set up portrayals in my SimState I do the following:
>
>         landPortrayal.setField(world.allLand); // world.allLand is an
> ObjectGrid2D with each element a Valued and Steppable object
> registered with Scheduler
>
>         landPortrayal.setMap(
>             new sim.util.gui.SimpleColorMap(
>                 new Color[] {Color.GREEN, Color.YELLOW}));
>
>    That is, I want (0,1] to map from green to yellow values.
>
> - Each stored object in my FastObjectGridPortrayal2D is a Steppable
> and is registered with the scheduler so that its doubleValue()
> iterates to the next random double
>
> I have verified that each object is setting doubleValue() to different
> random values and not to all zeros; yet all I see is a solid green
> block during runs.
>
> What am I doing wrong?
>
> Cheers,
>
> Mark
>