Search in sources :

Example 41 with LiteralExpressionImpl

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

the class SLDTestRunner method checkLiteralValue.

/**
 * Check literal value.
 *
 * @param message the message
 * @param expression the expression
 * @param expectedValue the expected value
 */
private void checkLiteralValue(String message, Expression expression, double expectedValue) {
    assertEquals(expression.getClass(), LiteralExpressionImpl.class);
    LiteralExpressionImpl literalExpression = (LiteralExpressionImpl) expression;
    Object value = literalExpression.getValue();
    assertEquals(value.getClass(), Double.class, message);
    Double actualValue = (Double) value;
    String additional = String.format(" Expected '%f' Actual '%f'", expectedValue, actualValue);
    assertTrue(Math.abs(expectedValue - actualValue) < epsilon, message + additional);
}
Also used : LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) XMLFieldLiteralString(com.sldeditor.common.xml.ui.XMLFieldLiteralString) XMLFieldLiteralDouble(com.sldeditor.common.xml.ui.XMLFieldLiteralDouble)

Example 42 with LiteralExpressionImpl

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

the class FieldConfigMarker method setValue.

/**
 * Sets the value.
 *
 * @param symbolizerType the symbolizer type
 * @param fieldConfigManager the field config manager
 * @param multiOptionPanel the multi option panel
 * @param graphic the graphic
 * @param symbol the symbol
 */
@Override
public void setValue(Class<?> symbolizerType, GraphicPanelFieldManager fieldConfigManager, FieldConfigSymbolType multiOptionPanel, Graphic graphic, GraphicalSymbol symbol) {
    if ((symbol != null) && (fieldConfigManager != null)) {
        MarkImpl markerSymbol = (MarkImpl) symbol;
        Expression wellKnownNameExpression = markerSymbol.getWellKnownName();
        if (wellKnownNameExpression instanceof LiteralExpressionImpl) {
            LiteralExpressionImpl literal = (LiteralExpressionImpl) wellKnownNameExpression;
            FieldConfigBase field = fieldConfigManager.get(symbolSelectionField);
            if (field != null) {
                field.populate(literal);
            }
            Expression expFillColour = null;
            Expression expFillOpacity = null;
            Expression expStrokeColour = null;
            Expression expStrokeOpacity = null;
            Expression expStrokeWidth = null;
            // Which opacity attribute do we use?
            if (symbol instanceof MarkImpl) {
                MarkImpl markSymbol = (MarkImpl) symbol;
                Fill fill = markSymbol.getFill();
                if (fill != null) {
                    expFillColour = fill.getColor();
                    if (!isOverallOpacity(symbolizerType)) {
                        expFillOpacity = fill.getOpacity();
                    }
                }
                Stroke stroke = markSymbol.getStroke();
                if (stroke != null) {
                    expStrokeColour = stroke.getColor();
                    if (!isOverallOpacity(symbolizerType)) {
                        expStrokeOpacity = stroke.getOpacity();
                    }
                    expStrokeWidth = stroke.getWidth();
                }
            }
            if (isOverallOpacity(symbolizerType)) {
                FieldConfigBase opacity = fieldConfigManager.get(FieldIdEnum.OVERALL_OPACITY);
                if (opacity != null) {
                    opacity.populate(graphic.getOpacity());
                }
            }
            FieldConfigBase opacity = fieldConfigManager.get(fillFieldConfig.getOpacity());
            if (opacity != null) {
                opacity.populate(expFillOpacity);
            }
            opacity = fieldConfigManager.get(strokeFieldConfig.getOpacity());
            if (opacity != null) {
                opacity.populate(expStrokeOpacity);
            }
            Class<?> panelId = getCommonData().getPanelId();
            GroupConfigInterface fillGroup = fieldConfigManager.getGroup(panelId, fillFieldConfig.getGroup());
            GroupConfigInterface strokeGroup = fieldConfigManager.getGroup(panelId, strokeFieldConfig.getGroup());
            if ((fillGroup == null) || (strokeGroup == null)) {
                return;
            }
            if (literal.toString().startsWith(GEOSERVER_MARKER_PREFIX)) {
                setGeoServerMarker(fieldConfigManager, expStrokeColour, expStrokeOpacity, fillGroup, strokeGroup);
            } else {
                setFillMarker(fieldConfigManager, expFillColour, expStrokeColour, expStrokeWidth, fillGroup, strokeGroup);
            }
        }
    }
}
Also used : Fill(org.geotools.styling.Fill) GraphicFill(org.opengis.style.GraphicFill) Stroke(org.geotools.styling.Stroke) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) MarkImpl(org.geotools.styling.MarkImpl) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface)

Example 43 with LiteralExpressionImpl

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

the class FieldConfigFont method getFontName.

/**
 * Gets the font name.
 *
 * @param font the font
 * @return the font name
 */
private String getFontName(Font font) {
    String fontName = "";
    if (font != null) {
        List<Expression> expressionList = font.getFamily();
        if ((expressionList != null) && !expressionList.isEmpty()) {
            LiteralExpressionImpl expression = (LiteralExpressionImpl) expressionList.get(0);
            fontName = expression.toString();
        }
    }
    return fontName;
}
Also used : Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl)

Example 44 with LiteralExpressionImpl

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

the class IsLike method createFilter.

/**
 * Creates the filter.
 *
 * @param parameterList the parameter list
 * @return the filter
 */
@Override
public Filter createFilter(List<Expression> parameterList) {
    LikeFilterImpl filter = null;
    if ((parameterList == null) || parameterList.size() != 6) {
        filter = new IsLikeExtended();
    } else {
        LiteralExpressionImpl pattern = (LiteralExpressionImpl) parameterList.get(1);
        LiteralExpressionImpl wildcardMulti = (LiteralExpressionImpl) parameterList.get(2);
        LiteralExpressionImpl wildcardSingle = (LiteralExpressionImpl) parameterList.get(3);
        LiteralExpressionImpl escape = (LiteralExpressionImpl) parameterList.get(4);
        LiteralExpressionImpl matchCase = (LiteralExpressionImpl) parameterList.get(5);
        filter = new IsLikeExtended(parameterList.get(0), (String) pattern.getValue(), (String) wildcardMulti.getValue(), (String) wildcardSingle.getValue(), (String) escape.getValue(), (Boolean) matchCase.getValue());
    }
    return filter;
}
Also used : LikeFilterImpl(org.geotools.filter.LikeFilterImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl)

Example 45 with LiteralExpressionImpl

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

the class CoordinateReferenceSystemValues 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) {
        LiteralExpressionImpl literal = (LiteralExpressionImpl) aValue;
        if (literal.getValue() != null) {
            value = literal.toString();
        }
    } else if ((aValue instanceof AttributeExpressionImpl) || (aValue instanceof FunctionExpressionImpl) || (aValue instanceof MathExpressionImpl)) {
        this.expression = (Expression) aValue;
    } else {
        if (aValue instanceof String) {
            value = ((String) aValue);
        }
    }
}
Also used : MathExpressionImpl(org.geotools.filter.MathExpressionImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) FunctionExpressionImpl(org.geotools.filter.FunctionExpressionImpl)

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