A static color (i.e. a color that will not change during the execution of the simulation) for a given view element property is specified in Ejs using either one of the predefined Ejs colors:
|
|
To specify a color that changes in run-time, you'll need to declare a variable of type Object, associate it to the corresponding element property, and then change the variable according to your program's logic.
For instance, if you declare a variable in Ejs called myColor, of type Object, the lines:
myColor = java.awt.Color.RED;
myColor = new java.awt.Color(255,0,0);can both be used in the Java code of your program to create a solid red color in run-time. The associated view element property will change accodingly.
If you need semi-transparent colors, use something like:
myColor = new java.awt.Color(255,0,0,127);The last parameter is the level of transparency desired. 255 makes a full solid color. Semi-transparent colors may slow down a little bit your program.