Search code examples
repast-simphony

GUI does not show agent attributes


See below, why does GUI not show the demandhist in the agent property (bottom left)?

enter image description here


Solution

  • Without some additional annotations, the Repast probing mechanism does not display non-primitive + String types. You can do one of two things

    • create getter / setter methods that return your List as a String and accept a String as a parameter respectively. The latter would parse the String and update the list with the parsed values.

    • Use a @ProbedProperty annotation and specify a String converter to do the conversion from the list to a String. For example,

    @ProbedProperty(usageName="list", displayName="A List", converter="repast.simphony.parameter.StringConverterFactory$StringStringConverter")
    public List<Integer> getList() {
        return Arrays.asList(1, 2, 3, 4);
    }
    

    Here, I'm using StringConverterFactory$StringStringConverter to do the conversion. This works fine for just a getter, but won't work for a setter. If you have a setter, you'll need to write your own StringConverter implementation.

    Lastly, if you use the ProbedProperty annotation, you may need to add it for the other properties you wish to show. For primitives, you can omit the converter. I think the presence of a ProbedProperty is taken to mean "don't display all the properties, only the ones I've annotated".