use of org.geotools.filter.LiteralExpressionImpl 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();
}
}
}
use of org.geotools.filter.LiteralExpressionImpl in project sldeditor by robward-scisys.
the class FieldConfigWKT method accept.
/**
* Accept.
*
* @param symbol the symbol
* @return true, if successful
*/
@Override
public boolean accept(GraphicalSymbol symbol) {
if (symbol != null) {
if (symbol instanceof MarkImpl) {
MarkImpl marker = (MarkImpl) symbol;
Expression expression = marker.getWellKnownName();
if (expression instanceof LiteralExpressionImpl) {
LiteralExpressionImpl lExpression = (LiteralExpressionImpl) expression;
Object value = lExpression.getValue();
if (value instanceof String) {
String valueString = (String) value;
if (valueString.startsWith(WKT_PREFIX)) {
return true;
}
}
}
}
}
return false;
}
use of org.geotools.filter.LiteralExpressionImpl in project sldeditor by robward-scisys.
the class ExpressionPanelv2 method addExpression.
/**
* Adds the expression.
*
* @param node the node
* @return the expression
*/
private Expression addExpression(ExpressionNode node) {
Expression localExpression = node.getExpression();
if (localExpression instanceof LiteralExpressionImpl) {
return localExpression;
} else if (localExpression instanceof AttributeExpressionImpl) {
return localExpression;
} else if (localExpression instanceof FunctionExpressionImpl) {
FunctionExpressionImpl functionExpression = (FunctionExpressionImpl) localExpression;
List<Expression> parameterlist = new ArrayList<>();
for (int childIndex = 0; childIndex < node.getChildCount(); childIndex++) {
ExpressionNode childNode = (ExpressionNode) node.getChildAt(childIndex);
parameterlist.add(addExpression(childNode));
}
functionExpression.setParameters(parameterlist);
return functionExpression;
} else if (localExpression instanceof MathExpressionImpl) {
MathExpressionImpl mathExpression = (MathExpressionImpl) localExpression;
ExpressionNode leftChildNode = (ExpressionNode) node.getChildAt(0);
mathExpression.setExpression1(addExpression(leftChildNode));
ExpressionNode rightChildNode = (ExpressionNode) node.getChildAt(1);
mathExpression.setExpression2(addExpression(rightChildNode));
return mathExpression;
} else if (localExpression instanceof ConcatenateFunction) {
ConcatenateFunction concatenateExpression = (ConcatenateFunction) localExpression;
List<Expression> parameters = new ArrayList<>();
for (int index = 0; index < node.getChildCount(); index++) {
ExpressionNode expressionNode = (ExpressionNode) node.getChildAt(0);
parameters.add(addExpression(expressionNode));
}
concatenateExpression.setParameters(parameters);
return concatenateExpression;
}
return null;
}
use of org.geotools.filter.LiteralExpressionImpl in project sldeditor by robward-scisys.
the class EnvironmentVariableField method setEnvironmentVariable.
/**
* Sets the environment variable.
*
* @param expression the new expression
*/
public void setEnvironmentVariable(Expression expression) {
if (expression instanceof EnvFunction) {
EnvFunction envFunction = (EnvFunction) expression;
LiteralExpressionImpl literal = (LiteralExpressionImpl) envFunction.getParameters().get(0);
envVarComboBox.setSelectedItem(literal.getValue());
} else if (expression instanceof LiteralExpressionImpl) {
LiteralExpressionImpl literal = (LiteralExpressionImpl) expression;
envVarComboBox.setSelectedItem(literal.getValue());
} else {
ConsoleManager.getInstance().error(this, Localisation.getString(DataSourceAttributePanel.class, "DataSourceAttributePanel.error1"));
}
}
use of org.geotools.filter.LiteralExpressionImpl in project sldeditor by robward-scisys.
the class PolygonFillDetails 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();
}
Aggregations