Print

Print


> On Jan 21, 2019, at 5:21 PM, John Filleau <[log in to unmask]> wrote:
> 
> How do I create a custom inspector drop down text widget with a domain of agent name strings?
>  
> I’m following the hexabug example program, where a drop-down menu is created to switch between rectangular or hexagonal display values, and trying to modify this to give a drop down list of agent names. I create an array in the main SimState child class of strings, and populate it in the start() method at the same time as I make the agents. Then, in the GUIState() child’s getInspector() method, I make a custom inspector with dom, get, and set methods. For the dom method, I return the String[] from my SimState child. However, this function is only called BEFORE SimState.start() is called.
> 
> Is there a way to create a drop down list inspector based on a String array that doesn’t exist until I hit the start button? Is there a method I can call somewhere in the GUIState after I start the simulation and my String[] foragerNames is populated?

Why not just say

public class AgentView {
                int forager = 0;
                public Object domAgentView() { if (((SocialFlowMonitoring)state).foragerNames == null) return new String[] {"Blah"}; else return ((SocialFlowMonitoring)state).foragerNames; }
                public String nameAgentView() { return "Agent View"; }
                public String desAgentView() { return "Shows the current view of the selected agent."; }
                public int getAgentView() { if (((SocialFlowMonitoring)state).foragerNames == null) return 0; else return forager; }
                public void setAgentView(int val) { if (((SocialFlowMonitoring)state).foragerNames != null) forager = val;
                }
    }


Sean