Search in sources :

Example 16 with Expression

use of org.opengis.filter.Expression in project geotoolkit by Geomatys.

the class ExpressionDemo method mathExpression.

private static Expression mathExpression() {
    final Expression multi = FF.multiply(FF.property("age"), FF.literal(3));
    final Expression add = FF.add(multi, FF.literal(10));
    return add;
}
Also used : Expression(org.opengis.filter.Expression)

Example 17 with Expression

use of org.opengis.filter.Expression in project geotoolkit by Geomatys.

the class CachedAnchorPoint method cache.

public static CachedAnchorPoint cache(final AnchorPoint anchor) {
    float cachedX = Float.NaN;
    float cachedY = Float.NaN;
    final Collection<String> attributs;
    if (anchor != null) {
        attributs = new ArrayList<String>();
        final Expression expX = anchor.getAnchorPointX();
        final Expression expY = anchor.getAnchorPointY();
        if (GO2Utilities.isStatic(expX)) {
            cachedX = GO2Utilities.evaluate(expX, null, Float.class, 0.5f);
        } else {
            GO2Utilities.getRequieredAttributsName(expX, attributs);
        }
        if (GO2Utilities.isStatic(expY)) {
            cachedY = GO2Utilities.evaluate(expY, null, Float.class, 0.5f);
        } else {
            GO2Utilities.getRequieredAttributsName(expY, attributs);
        }
    } else {
        attributs = Cache.EMPTY_ATTRIBUTS;
        // we can cache X and Y with default values
        cachedX = StyleConstants.DEFAULT_ANCHOR_POINT_Xf;
        cachedY = StyleConstants.DEFAULT_ANCHOR_POINT_Yf;
    }
    if (attributs.isEmpty()) {
        return new StaticAnchorPoint(anchor, cachedX, cachedY);
    } else {
        return new DynamicAnchorPoint(anchor, cachedX, cachedY, attributs);
    }
}
Also used : Expression(org.opengis.filter.Expression)

Example 18 with Expression

use of org.opengis.filter.Expression in project geotoolkit by Geomatys.

the class CachedDisplacement method cache.

public static CachedDisplacement cache(final Displacement anchor) {
    float cachedX = Float.NaN;
    float cachedY = Float.NaN;
    final Collection<String> attributs;
    if (anchor != null) {
        attributs = new ArrayList<String>();
        final Expression expX = anchor.getDisplacementX();
        final Expression expY = anchor.getDisplacementY();
        if (GO2Utilities.isStatic(expX)) {
            cachedX = GO2Utilities.evaluate(expX, null, Float.class, 0.5f);
        } else {
            GO2Utilities.getRequieredAttributsName(expX, attributs);
        }
        if (GO2Utilities.isStatic(expY)) {
            cachedY = GO2Utilities.evaluate(expY, null, Float.class, 0.5f);
        } else {
            GO2Utilities.getRequieredAttributsName(expY, attributs);
        }
    } else {
        attributs = Cache.EMPTY_ATTRIBUTS;
        // we can cache X and Y with default values
        cachedX = StyleConstants.DEFAULT_DISPLACEMENT_Xf;
        cachedY = StyleConstants.DEFAULT_DISPLACEMENT_Yf;
    }
    if (attributs.isEmpty()) {
        return new StaticDisplacement(anchor, cachedX, cachedY);
    } else {
        return new DynamicDisplacement(anchor, cachedX, cachedY, attributs);
    }
}
Also used : Expression(org.opengis.filter.Expression)

Example 19 with Expression

use of org.opengis.filter.Expression in project geotoolkit by Geomatys.

the class CachedExternal method recode.

private static BufferedImage recode(BufferedImage buffer, final Collection<ColorReplacement> replacements) {
    if (buffer != null) {
        for (final ColorReplacement replace : replacements) {
            final Expression fct = replace.getRecoding();
            buffer = (BufferedImage) fct.apply(buffer);
        }
    }
    return buffer;
}
Also used : Expression(org.opengis.filter.Expression) ColorReplacement(org.opengis.style.ColorReplacement)

Example 20 with Expression

use of org.opengis.filter.Expression in project geotoolkit by Geomatys.

the class CachedFill method getJ2DComposite.

/**
 * @return Java2D composite for this feature
 */
public AlphaComposite getJ2DComposite(final Object candidate) {
    evaluate();
    if (cachedComposite == null) {
        // if composite is null it means it is dynamic
        final Expression opacity = styleElement.getOpacity();
        Float j2dOpacity = GO2Utilities.evaluate(opacity, candidate, 1f, 0f, 1f);
        return AlphaComposite.getInstance(AlphaComposite.SRC_OVER, j2dOpacity.floatValue());
    }
    return cachedComposite;
}
Also used : Expression(org.opengis.filter.Expression)

Aggregations

Expression (org.opengis.filter.Expression)325 Test (org.junit.Test)112 LineString (org.locationtech.jts.geom.LineString)73 Literal (org.opengis.filter.Literal)65 ArrayList (java.util.ArrayList)47 MultiLineString (org.locationtech.jts.geom.MultiLineString)46 Unit (javax.measure.Unit)45 Description (org.opengis.style.Description)40 Fill (org.opengis.style.Fill)38 GraphicFill (org.opengis.style.GraphicFill)38 Stroke (org.opengis.style.Stroke)35 Geometry (org.locationtech.jts.geom.Geometry)31 Displacement (org.opengis.style.Displacement)29 GraphicStroke (org.opengis.style.GraphicStroke)29 ValueReference (org.opengis.filter.ValueReference)27 JAXBElement (javax.xml.bind.JAXBElement)22 LineSymbolizer (org.opengis.style.LineSymbolizer)22 PointSymbolizer (org.opengis.style.PointSymbolizer)22 PolygonSymbolizer (org.opengis.style.PolygonSymbolizer)22 MutableStyle (org.geotoolkit.style.MutableStyle)21