[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Java EZBin Implementation
From: |
Marcus G. Daniels |
Subject: |
Re: Java EZBin Implementation |
Date: |
09 May 2000 17:29:38 -0700 |
User-agent: |
Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4 |
>>>>> "MS" == Michele Sonnessa <address@hidden> writes:
MS> I would like to ask if it is possible in JavaSwarm to use
MS> the class EZBin to make an Histogram.
Below is an example of how this can be done.
In Java, there is a clear distinction between creating and using
phases: they are different classes. So a trickier part is connecting the
phases together. You do that with the
new EZBinCImpl (new EZBinImp ())
expression. The rest is like Objective C. (When there are
using-phase constructors like in EZGraph, it's easier since the phase
switch is hidden.)
Oh, I noticed there's a problem with the use of string setters in this
class, so you may want to get updated DLLs and a new swarm.jar from:
ftp://ftp.swarm.org/pub/swarm/binaries/w32/2.1.1-fixes
import swarm.Globals;
import swarm.analysis.EZBinC;
import swarm.analysis.EZBin;
import swarm.analysis.EZBinCImpl;
import swarm.analysis.EZBinImpl;
import swarm.simtoolsgui.GUISwarmImpl;
import swarm.defobj.Zone;
import swarm.collections.List;
import swarm.collections.ListImpl;
import swarm.Selector;
public class EZBinDemo extends GUISwarmImpl {
class Agent {
double value;
Agent (double value) {
this.value = value;
}
public double getAgentValue () {
return value;
}
}
EZBin ezBin;
List list;
EZBinDemo (Zone aZone) {
super (aZone);
list = new ListImpl (aZone);
for (int i = 0; i < 200; i++)
list.addLast (new Agent (Math.log (i)));
EZBinC ezBinC;
ezBinC = new EZBinCImpl (new EZBinImpl ());
ezBinC.createBegin (aZone);
ezBinC.setBinCount (10);
ezBinC.setLowerBound (0);
ezBinC.setUpperBound (5);
ezBinC.setCollection (list);
ezBinC.setTitle ("My EZBin");
ezBinC.setAxisLabelsX$Y ("count of log (i)", "i");
try {
ezBinC.setProbedSelector (new Selector (Agent.class,
"getAgentValue",
false));
} catch (Exception e) {
e.printStackTrace (System.err);
System.exit (1);
}
ezBin = (EZBin) ezBinC.createEnd ();
}
void show () {
ezBin.update ();
ezBin.output ();
}
static public void main (String args[]) {
Globals.env.initSwarm ("EZBinDemo", "0.0", "address@hidden", args);
EZBinDemo ezBinDemo = new EZBinDemo (Globals.env.globalZone);
ezBinDemo.show ();
ezBinDemo.buildObjects ();
ezBinDemo.buildActions ();
ezBinDemo.activateIn (null);
ezBinDemo.go ();
}
}
==================================
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.