Search in sources :

Example 6 with MathExpressionImpl

use of org.geotools.filter.MathExpressionImpl in project sldeditor by robward-scisys.

the class FilterPanelv2 method addExpression.

/**
 * Adds the expression.
 *
 * @param node the node
 * @return the expression
 */
private Expression addExpression(ExpressionNode node) {
    Expression expression = node.getExpression();
    if (expression instanceof LiteralExpressionImpl) {
        return expression;
    } else if (expression instanceof AttributeExpressionImpl) {
        return expression;
    } else if (expression instanceof FunctionExpressionImpl) {
        FunctionExpressionImpl functionExpression = (FunctionExpressionImpl) expression;
        List<Expression> parameterlist = new ArrayList<Expression>();
        for (int childIndex = 0; childIndex < node.getChildCount(); childIndex++) {
            ExpressionNode childNode = (ExpressionNode) node.getChildAt(childIndex);
            parameterlist.add(addExpression(childNode));
        }
        functionExpression.setParameters(parameterlist);
        return functionExpression;
    } else if (expression instanceof MathExpressionImpl) {
        MathExpressionImpl mathExpression = (MathExpressionImpl) expression;
        ExpressionNode leftChildNode = (ExpressionNode) node.getChildAt(0);
        mathExpression.setExpression1(addExpression(leftChildNode));
        ExpressionNode rightChildNode = (ExpressionNode) node.getChildAt(1);
        mathExpression.setExpression2(addExpression(rightChildNode));
        return mathExpression;
    }
    return null;
}
Also used : MathExpressionImpl(org.geotools.filter.MathExpressionImpl) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) ArrayList(java.util.ArrayList) FunctionExpressionImpl(org.geotools.filter.FunctionExpressionImpl)

Example 7 with MathExpressionImpl

use of org.geotools.filter.MathExpressionImpl in project sldeditor by robward-scisys.

the class CoordinateReferenceSystemValues method setValue.

/*
     * (non-Javadoc)
     *
     * @see
     * com.sldeditor.rendertransformation.types.RenderTransformValueInterface#setValue(java.lang.
     * Object)
     */
@Override
public void setValue(Object aValue) {
    this.value = null;
    this.expression = null;
    if (aValue instanceof LiteralExpressionImpl) {
        LiteralExpressionImpl literal = (LiteralExpressionImpl) aValue;
        if (literal.getValue() != null) {
            value = literal.toString();
        }
    } else if ((aValue instanceof AttributeExpressionImpl) || (aValue instanceof FunctionExpressionImpl) || (aValue instanceof MathExpressionImpl)) {
        this.expression = (Expression) aValue;
    } else {
        if (aValue instanceof String) {
            value = ((String) aValue);
        }
    }
}
Also used : MathExpressionImpl(org.geotools.filter.MathExpressionImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) FunctionExpressionImpl(org.geotools.filter.FunctionExpressionImpl)

Example 8 with MathExpressionImpl

use of org.geotools.filter.MathExpressionImpl in project sldeditor by robward-scisys.

the class ExpressionPanelv2 method addExpression.

/**
 * Adds the expression.
 *
 * @param node the node
 * @return the expression
 */
private Expression addExpression(ExpressionNode node) {
    Expression localExpression = node.getExpression();
    if (localExpression instanceof LiteralExpressionImpl) {
        return localExpression;
    } else if (localExpression instanceof AttributeExpressionImpl) {
        return localExpression;
    } else if (localExpression instanceof FunctionExpressionImpl) {
        FunctionExpressionImpl functionExpression = (FunctionExpressionImpl) localExpression;
        List<Expression> parameterlist = new ArrayList<>();
        for (int childIndex = 0; childIndex < node.getChildCount(); childIndex++) {
            ExpressionNode childNode = (ExpressionNode) node.getChildAt(childIndex);
            parameterlist.add(addExpression(childNode));
        }
        functionExpression.setParameters(parameterlist);
        return functionExpression;
    } else if (localExpression instanceof MathExpressionImpl) {
        MathExpressionImpl mathExpression = (MathExpressionImpl) localExpression;
        ExpressionNode leftChildNode = (ExpressionNode) node.getChildAt(0);
        mathExpression.setExpression1(addExpression(leftChildNode));
        ExpressionNode rightChildNode = (ExpressionNode) node.getChildAt(1);
        mathExpression.setExpression2(addExpression(rightChildNode));
        return mathExpression;
    } else if (localExpression instanceof ConcatenateFunction) {
        ConcatenateFunction concatenateExpression = (ConcatenateFunction) localExpression;
        List<Expression> parameters = new ArrayList<>();
        for (int index = 0; index < node.getChildCount(); index++) {
            ExpressionNode expressionNode = (ExpressionNode) node.getChildAt(0);
            parameters.add(addExpression(expressionNode));
        }
        concatenateExpression.setParameters(parameters);
        return concatenateExpression;
    }
    return null;
}
Also used : MathExpressionImpl(org.geotools.filter.MathExpressionImpl) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) ArrayList(java.util.ArrayList) ConcatenateFunction(org.geotools.filter.function.string.ConcatenateFunction) FunctionExpressionImpl(org.geotools.filter.FunctionExpressionImpl)

Example 9 with MathExpressionImpl

use of org.geotools.filter.MathExpressionImpl in project sldeditor by robward-scisys.

the class ExpressionNode method setMathExpression.

/**
 * Sets the math expression.
 *
 * @param expression the new math expression
 */
private void setMathExpression(Expression expression) {
    MathExpressionImpl mathsExpression = (MathExpressionImpl) expression;
    String expressionText = Localisation.getString(ExpressionPanelv2.class, "ExpressionPanelv2.expression");
    ExpressionNode childNode1 = new ExpressionNode();
    childNode1.setType(Number.class);
    childNode1.setName(expressionText + " 1");
    childNode1.setExpression(mathsExpression.getExpression1());
    this.insert(childNode1, this.getChildCount());
    ExpressionNode childNode2 = new ExpressionNode();
    childNode2.setType(Number.class);
    childNode2.setName(expressionText + " 2");
    childNode2.setExpression(mathsExpression.getExpression2());
    this.insert(childNode2, this.getChildCount());
}
Also used : MathExpressionImpl(org.geotools.filter.MathExpressionImpl)

Aggregations

MathExpressionImpl (org.geotools.filter.MathExpressionImpl)9 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)7 LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)7 Expression (org.opengis.filter.expression.Expression)7 FunctionExpressionImpl (org.geotools.filter.FunctionExpressionImpl)6 ArrayList (java.util.ArrayList)3 FunctionExpression (org.geotools.filter.FunctionExpression)3 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)1 List (java.util.List)1 InterpolationBicubic (javax.media.jai.InterpolationBicubic)1 InterpolationBicubic2 (javax.media.jai.InterpolationBicubic2)1 InterpolationBilinear (javax.media.jai.InterpolationBilinear)1 InterpolationNearest (javax.media.jai.InterpolationNearest)1 ConstantExpression (org.geotools.filter.ConstantExpression)1 FunctionImpl (org.geotools.filter.FunctionImpl)1 EnvFunction (org.geotools.filter.function.EnvFunction)1 ConcatenateFunction (org.geotools.filter.function.string.ConcatenateFunction)1 Function (org.opengis.filter.expression.Function)1