Search in sources :

Example 1 with MathExpressionImpl

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

the class ExpressionNode method setExpression.

/**
 * Sets the expression.
 *
 * @param expression the expression to set
 */
public void setExpression(Expression expression) {
    this.expression = expression;
    if (expression instanceof LiteralExpressionImpl) {
        Object value = ((LiteralExpressionImpl) expression).getValue();
        if (value instanceof AttributeExpressionImpl) {
            this.expression = (AttributeExpressionImpl) value;
        }
    }
    setDisplayString();
    this.removeAllChildren();
    if (this.expression instanceof EnvFunction) {
        setEnvFunction();
    } else if (this.expression instanceof FunctionExpression) {
        setFunctionExpression();
    } else if (this.expression instanceof FunctionImpl) {
        setFunctionImpl();
    } else if (this.expression instanceof Function) {
        setFunction();
    } else if (expression instanceof MathExpressionImpl) {
        setMathExpression(expression);
    } else if (expression instanceof AttributeExpressionImpl) {
    // AttributeExpressionImpl property = (AttributeExpressionImpl) expression;
    // TypeManager.getInstance().setLiteralType(literal.getValue().getClass());
    } else if (expression instanceof LiteralExpressionImpl) {
        LiteralExpressionImpl literal = (LiteralExpressionImpl) expression;
        if (literal.getValue() != null) {
            TypeManager.getInstance().setDataType(literal.getValue().getClass());
        }
    }
}
Also used : EnvFunction(org.geotools.filter.function.EnvFunction) Function(org.opengis.filter.expression.Function) EnvFunction(org.geotools.filter.function.EnvFunction) FunctionExpression(org.geotools.filter.FunctionExpression) MathExpressionImpl(org.geotools.filter.MathExpressionImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) FunctionImpl(org.geotools.filter.FunctionImpl)

Example 2 with MathExpressionImpl

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

the class ExpressionSubPanel method applyButton.

/**
 * Apply button.
 */
protected void applyButton() {
    Expression expression = null;
    String actionCommand = buttonGroup.getSelection().getActionCommand();
    if (actionCommand.compareTo(LITERAL) == 0) {
        expression = fieldConfig.getExpression();
    } else if (actionCommand.compareTo(ATTRIBUTE) == 0) {
        expression = dataSourceAttributePanel.getExpression();
    } else if (actionCommand.compareTo(FUNCTION) == 0) {
        expression = functionPanel.getExpression();
    } else if (actionCommand.compareTo(ENVVAR) == 0) {
        expression = envVarField.getExpression();
    } else if (actionCommand.compareTo(MATHS) == 0) {
        expression = mathsExpressionPanel.getExpression();
    }
    if (expression != null) {
        selectedNode.setExpression(expression);
    }
    // function expression nodes when function parameter has been changed
    if (selectedNode.getParent() instanceof ExpressionNode) {
        ExpressionNode parentNode = (ExpressionNode) selectedNode.getParent();
        if (parentNode != null) {
            int index = parentNode.getIndex(selectedNode);
            if (parentNode.getExpression() instanceof FunctionExpressionImpl) {
                FunctionExpression functionExpression = (FunctionExpression) parentNode.getExpression();
                List<Expression> parameterList = functionExpression.getParameters();
                parameterList.remove(index);
                parameterList.add(index, expression);
            } else if (parentNode.getExpression() instanceof MathExpressionImpl) {
                MathExpressionImpl mathExpression = (MathExpressionImpl) parentNode.getExpression();
                List<Expression> parameterList = new ArrayList<>();
                parameterList.add(mathExpression.getExpression1());
                parameterList.add(mathExpression.getExpression2());
                parameterList.remove(index);
                parameterList.add(index, expression);
            } else {
                FunctionInterfaceUtils.handleFunctionInterface(parentNode, index, expression);
            }
            parentNode.setDisplayString();
        }
    }
    if (parentObj != null) {
        parentObj.dataApplied();
    }
    updateButtonState(false);
}
Also used : FunctionExpression(org.geotools.filter.FunctionExpression) MathExpressionImpl(org.geotools.filter.MathExpressionImpl) FunctionExpression(org.geotools.filter.FunctionExpression) Expression(org.opengis.filter.expression.Expression) ArrayList(java.util.ArrayList) List(java.util.List) FunctionExpressionImpl(org.geotools.filter.FunctionExpressionImpl)

Example 3 with MathExpressionImpl

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

the class InterpolationValues 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) {
        String displayName = ((Expression) aValue).toString();
        if (InterpolationNearest.class.getSimpleName().compareTo(displayName) == 0) {
            value = new InterpolationNearest();
        } else if (InterpolationBilinear.class.getSimpleName().compareTo(displayName) == 0) {
            value = new InterpolationBilinear();
        } else if (displayName.startsWith(InterpolationBicubic2.class.getSimpleName())) {
            sampleBits = extractSampleBits(INTERPOLATION_BICUBIC2_PATTERN_MATCH, displayName);
            value = new InterpolationBicubic2(sampleBits);
        } else if (displayName.startsWith(InterpolationBicubic.class.getSimpleName())) {
            sampleBits = extractSampleBits(INTERPOLATION_BICUBIC_PATTERN_MATCH, displayName);
            value = new InterpolationBicubic(sampleBits);
        }
    } else if ((aValue instanceof AttributeExpressionImpl) || (aValue instanceof FunctionExpressionImpl) || (aValue instanceof MathExpressionImpl)) {
        this.expression = (Expression) aValue;
    }
}
Also used : InterpolationBicubic(javax.media.jai.InterpolationBicubic) InterpolationNearest(javax.media.jai.InterpolationNearest) InterpolationBicubic2(javax.media.jai.InterpolationBicubic2) MathExpressionImpl(org.geotools.filter.MathExpressionImpl) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) InterpolationBilinear(javax.media.jai.InterpolationBilinear) FunctionExpressionImpl(org.geotools.filter.FunctionExpressionImpl)

Example 4 with MathExpressionImpl

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

the class BatchUpdateFontData method updateFontSize.

/**
 * Update font size.
 *
 * @param updatedFontSize the font size to update tp
 */
public void updateFontSize(int updatedFontSize) {
    if (font != null) {
        Expression fontSize = font.getSize();
        if (!(String.valueOf(updatedFontSize).equals(fontSize.toString()))) {
            if (fontSize instanceof LiteralExpressionImpl) {
                int updatedSize = Double.valueOf(fontSize.toString()).intValue() + updatedFontSize;
                // Make sure we don't get negative sized fonts!
                if (updatedSize < 1) {
                    updatedSize = 1;
                }
                Expression exp = ff.literal(updatedSize);
                font.setSize(exp);
            } else if ((fontSize instanceof FunctionExpression) || (fontSize instanceof MathExpressionImpl) || (fontSize instanceof ConstantExpression) || (fontSize instanceof AttributeExpressionImpl)) {
                Expression updatedSize = ff.add(fontSize, ff.literal(updatedFontSize));
                font.setSize(updatedSize);
            }
        }
    }
}
Also used : FunctionExpression(org.geotools.filter.FunctionExpression) MathExpressionImpl(org.geotools.filter.MathExpressionImpl) ConstantExpression(org.geotools.filter.ConstantExpression) Expression(org.opengis.filter.expression.Expression) FunctionExpression(org.geotools.filter.FunctionExpression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) ConstantExpression(org.geotools.filter.ConstantExpression)

Example 5 with MathExpressionImpl

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

the class FloatValues 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 Float) {
        this.value = (Float) aValue;
    } else if (aValue instanceof Double) {
        this.value = ((Double) aValue).floatValue();
    } else if (aValue instanceof LiteralExpressionImpl) {
        LiteralExpressionImpl literal = (LiteralExpressionImpl) aValue;
        value = literal.evaluate(value, Float.class);
    } else if ((aValue instanceof AttributeExpressionImpl) || (aValue instanceof FunctionExpressionImpl) || (aValue instanceof MathExpressionImpl)) {
        this.expression = (Expression) aValue;
    }
}
Also used : MathExpressionImpl(org.geotools.filter.MathExpressionImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) FunctionExpressionImpl(org.geotools.filter.FunctionExpressionImpl)

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