[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: drawing agents like ellipses or lines?
From: |
Marcus G. Daniels |
Subject: |
Re: drawing agents like ellipses or lines? |
Date: |
06 Oct 2001 10:50:22 -0600 |
User-agent: |
Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.7 |
>>>>> "JB" == Jozef Babjak <address@hidden> writes:
JB> Hi, I tried to draw agents with method
JB> Raster.ellipseX0$Y0$X1$Y1$Width$Color(int, int, int, int, int,
JB> byte);
JB> but I saw only lines from left-top to right-bottom corner; not
JB> ellipses. I using Win2000 Pro SP1 and Swarm 2.1.1.
This works for me on both Linux and Windows 2000. I'm using the 2.2 pretest,
but I'm pretty sure this has been working since 2.1.1.1.
import swarm.Globals;
import swarm.defobj.Zone;
import swarm.random.NormalDist;
import swarm.random.NormalDistImpl;
import swarm.simtoolsgui.GUISwarmImpl;
import swarm.simtoolsgui.GUISwarm;
import swarm.gui.Colormap;
import swarm.gui.ColormapImpl;
import swarm.gui.RasterImpl;
import swarm.gui.Raster;
import swarm.activity.Schedule;
import swarm.activity.ScheduleImpl;
import swarm.activity.Activity;
import swarm.objectbase.Swarm;
import swarm.Selector;
class DrawEllipse extends GUISwarmImpl {
Schedule schedule;
NormalDist normalDist;
Raster raster;
static void main (String args[]) {
Globals.env.initSwarm ("DrawEllipse", "0.0", "bug-swarm.org", args);
GUISwarm guiSwarm = new DrawEllipse (Globals.env.globalZone);
guiSwarm.buildObjects ();
guiSwarm.buildActions ();
guiSwarm.activateIn (null);
guiSwarm.go ();
}
public DrawEllipse (Zone aZone) {
super (aZone);
}
public Object buildObjects () {
super.buildObjects ();
Colormap colormap = new ColormapImpl (getZone ());
colormap.setColor$ToName ((byte) 1, "green");
raster = new RasterImpl (getZone (), "raster");
raster.setColormap (colormap);
raster.setWidth$Height (200, 200);
raster.setWindowTitle ("Test");
raster.pack ();
raster.erase ();
normalDist = new NormalDistImpl (getZone (),
Globals.env.randomGenerator,
100.0, 50.0);
return this;
}
public void resample () {
int diameter = (int) normalDist.getDoubleSample ();
raster.ellipseX0$Y0$X1$Y1$Width$Color (100 - diameter, 100 - diameter, 100
+ diameter, 100 + diameter, 1, (byte) 1);
raster.drawSelf ();
getActionCache ().doTkEvents ();
}
public Object buildActions () {
super.buildActions ();
schedule = new ScheduleImpl (getZone (), 1);
try {
Selector sel = new Selector (getClass (), "resample", false);
schedule.at$createActionTo$message (0, this, sel);
} catch (Exception e) {
e.printStackTrace (System.err);
System.exit (1);
}
return this;
}
public Activity activateIn (Swarm swarmContext) {
super.activateIn (swarmContext);
schedule.activateIn (this);
return getActivity ();
}
}
==================================
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.
- Problem with using RAM, Babjak Jozef, 2001/10/03
- simple problem, Holger Perlt, 2001/10/10
- Re: simple problem, pauljohn, 2001/10/10
- Archiver / syntax, Holger Perlt, 2001/10/11
- syntax etc., Holger Perlt, 2001/10/12
- Using Averager ( was Re: syntax etc., pauljohn, 2001/10/12
- Re: syntax etc., Marcus G. Daniels, 2001/10/12