use of org.geotools.filter.ConstantExpression in project sldeditor by robward-scisys.
the class BatchUpdateFontData method updateFontSize.
/**
* Update font size.
*
* @param fontSize the font size
*/
public void updateFontSize(int fontSize) {
if (font != null) {
if (!(String.valueOf(fontSize).equals(font.getSize().toString()))) {
if (font.getSize() instanceof LiteralExpressionImpl) {
int updatedSize = Double.valueOf(font.getSize().toString()).intValue() + fontSize;
// Make sure we don't get negative sized fonts!
if (updatedSize < 1) {
updatedSize = 1;
}
Expression exp = ff.literal(updatedSize);
font.setSize(exp);
} else if ((font.getSize() instanceof FunctionExpression) || (font.getSize() instanceof MathExpressionImpl) || (font.getSize() instanceof ConstantExpression) || (font.getSize() instanceof AttributeExpressionImpl)) {
Expression updatedSize = ff.add(font.getSize(), ff.literal(fontSize));
font.setSize(updatedSize);
}
}
}
}
use of org.geotools.filter.ConstantExpression in project sldeditor by robward-scisys.
the class StrokeDetails method getStrokeDashArray.
/**
* Gets the stroke dash array.
*
* @param stroke the stroke
* @return the stroke dash array
*/
private List<Float> getStrokeDashArray(Stroke stroke) {
List<Expression> expressionList = stroke.dashArray();
List<Float> valueList = new ArrayList<Float>();
if (expressionList != null) {
for (Expression expression : expressionList) {
if (expression instanceof LiteralExpressionImpl) {
LiteralExpressionImpl lExpression = (LiteralExpressionImpl) expression;
Float objValue = null;
if (lExpression.getValue() instanceof Float) {
objValue = (Float) lExpression.getValue();
} else if (lExpression.getValue() instanceof Double) {
objValue = ((Double) lExpression.getValue()).floatValue();
}
valueList.add(objValue);
} else if (expression instanceof ConstantExpression) {
ConstantExpression cExpression = (ConstantExpression) expression;
Float objValue = (Float) cExpression.getValue();
valueList.add(objValue);
}
}
}
return valueList;
}
use of org.geotools.filter.ConstantExpression in project sldeditor by robward-scisys.
the class FieldConfigBase method populate.
/**
* Populate.
*
* @param expression the expression
*/
public void populate(Expression expression) {
if (attributeSelectionPanel != null) {
attributeSelectionPanel.populateAttributeComboxBox(expression);
}
if (expression == null) {
expressionType = ExpressionTypeEnum.E_VALUE;
revertToDefaultValue();
valueUpdated();
} else {
if (expression instanceof LiteralExpressionImpl) {
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();
}
} else if (expression instanceof ConstantExpression) {
ConstantExpression cExpression = (ConstantExpression) expression;
Object objValue = cExpression.getValue();
expressionType = ExpressionTypeEnum.E_VALUE;
populateExpression(objValue);
valueUpdated();
} else if (expression instanceof NilExpression) {
Object objValue = null;
expressionType = ExpressionTypeEnum.E_VALUE;
populateExpression(objValue);
valueUpdated();
} else if (expression instanceof ProcessFunction) {
ProcessFunction processExpression = (ProcessFunction) expression;
Object objValue = processExpression;
expressionType = ExpressionTypeEnum.E_VALUE;
populateExpression(objValue);
valueUpdated();
} else if (expression instanceof AttributeExpressionImpl) {
expressionType = ExpressionTypeEnum.E_ATTRIBUTE;
if (attributeSelectionPanel != null) {
attributeSelectionPanel.setAttribute(expression);
} else {
populateExpression(expression);
}
setCachedExpression(expression);
} else if (expression instanceof FunctionExpressionImpl) {
expressionType = ExpressionTypeEnum.E_EXPRESSION;
if (attributeSelectionPanel != null) {
attributeSelectionPanel.populate(expression);
}
setCachedExpression(expression);
} else if (expression instanceof BinaryExpression) {
expressionType = ExpressionTypeEnum.E_EXPRESSION;
if (attributeSelectionPanel != null) {
attributeSelectionPanel.populate(expression);
}
setCachedExpression(expression);
} else {
expressionType = ExpressionTypeEnum.E_EXPRESSION;
}
}
setValueFieldState();
}
use of org.geotools.filter.ConstantExpression 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();
}
}
}
Aggregations