swarm-support
[Top][All Lists]
Advanced

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

general gizmos


From: Ginger Booth
Subject: general gizmos
Date: Fri, 19 Jan 96 13:54:33 EST

TWIMC:

    Chris asked if anybody had written any generally useful gizmos.  These
aren't much, but I offer them up.  Let me know if you're interested.

// A graph that fetches its data, draws it.  Actually traces anything of
// integral value, but default labels are for populations.
@interface TraceGraph : SwarmObject {
    ...etc...
}
+create;
-track: (unsigned*) censusvar Key: (char*) label Color: (char*) colorname;
-setWinTitle: (char*) label;
-setYAxisLabel: (char*) label;
-createEnd;
-step;                                  
@end

// Since all in this graph is expressed as a percent, we need to explicitly
// say what to use as onehundred % to scale everything else.  I intend to
// use different divisors for different items in the same graph.  Hence, the
// "data" and "onehundred" lists.  Default labels "Population Structure".
@interface FuzzyGraph : SwarmObject {           // a histogram for buckets
    ...etc...
}
+create;
-track: (unsigned*) datavar Scale: (unsigned*) onehunvar 
   Key: (char*) label Color: (char*) colorname;
-setWinTitle: (char*) label;
-setXAxisLabel: (char*) label;
-setYAxisLabel: (char*) label;
-createEnd;
-step;                                          
@end


Example use:

void makeStatGraphs()
{
    popGraph = [TraceGraph create];
    [popGraph track: &censusCritters Key: "Plants"  Color: "green3"];
    [popGraph track: &censusGrazers  Key: "Goppers" Color: "goldenrod1"];
    [popGraph track: &censusCarnies  Key: "Spiders" Color: "purple"];
    popGraph = [popGraph createEnd];
    
    plantStatGraph = [FuzzyGraph create];
    [plantStatGraph track: &deadCritterBins->infant 
                Scale: &deadCritterBins->total
                Key: "InfantM" Color: "black"];
    [plantStatGraph track: &liveCritterBins->childless
                Scale: &liveCritterBins->headcount
                Key: "Nokids" Color: "green4"];
    [plantStatGraph track: &liveCritterBins->somekids
                Scale: &liveCritterBins->headcount
                Key: "Somekids" Color: "green4"];
    [plantStatGraph track: &liveCritterBins->manykids
                Scale: &liveCritterBins->headcount
                Key: "Manykids" Color: "green4"];
    [plantStatGraph setXAxisLabel: "Plants"];
    plantStatGraph = [plantStatGraph createEnd];
}

// then in main.m somewhere
  [displayActions createActionTo: popGraph message: M(step)];
  [displayActions createActionTo: plantStatGraph message: M(step)];

Ciao,
    Ginger
    


reply via email to

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