Search in sources :

Example 51 with LiteralExpressionImpl

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

the class WindBarbDetails method updateSymbol.

/**
 * Update symbol.
 */
private void updateSymbol() {
    if (!Controller.getInstance().isPopulating()) {
        ValueComboBoxData windSpeedUnits = fieldConfigVisitor.getComboBox(FieldIdEnum.WINDBARB_WINDSPEED_UNITS);
        Expression windSpeedExpression = fieldConfigVisitor.getExpression(FieldIdEnum.WINDBARB_WINDSPEED);
        boolean inNorthernHemisphere = fieldConfigVisitor.getBoolean(FieldIdEnum.WINDBARB_NORTHERN_HEMISPHERE);
        Object windSpeed = null;
        if (windSpeedExpression == null) {
            windSpeed = Integer.valueOf(0);
        } else if (windSpeedExpression instanceof LiteralExpressionImpl) {
            LiteralExpressionImpl literalExpression = (LiteralExpressionImpl) windSpeedExpression;
            windSpeed = literalExpression.getValue();
        } else if (windSpeedExpression instanceof ConstantExpression) {
            ConstantExpression constantExpression = (ConstantExpression) windSpeedExpression;
            windSpeed = constantExpression.getValue();
        } else if (windSpeedExpression instanceof AttributeExpressionImpl) {
            AttributeExpressionImpl attributeExpression = (AttributeExpressionImpl) windSpeedExpression;
            windSpeed = String.format("<ogc:PropertyName>%s</ogc:PropertyName>", attributeExpression.getPropertyName());
        } else {
            ConsoleManager.getInstance().error(this, Localisation.getField(WindBarbDetails.class, "WindBarb.windspeedError1") + windSpeedExpression.getClass().getName());
        }
        String url = String.format("windbarbs://default(%s)[%s]", windSpeed, windSpeedUnits.getKey());
        if (!inNorthernHemisphere) {
            url = url + HEMISPHERE_S;
        }
        windBarbsExpression = getFilterFactory().literal(url);
        if (parentObj != null) {
            parentObj.windBarbValueUpdated();
        }
    }
}
Also used : ConstantExpression(org.geotools.filter.ConstantExpression) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) ConstantExpression(org.geotools.filter.ConstantExpression) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 52 with LiteralExpressionImpl

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

the class FieldConfigWKT method accept.

/**
 * Accept.
 *
 * @param symbol the symbol
 * @return true, if successful
 */
@Override
public boolean accept(GraphicalSymbol symbol) {
    if (symbol != null) {
        if (symbol instanceof MarkImpl) {
            MarkImpl marker = (MarkImpl) symbol;
            Expression expression = marker.getWellKnownName();
            if (expression instanceof LiteralExpressionImpl) {
                LiteralExpressionImpl lExpression = (LiteralExpressionImpl) expression;
                Object value = lExpression.getValue();
                if (value instanceof String) {
                    String valueString = (String) value;
                    if (valueString.startsWith(WKT_PREFIX)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) MarkImpl(org.geotools.styling.MarkImpl)

Example 53 with LiteralExpressionImpl

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

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

the class EnvironmentVariableField method setEnvironmentVariable.

/**
 * Sets the environment variable.
 *
 * @param expression the new expression
 */
public void setEnvironmentVariable(Expression expression) {
    if (expression instanceof EnvFunction) {
        EnvFunction envFunction = (EnvFunction) expression;
        LiteralExpressionImpl literal = (LiteralExpressionImpl) envFunction.getParameters().get(0);
        envVarComboBox.setSelectedItem(literal.getValue());
    } else if (expression instanceof LiteralExpressionImpl) {
        LiteralExpressionImpl literal = (LiteralExpressionImpl) expression;
        envVarComboBox.setSelectedItem(literal.getValue());
    } else {
        ConsoleManager.getInstance().error(this, Localisation.getString(DataSourceAttributePanel.class, "DataSourceAttributePanel.error1"));
    }
}
Also used : EnvFunction(org.geotools.filter.function.EnvFunction) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl)

Example 55 with LiteralExpressionImpl

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

the class PolygonFillDetails method optionSelected.

/**
 * Option selected.
 *
 * @param fieldPanelId the field panel id
 * @param selectedItem the selected item
 */
@Override
public void optionSelected(Class<?> fieldPanelId, String selectedItem) {
    setSymbolTypeVisibility(fieldPanelId, selectedItem);
    selectedFillPanelId = fieldPanelId;
    FieldConfigBase fieldConfig = fieldConfigManager.get(FieldIdEnum.SIZE);
    if (fieldConfig.isEnabled()) {
        Expression expression = fieldConfig.getExpression();
        if (expression instanceof LiteralExpressionImpl) {
            LiteralExpressionImpl l = (LiteralExpressionImpl) expression;
            Double d = (Double) l.getValue();
            if (d <= 0.0) {
                fieldConfigVisitor.populateField(FieldIdEnum.SIZE, getFilterFactory().literal(1));
            }
        }
    }
    dataHasChanged();
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl)

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