Search in sources :

Example 36 with LiteralExpressionImpl

use of org.geotools.filter.LiteralExpressionImpl in project ddf by codice.

the class OpenSearchQueryTest method verifyEqualsFilter.

private void verifyEqualsFilter(Filter filter, String expectedPropertyName, String expectedValue) {
    assertTrue(filter instanceof IsEqualsToImpl);
    IsEqualsToImpl equalsFilter = (IsEqualsToImpl) filter;
    AttributeExpressionImpl expression1 = (AttributeExpressionImpl) equalsFilter.getExpression1();
    LOGGER.debug("propertyName = {}", expression1.getPropertyName());
    assertEquals(expectedPropertyName, expression1.getPropertyName());
    LiteralExpressionImpl expression2 = (LiteralExpressionImpl) equalsFilter.getExpression2();
    LOGGER.debug("version to search for = {}", expression2.getValue());
    assertEquals(expectedValue, expression2.getValue());
}
Also used : AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) IsEqualsToImpl(org.geotools.filter.IsEqualsToImpl)

Example 37 with LiteralExpressionImpl

use of org.geotools.filter.LiteralExpressionImpl 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 38 with LiteralExpressionImpl

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

the class FieldConfigBase method populate.

/**
 * Populate.
 *
 * @param expression the expression
 */
public void populate(Expression expression) {
    if (attributeSelectionPanel != null) {
        attributeSelectionPanel.populateAttributeComboxBox(expression);
    }
    if (expression == null) {
        expressionType = ExpressionTypeEnum.E_VALUE;
        revertToDefaultValue();
        valueUpdated();
    } else {
        if (expression instanceof LiteralExpressionImpl) {
            LiteralExpressionImpl lExpression = (LiteralExpressionImpl) expression;
            Object objValue = lExpression.getValue();
            if (objValue instanceof AttributeExpressionImpl) {
                expressionType = ExpressionTypeEnum.E_ATTRIBUTE;
                if (attributeSelectionPanel != null) {
                    attributeSelectionPanel.setAttribute((AttributeExpressionImpl) objValue);
                }
                setCachedExpression((AttributeExpressionImpl) objValue);
            } else {
                expressionType = ExpressionTypeEnum.E_VALUE;
                populateExpression(objValue);
                valueUpdated();
            }
        } else if (expression instanceof ConstantExpression) {
            ConstantExpression cExpression = (ConstantExpression) expression;
            Object objValue = cExpression.getValue();
            expressionType = ExpressionTypeEnum.E_VALUE;
            populateExpression(objValue);
            valueUpdated();
        } else if (expression instanceof NilExpression) {
            Object objValue = null;
            expressionType = ExpressionTypeEnum.E_VALUE;
            populateExpression(objValue);
            valueUpdated();
        } else if (expression instanceof ProcessFunction) {
            ProcessFunction processExpression = (ProcessFunction) expression;
            Object objValue = processExpression;
            expressionType = ExpressionTypeEnum.E_VALUE;
            populateExpression(objValue);
            valueUpdated();
        } else if (expression instanceof AttributeExpressionImpl) {
            expressionType = ExpressionTypeEnum.E_ATTRIBUTE;
            if (attributeSelectionPanel != null) {
                attributeSelectionPanel.setAttribute(expression);
            } else {
                populateExpression(expression);
            }
            setCachedExpression(expression);
        } else if (expression instanceof FunctionExpressionImpl) {
            expressionType = ExpressionTypeEnum.E_EXPRESSION;
            if (attributeSelectionPanel != null) {
                attributeSelectionPanel.populate(expression);
            }
            setCachedExpression(expression);
        } else if (expression instanceof BinaryExpression) {
            expressionType = ExpressionTypeEnum.E_EXPRESSION;
            if (attributeSelectionPanel != null) {
                attributeSelectionPanel.populate(expression);
            }
            setCachedExpression(expression);
        } else {
            expressionType = ExpressionTypeEnum.E_EXPRESSION;
        }
    }
    setValueFieldState();
}
Also used : ProcessFunction(org.geotools.process.function.ProcessFunction) BinaryExpression(org.opengis.filter.expression.BinaryExpression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) ConstantExpression(org.geotools.filter.ConstantExpression) NilExpression(org.opengis.filter.expression.NilExpression) FunctionExpressionImpl(org.geotools.filter.FunctionExpressionImpl)

Example 39 with LiteralExpressionImpl

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

the class ColourRampPanel method populateValue.

/**
 * Populate value.
 *
 * @param spinner the spinner
 * @param colorMapEntry the color map entry
 */
private void populateValue(FieldConfigInteger spinner, ColorMapEntry colorMapEntry) {
    if (spinner == null) {
        return;
    }
    if (colorMapEntry == null) {
        return;
    }
    int quantity = 1;
    Expression quantityExpression = colorMapEntry.getQuantity();
    if (quantityExpression != null) {
        Object quantityValue = ((LiteralExpressionImpl) quantityExpression).getValue();
        if (quantityValue instanceof Integer) {
            quantity = ((Integer) quantityValue).intValue();
        } else if (quantityValue instanceof Double) {
            quantity = ((Double) quantityValue).intValue();
        } else if (quantityValue instanceof String) {
            quantity = Double.valueOf((String) quantityValue).intValue();
        }
    }
    spinner.populateField(quantity);
}
Also used : FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl)

Example 40 with LiteralExpressionImpl

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

the class ColourRamp method getColour.

/**
 * Gets the colour.
 *
 * @param data the data
 * @param quantityExpression the quantity expression
 * @param reverseColours the reverse colours
 * @return the colour
 */
public Expression getColour(ColourRampData data, Expression quantityExpression, boolean reverseColours) {
    Expression expression = null;
    if (quantityExpression instanceof LiteralExpressionImpl) {
        int value = Integer.parseInt(quantityExpression.toString());
        int tmpRange = Math.abs(data.getMaxValue() - data.getMinValue());
        // Check to see if we have set up the gradient yet
        if ((range != tmpRange) || (lastMinValue != data.getMinValue()) || (lastReverseColoursFlag != reverseColours)) {
            range = tmpRange;
            lastMinValue = data.getMinValue();
            gradientImage = createImage(range, reverseColours);
            lastReverseColoursFlag = reverseColours;
        }
        int pos = value - data.getMinValue();
        if (pos >= range) {
            pos = range - 1;
        }
        if (pos < 0) {
            pos = 0;
        }
        int rgb = gradientImage.getRGB(pos, 0);
        Color colour = new Color(rgb);
        expression = ff.literal(ColourUtils.fromColour(colour));
    }
    return expression;
}
Also used : Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) Color(java.awt.Color) GradientPaint(java.awt.GradientPaint)

Aggregations

LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)58 Expression (org.opengis.filter.expression.Expression)33 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)20 AttributeType (ddf.catalog.data.AttributeType)7 MathExpressionImpl (org.geotools.filter.MathExpressionImpl)7 FunctionExpressionImpl (org.geotools.filter.FunctionExpressionImpl)6 MarkImpl (org.geotools.styling.MarkImpl)6 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)5 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 ConstantExpression (org.geotools.filter.ConstantExpression)4 IsEqualsToImpl (org.geotools.filter.IsEqualsToImpl)4 Literal (org.opengis.filter.expression.Literal)4 XMLFieldLiteralString (com.sldeditor.common.xml.ui.XMLFieldLiteralString)3 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)3 Color (java.awt.Color)3 Geometry (org.locationtech.jts.geom.Geometry)3 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)2 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)2 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)2