use of org.geotools.filter.MathExpressionImpl in project sldeditor by robward-scisys.
the class FilterPanelv2 method addExpression.
/**
* Adds the expression.
*
* @param node the node
* @return the expression
*/
private Expression addExpression(ExpressionNode node) {
Expression expression = node.getExpression();
if (expression instanceof LiteralExpressionImpl) {
return expression;
} else if (expression instanceof AttributeExpressionImpl) {
return expression;
} else if (expression instanceof FunctionExpressionImpl) {
FunctionExpressionImpl functionExpression = (FunctionExpressionImpl) expression;
List<Expression> parameterlist = new ArrayList<Expression>();
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 (expression instanceof MathExpressionImpl) {
MathExpressionImpl mathExpression = (MathExpressionImpl) expression;
ExpressionNode leftChildNode = (ExpressionNode) node.getChildAt(0);
mathExpression.setExpression1(addExpression(leftChildNode));
ExpressionNode rightChildNode = (ExpressionNode) node.getChildAt(1);
mathExpression.setExpression2(addExpression(rightChildNode));
return mathExpression;
}
return null;
}
use of org.geotools.filter.MathExpressionImpl 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);
}
}
}
use of org.geotools.filter.MathExpressionImpl 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.MathExpressionImpl in project sldeditor by robward-scisys.
the class ExpressionNode method setMathExpression.
/**
* Sets the math expression.
*
* @param expression the new math expression
*/
private void setMathExpression(Expression expression) {
MathExpressionImpl mathsExpression = (MathExpressionImpl) expression;
String expressionText = Localisation.getString(ExpressionPanelv2.class, "ExpressionPanelv2.expression");
ExpressionNode childNode1 = new ExpressionNode();
childNode1.setType(Number.class);
childNode1.setName(expressionText + " 1");
childNode1.setExpression(mathsExpression.getExpression1());
this.insert(childNode1, this.getChildCount());
ExpressionNode childNode2 = new ExpressionNode();
childNode2.setType(Number.class);
childNode2.setName(expressionText + " 2");
childNode2.setExpression(mathsExpression.getExpression2());
this.insert(childNode2, this.getChildCount());
}
Aggregations