Print

Print


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