swarm-support
[Top][All Lists]
Advanced

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

EZBar class


From: Gary Polhill
Subject: EZBar class
Date: Wed, 11 Nov 1998 15:02:32 +0000

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

--

Macaulay Land Use Research Institute, Craigiebuckler, Aberdeen. AB15 8QH
Tel: +44 (0) 1224 318611               Email: address@hidden


Attachment: ezbareg.tar.gz
Description: GNU Zip compressed data


reply via email to

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