Dynamic colors for flow elements in AnyLogic?

28 Views Asked by At

I would like for the flows (and also stocks) within my system dynamics model to change color on the basis of certain thresholds being crossed. Is this possible?

Based on this response (How to change the color of rectangular node based on number of agents in the node in Anylogic?), I tried to create an event that would trigger a color change in which the flow "recividism" would be blue when its value was below 90,000 and red whenever its value was above 90,000.

I made it a "Timeout" trigger type with a "Cyclic" mode" and entered the following code:

if(recividism<90000){
   recividism.setFillColor(red);
}else{
   recividism.setFillColor(blue);
}

But it just produces an error saying "Cannot invoke setFillColor(Color) on primitive type double". Is there a way to resolve this and to have dynamic colors in flow elements?

1

There are 1 best solutions below

1
On

You need to call the setFillColor method on something that can, in fact, change its color. Your recividism is a double variable. A number cannot change color :)

So drag in a rectangle and adjust your code, something like

if(recividism<90000){
   myNewRectangle.setFillColor(red);
}else{
   myNewRectangle.setFillColor(blue);
}