[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problems with Value2dDisplay
From: |
Alex Lancaster |
Subject: |
Re: Problems with Value2dDisplay |
Date: |
31 Jul 1998 17:57:10 -0600 |
>>>>> "JM" == James Marshall <address@hidden> writes:
JM> Hi, here's all the relevant code from my buildObjects method in my
JM> observer swarm, as requested by Alex. I hope someone can help me
JM> on this because I really want to use the results from my Swarm sim
JM> in a paper I'm currently writing! James
JM> -buildObjects { populationColourMap=[Colormap create: globalZone];
JM> [populationColourMap setColor: 0 ToName: "blue"]; for (l1=1;
JM> l1<=10; l1++) { [populationColourMap setColor: l1 ToGrey:
JM> (double)l1/10]; }
JM> populationRaster=[ZoomRaster create: globalZone];
JM> [populationRaster setColormap: populationColourMap];
JM> [populationRaster setZoomFactor: (500/[epdSwarm getWorldXSize])];
JM> [populationRaster setWidth: [epdSwarm getWorldXSize] Height:
JM> [epdSwarm getWorldYSize]]; [populationRaster setWindowTitle: "EPD
JM> Population"]; [populationRaster drawSelf]; [populationRaster
JM> pack];
JM> populationDisplay=[Value2dDisplay createBegin: [self getZone]];
JM> [populationDisplay setDisplayWidget: populationRaster colormap:
JM> populationColourMap]; [populationDisplay setDiscrete2dToDisplay:
JM> [epdSwarm getWorldDisplay]]; populationDisplay=[populationDisplay
JM> createEnd]; [populationDisplay setDisplayMappingM: 1 C: 0];
JM> return self; }
>> >>>>> "JM" == James Marshall <address@hidden> writes:
>>
JM> [populationDisplay putValue:
JM> (long)(((double)localPopulation/maxAgents)*10+1) atX: x Y: y];
JM> printf("%i\n",(int)[populationDisplay getValueAtX: x Y: y]);
Are you sure this code is right? You should be attempting to set the
value at each point through the underlying Discrete2d data structure -
in your example it's whatever's returned by the [epdSwarm
getWorldDisplay] method call - rather than the Value2Display instance
variable (iVar).
In other words, Discrete2d grids `know' how to display themselves.
You don't need to explicitly set them.
Are you using the same variable name for the Discrete2d iVar (or
subclass thereof) in your ModelSwarm *and* the Value2dDisplay iVar in
your ObserverSwarm, perhaps?
--- Alex
--
Alex Lancaster | e-mail: address@hidden
Swarm Developer | web: http://www.santafe.edu/~alex
Santa Fe Institute | tel: +1-(505) 984-8800 (ext 242)
------------------------------------------------------------------
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.
==================================