public class TLcdExpressionFactory extends Object
This builder contains static methods to construct nested expressions
.
and
, or
, not
, eq
, neq
, lt
, lte
, gt
, gte
min
, max
, clamp
, mix
, add
, sub
, mul
, div
, between
, fraction
ifThenElse
, map
, mixmap
, cases
, when
constant
, attribute
, parameter
sin
, cos
, tan
, asin
,
acos
, atan
cross product
, dot product
, divide
, multiply
,
add
, substract
distance
, view position
float
Attributes are used to retrieve values from domain objects. The values can be retrieved in three ways:
AttributeValueProvider
: see here
ILcdDataObject
s by supplying a TLcdDataProperty
: see here
ILcdDataObject
s by supplying a ILcdDataObjectExpression
: see here
Parameters are like constants, but can be varied over time, without having to re-create the expression they are used in. They can be created using parameter
.
Examples
This expression will return a color depending on whether an ID is 4321.
ILcdExpression<Integer> idAttribute = attribute(Integer.class, dataType.getProperty("ID"));
ILcdExpression<Color> expression = ifThenElse(eq(idAttribute, constant(4321)), constant(Color.red), constant(Color.blue))
This expression returns true for objects that have class 43 and lie in a time window specified by varying parameters.
ILcdParameter<Integer> minTimeParameter = parameter("minTime", 0);
ILcdParameter<Integer> maxTimeParameter = parameter("maxTime", 1);
ILcdExpression<Boolean> visible = and(eq(classAttribute, constant(43)), between(timeAttribute, minTimeParameter, maxTimeParameter));
Modifier and Type | Class and Description |
---|---|
static interface |
TLcdExpressionFactory.AttributeValueProvider<T>
Can retrieve values from domain objects.
|
static interface |
TLcdExpressionFactory.CaseExpression<T>
An expression that can be used to chain many if-then expressions.
|
Modifier and Type | Method and Description |
---|---|
static <T extends Number> |
acos(ILcdExpression<T> aValue)
Returns an expression that is the arc cosine of the input value; the returned angle is in the
range 0.0 through pi.
|
static <T extends Number> |
add(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight)
Returns an expression that adds up its parameters.
|
static <T extends Number> |
add(ILcdExpression<T> aLeft,
T aRight)
Returns an expression that adds up its parameters.
|
static <T extends Number> |
add(T aLeft,
ILcdExpression<T> aRight)
Returns an expression that adds up its parameters.
|
static <T extends ILcdPoint> |
addPoint(ILcdExpression<T> aLeft,
ILcdExpression<? extends Number> aRight)
Returns an expression that adds a number to a point.
|
static <T extends ILcdPoint> |
addPoints(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight)
Returns an expression that adds two points.
|
static ILcdExpression<Boolean> |
and(ILcdExpression<Boolean> aLeft,
ILcdExpression<Boolean> aRight)
Returns an expression that is the boolean 'and' of its parts.
|
static <T extends Number> |
asin(ILcdExpression<T> aValue)
Returns an expression that is the arc sine of the input value; the returned angle is in the
range -pi/2 through pi/2.
|
static <T extends Number> |
atan(ILcdExpression<T> aValue)
Returns an expression that is the arc tangent of the input value; the returned angle is in the
range -pi/2 through pi/2.
|
static <T> ILcdExpression<T> |
attribute(Class<T> aType,
TLcdDataProperty aProperty)
Creates a new attribute expression that can retrieve values from data properties.
|
static <T> ILcdExpression<T> |
attribute(String aName,
Class<T> aType,
ILcdDataObjectExpression aExpression)
Creates a new attribute expression that can retrieve values from domain objects.
|
static <T> ILcdExpression<T> |
attribute(String aName,
Class<T> aType,
TLcdExpressionFactory.AttributeValueProvider<T> aProvider)
Creates a new attribute expression that can retrieve values from domain objects.
|
static <T extends Number> |
between(ILcdExpression<T> aValue,
ILcdExpression<T> aLowerBound,
ILcdExpression<T> aUpperBound)
Returns an expression that verifies if a given value is between a lower and upper bound.
|
static <T> TLcdExpressionFactory.CaseExpression<T> |
cases(ILcdExpression<T> aDefault)
Returns an expression that can be used to chain multiple if-then statements together.
|
static <T> TLcdExpressionFactory.CaseExpression<T> |
cases(T aDefault)
Returns an expression that can be used to chain multiple if-then statements together.
|
static <T extends Number> |
clamp(ILcdExpression<T> aValue,
ILcdExpression<T> aMin,
ILcdExpression<T> aMax)
Returns an expression that limits a value to the given range.
|
static <T extends Number> |
clamp(ILcdExpression<T> aValue,
T aMin,
T aMax)
Returns an expression that limits a value to the given range.
|
static <T> ILcdExpression<T> |
constant(T aValue)
Returns an expression that always evaluates to the same constant value.
|
static <T extends Number> |
cos(ILcdExpression<T> aValue)
Returns an expression that is the trigonometric cosine of the input value.
|
static <T extends ILcdPoint> |
crossProduct(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight)
Returns an expression that calculates the cross product of two points.
|
static <T extends ILcdPoint> |
distance(ILcdExpression<T> aFirst,
ILcdExpression<T> aSecond)
Returns an expression that is the Euclidean distance between two points.
|
static <T extends Number> |
div(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight)
Returns an expression that divides its parameters.
|
static <T extends Number> |
div(ILcdExpression<T> aLeft,
T aRight)
Returns an expression that divides its parameters.
|
static <T extends Number> |
div(T aLeft,
ILcdExpression<T> aRight)
Returns an expression that divides its parameters.
|
static <T extends ILcdPoint> |
dividePoint(ILcdExpression<T> aLeft,
ILcdExpression<? extends Number> aRight)
Returns an expression that divides a point with a number.
|
static <T extends ILcdPoint> |
dotProduct(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight)
Returns an expression that calculates the dot product of two points.
|
static <T> ILcdExpression<Boolean> |
eq(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight)
Returns an expression that verifies if its parameters are equal.
|
static <T> ILcdExpression<Boolean> |
eq(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight,
float aEpsilon)
Returns an expression that verifies if its parameters are equal given an epsilon deviation.
|
static <T extends Number> |
eq(ILcdExpression<T> aLeft,
T aRight)
Returns an expression that verifies if its parameters are equal.
|
static <T extends Number> |
eq(T aLeft,
ILcdExpression<T> aRight)
Returns an expression that verifies if its parameters are equal.
|
static <T extends Number> |
fraction(ILcdExpression<T> aValue,
ILcdExpression<T> aLowerBound,
ILcdExpression<T> aUpperBound)
Returns an expression that calculates the percentage of the given value in the range [aLowerBound, aUpperBound].
|
static <T extends Number> |
fraction(ILcdExpression<T> aValue,
T aLowerBound,
T aUpperBound)
Returns an expression that calculates the percentage of the given value in the range [aLowerBound, aUpperBound].
|
static <T extends Number> |
gt(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight)
Returns an expression that compares its parts using the greater-than operator.
|
static <T extends Number> |
gt(ILcdExpression<T> aLeft,
T aRight)
Returns an expression that compares its parts using the greater-than operator.
|
static <T extends Number> |
gt(T aLeft,
ILcdExpression<T> aRight)
Returns an expression that compares its parts using the greater-than operator.
|
static <T extends Number> |
gte(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight)
Returns an expression that compares its parts using the greater-than-or-equal operator.
|
static <T extends Number> |
gte(ILcdExpression<T> aLeft,
T aRight)
Returns an expression that compares its parts using the greater-than-or-equal operator.
|
static <T extends Number> |
gte(T aLeft,
ILcdExpression<T> aRight)
Returns an expression that compares its parts using the greater-than-or-equal operator.
|
static <T> ILcdExpression<T> |
ifThenElse(ILcdExpression<Boolean> aIf,
ILcdExpression<T> aThen,
ILcdExpression<T> aElse)
Returns an expression that corresponds to an if-then-else structure.
|
static <T extends Number> |
log(ILcdExpression<T> aValue)
Returns an expression that is the natural logarithm of the parameter.
|
static <L extends Number,R extends Number> |
lt(ILcdExpression<L> aLeft,
ILcdExpression<R> aRight)
Returns an expression that compares its parts using the less-than operator.
|
static <T extends Number> |
lt(ILcdExpression<T> aLeft,
T aRight)
Returns an expression that compares its parts using the less-than operator.
|
static <T extends Number> |
lt(T aLeft,
ILcdExpression<T> aRight)
Returns an expression that compares its parts using the less-than operator.
|
static <T extends Number> |
lte(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight)
Returns an expression that compares its parts using the less-than-or-equal operator.
|
static <T extends Number> |
lte(ILcdExpression<T> aLeft,
T aRight)
Returns an expression that compares its parts using the less-than-or-equal operator.
|
static <T extends Number> |
lte(T aLeft,
ILcdExpression<T> aRight)
Returns an expression that compares its parts using the less-than-or-equal operator.
|
static <T,I extends Number> |
map(ILcdExpression<I> aIndex,
ILcdExpression<T>[] aValues,
ILcdExpression<T> aDefault)
Returns an expression that maps an index onto an expression.
|
static <T,I extends Number> |
map(ILcdExpression<I> aIndex,
T[] aValues,
T aDefault)
Returns an expression that maps an index onto a value.
|
static <T extends Number> |
max(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight)
Returns an expression that returns the maximum of its parameters.
|
static <T extends Number> |
max(ILcdExpression<T> aLeft,
T aRight)
Returns an expression that returns the maximum of its parameters.
|
static <T extends Number> |
max(T aLeft,
ILcdExpression<T> aRight)
Returns an expression that returns the maximum of its parameters.
|
static <T extends Number> |
min(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight)
Returns an expression that returns the minimum of its parameters.
|
static <T extends Number> |
min(ILcdExpression<T> aLeft,
T aRight)
Returns an expression that returns the minimum of its parameters.
|
static <T extends Number> |
min(T aLeft,
ILcdExpression<T> aRight)
Returns an expression that returns the minimum of its parameters.
|
static <R,T extends Number> |
mix(ILcdExpression<R> aFrom,
ILcdExpression<R> aTo,
ILcdExpression<T> aFraction)
Returns an expression that calculates an interpolated or extrapolated result between
aFrom and aTo based on the given fraction. |
static <R,T extends Number> |
mix(R aFrom,
R aTo,
ILcdExpression<T> aFraction)
Returns an expression that calculates an interpolated or extrapolated result between
aFrom and aTo based on the given fraction. |
static <R> ILcdExpression<R> |
mixmap(ILcdExpression<Float> aValue,
float[] aThresholds,
R[] aValues)
|
static <R> ILcdExpression<R> |
mixmap(ILcdExpression<Float> aFraction,
R[] aValues)
|
static ILcdExpression<Color> |
mixmap(ILcdExpression<Float> aValue,
TLcdColorMap aColorMap)
Returns an expression that behaves as a
color map . |
static <T extends Number> |
mod(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight)
Returns an expression that finds the modulus of its left parameter with respect to the right parameter.
|
static <T extends Number> |
mod(ILcdExpression<T> aLeft,
T aRight)
Returns an expression that finds the modulus of its left parameter with respect to the right parameter.
|
static <T extends Number> |
mod(T aLeft,
ILcdExpression<T> aRight)
Returns an expression that finds the modulus of its left parameter with respect to the right parameter.
|
static <T extends Number> |
modPoint(ILcdExpression<ILcdPoint> aLeft,
ILcdExpression<T> aRight)
Returns an expression that finds the modulus of its left parameter with respect to the right parameter.
|
static <T extends Number> |
mul(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight)
Returns an expression that multiplies its parameters.
|
static <T extends Number> |
mul(ILcdExpression<T> aLeft,
T aRight)
Returns an expression that multiplies its parameters.
|
static <T extends Number> |
mul(T aLeft,
ILcdExpression<T> aRight)
Returns an expression that multiplies its parameters.
|
static <T extends ILcdPoint> |
multiplyPoint(ILcdExpression<T> aLeft,
ILcdExpression<? extends Number> aRight)
Returns an expression that multiplies a point with a number.
|
static <T> ILcdExpression<Boolean> |
neq(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight)
Returns an expression that verifies if its parameters are not equal.
|
static <T> ILcdExpression<Boolean> |
neq(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight,
float aEpsilon)
Returns an expression that verifies if its parameters are not equal given an epsilon deviation.
|
static <T extends Number> |
neq(ILcdExpression<T> aLeft,
T aRight)
Returns an expression that verifies if its parameters are not equal.
|
static <T extends Number> |
neq(T aLeft,
ILcdExpression<T> aRight)
Returns an expression that verifies if its parameters are not equal.
|
static ILcdExpression<Boolean> |
not(ILcdExpression<Boolean> aParameter)
Returns an expression that is the boolean 'not' of its parameter.
|
static ILcdExpression<Boolean> |
or(ILcdExpression<Boolean> aLeft,
ILcdExpression<Boolean> aRight)
Returns an expression that is the boolean 'or' of its parts.
|
static <T> ILcdParameter<T> |
parameter(String aName,
T aStartingValue)
Creates a new parameter expression.
|
static <R,T extends Number> |
scale(ILcdExpression<R> aValue,
ILcdExpression<T> aScale)
Returns an expression that scales a given value by a factor.
|
static <T extends Number> |
sin(ILcdExpression<T> aValue)
Returns an expression that is the trigonometric sine of the input value.
|
static <T extends Number> |
sub(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight)
Returns an expression that subtracts its parameters.
|
static <T extends Number> |
sub(ILcdExpression<T> aLeft,
T aRight)
Returns an expression that subtracts its parameters.
|
static <T extends Number> |
sub(T aLeft,
ILcdExpression<T> aRight)
Returns an expression that subtracts its parameters.
|
static <T extends ILcdPoint> |
subtractPoint(ILcdExpression<T> aLeft,
ILcdExpression<? extends Number> aRight)
Returns an expression that subtracts a number from a point.
|
static <T extends ILcdPoint> |
subtractPoints(ILcdExpression<T> aLeft,
ILcdExpression<T> aRight)
Returns an expression that subtracts two points.
|
static <T extends Number> |
tan(ILcdExpression<T> aValue)
Returns an expression that is the trigonometric tangent of the input value.
|
static ILcdExpression<Float> |
toFloat(ILcdExpression<? extends Number> aValue)
Returns an expression that converts (casts) to floating point number.
|
static ILcdExpression<ILcdPoint> |
viewPositionAttribute()
Returns an expression that represents the swing view position of the object.
|
public static ILcdExpression<Boolean> and(ILcdExpression<Boolean> aLeft, ILcdExpression<Boolean> aRight)
For example, and(constant(true), constant(false))
returns true.
aLeft
- Expression parameteraRight
- Expression parameterpublic static ILcdExpression<Boolean> or(ILcdExpression<Boolean> aLeft, ILcdExpression<Boolean> aRight)
For example, or(constant(true), constant(false))
returns true.
aLeft
- Expression parameteraRight
- Expression parameterpublic static ILcdExpression<Boolean> not(ILcdExpression<Boolean> aParameter)
For example, not(constant(true))
returns false.
aParameter
- Expression parameterpublic static <L extends Number,R extends Number> ILcdExpression<Boolean> lt(ILcdExpression<L> aLeft, ILcdExpression<R> aRight)
The expression evaluates to true
if aLeft
< aRight
.
For example, lt(constant(3), constant(5))
returns true.
L
- Type of the left-side expression, must be a Number
R
- Type of the left-side expression, must be a Number
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<Boolean> lt(T aLeft, ILcdExpression<T> aRight)
The expression evaluates to true
if aLeft
< aRight
.
For example, lt(3, constant(5))
returns true.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side constantaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<Boolean> lt(ILcdExpression<T> aLeft, T aRight)
The expression evaluates to true
if aLeft
< aRight
.
For example, lt(constant(3), 5)
returns true.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side constantpublic static <T extends Number> ILcdExpression<Boolean> lte(ILcdExpression<T> aLeft, ILcdExpression<T> aRight)
The expression evaluates to true
if aLeft
<= aRight
.
For example, lte(constant(3), constant(3))
returns true.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<Boolean> lte(T aLeft, ILcdExpression<T> aRight)
The expression evaluates to true
if aLeft
<= aRight
.
For example, lte(3, constant(3))
returns true.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side constantaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<Boolean> lte(ILcdExpression<T> aLeft, T aRight)
The expression evaluates to true
if aLeft
<= aRight
.
For example, lte(constant(3), 3)
returns true.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side constantpublic static <T extends Number> ILcdExpression<Boolean> gt(ILcdExpression<T> aLeft, ILcdExpression<T> aRight)
The expression evaluates to true
if aLeft
> aRight
.
For example, gt(constant(3), constant(3))
returns false.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<Boolean> gt(T aLeft, ILcdExpression<T> aRight)
The expression evaluates to true
if aLeft
> aRight
.
For example, gt(3, constant(3))
returns false.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side constantaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<Boolean> gt(ILcdExpression<T> aLeft, T aRight)
The expression evaluates to true
if aLeft
> aRight
.
For example, gt(constant(3), 3)
returns false.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side constantpublic static <T extends Number> ILcdExpression<Boolean> gte(ILcdExpression<T> aLeft, ILcdExpression<T> aRight)
The expression evaluates to true
if aLeft
>= aRight
.
For example, gte(constant(3), constant(3))
returns true.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<Boolean> gte(T aLeft, ILcdExpression<T> aRight)
The expression evaluates to true
if aLeft
>= aRight
.
For example, gte(3, constant(3))
returns true.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side constantaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<Boolean> gte(ILcdExpression<T> aLeft, T aRight)
The expression evaluates to true
if aLeft
>= aRight
.
For example, gte(constant(3), 3)
returns true.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side constantpublic static <T extends Number> ILcdExpression<Boolean> between(ILcdExpression<T> aValue, ILcdExpression<T> aLowerBound, ILcdExpression<T> aUpperBound)
In other words, this expression checks whether aValue
is in the range [aLowerBound, aUpperBound]
.
The expression evaluates to true
if aValue
>= aLowerBound
and aValue
<= aUpperBound
.
For example, between(constant(4), constant(3), constant(5))
returns true.
T
- Type of the parameter expressions, must be a Number
aValue
- Value to evaluateaLowerBound
- Lower-bound expressionaUpperBound
- Upper-bound expressionpublic static <T> ILcdExpression<Boolean> eq(ILcdExpression<T> aLeft, ILcdExpression<T> aRight, float aEpsilon)
The expression evaluates to true
if Math.abs(aLeft-aRight) <= aEpsilon
(for numbers).
For points and colors each component is checked for equality with the epsilon value.
For objects e.g. ILcdIcon
, the epsilon value is ignored.
For example, eq(constant(3.005), constant(3), 0.01f)
returns true.
T
- Type of the parameter expressionsaLeft
- Left-side expressionaRight
- Right-side expressionaEpsilon
- the allowed epsilon value for the equality check.public static <T> ILcdExpression<Boolean> eq(ILcdExpression<T> aLeft, ILcdExpression<T> aRight)
The expression evaluates to true
if aLeft
== aRight
(for numbers), or aLeft.equals(aRight)
(for objects).
For example, eq(constant(3), constant(4))
returns false.
T
- Type of the parameter expressionsaLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<Boolean> eq(T aLeft, ILcdExpression<T> aRight)
The expression evaluates to true
if aLeft
== aRight
.
For example, eq(3, constant(4))
returns false.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side constantaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<Boolean> eq(ILcdExpression<T> aLeft, T aRight)
The expression evaluates to true
if aLeft
== aRight
.
For example, eq(constant(3), 4)
returns false.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side constantpublic static <T> ILcdExpression<Boolean> neq(ILcdExpression<T> aLeft, ILcdExpression<T> aRight, float aEpsilon)
The expression evaluates to false
if Math.abs(aLeft-aRight) <= aEpsilon
(for numbers).
For points and colors each component is checked for non-equality with the epsilon value.
For objects e.g. ILcdIcon
, the epsilon value is ignored.
For example, eq(constant(3.005), constant(3), 0.01f)
returns false.
T
- Type of the parameter expressionsaLeft
- Left-side expressionaRight
- Right-side expressionaEpsilon
- the allowed epsilon value for the non-equality check.public static <T> ILcdExpression<Boolean> neq(ILcdExpression<T> aLeft, ILcdExpression<T> aRight)
The expression evaluates to true
if aLeft
!= aRight
(for numbers), or !aLeft.equals(aRight)
(for objects).
For example, neq(constant(3), constant(4))
returns true.
T
- Type of the parameter expressionsaLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<Boolean> neq(T aLeft, ILcdExpression<T> aRight)
The expression evaluates to true
if aLeft
!= aRight
.
For example, neq(3, constant(4))
returns true.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side constantaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<Boolean> neq(ILcdExpression<T> aLeft, T aRight)
The expression evaluates to true
if aLeft
!= aRight
.
For example, neq(constant(3), 4)
returns true.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side constantpublic static <T extends Number> ILcdExpression<T> mul(ILcdExpression<T> aLeft, ILcdExpression<T> aRight)
The expression evaluates aLeft
* aRight
.
For example, mul(constant(3), constant(4))
returns 12.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> mul(T aLeft, ILcdExpression<T> aRight)
The expression evaluates aLeft
* aRight
.
For example, mul(3, constant(4))
returns 12.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side constantaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> mul(ILcdExpression<T> aLeft, T aRight)
The expression evaluates aLeft
* aRight
.
For example, mul(constant(3), 4)
returns 12.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side constantpublic static <T extends ILcdPoint> ILcdExpression<T> multiplyPoint(ILcdExpression<T> aLeft, ILcdExpression<? extends Number> aRight)
The expression evaluates aLeft
* aRight
.
For example, multiplyPoint(constant(new TLcdXYZPoint(2, 3, 4)), constant(2))
returns new TLcdXYZPoint(4, 6, 8)
.
T
- Type of the parameter expressions, must be a ILcdPoint
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> div(ILcdExpression<T> aLeft, ILcdExpression<T> aRight)
The expression evaluates aLeft
/ aRight
.
For example, div(constant(5.0), constant(2.0))
returns 2.5.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> div(T aLeft, ILcdExpression<T> aRight)
The expression evaluates aLeft
/ aRight
.
For example, div(5.0, constant(2.0))
returns 2.5.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side constantaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> div(ILcdExpression<T> aLeft, T aRight)
The expression evaluates aLeft
/ aRight
.
For example, div(constant(5.0), 2.0)
returns 2.5.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side constantpublic static <T extends ILcdPoint> ILcdExpression<T> dividePoint(ILcdExpression<T> aLeft, ILcdExpression<? extends Number> aRight)
The expression evaluates aLeft
/ aRight
.
For example, dividePoint(constant(new TLcdXYZPoint(2, 3, 4)), constant(2))
returns new TLcdXYZPoint(1, 1.5, 2)
.
T
- Type of the parameter expressions, must be a ILcdPoint
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<ILcdPoint> modPoint(ILcdExpression<ILcdPoint> aLeft, ILcdExpression<T> aRight)
The expression evaluates aLeft
% aRight
.
For example, modPoint(constant(new TLcdXYZPoint(7, 8, 9)), constant(3))
returns new TLcdXYZPoint(1, 2, 0)
.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side expressionILcdPoint
public static <T extends Number> ILcdExpression<T> mod(ILcdExpression<T> aLeft, ILcdExpression<T> aRight)
The expression evaluates aLeft
% aRight
.
For example, mod(constant(7.0), constant(3.0))
returns 1.0.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> mod(T aLeft, ILcdExpression<T> aRight)
The expression evaluates aLeft
% aRight
.
For example, mod(7.0, constant(3.0))
returns 1.0.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side constantaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> mod(ILcdExpression<T> aLeft, T aRight)
The expression evaluates aLeft
% aRight
.
For example, mod(constant(7.0), 3.0)
returns 1.0.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side constantpublic static <T extends ILcdPoint> ILcdExpression<Float> dotProduct(ILcdExpression<T> aLeft, ILcdExpression<T> aRight)
The expression evaluates aLeft
. aRight
.
For example, dotProduct(constant(new TLcdXYZPoint(10, 10, 10)), constant(new TLcdXYZPoint(1, 1, 1)))
returns 30.0.
T
- Type of the parameter expressions, must be a ILcdPoint
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends ILcdPoint> ILcdExpression<T> crossProduct(ILcdExpression<T> aLeft, ILcdExpression<T> aRight)
The expression evaluates aLeft
X aRight
.
For example, crossProduct(constant(new TLcdXYZPoint(2, 3, 4)), constant(new TLcdXYZPoint(5, 6, 7)))
returns new TLcdXYZPoint(-3, 6, -3)
.
T
- Type of the parameter expressions, must be a ILcdPoint
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> add(ILcdExpression<T> aLeft, ILcdExpression<T> aRight)
The expression evaluates aLeft
+ aRight
.
For example, add(constant(2), constant(3))
returns 5.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> add(T aLeft, ILcdExpression<T> aRight)
The expression evaluates aLeft
+ aRight
.
For example, add(2, constant(3))
returns 5.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side constantaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> add(ILcdExpression<T> aLeft, T aRight)
The expression evaluates aLeft
+ aRight
.
For example, add(constant(2), 3)
returns 5.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side constantpublic static <T extends ILcdPoint> ILcdExpression<T> addPoint(ILcdExpression<T> aLeft, ILcdExpression<? extends Number> aRight)
The expression evaluates aLeft
+ aRight
.
For example, addPoint(constant(new TLcdXYZPoint(2, 3, 4)), constant(5))
returns new TLcdXYZPoint(7, 8, 9)
.
T
- Type of the parameter expressions, must be a ILcdPoint
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends ILcdPoint> ILcdExpression<T> addPoints(ILcdExpression<T> aLeft, ILcdExpression<T> aRight)
The expression evaluates aLeft
+ aRight
.
For example, addPoint(constant(new TLcdXYZPoint(2, 3, 4)), constant(new TLcdXYZPoint(1, 2, 3)))
returns new TLcdXYZPoint(3, 5, 7)
.
T
- Type of the parameter expressions, must be a ILcdPoint
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> sub(ILcdExpression<T> aLeft, ILcdExpression<T> aRight)
The expression evaluates aLeft
- aRight
.
For example, sub(constant(2), constant(3))
returns -1.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> sub(T aLeft, ILcdExpression<T> aRight)
The expression evaluates aLeft
- aRight
.
For example, sub(2, constant(3))
returns -1.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side constantaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> sub(ILcdExpression<T> aLeft, T aRight)
The expression evaluates aLeft
- aRight
.
For example, sub(constant(2), 3)
returns -1.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side constantpublic static <T extends ILcdPoint> ILcdExpression<T> subtractPoint(ILcdExpression<T> aLeft, ILcdExpression<? extends Number> aRight)
The expression evaluates aLeft
- aRight
.
For example, subtractPoint(constant(new TLcdXYZPoint(2, 3, 4)), constant(5))
returns new TLcdXYZPoint(-3, -2, -1)
.
T
- Type of the parameter expressions, must be a ILcdPoint
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends ILcdPoint> ILcdExpression<T> subtractPoints(ILcdExpression<T> aLeft, ILcdExpression<T> aRight)
The expression evaluates aLeft
- aRight
.
For example, subtractPoint(constant(new TLcdXYZPoint(2, 3, 4)), constant(new TLcdXYZPoint(1, 1, 1))
returns new TLcdXYZPoint(1, 2, 3)
.
T
- Type of the parameter expressions, must be a ILcdPoint
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> min(ILcdExpression<T> aLeft, ILcdExpression<T> aRight)
The expression evaluates to aLeft
if aLeft
< aRight
, aRight
otherwise.
For example, min(constant(2), constant(3))
returns 2.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> min(T aLeft, ILcdExpression<T> aRight)
The expression evaluates to aLeft
if aLeft
< aRight
, aRight
otherwise.
For example, min(2, constant(3))
returns 2.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side constantaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> min(ILcdExpression<T> aLeft, T aRight)
The expression evaluates to aLeft
if aLeft
< aRight
, aRight
otherwise.
For example, min(constant(2), 3)
returns 2.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side constantpublic static <T extends Number> ILcdExpression<T> max(ILcdExpression<T> aLeft, ILcdExpression<T> aRight)
The expression evaluates to aLeft
if aLeft
> aRight
, aRight
otherwise.
For example, max(constant(2), constant(3))
returns 3.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> max(T aLeft, ILcdExpression<T> aRight)
The expression evaluates to aLeft
if aLeft
> aRight
, aRight
otherwise.
For example, max(2, constant(3))
returns 3.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side constantaRight
- Right-side expressionpublic static <T extends Number> ILcdExpression<T> max(ILcdExpression<T> aLeft, T aRight)
The expression evaluates to aLeft
if aLeft
> aRight
, aRight
otherwise.
For example, max(constant(2), 3)
returns 3.
T
- Type of the parameter expressions, must be a Number
aLeft
- Left-side expressionaRight
- Right-side constantpublic static <T extends Number> ILcdExpression<T> clamp(ILcdExpression<T> aValue, ILcdExpression<T> aMin, ILcdExpression<T> aMax)
The expression evaluates to max(aMin, min(aMax, aValue))
.
For example, clamp(constant(5), constant(10), constant(20))
returns 10.
T
- The type, must be a numberaValue
- The value to clampaMin
- The lower boundaMax
- The upper boundpublic static <T extends Number> ILcdExpression<T> clamp(ILcdExpression<T> aValue, T aMin, T aMax)
The expression evaluates to max(aMin, min(aMax, aValue))
.
For example, clamp(constant(5), 10, 20)
returns 10.
T
- The type, must be a numberaValue
- The value to clampaMin
- The lower boundaMax
- The upper boundpublic static <R,T extends Number> ILcdExpression<R> mix(ILcdExpression<R> aFrom, ILcdExpression<R> aTo, ILcdExpression<T> aFraction)
aFrom
and aTo
based on the given fraction.
This expression is not limited to numbers, but can also be used to interpolate ILcdPoint
or Color
objects.
For example, mix(constant(Color.black), constant(Color.white), constant(0.5))
results in a grey color.
T
- Type of the fraction expression, must be a Number
R
- Type of the input and output expressionsaFrom
- The value corresponding to fraction 0aTo
- The value corresponding to fraction 1aFraction
- The fraction, in range [0,1] for interpolation, <0 or >1 for extrapolationpublic static <R,T extends Number> ILcdExpression<R> mix(R aFrom, R aTo, ILcdExpression<T> aFraction)
aFrom
and aTo
based on the given fraction.
This expression is not limited to numbers, but can also be used to interpolate ILcdPoint
or Color
objects.
For example, mix(constant(Color.black), constant(Color.white), constant(0.5))
results in a grey color.
T
- Type of the fraction expression, must be a Number
R
- Type of the input and output expressionsaFrom
- The value corresponding to fraction 0aTo
- The value corresponding to fraction 1aFraction
- The fraction, in range [0,1] for interpolation, <0 or >1 for extrapolationpublic static <R,T extends Number> ILcdExpression<R> scale(ILcdExpression<R> aValue, ILcdExpression<T> aScale)
The expression evaluates to aValue * aScale
.
For example, scale(constant(Color.WHITE), constant(0.5f)
results in a gray color.
R
- Type of the parameter expressionsT
- Type of the scale expressions, must be a Number
aValue
- Value the value to scaleaScale
- Lower the scale factorpublic static <T extends Number> ILcdExpression<T> fraction(ILcdExpression<T> aValue, ILcdExpression<T> aLowerBound, ILcdExpression<T> aUpperBound)
The expression evaluates to aValue-aLowerBound / aUpperBound-aLowerBound
.
For example, fraction(constant(15), constant(10), constant(20))
results in 0.5
.
T
- Type of the parameter expressions, must be a Number
aValue
- Value to testaLowerBound
- Lower bound expressionaUpperBound
- Upper bound expressionpublic static <T extends Number> ILcdExpression<T> fraction(ILcdExpression<T> aValue, T aLowerBound, T aUpperBound)
The expression evaluates to aValue-aLowerBound / aUpperBound-aLowerBound
.
For example, fraction(constant(15), 10, 20)
results in 0.5
.
T
- Type of the parameter expressions, must be a Number
aValue
- Value to testaLowerBound
- Lower bound constantaUpperBound
- Upper bound constantpublic static <T> ILcdExpression<T> ifThenElse(ILcdExpression<Boolean> aIf, ILcdExpression<T> aThen, ILcdExpression<T> aElse)
The expression evaluates aThen
if aIf
returns true, otherwise it evaluates aThen
.
For example, ifThenElse(lt(3, 5), constant(Color.black), constant(Color.white))
returns black.
T
- Type of the expressionsaIf
- a boolean expressionaThen
- the expression evaluated if aIf
returns trueaElse
- the expression evaluated if aIf
return falsepublic static <T,I extends Number> ILcdExpression<T> map(ILcdExpression<I> aIndex, ILcdExpression<T>[] aValues, ILcdExpression<T> aDefault)
The expression first determines an index, then evaluates the expression corresponding to the index.
For example:
map(constant(2), new ILcdExpression<Color>[] {constant(red), constant(green), constant(blue)}, constant(black))
returns bluemap(constant(6), new ILcdExpression<Color>[] {constant(red), constant(green), constant(blue)}, constant(black))
returns black
Usually, the same method with constants is more convenient, see map(ILcdExpression, Object[], Object)
.
T
- The type of the valuesI
- The type of the index in the values, must be a numberaIndex
- The expression that calculates the index to useaValues
- A list of value expressionsaDefault
- The expression used as default when the computed index is not validpublic static <T,I extends Number> ILcdExpression<T> map(ILcdExpression<I> aIndex, T[] aValues, T aDefault)
The expression first determines an index, then returns the value corresponding to the index.
For example:
map(constant(2), new Color[] {red, green, blue}, black)
returns bluemap(constant(6), new Color[] {red, green, blue}, black)
returns blackT
- The type of the valuesI
- The type of the index in the values, must be a numberaIndex
- The expression that calculates the index to useaValues
- A list of constant valuesaDefault
- The default value when the computed index is not validpublic static <R> ILcdExpression<R> mixmap(ILcdExpression<Float> aFraction, R[] aValues)
mix
) based on two table lookups (map
).
This expression is not limited to numbers, but can also be used to interpolate ILcdPoint
or Color
objects.
For example, mixmap(constant(0.75), new Color[] {orange, yellow, red})
results in a color between yellow and red.
R
- Type of the input and output expressionsaFraction
- The fraction, in range [0,1].aValues
- A list of value expressionspublic static <R> ILcdExpression<R> mixmap(ILcdExpression<Float> aValue, float[] aThresholds, R[] aValues)
mix
) based on two table lookups (map
).
The input value is in the same unit as the thresholds.
This expression is not limited to numbers, but can also be used to interpolate ILcdPoint
or Color
objects.
For example, mixmap(constant(1.5), new float[] {1, 2, 3}, new Color[] {orange, yellow, red})
results in a color between orange and yellow:
R
- Type of the input and output expressionsaValue
- The input value, in the same unit as the thresholdsaThresholds
- A list of thresholdsaValues
- A list of resulting value expressionspublic static ILcdExpression<Color> mixmap(ILcdExpression<Float> aValue, TLcdColorMap aColorMap)
color map
.
For example, mixmap(constant(15), new TLcdColorMap(new TLcdInterval(10, 30), new double[] {10, 20, 30}, new Color[] {orange, yellow, red}))
results in a color between orange and yellow.
aValue
- The value to use in the color map lookupaColorMap
- The color mappublic static ILcdExpression<Float> toFloat(ILcdExpression<? extends Number> aValue)
For example, toFloat(constant(1))
returns 1.0.
attribute(java.lang.String, java.lang.Class<T>, com.luciad.util.expression.TLcdExpressionFactory.AttributeValueProvider<T>)
expressions, only those that have the type Float, Double, Integer, Short or Byte as type are supported.aValue
- A number expressionpublic static <T extends Number> ILcdExpression<Float> sin(ILcdExpression<T> aValue)
For example, sin(constant(Math.PI/6))
returns 0.5.
aValue
- An angle, in radians.Math.sin(double)
public static <T extends Number> ILcdExpression<Float> cos(ILcdExpression<T> aValue)
For example, cos(constant(Math.PI/3))
returns 0.5.
aValue
- An angle, in radians.Math.cos(double)
public static <T extends Number> ILcdExpression<Float> tan(ILcdExpression<T> aValue)
For example, tan(constant(Math.PI/4))
returns 1.0.
aValue
- An angle, in radians.Math.tan(double)
public static <T extends Number> ILcdExpression<Float> asin(ILcdExpression<T> aValue)
For example, asin(constant(0.5))
returns 0.5235 (Math.PI/6).
aValue
- Expression parameterMath.asin(double)
public static <T extends Number> ILcdExpression<Float> acos(ILcdExpression<T> aValue)
For example, acos(constant(0.5))
returns 1.0471 (Math.PI/3).
aValue
- Expression parameterMath.acos(double)
public static <T extends Number> ILcdExpression<Float> atan(ILcdExpression<T> aValue)
For example, atan(constant(1.0))
returns 0.7853 (Math.PI/4).
aValue
- Expression parameterMath.atan(double)
public static ILcdExpression<ILcdPoint> viewPositionAttribute()
public static <T extends ILcdPoint> ILcdExpression<Float> distance(ILcdExpression<T> aFirst, ILcdExpression<T> aSecond)
For example, distance(constant(new TLcdXYPoint(20, 10)), constant(new TLcdXYPoint(10,10)))
returns 10.0.
aFirst
- Expression parameteraSecond
- Expression parameterpublic static <T extends Number> ILcdExpression<Float> log(ILcdExpression<T> aValue)
For example, log(constant(100.0))
returns 4.60517.
aValue
- Expression parameterMath.log(double)
public static <T> TLcdExpressionFactory.CaseExpression<T> cases(ILcdExpression<T> aDefault)
For example, cases(constant(Color.black)).when(constant(true), Color.red).when(constant(false), Color.green)
returns red.
T
- The result type of the 'case' expressionaDefault
- The expression evaluated if no if-then statement is metpublic static <T> TLcdExpressionFactory.CaseExpression<T> cases(T aDefault)
For example, cases(Color.black).when(constant(true), Color.red).when(constant(false), Color.green)
returns red.
T
- The result type of the 'case' expressionaDefault
- The expression evaluated if no if-then statement is metpublic static <T> ILcdExpression<T> constant(T aValue)
For example, constant(Color.red)
always returns red.
T
- The type of the constantaValue
- The constant valuepublic static <T> ILcdExpression<T> attribute(String aName, Class<T> aType, TLcdExpressionFactory.AttributeValueProvider<T> aProvider)
Note that you should create the attributes once, up front, and re-use them in expressions later.
For example, attribute("x", Float.class, fMyFloatProvider)
returns float numbers retrieved by fMyFloatProvider
.
T
- The type of the values of the attribute, must correspond to aType
aName
- The name of the attributeaType
- The type of the attribute, must correspond to aProvider
- The provider that will actually retrieve the values from domain objectspublic static <T> ILcdExpression<T> attribute(String aName, Class<T> aType, ILcdDataObjectExpression aExpression)
Note that you should create the attributes once, up front, and re-use them in expressions later.
For example, attribute("x", Float.class, fSomeExpression)
returns float numbers retrieved by fSomeExpression
.
T
- The type of the values of the attribute, must correspond to aType
aName
- The name of the attributeaType
- The type of the attribute, must correspond to aExpression
- The provider that will actually retrieve the values from domain objectspublic static <T> ILcdExpression<T> attribute(Class<T> aType, TLcdDataProperty aProperty)
Note that you should create the attributes once, up front, and re-use them in expressions later.
For example, attribute(Float.class, fDataType.getProperty("p"))
returns the content of that data property.
T
- The type of the values of the attribute, must correspond to aType
aType
- The type of the attribute, must correspond to aProperty
- The data property whose values are usedpublic static <T> ILcdParameter<T> parameter(String aName, T aStartingValue)
Note that you should create the parameters once, up front, and re-use them in expressions later.
Use ILcdParameter#setValue
to change the value of the parameter. Note that the users of your expressions
will automatically re-evaluate. You do not have to notify them. In particular for painters and layers, you
no not have to fire style change events.
T
- The type of the parameteraName
- The name of the parameteraStartingValue
- The initial value