Search in sources :

Example 1 with FunctionExpressionImpl

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

the class ExpressionSubPanel method displayExpression.

/**
 * Display expression.
 *
 * @param node the node
 */
private void displayExpression(ExpressionNode node) {
    if (panelLiteral.getComponentCount() == 2) {
        panelLiteral.remove(1);
    }
    if (node == null) {
        return;
    }
    fieldConfig = PanelField.getField(ExpressionPanelv2.class, "ExpressionSubPanel.value", node.getType());
    if (fieldConfig != null) {
        fieldConfig.createUI();
        fieldConfig.addDataChangedListener(new UpdateSymbolInterface() {

            @Override
            public void dataChanged(FieldIdEnum changedField) {
                buttonGroup.setSelected(rdbtnLiteral.getModel(), true);
                updateButtonState(true);
            }
        });
        panelLiteral.add(fieldConfig.getPanel());
        // Reset the fields
        dataSourceAttributePanel.setAttribute(null);
        functionPanel.setFunction(null);
        dataSourceAttributePanel.setDataType(node.getType());
        Expression expression = node.getExpression();
        if (expression instanceof AttributeExpressionImpl) {
            dataSourceAttributePanel.setAttribute(expression);
            buttonGroup.setSelected(rdbtnAttribute.getModel(), true);
        } else if (expression instanceof EnvFunction) {
            envVarField.setEnvironmentVariable(expression);
            buttonGroup.setSelected(rdbtnEnvVar.getModel(), true);
        } else if (expression instanceof FunctionExpressionImpl) {
            functionPanel.setFunction(expression);
            buttonGroup.setSelected(rdbtnFunction.getModel(), true);
        } else {
            fieldConfig.populate(expression);
            buttonGroup.setSelected(rdbtnLiteral.getModel(), true);
        }
    }
    Dimension boxSize = box.getPreferredSize();
    setPreferredSize(boxSize);
    revalidate();
}
Also used : EnvFunction(org.geotools.filter.function.EnvFunction) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) UpdateSymbolInterface(com.sldeditor.ui.iface.UpdateSymbolInterface) Dimension(java.awt.Dimension) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) FunctionExpressionImpl(org.geotools.filter.FunctionExpressionImpl)

Example 2 with FunctionExpressionImpl

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

the class FunctionField method setFunction.

/**
 * Sets the function.
 *
 * @param expression the new attribute
 */
public void setFunction(Expression expression) {
    if (expression == null) {
        functionComboBox.setSelectedIndex(-1);
    } else {
        if (expression instanceof FunctionExpressionImpl) {
            FunctionExpressionImpl functionExpression = (FunctionExpressionImpl) expression;
            FunctionName function = functionExpression.getFunctionName();
            String functionName = function.getName();
            oldValueObj = functionName;
            functionComboBox.setSelectedItem(functionName);
        } else {
            ConsoleManager.getInstance().error(this, Localisation.getString(FunctionField.class, "DataSourceAttributePanel.error1"));
        }
    }
}
Also used : FunctionName(org.opengis.filter.capability.FunctionName) FunctionExpressionImpl(org.geotools.filter.FunctionExpressionImpl)

Example 3 with FunctionExpressionImpl

use of org.geotools.filter.FunctionExpressionImpl 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)

Example 4 with FunctionExpressionImpl

use of org.geotools.filter.FunctionExpressionImpl 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 5 with FunctionExpressionImpl

use of org.geotools.filter.FunctionExpressionImpl 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 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;
    } else if (expression instanceof ConcatenateFunction) {
        ConcatenateFunction concatenateExpression = (ConcatenateFunction) expression;
        List<Expression> parameters = new ArrayList<Expression>();
        ExpressionNode leftChildNode = (ExpressionNode) node.getChildAt(0);
        parameters.add(addExpression(leftChildNode));
        ExpressionNode rightChildNode = (ExpressionNode) node.getChildAt(1);
        parameters.add(addExpression(rightChildNode));
        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)

Aggregations

FunctionExpressionImpl (org.geotools.filter.FunctionExpressionImpl)8 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)7 LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)6 Expression (org.opengis.filter.expression.Expression)6 MathExpressionImpl (org.geotools.filter.MathExpressionImpl)5 ArrayList (java.util.ArrayList)2 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)1 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)1 UpdateSymbolInterface (com.sldeditor.ui.iface.UpdateSymbolInterface)1 Dimension (java.awt.Dimension)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 EnvFunction (org.geotools.filter.function.EnvFunction)1 ConcatenateFunction (org.geotools.filter.function.string.ConcatenateFunction)1 ProcessFunction (org.geotools.process.function.ProcessFunction)1 FunctionName (org.opengis.filter.capability.FunctionName)1 BinaryExpression (org.opengis.filter.expression.BinaryExpression)1