Search in sources :

Example 1 with ConstantExpression

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

the class BatchUpdateFontData method updateFontSize.

/**
 * Update font size.
 *
 * @param fontSize the font size
 */
public void updateFontSize(int fontSize) {
    if (font != null) {
        if (!(String.valueOf(fontSize).equals(font.getSize().toString()))) {
            if (font.getSize() instanceof LiteralExpressionImpl) {
                int updatedSize = Double.valueOf(font.getSize().toString()).intValue() + fontSize;
                // Make sure we don't get negative sized fonts!
                if (updatedSize < 1) {
                    updatedSize = 1;
                }
                Expression exp = ff.literal(updatedSize);
                font.setSize(exp);
            } else if ((font.getSize() instanceof FunctionExpression) || (font.getSize() instanceof MathExpressionImpl) || (font.getSize() instanceof ConstantExpression) || (font.getSize() instanceof AttributeExpressionImpl)) {
                Expression updatedSize = ff.add(font.getSize(), ff.literal(fontSize));
                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 2 with ConstantExpression

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

the class StrokeDetails method getStrokeDashArray.

/**
 * Gets the stroke dash array.
 *
 * @param stroke the stroke
 * @return the stroke dash array
 */
private List<Float> getStrokeDashArray(Stroke stroke) {
    List<Expression> expressionList = stroke.dashArray();
    List<Float> valueList = new ArrayList<Float>();
    if (expressionList != null) {
        for (Expression expression : expressionList) {
            if (expression instanceof LiteralExpressionImpl) {
                LiteralExpressionImpl lExpression = (LiteralExpressionImpl) expression;
                Float objValue = null;
                if (lExpression.getValue() instanceof Float) {
                    objValue = (Float) lExpression.getValue();
                } else if (lExpression.getValue() instanceof Double) {
                    objValue = ((Double) lExpression.getValue()).floatValue();
                }
                valueList.add(objValue);
            } else if (expression instanceof ConstantExpression) {
                ConstantExpression cExpression = (ConstantExpression) expression;
                Float objValue = (Float) cExpression.getValue();
                valueList.add(objValue);
            }
        }
    }
    return valueList;
}
Also used : ConstantExpression(org.geotools.filter.ConstantExpression) Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) ConstantExpression(org.geotools.filter.ConstantExpression) ArrayList(java.util.ArrayList)

Example 3 with ConstantExpression

use of org.geotools.filter.ConstantExpression 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 4 with ConstantExpression

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

Aggregations

ConstantExpression (org.geotools.filter.ConstantExpression)4 LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)4 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)3 Expression (org.opengis.filter.expression.Expression)3 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)1 ArrayList (java.util.ArrayList)1 FunctionExpression (org.geotools.filter.FunctionExpression)1 FunctionExpressionImpl (org.geotools.filter.FunctionExpressionImpl)1 MathExpressionImpl (org.geotools.filter.MathExpressionImpl)1 ProcessFunction (org.geotools.process.function.ProcessFunction)1 BinaryExpression (org.opengis.filter.expression.BinaryExpression)1 NilExpression (org.opengis.filter.expression.NilExpression)1