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;
}
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);
}
}
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);
}
}
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;
}
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;
}
Aggregations