swarm-support
[Top][All Lists]
Advanced

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

Re: drawHistogramWithDouble ()


From: Paul Johnson
Subject: Re: drawHistogramWithDouble ()
Date: Mon, 04 Feb 2002 18:41:12 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.7) Gecko/20020104

In the current swarm source, I find this method in tkobjc/Histogram.m


- (void)drawHistogramWithDouble: (double *)points
{
  unsigned i;

  for (i = 0; i < binCount; i++)
    [globalTkInterp eval: "%s element configure %s -data { %d %f }",
                    widgetName, elements[i], i, points[i]];
}

If it works in Java, it seems to me it ought to work in Obj-C. What errors do you get if you try it? I used to have some working Histogram code around here in Obj-C, [looking]. Ah, ASM-2.2 (http://ArtStkMkt.sourceforge.net) has it:


--- a bit from buildObjects looks like:
  positionHisto = [Histogram createBegin: [self getZone]];
  SET_WINDOW_GEOMETRY_RECORD_NAME (positionHisto);
  [positionHisto setBinCount: numagents];
  positionHisto = [positionHisto createEnd];

  [positionHisto setWidth: 500 Height: 250];
  [positionHisto hideLegend];
  [positionHisto setTitle: "Agent Position"];
  [positionHisto setAxisLabelsX: "agents" Y: "position"];
  [positionHisto pack];
----

and the method called to redraw on that at each step is:

- updateHistos
{
  id index;
  id agent;
  int i;
  int numagents = [[asmModelSwarm getAgentList] getCount];
  double position[numagents];
  double relativeWealth[numagents];
  //double cash[numagents];

  index = [[asmModelSwarm getAgentList] begin: [self getZone]];

  for(i=0; (agent = [index next]); i++)
    {
      double initcash=[(id)arguments getModelParams]->initialcash;
      position[i] = [agent getAgentPosition];
      relativeWealth[i] = [agent getWealth]/initcash;
      //cash[i] = [agent getCash];
    }
  [index drop];
  [positionHisto drawHistogramWithDouble: position];
  [relativeWealthHisto drawHistogramWithDouble: relativeWealth];
  //[cashHisto drawHistoWithDouble: cash];

  return self;
}




Luis R. Izquierdo wrote:

Hi everybody!

Does anyone know what is the equivalent in Java-Swarm implementation for the method drawHistogramWithDouble() in objective C ?

Thanks a lot!

Luis




--
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ku.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 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]