swarm-support
[Top][All Lists]
Advanced

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

Gary's EZbar example updated


From: Paul Johnson
Subject: Gary's EZbar example updated
Date: Fri, 08 Sep 2000 10:31:14 -0500

I just updated Gary's bar chart example and put it here:
http://lark.cc.ukans.edu/~pauljohn/Swarm/OtherPeoplesCode/GaryPolhill/ezbareg-2.0.tar.gz

Note this produces a bar chart, not a histogram. A bar chart shows the
values of a variable for each value of a different variable.

There were some interface changes in the Swarm Histogram library (and
some little thing about the Colormap) that required minor changes in
this code. It runs for me against the Swarm snap from July 26, 2000.

Here is Gary Polhill's note from 11/11/98 

Here then (after some last minute debugging!) is the EZBar class. To use
it, you will need the DBColormap class. These two are included in the
attached gzipped tar, which features a modified version of heatbugs that
includes an example of how to set up an EZBar. (You treat a DBColormap
exactly the same way as you do a Colormap -- except when passing your
colormap to a method that expects something that follows the Colormap
protocol. Then you pass [myColormap getColormap] instead of myColormap.)
DBColormap keeps a record of the text for each colour as a String (e.g.
"#FFC756" or "red3"). These strings are needed by EZBar to send the
colours of each bar to the Histogram (which, if you ask me, really
ought to take a colourmap and an array of Colors for each bar).

EZBar is a hack of EZBin, which allows you (optionally) to set the
colours and labels for each bar. (The labels are displayed as a legend,
not under the axis.) EZBar is given a collection, each member of which
has a method which provides a value for the bar, and, if required, a
method to return a colour, and/or another method to return a label. The
collection graphed is fixed at the time the graph is created. It copes
OK with a member of the collection dying, but won't create a new bar for
new members of the collection. Instead it keeps a count of these in the
outliers instance variable. Unfortunately, I couldn't make sense of the
setActiveOutlierText:count: method in the Histogram class (and I didn't
try overly hard), so the outliers don't get displayed.

I apologise for inconsistent spellings of the word "colour", which
depended on whether I was in English or American mode that day.

The heatbugs mutant app attached has 3 classes of bug. A bar is
displayed on the chart for each bug. (So the default in the modelSwarm
doesn't have many bugs in it.) The bugs are either original heatbugs,
edible heatbugs, or killerbugs (which eat the edible heatbugs, hunting
them down by following the heat gradient). The bar chart displays the
unhappiness of each bug for each cycle. (If the showCurrent method
was not called during the creation of the chart in the observerSwarm,
the chart would show a running average over time.) Each type of bug
gets displayed on the world raster in a different colour, and the
bar chart also displays its bars using these colours, as appropriate.

Gary
-- 
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ukans.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]