|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.demo.filter.function.ColorRampFunction
public class ColorRampFunction
Illustrates how to write a custom filter function that implements the Function interface directly. The example here is a function that can be used in a Style to dynamically set the fill color of polygon features based on a numeric feature attribute (e.g. country population size).
GeoTools provides a great many useful filter functions for numeric and
spatial operations but sometimes it is still necessary, or perhaps easier,
for users to create custom functions. This can be done by extending the
GeoTools classes or, as in this example, implementing the Function
interface directly.
Field Summary |
---|
Fields inherited from interface org.opengis.filter.expression.Expression |
---|
NIL |
Constructor Summary | |
---|---|
ColorRampFunction(org.opengis.filter.expression.Expression valueExpr,
float minValue,
float maxValue,
float saturation,
float brightness)
Constructor. |
Method Summary | ||
---|---|---|
java.lang.Object |
accept(org.opengis.filter.expression.ExpressionVisitor visitor,
java.lang.Object arg)
Accept a visitor that wishes to examine this function's parameters. |
|
java.lang.Object |
evaluate(java.lang.Object feature)
Evaluate the function for a given feature. |
|
|
evaluate(java.lang.Object feature,
java.lang.Class<T> clazz)
Evaluate the function for a given feature. |
|
org.opengis.filter.expression.Literal |
getFallbackValue()
Get the fallback value for this function |
|
java.lang.String |
getName()
Get the name of this function |
|
java.util.List<org.opengis.filter.expression.Expression> |
getParameters()
Get the parameters that have been set for this function (only one parameter for the current implementation). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ColorRampFunction(org.opengis.filter.expression.Expression valueExpr, float minValue, float maxValue, float saturation, float brightness)
valueExpr
- the expression that will be used to get the feature value
from which the fill color will be calculatedminValue
- minimum expected feature valuemaxValue
- maximum expected feature valuesaturation
- HSB color model saturation (between 0 and 1)brightness
- HSB color model brightness (between 0 and 1)Method Detail |
---|
public java.lang.String getName()
getName
in interface org.opengis.filter.expression.Function
public java.util.List<org.opengis.filter.expression.Expression> getParameters()
getParameters
in interface org.opengis.filter.expression.Function
public org.opengis.filter.expression.Literal getFallbackValue()
getFallbackValue
in interface org.opengis.filter.expression.Function
Color.GRAY
as a Literal
objectpublic java.lang.Object evaluate(java.lang.Object feature)
evaluate
in interface org.opengis.filter.expression.Expression
feature
- the input feature
Color
objectpublic <T> T evaluate(java.lang.Object feature, java.lang.Class<T> clazz)
evaluate
in interface org.opengis.filter.expression.Expression
T
- type parameter - must be Color
or a subclassfeature
- the input featureclazz
- a Class object for the type (e.g. Color.class
)
Color
objectpublic java.lang.Object accept(org.opengis.filter.expression.ExpressionVisitor visitor, java.lang.Object arg)
accept
in interface org.opengis.filter.expression.Expression
visitor
- a visitor objectarg
- visitor-specific argument
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |