swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

One problem, one distraction


From: Paul E. Johnson
Subject: One problem, one distraction
Date: Tue, 02 Feb 1999 16:10:00 -0600

I'm fiddling with an ObserverSwarm.  I have 2 questions:

I now have working code that creates a sequence of rasters, puts each in
a list, and makes a display.  I created a new class "WhiteRaster" which
is just a ZoomRaster descendant that has a white background and can
respond to a few methods.  For concreteness, here's the code:

   for(i=0; i< (DIMENSION/2); i++)
     {
   char rasterName[15];
   policyRaster = [WhiteRaster create: [self getZone]];
   [policyRaster setSpaceNumber: i];
   sprintf(rasterName,"PolicySpace%02d",i);
   SET_WINDOW_GEOMETRY_RECORD_NAME(rasterName); // [[line 07 ]]
   [policyRaster setColormap: colorMap];
   [policyRaster setZoomFactor: 4];
   [policyRaster setWidth: [[modelSwarm getPolicySpace:i] getSizeX]
                 Height: [[modelSwarm getPolicySpace:i] getSizeY]];
  [policyRaster setWindowTitle: rasterName];
  [policyRaster pack];                             // draw the window.
  [policyRasterList addLast: policyRaster];

  voterDisplay = [Object2dDisplay createBegin: [self getZone]];
  [voterDisplay setDisplayWidget: policyRaster];
  [voterDisplay setDiscrete2dToDisplay: [modelSwarm getPolicySpace:i]];
  [voterDisplay setObjectCollection: [modelSwarm getCitizenList]];
  [voterDisplay setDisplayMessage: M(drawSelfOn:)];   // [[line 19]]
   voterDisplay = [voterDisplay createEnd];
  [voterDisplayList addLast: voterDisplay];

   policyDisplay = [Object2dDisplay createBegin: [self getZone]];
   [policyDisplay setDisplayWidget: policyRaster];
   [policyDisplay setDiscrete2dToDisplay: [modelSwarm
getPolicySpace:i]];
   [policyDisplay setObjectCollection: [modelSwarm getRecruiterList]];

   [policyDisplay setDisplayMessage: M(drawProposalOn:)];   // draw
method
   policyDisplay = [policyDisplay createEnd];
   [policyDisplayList addLast: policyDisplay];
  

   [policyRaster setButton: ButtonRight Client: voterDisplay Message:
M(makeProbeAtX:Y:)];

     }

There are 2 problems.
1. Line  07 causes acompiler error:
ObserverSwarm.m: In function `_i_ObserverSwarm__buildObjects':
ObserverSwarm.m:158: warning: invalid receiver type `char  []'
ObserverSwarm.m:158: invalid use of non-lvalue array
ObserverSwarm.m:158: invalid use of non-lvalue array
make: *** [ObserverSwarm.o] Error 1

Why? Comment that out, this works fine.

2. There's something funny in the way the compiler processes the
setDisplayMessage for the Object2dDisplay. Implicitly this passes the
raster to which the object that will draw itself, which is a WhiteRaster
object. 

  [voterDisplay setDisplayMessage: M(drawSelfOn:)];   // [[line 19]]

I say "implicitly" because the identity of the raster is passed as a
parameter of drawSwlfOn.  Inside the target object, there is a method

-drawSelfOn: (id <Raster>) r 

and inside that method I make calls on the WhiteRaster object to reveal
some information about itself before the object decides how to draw
itself. The WhiteRaster object does indeed respond and the program runs.
The object drawing itself is Citizen and inside its drawSelfOn method
there are calls like [r getXDimNumber] and [r getYDimNumber]. The
compiler seems to think the object on which the Citizen is to draw is
Object2dDisplay, rather than WhiteRaster, so I get these warnings 

Citizen.m:331: warning: method `getXDimNumber' not implemented by
protocol.
Citizen.m:331: warning: return type defaults to id
Citizen.m:331: warning: method `getYDimNumber' not implemented by
protocol.
Citizen.m:331: warning: return type defaults to id

What do you think?

-- 
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (913) 864-9086
Lawrence, Kansas 66045                FAX: (913) 864-5700

                  ==================================
   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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]