I have a model that uses the Geomason library to have the districts of a
country as a GeomVectorField. The colour of each district changes based
on how many agents are in the district (similar to the Colorworld example).
What I would like to do now is that the user of the model should be able
to change the quantity on which the colour is based. So for example, the
number of agents in the district would be the standard quantity, but
another possible quantity to choose from could be the percentage of
agents with a certain attribute (say, over 65 years old).
I know that it is possible to change global model parameters with an
inspector if the parameter is implemented as a property (with getter and
setter methods). However, I feel that the type of quantity to display
should rather be a property of the GUI, not of the model. Unfortunately,
if I overwrite the getSimulationInspectedObject() method and return not
"state", but the GUIState itself, I get only errors.
The other problem is that if the user changes what quantity to display
this must somehow be communicated to the portrayals. So instead of
calling something like district.getNumberOfPeople() in the draw()
method, the portrayal should change that to something like
Now I'm clueless about what the best way to make the portrayals aware of
the global model parameter that governs which quantity to display is.
Every portrayal could hold a reference to the SimState, but I don't know
if this really is a good design. Maybe some different, better way is
intended for doing this?
Thanks and kind regards,