Search in sources :

Example 46 with LiteralExpressionImpl

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

the class IsLessThan method createFilter.

/**
 * Creates the filter.
 *
 * @param parameterList the parameter list
 * @return the filter
 */
@Override
public Filter createFilter(List<Expression> parameterList) {
    IsLessThenImpl filter = null;
    if ((parameterList == null) || (parameterList.size() < 2) || (parameterList.size() > 3)) {
        filter = new IsLessThanExtended();
    } else {
        LiteralExpressionImpl matchCase = (LiteralExpressionImpl) parameterList.get(2);
        filter = new IsLessThanExtended(parameterList.get(0), parameterList.get(1), (Boolean) matchCase.getValue());
    }
    return filter;
}
Also used : IsLessThenImpl(org.geotools.filter.IsLessThenImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl)

Example 47 with LiteralExpressionImpl

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

the class FontUtils method getFont.

/**
 * Converts a org.geotools.styling.Font to java.awt.Font
 *
 * @param font the GeoTools font
 * @return the Java font
 */
public static java.awt.Font getFont(Font font) {
    LiteralExpressionImpl sizeExpression = ((LiteralExpressionImpl) font.getSize());
    Object obj = sizeExpression.getValue();
    int size;
    if (obj instanceof String) {
        size = Integer.valueOf((String) obj);
    } else if (obj instanceof Double) {
        size = ((Double) obj).intValue();
    } else {
        size = Integer.valueOf(((String) obj).toString());
    }
    int styleMask = java.awt.Font.PLAIN;
    String styleName = font.getStyle().toString();
    if (styleName != null) {
        if (styleName.compareToIgnoreCase("ITALIC") == 0) {
            styleMask |= java.awt.Font.ITALIC;
        }
    }
    String weightName = font.getWeight().toString();
    if (weightName != null) {
        if (weightName.compareToIgnoreCase("BOLD") == 0) {
            styleMask |= java.awt.Font.BOLD;
        }
    }
    String name = font.getFamily().get(0).toString();
    return new java.awt.Font(name, styleMask, size);
}
Also used : LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) Font(org.geotools.styling.Font)

Example 48 with LiteralExpressionImpl

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

the class FieldConfigGeometryField method populateExpression.

/**
 * Populate expression.
 *
 * @param objValue the obj value
 */
/*
     * (non-Javadoc)
     *
     * @see com.sldeditor.ui.detail.config.FieldConfigBase#populateExpression(java.lang.Object)
     */
@Override
public void populateExpression(Object objValue) {
    String propertyName = null;
    if (objValue instanceof PropertyExistsFunction) {
        Expression e = ((PropertyExistsFunction) objValue).getParameters().get(0);
        propertyName = e.toString();
    } else if (objValue instanceof AttributeExpressionImpl) {
        propertyName = ((AttributeExpressionImpl) objValue).getPropertyName();
    } else if (objValue instanceof LiteralExpressionImpl) {
        propertyName = AttributeUtils.extract((String) ((LiteralExpressionImpl) objValue).getValue());
    }
    populateField(propertyName);
}
Also used : PropertyExistsFunction(org.geotools.filter.function.PropertyExistsFunction) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl)

Example 49 with LiteralExpressionImpl

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

the class FieldConfigColour method populateExpression.

/**
 * Populate expression.
 *
 * @param objValue the obj value
 */
/*
     * (non-Javadoc)
     *
     * @see com.sldeditor.ui.detail.config.FieldConfigBase#populateExpression(java.lang.Object)
     */
@Override
public void populateExpression(Object objValue) {
    String sValue = null;
    boolean validColour = true;
    if (objValue instanceof LiteralExpressionImpl) {
        sValue = ((LiteralExpressionImpl) objValue).toString();
    } else if (objValue instanceof String) {
        sValue = (String) objValue;
    } else {
        validColour = false;
        if (objValue != null) {
            ConsoleManager.getInstance().error(this, "Colour expression is of unknown type : " + objValue.getClass().getName());
        } else {
        // Null is allowed, just will not be shown
        }
    }
    if ((colourButton != null) && validColour) {
        if (!sValue.startsWith("#")) {
            ConsoleManager.getInstance().error(this, "Colour string does not start with #" + sValue);
        } else {
            Expression opacity = getFilterFactory().literal(DefaultSymbols.defaultColourOpacity());
            colourButton.populate(sValue, opacity);
            if (!FieldConfigColour.this.isSuppressUndoEvents()) {
                Color newValue = colourButton.getColour();
                UndoManager.getInstance().addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, newValue));
                oldValueObj = newValue;
            }
        }
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) Color(java.awt.Color)

Example 50 with LiteralExpressionImpl

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

the class ColourMapData method getNextQuantity.

/**
 * Gets the next quantity.
 *
 * @return the next quantity
 */
public Expression getNextQuantity() {
    Expression nextQuantity = null;
    if (quantity != null) {
        if (quantity instanceof LiteralExpressionImpl) {
            double quantityValue = Double.parseDouble(quantity.toString());
            nextQuantity = ff.literal(quantityValue + 1);
        } else {
            // Could be a function expression so just leave alone
            nextQuantity = quantity;
        }
    }
    return nextQuantity;
}
Also used : 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