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