Print

Print


Why going through the pain of encoding things in a string when you can just
put a hashmap in there? Or even better, a "agentdata" object of your item
to cut down on casting?

I am not sure why using the agent itself does not work but I don't have
mason in front of me.

On Thu, 14 Feb 2019, 22:38 Annetta Burger, <[log in to unmask]> wrote:

> I like your solution...I didn't think to setUserData() to the agent object
> itself.
>
>                 this.getGeometry().setUserData(this);  -- setting the
> UserData to the agent Indv class object
>
> Unfortunately, I am now getting a casting error in the Portrayal:
>
>                 java.lang.ClassCastException: java.base/java.lang.Integer
> cannot be cast to disaster.Indv
>
> I've tried the casting a number of ways and am getting this same error:
>
>                 int hColor = ((Indv)
> (((MasonGeometry)object).getUserData())).getHealthStatus();  -- original
> suggestion
>                 int hColor = (int) ((Indv)
> ((MasonGeometry)object).getUserData()).getHealthStatus();  -- casting back
> to int
>
> Is there a Java type limitation to get/setUserData()?
>
>
> Another solution to the problem would be to encode the UserData with
> multiple bits of information in a String. I could then break it up in
> decoding methods. It's a little more complex, but it may be more natural to
> the use of get/setUserData()?
>
> Annetta
>