swarm-support
[Top][All Lists]
Advanced

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

Re: What is the mistake ?!


From: Marcus G. Daniels
Subject: Re: What is the mistake ?!
Date: 05 Aug 2000 13:59:36 -0700
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4

>>>>> "M" == Mehrez Essafi <Mehrez> writes:

M> I found difficulties building an histogram in a java version
M> application and I have'nt an exemple of that. 

The thing is how the phases are connected together by the creating phase 
constructor... specifically, this line:

    ezBinC = new EZBinCImpl (new EZBinImpl ());

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.



reply via email to

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