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);
}
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);
}
}
}
}
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;
}
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;
}
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);
}
}
}
Aggregations