There's the sticking point - I was using the terminology wrong. I *am* trying to dynamically update the custom drop-down list. Inspectors may not factor into this. Sorry about the confusion.
-----Original Message-----
From: MASON Multiagent Simulation Toolkit [mailto:[log in to unmask]] On Behalf Of Sean Luke
Sent: Tuesday, January 22, 2019 1:42 PM
To: [log in to unmask]
Subject: Re: Custom Inspector with Domain of Agent Names
Inspectors are allocated dynamically. They're not created until you have hit an object in a field (double-clicked on it). So domAgentView shouldn't get called until after you have actually *clicked* on an agent. Why wouldn't the agent have its information determined by then?
If instead you're trying to dynamically change the name list, then you're going to have to build a custom inspector with a custom drop-down. That's more work of course.
Sean
> On Jan 22, 2019, at 1:37 PM, John Filleau <[log in to unmask]> wrote:
>
> That doesn't quite work either, since foragerNames is always null whenever domAgentView() is called. I have a work around, so this isn't too much of a sticking point. I just thought a drop down list of agent names would be nice to have.
>
> I'll put the documentation under my pillow tonight and see if I can figure it out (maybe I'll try reading it a little more as well).
>
> Thanks all,
> John
>
> -----Original Message-----
> From: MASON Multiagent Simulation Toolkit [mailto:[log in to unmask]] On Behalf Of Sean Luke
> Sent: Tuesday, January 22, 2019 1:26 PM
> To: [log in to unmask]
> Subject: Re: Custom Inspector with Domain of Agent Names
>
>> 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
|