Wednesday, April 18, 2007

Creating Slider bars in Repast

Slider bars (as in the image above) are a easy way to change model parameters of a simulation. Someone asked how to create a Slider Bar within a Repast model, so I thought I would share it. To create one is relatively straight forward. All you need to do is place this piece of code in the setup method:

//creates a slider which has to be an int.
RangePropertyDescriptor pdMovement = new RangePropertyDescriptor("Movement", 0, 1000, 200);

descriptors.put("Movement", pdMovement);

Where “Movement” relates to the “Movement” parameter in the getInitParam method. For example:

String [] initparams = {"PerAgents", "Movement",
};
return initparams;
}

Further information on PropertyDescriptors can be found on the Repast Website under "How to Create PropertyDescriptors"


1 comment:

Bennett said...

I just stumbled onto your site. This post saved me a bunch of time! Thanks!