Expressions are used to customize the
format and value of a parameter. For example, you can use an
expression to perform the following functions to an object:
- Blink in two different colors
- Display the date in a specific format
- Join the value of two expressions
- Return the square root of a parameter
An expression can be set on any attribute
contained in a symbol.
To use an expression on an object:
-
Open the symbol that you made in Creating a rotation interactor for multiple objects.
-
Select the Text object.
-
In the Styling Customizer, click the Text tab.
-
Right-click the Label field.A pop-up menu appears.
-
Click Enter an Expression.
-
Delete the contents of the Label field.It is changed into a drop down list.
-
Click the arrow on the right of the Label field.The list of expressions appears.
-
Select the
@rotationValue
expression. -
Enter the expression as follows:
rotationValue(0,360,@rotate,0,360)
. -
Test this symbol by clicking Preview.
As you rotate the mouse over the symbol,
the Text label is updated to show the angle of rotation.
Expressions can combine other expressions,
model attributes and string literals. For example, the following
expression prints the integer value of a parameter in a string.
concat("the rotation value is ",
rotationValue(0,360,@rotate,0,360), ".")
Note
When creating expressions, always select
values from the list, do not type the parameter name or
expression by hand.
Possible expressions are listed in the
following table.
Symbol Editor expressions
Name |
Description
|
Example
|
---|---|---|
parameter specification
|
Any
parameter in the symbol. |
@myparam
|
parameter (parametername)
|
Any parameter in the symbol specified as a
String
.
|
@parameter("myparam")
|
int(expr)
|
Evaluates the argument as an expression. The result is a
number of type
Integer
.
|
int(@param*100)
|
long(expr)
|
Evaluates the argument as an expression. The result is a
number of type
Long
.
|
long(@x+@y)
|
float(expr)
|
Evaluates the argument as an expression. The result is a
number of type
Float
.
|
float(cos(@value))
|
double(expr)
|
Evaluates the argument as an expression. The result is a
number of type
Double
.
|
double(@value*3)
|
cast(expr,type)
|
Casts a value to a type. The second argument can be a fully
qualified class name (entered as a
String
) or a class object.
|
cast(@param,"java.awt.Color")
|
min(arg0, arg1, ...)
|
Returns the smallest number among the arguments. All arguments
must be numbers. Unless otherwise specified, the arguments are
interpreted as numbers of type
Double
.
|
min(@x,@y,0)
|
max(arg0, arg1, ...)
|
Returns the largest number among the arguments. All arguments
must be numbers. Unless otherwise specified, the arguments are
interpreted as numbers of type
Double
.
|
max(@x,@y,1000)
|
invoke(obj,methodname,signature,arg...)
|
Invokes
a method on the object by introspection. The signature string
specifies the argument types of the method as a comma
separated list of (fully qualified) type names. The object and
the arguments must be cast accordingly. |
The specification
@|invoke(cast(@val,java.lang.String),
substring,"int,int",int(3),int(6))
. This use corresponds to the call
((String)@val).substring(3,6)
.
|
invokeStatic(classname,methodname,signature,arg...)
|
Invokes
a static method on the specified class by introspection. The
signature string specifies the argument types of the method as
a comma separated list of (fully qualified) type names. The
arguments must be cast accordingly. |
The specification
@|invokeStatic("java.lang.Math",
"atan2","double,double",double(0.6),
double(0.4))
. This use corresponds to the call
java.lang.Math.atan2(0.6,0.4)
.
|
new(classname,signature,arg...)
|
Invokes
a constructor on the specified class by introspection. The
signature string specifies the argument types of the method as
a comma separated list of (fully qualified) type names. The
arguments must be cast accordingly. |
The specification
@|new("java.util.Date","long",
long(1293840000000))
. This use corresponds to the call
java.util.Date(1293840000000L)
.
|
abs(arg)
|
Absolute
value of the parameter. |
See java.lang.Math
|
sin(arg)
|
Returns the trigonometric sine of an angle. |
See java.lang.Math
|
cos(arg)
|
Returns
the trigonometric cosine of an angle. |
See java.lang.Math
|
tan(arg)
|
Returns
the trigonometric tangent of an angle. |
See java.lang.Math
|
asin(arg)
|
Returns
the arc sine of an angle, in the range of -pi/2 through pi/2. |
See java.lang.Math
|
acos(arg)
|
Returns
the arc cosine of an angle, in the range of 0.0 through pi. |
See java.lang.Math
|
atan(arg)
|
Returns
the arc tangent of an angle, in the range of -pi/2 through
pi/2. |
See java.lang.Math
|
log(exp)
|
Returns
the natural logarithm (base e) of a double value |
See java.lang.Math
|
exp(arg)
|
Returns
Euler's number e raised to the power of a double value. |
See java.lang.Math
|
ceil(arg)
|
Returns
the smallest (closest to negative infinity) double value that
is not less than the argument and is equal to a mathematical
integer. |
See java.lang.Math
|
floor(arg)
|
Returns
the largest (closest to positive infinity) double value that
is not greater than the argument and is equal to a
mathematical integer. |
See java.lang.Math
|
rint(arg)
|
Returns
the double value that is closest in value to the argument and
is equal to a mathematical integer. |
See java.lang.Math
|
round(arg)
|
Returns
the integer value that is closest to the argument. The result
is rounded to an integer by adding 1/2, then taking the floor
of the result |
See java.lang.Math
|
sqrt(arg)
|
Returns
the correctly rounded positive square root of a double value. |
See java.lang.Math
|
rotationValue(min,max,value,start,end)
|
Calculates the rotation angle by mapping the
value
parameter from range 0 to
max
-
min
to the range
start
to
end
.
|
rotationValue(0,100,@rotate,10,20)
|
random()
|
Returns
a random number between 0 and 1. |
random()
|
random(n)
|
Returns
a random number between 0 and n. |
random(16)
|
point(x, y)
|
Returns a point of type
IlvPoint
.
|
point(5,5)
|
rect(x, y, w, h)
|
Returns a rectangle of type
IlvRect
.
|
rect(0,0,100,50)
|
blinkingColor(onColor, offColor)
|
Returns an alternating blinking color with the timing
specified in the
IlvBlinkingRenderer
.
|
blinking(green,yellow)
|
blinkingColor(onColor, offColor,
onTime, offTime)
|
Returns an alternating blinking color with the timing,
onTime
and
offTime
, specified in milliseconds.
|
blinking(green,yellow,500,1000)
|
brighterColor(color)
|
Returns a color that corresponds to
Color.brighter
.
|
brighterColor(gray)
|
darkerColor(color)
|
Returns a color that corresponds to
Color.darker
.
|
darkerColor(red)
|
concat(arg1,...,argn)
|
Returns the concatenation of the arguments
arg1,...,argn
as strings.
|
concat("result is: ",@result)
|
emptyString()
|
Returns
an empty string. |
emptyString()
|
messageFormat(format,arg0,arg1,...)
|
Formats different strings to a specific message format. See java.text.MessageFormat
for details.
|
messageFormat('{0}:
{1,number,#.##}','result',44.2874).
This use returns 44.28" |
decimalFormat(format,arg)
|
Returns a formatted string from a number. See java.text.DecimalFormat
for details.
|
decimalFormat("#.#", pi)
This returns "3.1". |
simpleDateFormat(format, arg[,
locale])
|
Returns a formatted string from a date. See java.text.SimpleDateFormat
for details.
|
simpleDateFormat("MM/dd/yyyy",@date)
This returns "10/01/2001" |
customFormat(formatBean,arg0,arg1,...)
|
Returns
a formatted string. The formatBean parameter must be a Java
object of type MessageFormat, NumberFormat, or DateFormat,
typically defined using the @#id syntax. |
customFormat(@#format, '{0} {1}',
'result', 44.2874)
|
locale()
|
Returns
the locale of the object being styled or of the current
context. |
locale()
|
localized(resourceBundleName,
resourceName[, locale])
|
Returns
the localized value of the designated resource, fetched from a
ResourceBundle, as a string. |
localized('ilog.views.messages','ilog.views.defaultLabel')
|
childrenCount()
|
Returns
the number of children. |
childrenCount()==0
|
Many of these expressions are CSS functions, see Using custom functions. If you want to
register your own predefined CSS functions in the Symbol Editor,
extract the file ilog/views/util/css/cssfunctions.properties
from jviews-framework-all.jar. This
file contains the settings for predefined CSS functions. Follow
the instructions in this file to add your own CSS functions.