/*
* Simple definition of a program parameter without push service.
* This parameter has to be updated by "pulling" it from the parameter
* collection using *parCollection*.getParValue(...).
*/
parsList.add(new SingleParameter(
"GridFields", // Parameter name.
Datatypes.integerRange(0, 200), // Data type.
100, // Standard value.
"The width and height of the field.", // Description.
CARS_PARAMETERS_CATEGORY_NAME)); // Category.
/*
* Better implementation of program parameters including push service.
* Using this method, you do not have to get the parameter values from
* the parameter collection (which is inefficient), but the fields
* given in this class are set automatically to the correct values any
* time a program parameter is changed.
*
* Consider this an example for a parameter connected to a listener class (this).
* The class given as last parameter (CarsParameter.class in this case) has to
* implement a static field with the same name as the parameter name (numCars
* in this case) and, preferably, a static setter method (setNumCars(.) in
* this case) to securely set the field. At program start and at any time
* the respective parameter is set, the ParCollection calls the setter
* method in "push" manner or, if the setter fails, sets the field directly.
* This way of connecting a program parameter to a java field should be
* preferred above checking parameters in "pull" manner using the getParValue...
* methods of ParCollection as it is more efficient and secure.
* (Both the setter and the field may be private if desired.)
*/
parsList.add(new SingleParameter(
NUM_CARS_PAR_NAME, // Parameter name.
Datatypes.integerRange(0, 2000), // Data type.
100, // Standard value.
"The number of cars.", // Description.
CARS_PARAMETERS_CATEGORY_NAME, // Category.
TrafficParameters.class)); // NEW! Listener class connected to the parameter.
parsList.add(new SingleParameter(
NUM_STREETS_PAR_NAME,
Datatypes.integerRange(1, 12),
5,
"The number of streets in each direction.",
CARS_PARAMETERS_CATEGORY_NAME,
TrafficParameters.class));
parsList.add(new SingleParameter(
CAR_MAX_SPEED_PAR_NAME,
Datatypes.integerRange(0, 100),
100,
"The maximum speed any car can have as target speed.",
CARS_PARAMETERS_CATEGORY_NAME,
TrafficParameters.class));
parsList.add(new SingleParameter(
CAR_MIN_SPEED_PAR_NAME,
Datatypes.integerRange(0, 100),
100,
"The minimum speed any car can have as target speed.",
CARS_PARAMETERS_CATEGORY_NAME,
TrafficParameters.class));
parsList.add(new SingleParameter(
TWO_LANES_PAR_NAME,
Datatypes.BOOLEAN,
true,
"If every street has two directions (or else one).",
CARS_PARAMETERS_CATEGORY_NAME,
TrafficParameters.class));
parsList.add(new SingleParameter(
ACTIVATE_COLL_STRAT_PAR_NAME,
Datatypes.BOOLEAN,
true,
"If the collision strategy is used (or else not).",
CARS_PARAMETERS_CATEGORY_NAME,
TrafficParameters.class));
parsList.add(new SingleParameter(
PROPORTION_OF_ROUNDABOUTS_PAR_NAME,
Datatypes.integerRange(0, 100),
50,
"The percentage of roundabouts in relation to crossings.",
CARS_PARAMETERS_CATEGORY_NAME,
TrafficParameters.class));
parsList.add(new SingleParameter(
ROUNDABOUT_RADIUS_PAR_NAME,
Datatypes.integerRange(2, 20),
4,
"The roundabout radius.",
CARS_PARAMETERS_CATEGORY_NAME,
TrafficParameters.class));
parsList.add(new SingleParameter(
NUM_OF_STORED_TRACE_POINTS_PAR_NAME,
Datatypes.INTEGER,
40,
"The length of the trace displayed for each car.",
CARS_PARAMETERS_CATEGORY_NAME,
TrafficParameters.class));
parsList.add(new SingleParameter(
"collisionStrategy",
Datatypes.fixedStringSet(StrategyFactory.getCollisionClassNames()),
StrategyFactory.getCollisionClassNames()[0],
"The collision strategy followed by the cars.",
CARS_PARAMETERS_CATEGORY_NAME,
TrafficParameters.class));
parsList.add(new SingleParameter(
"drivingStrategy",
Datatypes.fixedStringSet(StrategyFactory.getDrivingClassNames()),
StrategyFactory.getDrivingClassNames()[0],
"The driving strategy followed by the cars.",
CARS_PARAMETERS_CATEGORY_NAME,