Search in sources :

Example 21 with LiteralExpressionImpl

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

the class PointFillDetails 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)

Example 22 with LiteralExpressionImpl

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

the class ExtractAttributes method extractAttribute.

/**
 * Extract attribute.
 *
 * @param attributeType the attribute type
 * @param expression the expression
 * @param foundList the found list
 * @return the class
 */
protected Class<?> extractAttribute(Class<?> attributeType, Expression expression, List<String> foundList) {
    Class<?> returnType = String.class;
    if (expression instanceof AttributeExpressionImpl) {
        AttributeExpressionImpl attribute = (AttributeExpressionImpl) expression;
        extractPropertyAttribute(attributeType, foundList, attribute);
    } else if (expression instanceof Function) {
        Function function = (Function) expression;
        returnType = extractFunctionAttribute(foundList, function);
    } else if (expression instanceof LiteralExpressionImpl) {
        LiteralExpressionImpl literal = (LiteralExpressionImpl) expression;
        returnType = extractLiteralAttribute(returnType, literal);
    }
    return returnType;
}
Also used : Function(org.opengis.filter.expression.Function) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) LineString(org.locationtech.jts.geom.LineString)

Example 23 with LiteralExpressionImpl

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

the class StandardPanel method getStandardData.

/**
 * Gets the standard data.
 *
 * @return the standard data
 */
protected StandardData getStandardData() {
    StandardData standardData = new StandardData();
    if (fieldConfigVisitor.getFieldConfig(FieldIdEnum.NAME) != null) {
        standardData.name = fieldConfigVisitor.getText(FieldIdEnum.NAME);
    }
    if ((fieldConfigVisitor.getFieldConfig(FieldIdEnum.TITLE) != null) && (fieldConfigVisitor.getFieldConfig(FieldIdEnum.DESCRIPTION) != null)) {
        InternationalString titleString = Text.text(fieldConfigVisitor.getText(FieldIdEnum.TITLE));
        InternationalString descriptionString = Text.text(fieldConfigVisitor.getText(FieldIdEnum.DESCRIPTION));
        standardData.description = getStyleFactory().description(titleString, descriptionString);
    }
    FieldConfigBase uomFieldConfig = fieldConfigManager.get(FieldIdEnum.UOM);
    if (uomFieldConfig != null) {
        Expression uomExpression = fieldConfigVisitor.getExpression(FieldIdEnum.UOM);
        String uomString = "";
        if (uomExpression instanceof LiteralExpressionImpl) {
            uomString = (String) ((LiteralExpressionImpl) uomExpression).getValue();
        } else {
            if (uomExpression != null) {
                ConsoleManager.getInstance().error(this, Localisation.getString(StandardPanel.class, "StandardPanel.unsupportedUOM") + uomExpression.getClass().getName());
            }
        }
        standardData.unit = null;
        if (!uomString.equals("") && !uomString.equals("Map Units")) {
            standardData.unit = UomOgcMapping.get(uomString);
        }
    }
    return standardData;
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) InternationalString(org.opengis.util.InternationalString) Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) InternationalString(org.opengis.util.InternationalString)

Example 24 with LiteralExpressionImpl

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

the class FieldConfigBase method populateLiteralExpression.

/**
 * Populate literal expression.
 *
 * @param expression the expression
 */
private void populateLiteralExpression(Expression expression) {
    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();
    }
}
Also used : AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl)

Example 25 with LiteralExpressionImpl

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

the class FieldConfigPopulationTest method testExpression.

/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigPopulation#populateField(com.sldeditor.ui.detail.config.FieldId,
 * org.opengis.filter.expression.Expression)}. Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigPopulation#populateField(com.sldeditor.common.xml.ui.FieldIdEnum,
 * org.opengis.filter.expression.Expression)}. Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigPopulation#getExpression(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigPopulation#getExpression(com.sldeditor.common.xml.ui.FieldIdEnum)}.
 */
@Test
public void testExpression() {
    FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
    FieldConfigInteger intField = new FieldConfigInteger(new FieldConfigCommonData(Geometry.class, fieldId, "label", true, false));
    intField.createUI();
    fieldConfigManager.add(fieldId, intField);
    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
    int expectedValue = 1256;
    StyleBuilder styleBuilder = new StyleBuilder();
    Expression expression = styleBuilder.literalExpression(expectedValue);
    obj.populateField(fieldId, expression);
    LiteralExpressionImpl actualValue = (LiteralExpressionImpl) obj.getExpression(fieldId);
    assertEquals(expectedValue, ((Integer) actualValue.getValue()).intValue());
    actualValue = (LiteralExpressionImpl) obj.getExpression(fieldId);
    assertEquals(expectedValue, ((Integer) actualValue.getValue()).intValue());
    // This shouldn't work as it does not know about the field
    FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
    obj.populateField(wrongFieldEnum, expression);
    assertNull(obj.getExpression(wrongFieldEnum));
    // Try with null
    obj.populateField(fieldId, null);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) StyleBuilder(org.geotools.styling.StyleBuilder) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) Test(org.junit.jupiter.api.Test)

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