Class StyleExpressionFactory
style expressions
that can be used when styling data.
- Boolean operations:
and
,or
,not
,eq
,neq
,lt
,lte
,gt
,gte
- Numerical operations:
min
,max
,clamp
,mix
,add
,subtract
,multiply
,divide
,between
,fraction
- Control operations:
ifThenElse
,map
,mixMap
,cases
- Value expressions:
constant
,attribute (double)
,attribute (color)
,attribute (coordinate)
,attribute (position)
,parameter
- Trigonometric operations:
sin
,cos
,tan
,asin
,acos
,atan
- Vector operations:
cross product
,dot product
,divide
,multiply
,add
,substract
- Distance operations:
distance
,length
Example:
if (value1 < value2) { return "Color(255, 55, 55, 127)"; else { return "Color(55, 255, 55, 127)"; }can be converted to an expression:
StyleExpression<Color> expression = StyleExpressionFactory.ifThenElse(
StyleExpressionFactory.lt(StyleExpressionFactory.constant(value1), StyleExpressionFactory.constant(value2)), // comparison
StyleExpressionFactory.constant(color(255, 55, 55, 127)), // then
StyleExpressionFactory.constant(color(55, 255, 55, 127))); // else
-
Method Summary
Modifier and TypeMethodDescriptionstatic StyleExpression
<Double> abs
(StyleExpression<Double> value) Creates an expression that returns an expression with the absolute value.static <T> StyleExpression
<T> acos
(StyleExpression<T> operand) Creates an expression that takes the arccosine of another expression.static <T,
U> StyleExpression <T> add
(StyleExpression<T> first, StyleExpression<U> second) Creates an expression that adds the values of the two provided expressions.static StyleExpression
<Boolean> andOp
(StyleExpression<Boolean> value1, StyleExpression<Boolean> value2) Creates an expression that is the boolean 'and' of its parts.static <T> StyleExpression
<T> asin
(StyleExpression<T> operand) Creates an expression that takes the arcsine of another expression.static <T> StyleExpression
<T> atan
(StyleExpression<T> operand) Creates an expression that takes the arcsine of another expression.static StyleExpression
<Boolean> between
(StyleExpression<Double> lowerBound, StyleExpression<Double> upperBound, StyleExpression<Double> value) Creates an expression that evaluates whether the result of the operand is between a lower and upper bound (inclusive).static <T> StyleExpression
<T> cases
(StyleExpression<T> defaultExpression, List<StyleExpression<Boolean>> conditions, List<StyleExpression<T>> expressions) static <T,
U> StyleExpression <T> clamp
(StyleExpression<T> operand, StyleExpression<U> lowerBound, StyleExpression<U> upperBound) Creates an expression that limits an operand to a range.static StyleExpression
<android.graphics.Color> colorAttribute
(String attributeName) Creates an attribute expression that represents a color.static <T> StyleExpression
<T> constant
(T value) Creates an expression that represents a 'constant' value.static StyleExpression
<Coordinate> coordinateAttribute
(String attributeName) Creates an attribute expression that represents a coordinate.static <T> StyleExpression
<T> cos
(StyleExpression<T> operand) Creates an expression that takes the cosine of another expression.static StyleExpression
<Coordinate> crossProduct
(StyleExpression<Coordinate> first, StyleExpression<Coordinate> second) Creates an expression that calculates the cross product of two expressions representingCoordinate
.static StyleExpression
<android.graphics.Color> Creates an expression representing the default color that is applied to a mesh.static <T> StyleExpression
<Double> distance
(StyleExpression<T> first, StyleExpression<T> second) Creates an expression that calculates the Euclidean distance between two expressions representing points.static <T,
U> StyleExpression <T> divide
(StyleExpression<T> first, StyleExpression<U> second) Creates an expression that divides the value of the first expression by the value of the second expression.static <T> StyleExpression
<Double> dotProduct
(StyleExpression<T> first, StyleExpression<T> second) Creates an expression that calculates the dot product of the given expressions.static StyleExpression
<Double> doubleAttribute
(String attributeName) Creates an attribute expression that represents a double.static StyleExpression
<Boolean> eq
(StyleExpression<Double> first, StyleExpression<Double> second, StyleExpression<Double> threshold) Creates an expression that evaluates whether the two given expression evaluate to close values, given some threshold.static <T> StyleExpression
<Boolean> eq
(StyleExpression<T> first, StyleExpression<T> second) Creates an expression that evaluates whether the two given expression evaluate to the same value.static <T,
U> StyleExpression <T> fraction
(StyleExpression<T> operand, StyleExpression<U> lowerBound, StyleExpression<U> upperBound) Creates an expression that calculates the fraction of the given operand in the range[lowerBound, upperBound]
evaluates to(operand - lowerBound) / (upperBound - lowerBound)
.static StyleExpression
<Boolean> Creates an expression that determines whether a part of a mesh is facing to or away from the camera.static StyleExpression
<Boolean> gt
(StyleExpression<Double> first, StyleExpression<Double> second) Creates an expression that evaluates whether the result of the first expression is strictly greater than the result of the second expression.static StyleExpression
<Boolean> gte
(StyleExpression<Double> first, StyleExpression<Double> second) Creates an expression that evaluates whether the result of the first expression is greater than or equal to the result of the second expression.static <T> StyleExpression
<T> ifThenElse
(StyleExpression<Boolean> condition, StyleExpression<T> thenExpression, StyleExpression<T> elseExpression) Creates an expression that implements if-then-else logic.static StyleExpression
<Double> length
(StyleExpression<Coordinate> operand) Creates an expression that calculates the length of aCoordinate
.static <T> StyleExpression
<T> log
(StyleExpression<T> operand) Creates an expression that takes the natural logarithm of another expression.static StyleExpression
<Boolean> lt
(StyleExpression<Double> first, StyleExpression<Double> second) Creates an expression that evaluates whether the result of the first expression is strictly less than the result of the second expression.static StyleExpression
<Boolean> lte
(StyleExpression<Double> first, StyleExpression<Double> second) Creates an expression that evaluates whether the result of the first expression is less than or equal to the result of the second expression.static <T> StyleExpression
<T> map
(StyleExpression<Double> indexExpression, List<StyleExpression<T>> values, StyleExpression<T> defaultExpression) static <T,
U> StyleExpression <T> max
(StyleExpression<T> first, StyleExpression<U> second) Creates an expression that returns the maximum of the given expressions.static <T,
U> StyleExpression <T> min
(StyleExpression<T> first, StyleExpression<U> second) Creates an expression that returns the minimum of the given expressions.static <T> StyleExpression
<T> mix
(StyleExpression<T> first, StyleExpression<T> second, StyleExpression<Double> fraction) Creates an expression that calculates an interpolated or extrapolated result between the result of first and second based on the result of fraction.static <T> StyleExpression
<T> mixMap
(StyleExpression<Double> fraction, List<StyleExpression<T>> values) static <T,
U> StyleExpression <T> multiply
(StyleExpression<T> first, StyleExpression<U> second) Creates an expression that multiplies the values of the two provided expressions.static <T> StyleExpression
<Boolean> neq
(StyleExpression<T> first, StyleExpression<T> second) Creates an expression that evaluates whether the two given expression do not evaluate to the same value.static StyleExpression
<Coordinate> normalize
(StyleExpression<Coordinate> operand) Creates an expression that normalizes aCoordinate
.static StyleExpression
<Boolean> notOp
(StyleExpression<Boolean> value) Creates an expression that is the boolean 'not' of the given expression.static StyleExpression
<Boolean> orOp
(StyleExpression<Boolean> value1, StyleExpression<Boolean> value2) Creates an expression that is the boolean 'or' of its parts.static <T> StyleExpression
<T> parameter
(Observable<T> observable) Creates a parameter expression that is a style expression that can be changed at runtime.static StyleExpression
<Coordinate> Creates an expression that represents the position of the data that is styled.static <T> StyleExpression
<T> pow
(StyleExpression<T> first, StyleExpression<T> second) Creates an expression that returns the result of the first expression raised to the power of the result of the second expression.static <T> StyleExpression
<T> sin
(StyleExpression<T> operand) Creates an expression that takes the sine of another expression.static <T,
U> StyleExpression <T> subtract
(StyleExpression<T> first, StyleExpression<U> second) Creates an expression that subtracts the value of the second expression from the value of the first expression.static <T> StyleExpression
<T> tan
(StyleExpression<T> operand) Creates an expression that takes the tangent of another expression.
-
Method Details
-
constant
Creates an expression that represents a 'constant' value.- Type Parameters:
T
- the type of the constant:java.lang.Double
,java.lang.Boolean
,Coordinate
orandroid.graphics.Color
.- Parameters:
value
- a value for the constant.- Returns:
- an expression that represents a constant value.
-
parameter
Creates a parameter expression that is a style expression that can be changed at runtime.When it is changed, the styling will be updated to reflect the new value without having to re-create the expressions in which it is used. This makes it possible to make changes to the styling with almost-zero overhead.
- Type Parameters:
T
- the type of the constant:java.lang.Double
,java.lang.Boolean
,Coordinate
orandroid.graphics.Color
.- Parameters:
observable
- an object that represents a mutable value. Users can hold on to thisObservable
in order to change the parameter value.- Returns:
- a new parameter expression
-
mix
@NotNull public static <T> StyleExpression<T> mix(@NotNull StyleExpression<T> first, @NotNull StyleExpression<T> second, @NotNull StyleExpression<Double> fraction) Creates an expression that calculates an interpolated or extrapolated result between the result of first and second based on the result of fraction.- Type Parameters:
T
- the type of the value to mix. Can bejava.lang.Double
,Coordinate
orandroid.graphics.Color
.- Parameters:
first
- the first expression that is mixedsecond
- the second expression that is mixedfraction
- the mixing fraction. In range [0, 1] for interpolation. May also be a value outside that interval for extrapolation.- Returns:
- an expression that calculates an interpolated or extrapolated result between the result of first and second based on the result of the fraction expression. Results in a double, point or color depending on the type of the operands.
-
acos
Creates an expression that takes the arccosine of another expression.- Type Parameters:
T
- the type of the operand. Can bejava.lang.Double
,Coordinate
.- Parameters:
operand
- the expression of which to take the arccosine. ForCoordinate
, the function is applied to the individual element values.- Returns:
- an expression that takes the arccosine of another expression, in radians. Results in a double,
Coordinate
.
-
asin
Creates an expression that takes the arcsine of another expression.- Type Parameters:
T
- the type of the operand. Can bejava.lang.Double
,Coordinate
.- Parameters:
operand
- the expression of which to take the arcsine. ForCoordinate
, the function is applied to the individual element values.- Returns:
- an expression that takes the arcsine of another expression, in radians. Results in a double,
Coordinate
.
-
atan
Creates an expression that takes the arcsine of another expression.- Type Parameters:
T
- the type of the operand. Can bejava.lang.Double
,Coordinate
.- Parameters:
operand
- the expression of which to take the arctangent. ForCoordinate
, the function is applied to the individual element values.- Returns:
- an expression that takes the arctangent of another expression, in radians. Results in a double,
Coordinate
.
-
cos
Creates an expression that takes the cosine of another expression.- Type Parameters:
T
- the type of the operand. Can be double orCoordinate
.- Parameters:
operand
- the expression of which to take the cosine. ForCoordinate
, the function is applied to the individual element values. Values assumed to be in radians.- Returns:
- an expression that takes the cosine of another expression. Results in a double,
Coordinate
.
-
sin
Creates an expression that takes the sine of another expression.- Type Parameters:
T
- the type of the operand. Can bejava.lang.Double
,Coordinate
.- Parameters:
operand
- the expression of which to take the sine. ForCoordinate
, the function is applied to the individual element values. Values assumed to be in radians.- Returns:
- an expression that takes the sine of another expression. Results in a double,
Coordinate
.
-
tan
Creates an expression that takes the tangent of another expression.- Type Parameters:
T
- the type of the operand. Can bejava.lang.Double
,Coordinate
.- Parameters:
operand
- the expression of which to take the tangent. ForCoordinate
, the function is applied to the individual element values. Values assumed to be in radians.- Returns:
- an expression that takes the tangent of another expression. Results in a double,
Coordinate
.
-
pow
@NotNull public static <T> StyleExpression<T> pow(@NotNull StyleExpression<T> first, @NotNull StyleExpression<T> second) Creates an expression that returns the result of the first expression raised to the power of the result of the second expression.The type of the operands should be the same. The (elements of the) first argument must not be less than 0 and if it is 0, the (corresponding elements of the) second argument must be greater than 0.
- Type Parameters:
T
- the type of the expressions:java.lang.Double
,Coordinate
.- Parameters:
first
- The first expression to evaluate. Should result in a double,Coordinate
or android.graphics.Color.second
- The second expression to evaluate. Should result in the same type as first.- Returns:
- An expression that returns the result of the first expression to the power of the result of the second expression. Results in a double,
Coordinate
depending on the type of the operands.
-
log
Creates an expression that takes the natural logarithm of another expression.- Type Parameters:
T
- the type of the operand expression:java.lang.Double
,Coordinate
.- Parameters:
operand
- The expression of which to take the natural logarithm. Should result in a double,Coordinate
.- Returns:
- an expression that takes the natural logarithm of another expression.
-
min
@NotNull public static <T,U> StyleExpression<T> min(@NotNull StyleExpression<T> first, @NotNull StyleExpression<U> second) Creates an expression that returns the minimum of the given expressions.- Type Parameters:
T
- the type of the first expression:java.lang.Double
,Coordinate
orandroid.graphics.Color
.U
- the type of the second expression. Must be equal to T, orjava.lang.Double
.- Parameters:
first
- The first expression to evaluate. Should result in a double, point or color.second
- The second expression to evaluate. Should result in the same type as first or a double.- Returns:
- an expression that resolves to the minimum of the two provided expressions. When a double is used with another type, the operation is applied to the individual element values and the result is of the other type (note that for
android.graphics.Color
, each component is treated as a normalized value ([0, 1]
)).
-
max
@NotNull public static <T,U> StyleExpression<T> max(@NotNull StyleExpression<T> first, @NotNull StyleExpression<U> second) Creates an expression that returns the maximum of the given expressions.- Type Parameters:
T
- the type of the first expression:java.lang.Double
,Coordinate
orandroid.graphics.Color
.U
- the type of the second expression. Must be equal to T, orjava.lang.Double
.- Parameters:
first
- The first expression to evaluate. Should result in a double, point or color.second
- The second expression to evaluate. Should result in the same type as first or a double.- Returns:
- an expression that resolves to the maximum of the two provided expressions. When a double is used with another type, the operation is applied to the individual element values and the result is of the other type (note that for
android.graphics.Color
, each component is treated as a normalized value ([0, 1]
)).
-
add
@NotNull public static <T,U> StyleExpression<T> add(@NotNull StyleExpression<T> first, @NotNull StyleExpression<U> second) Creates an expression that adds the values of the two provided expressions.If both expressions are of the same type, the values are added as expected. If the first expression is of type
Coordinate
orandroid.graphics.Color
, and second expression is of type double, then the value of second expression is added to every sub element of the first expression (note that forandroid.graphics.Color
, each component is treated as a normalized value ([0, 1]
)).- Type Parameters:
T
- the type of the value of the first expression. Can bejava.lang.Double
,Coordinate
orandroid.graphics.Color
.U
- the type of the value of the second expression. Can be the same as T, orjava.lang.Double
.- Parameters:
first
- the first expression to be addedsecond
- the second expression to be added- Returns:
- an expression of the same type as first.
-
subtract
@NotNull public static <T,U> StyleExpression<T> subtract(@NotNull StyleExpression<T> first, @NotNull StyleExpression<U> second) Creates an expression that subtracts the value of the second expression from the value of the first expression.If both expressions are of the same type, the values are subtracted as expected. If the first expression is of type
Coordinate
orandroid.graphics.Color
, and second expression is of type double, then the value of second expression is subtracted from every sub element of the first expression (note that forandroid.graphics.Color
, each component is treated as a normalized value ([0, 1]
)).- Type Parameters:
T
- the type of the value of the first expression. Can bejava.lang.Double
,Coordinate
orandroid.graphics.Color
.U
- the type of the value of the second expression. Can be the same as T, orjava.lang.Double
.- Parameters:
first
- the expression to be subtracted fromsecond
- the expression to be subtracted- Returns:
- an expression of the same type as first.
-
multiply
@NotNull public static <T,U> StyleExpression<T> multiply(@NotNull StyleExpression<T> first, @NotNull StyleExpression<U> second) Creates an expression that multiplies the values of the two provided expressions.If both expressions are of the same type, the values are multiplied component by component. If the first expression is of type
Coordinate
orandroid.graphics.Color
, and second expression is of type double, then the value of second expression is multiplied with every sub element of the first expression (note that forandroid.graphics.Color
, each component is treated as a normalized value ([0, 1]
)).- Type Parameters:
T
- the type of the value of the first expression. Can bejava.lang.Double
,Coordinate
orandroid.graphics.Color
.U
- the type of the value of the second expression. Can be the same as T, orjava.lang.Double
.- Parameters:
first
- the first expression to be multipliedsecond
- the second expression to be multiplied- Returns:
- an expression of the same type as first.
-
divide
@NotNull public static <T,U> StyleExpression<T> divide(@NotNull StyleExpression<T> first, @NotNull StyleExpression<U> second) Creates an expression that divides the value of the first expression by the value of the second expression.If both expressions are of the same type, the values are divided component by component. If the first expression is of type
Coordinate
orandroid.graphics.Color
, and second expression is of type double, then every sub element of the first expression is divided by the value of second expression (note that forandroid.graphics.Color
, each component is treated as a normalized value ([0, 1]
)).- Type Parameters:
T
- the type of the value of the first expression. Can bejava.lang.Double
,Coordinate
orandroid.graphics.Color
.U
- the type of the value of the second expression. Can be the same as T, orjava.lang.Double
.- Parameters:
first
- the dividend expressionsecond
- the divisor expression- Returns:
- an expression of the same type as first.
-
fraction
@NotNull public static <T,U> StyleExpression<T> fraction(@NotNull StyleExpression<T> operand, @NotNull StyleExpression<U> lowerBound, @NotNull StyleExpression<U> upperBound) Creates an expression that calculates the fraction of the given operand in the range[lowerBound, upperBound]
evaluates to(operand - lowerBound) / (upperBound - lowerBound)
.For values of operand outside the range
[lowerBound, upperBound]
, the results will lie outside the range[0, 1]
. If the operand is of typeCoordinate
orandroid.graphics.Color
and the bounds are of type double, the result will be of the same type as the operand with fraction being applied on each component (note that forandroid.graphics.Color
, each component is treated as a normalized value ([0, 1]
)).- Type Parameters:
T
- the type of the operand:java.lang.Double
,Coordinate
orandroid.graphics.Color
.U
- the type of lowerBound and upperBound. Must be equal to T, orjava.lang.Double
.- Parameters:
operand
- the operand to evaluatelowerBound
- the lowerBound to evaluate.upperBound
- the upperBoundBound to evaluate.- Returns:
- an expression of the same type as operand
-
clamp
@NotNull public static <T,U> StyleExpression<T> clamp(@NotNull StyleExpression<T> operand, @NotNull StyleExpression<U> lowerBound, @NotNull StyleExpression<U> upperBound) Creates an expression that limits an operand to a range.The type of the bounds has to be the same. For
Coordinate
orandroid.graphics.Color
, the clamping is applied to each component independently, either using the corresponding component in the bound (if of the same type as operand) or the bound value if double (note that forandroid.graphics.Color
, each component is treated as a normalized value ([0, 1]
)).- Type Parameters:
T
- the type of the operand:java.lang.Double
,Coordinate
orandroid.graphics.Color
.U
- the type of lowerBound and upperBound. Must be equal to T, orjava.lang.Double
.- Parameters:
operand
- the operand to evaluate. Should result in a double, point or color.lowerBound
- a double expression representing the lowerBoundupperBound
- a double expression representing the upperBound- Returns:
- an expression (of the same type as operand) that limits the value of range to the range
[lowerBound, upperBound]
. If operand is a android.graphics.Color orCoordinate
and bounds are doubles, the operation is applies to the individual element values.
-
eq
@NotNull public static <T> StyleExpression<Boolean> eq(@NotNull StyleExpression<T> first, @NotNull StyleExpression<T> second) Creates an expression that evaluates whether the two given expression evaluate to the same value.Note: in most cases, it is advised to use a threshold when comparing values. This can be done using the eq method that also takes a threshold expression as parameter.
- Type Parameters:
T
- the type of the value of both expressions. Can bejava.lang.Boolean
,java.lang.Double
,Coordinate
orandroid.graphics.Color
.- Parameters:
first
- the first expression to be comparedsecond
- the second expression to be compared- Returns:
- a boolean expression that evaluates to true if and only if both expressions evaluate to the same value.
-
neq
@NotNull public static <T> StyleExpression<Boolean> neq(@NotNull StyleExpression<T> first, @NotNull StyleExpression<T> second) Creates an expression that evaluates whether the two given expression do not evaluate to the same value.- Type Parameters:
T
- the type of the value of both expressions. Can bejava.lang.Boolean
,java.lang.Double
,Coordinate
orandroid.graphics.Color
.- Parameters:
first
- the first expression to be comparedsecond
- the second expression to be compared- Returns:
- a boolean expression that evaluates to true if and only if the expressions evaluate to different values
-
ifThenElse
@NotNull public static <T> StyleExpression<T> ifThenElse(@NotNull StyleExpression<Boolean> condition, @NotNull StyleExpression<T> thenExpression, @NotNull StyleExpression<T> elseExpression) Creates an expression that implements if-then-else logic.- Type Parameters:
T
- the type of the value of thenExpression and elseExpression. Can bejava.lang.Boolean
,java.lang.Double
,Coordinate
orandroid.graphics.Color
.- Parameters:
condition
- the expression that decides which of the other expressions to takethenExpression
- the expression whose result will be returned if condition is trueelseExpression
- the expression whose result will be returned if condition is false- Returns:
- an expression that return the result of one of the other expressions, based on the condition
-
cases
@NotNull public static <T> StyleExpression<T> cases(@NotNull StyleExpression<T> defaultExpression, @NotNull List<StyleExpression<Boolean>> conditions, @NotNull List<StyleExpression<T>> expressions) -
dotProduct
@NotNull public static <T> StyleExpression<Double> dotProduct(@NotNull StyleExpression<T> first, @NotNull StyleExpression<T> second) Creates an expression that calculates the dot product of the given expressions.The type of the result of the two given expressions should be the same. You can take the dot product of doubles or
Coordinate
. Coordinates interpreted as vectors for this operation.- Type Parameters:
T
- the type of the first and second expressions: double,Coordinate
.- Parameters:
first
- The first expression to evaluate. Should result in a double,Coordinate
.second
- The second expression to evaluate. Should result in the same type as first.- Returns:
- An expression that calculates the dot product of the given expressions. Results in a double.
-
map
@NotNull public static <T> StyleExpression<T> map(@NotNull StyleExpression<Double> indexExpression, @NotNull List<StyleExpression<T>> values, @NotNull StyleExpression<T> defaultExpression) -
mixMap
@NotNull public static <T> StyleExpression<T> mixMap(@NotNull StyleExpression<Double> fraction, @NotNull List<StyleExpression<T>> values) -
distance
@NotNull public static <T> StyleExpression<Double> distance(@NotNull StyleExpression<T> first, @NotNull StyleExpression<T> second) Creates an expression that calculates the Euclidean distance between two expressions representing points.The distance is defined as follows for the following supported types:
- double: the distance between the double values:
abs(second - first)
. Coordinate
: the regular cartesian distance:sqrt(x*x + y*y + z*z)
.
- Type Parameters:
T
- the type of expressions:java.lang.Double
,Coordinate
.- Parameters:
first
- the first expressionsecond
- the second expression- Returns:
- an expression that calculates the Euclidean distance between two expressions.
- double: the distance between the double values:
-
abs
Creates an expression that returns an expression with the absolute value.- Parameters:
value
- the input for the abs function- Returns:
- the absolute value of the given expression
-
andOp
@NotNull public static StyleExpression<Boolean> andOp(@NotNull StyleExpression<Boolean> value1, @NotNull StyleExpression<Boolean> value2) Creates an expression that is the boolean 'and' of its parts.- Parameters:
value1
- the first expression to which the 'and' operator is appliedvalue2
- the second expression to which the 'and' operator is applied- Returns:
- an expression that is the boolean 'and' of the given expressions
-
orOp
@NotNull public static StyleExpression<Boolean> orOp(@NotNull StyleExpression<Boolean> value1, @NotNull StyleExpression<Boolean> value2) Creates an expression that is the boolean 'or' of its parts.- Parameters:
value1
- the first expression to which the 'or' operator is appliedvalue2
- the second expression to which the 'or' operator is applied- Returns:
- an expression that is the boolean 'or' of the given expressions
-
notOp
Creates an expression that is the boolean 'not' of the given expression.- Parameters:
value
- a boolean expression- Returns:
- an expression that is the boolean 'not' of the given expression
-
doubleAttribute
Creates an attribute expression that represents a double.Expressions are evaluated for certain objects. Those object may have attributes ascribed to them. This expression allows access to those attributes by name. Which attributes are available depends on the evaluator of the expression, and on the data itself.
For example, for
OGC 3D tiles
point cloud data, there is no fixed set of available attributes, but data files can define certain attributes, like 'color' or 'intensity' for each of the points in the point cloud. When these attributes are known up-front, you can use them as part of the style expression, for example to give each point its actual color, or to create a color based on the intensity value.You can discover which attributes you can use in the documentation of the model decoder of the format that is used. For example:
When you display
3D tiles data
, the layer only loads a subset of the available attributes in memory by default. To make sure that all required attributes are loaded, you mustspecify
which attributes are used in the style expressions.- Parameters:
attributeName
- the name of the attribute.- Returns:
- a double expression that represents the value for the given attribute
-
coordinateAttribute
@NotNull public static StyleExpression<Coordinate> coordinateAttribute(@NotNull String attributeName) Creates an attribute expression that represents a coordinate.Expressions are evaluated for certain objects. Those object may have attributes ascribed to them. This expression allows access to those attributes by name. Which attributes are available depends on the evaluator of the expression, and on the data itself.
For example, for
OGC 3D tiles
point cloud data, there is no fixed set of available attributes, but data files can define certain attributes, like 'color' or 'intensity' for each of the points in the point cloud. When these attributes are known up-front, you can use them as part of the style expression, for example to give each point its actual color, or to create a color based on the intensity value.You can discover which attributes you can use in the documentation of the model decoder of the format that is used. For example:
When you display
3D tiles data
, the layer only loads a subset of the available attributes in memory by default. To make sure that all required attributes are loaded, you mustspecify
which attributes are used in the style expressions.- Parameters:
attributeName
- the name of the attribute.- Returns:
- a coordinate expression that represents the value for the given attribute
-
colorAttribute
@NotNull public static StyleExpression<android.graphics.Color> colorAttribute(@NotNull String attributeName) Creates an attribute expression that represents a color.Expressions are evaluated for certain objects. Those object may have attributes ascribed to them. This expression allows access to those attributes by name. Which attributes are available depends on the evaluator of the expression, and on the data itself.
For example, for
OGC 3D tiles
point cloud data, there is no fixed set of available attributes, but data files can define certain attributes, like 'color' or 'intensity' for each of the points in the point cloud. When these attributes are known up-front, you can use them as part of the style expression, for example to give each point its actual color, or to create a color based on the intensity value.You can discover which attributes you can use in the documentation of the model decoder of the format that is used. For example:
When you display
3D tiles data
, the layer only loads a subset of the available attributes in memory by default. To make sure that all required attributes are loaded, you mustspecify
which attributes are used in the style expressions.- Parameters:
attributeName
- the name of the attribute.- Returns:
- a color expression that represents the value for the given attribute
-
positionAttribute
Creates an expression that represents the position of the data that is styled.For example, for point clouds it represents for the position of an individual point in that point cloud. This for example makes it possible to adapt the transparency of points of a point cloud depending on their distance from an other location.
- Returns:
- a coordinate expression that represents the position of the data that is being styled.
-
lt
@NotNull public static StyleExpression<Boolean> lt(@NotNull StyleExpression<Double> first, @NotNull StyleExpression<Double> second) Creates an expression that evaluates whether the result of the first expression is strictly less than the result of the second expression.- Parameters:
first
- the first double expression to be comparedsecond
- the second double expression to be compared- Returns:
- a boolean expression that evaluates to true if and only if first evaluates to a double less than second
-
lte
@NotNull public static StyleExpression<Boolean> lte(@NotNull StyleExpression<Double> first, @NotNull StyleExpression<Double> second) Creates an expression that evaluates whether the result of the first expression is less than or equal to the result of the second expression.- Parameters:
first
- the first double expression to be comparedsecond
- the second double expression to be compared- Returns:
- a boolean expression that evaluates to true if and only if first evaluates to a double less than or equal to second
-
gt
@NotNull public static StyleExpression<Boolean> gt(@NotNull StyleExpression<Double> first, @NotNull StyleExpression<Double> second) Creates an expression that evaluates whether the result of the first expression is strictly greater than the result of the second expression.- Parameters:
first
- the first double expression to be comparedsecond
- the second double expression to be compared- Returns:
- a boolean expression that evaluates to true if and only if first evaluates to a double greater than second
-
gte
@NotNull public static StyleExpression<Boolean> gte(@NotNull StyleExpression<Double> first, @NotNull StyleExpression<Double> second) Creates an expression that evaluates whether the result of the first expression is greater than or equal to the result of the second expression.- Parameters:
first
- the first double expression to be comparedsecond
- the second double expression to be compared- Returns:
- a boolean expression that evaluates to true if and only if first evaluates to a double greater than or equal to second
-
eq
@NotNull public static StyleExpression<Boolean> eq(@NotNull StyleExpression<Double> first, @NotNull StyleExpression<Double> second, @NotNull StyleExpression<Double> threshold) Creates an expression that evaluates whether the two given expression evaluate to close values, given some threshold.The size of the threshold depends on the values you want to compare:
- when you want to compare floating point values, you need to take into account that during rendering the values are represented as 32-bit floating point (float) values. So the size of the threshold depends on the magnitude of the values that are used, and the float precision.
- when you want to compare values that represent integers, this method should be used with a threshold of 0.5.
- Parameters:
first
- The first expression to evaluatesecond
- The second expression to evaluatethreshold
- TheExpression
describing the maximum threshold before considering both values too far from each other.- Returns:
- An expression that evaluates to true if the two expressions evaluate to close values, given the maximum threshold.
-
between
@NotNull public static StyleExpression<Boolean> between(@NotNull StyleExpression<Double> lowerBound, @NotNull StyleExpression<Double> upperBound, @NotNull StyleExpression<Double> value) Creates an expression that evaluates whether the result of the operand is between a lower and upper bound (inclusive).In other words, this expression checks whether operand is in the range
[lowerBound, upperBound]
.- Parameters:
lowerBound
- a double expression representing the lowerBoundupperBound
- a double expression representing the upperBoundvalue
- the double expression to test- Returns:
- an expression that evaluates to true if and only if value is in the range
[lowerBound, upperBound]
.
-
crossProduct
@NotNull public static StyleExpression<Coordinate> crossProduct(@NotNull StyleExpression<Coordinate> first, @NotNull StyleExpression<Coordinate> second) Creates an expression that calculates the cross product of two expressions representingCoordinate
.- Parameters:
first
- The first expression to evaluate.second
- The second expression to evaluate.- Returns:
- An expression that calculates the cross product of the given expressions. Results in a
Coordinate
(vector).
-
defaultColor
Creates an expression representing the default color that is applied to a mesh.The result depends on what is available in the data. It can be the color of a texture, a color attribute, a constant color default, etc.
This type of expression is only supported for
mesh styling
expressions used byTileSet3DLayer
.- Returns:
- an expression representing the default color that is applied to a mesh.
-
frontFacing
Creates an expression that determines whether a part of a mesh is facing to or away from the camera.You can for example use it in a color expression to distinguish front-facing from back-facing pixels, and render those differently. This type of expression is only supported for
mesh styling expressions
used byTileSet3DLayer
.The facing is determined based on triangle winding.
If you simply wish to hide back-faced triangles, use
MeshStyle.Builder#facetCulling
withFacetCullingType#BackfaceCulling
as parameter.- Returns:
- an expression that determines whether a part of a mesh is facing to or away from the camera.
-
normalize
@NotNull public static StyleExpression<Coordinate> normalize(@NotNull StyleExpression<Coordinate> operand) Creates an expression that normalizes aCoordinate
.- Parameters:
operand
- The expression to evaluate.- Returns:
- an expression the computes the normalized
Coordinate
.
-
length
Creates an expression that calculates the length of aCoordinate
.- Parameters:
operand
- The expression to evaluate.- Returns:
- an expression that computes the length as a number.
-