use of org.geotools.filter.MathExpressionImpl in project sldeditor by robward-scisys.
the class ExpressionNode method setExpression.
/**
* Sets the expression.
*
* @param expression the expression to set
*/
public void setExpression(Expression expression) {
this.expression = expression;
if (expression instanceof LiteralExpressionImpl) {
Object value = ((LiteralExpressionImpl) expression).getValue();
if (value instanceof AttributeExpressionImpl) {
this.expression = (AttributeExpressionImpl) value;
}
}
setDisplayString();
this.removeAllChildren();
if (this.expression instanceof EnvFunction) {
setEnvFunction();
} else if (this.expression instanceof FunctionExpression) {
setFunctionExpression();
} else if (this.expression instanceof FunctionImpl) {
setFunctionImpl();
} else if (this.expression instanceof Function) {
setFunction();
} else if (expression instanceof MathExpressionImpl) {
setMathExpression(expression);
} else if (expression instanceof AttributeExpressionImpl) {
// AttributeExpressionImpl property = (AttributeExpressionImpl) expression;
// TypeManager.getInstance().setLiteralType(literal.getValue().getClass());
} else if (expression instanceof LiteralExpressionImpl) {
LiteralExpressionImpl literal = (LiteralExpressionImpl) expression;
if (literal.getValue() != null) {
TypeManager.getInstance().setDataType(literal.getValue().getClass());
}
}
}
use of org.geotools.filter.MathExpressionImpl in project sldeditor by robward-scisys.
the class ExpressionSubPanel method applyButton.
/**
* Apply button.
*/
protected void applyButton() {
Expression expression = null;
String actionCommand = buttonGroup.getSelection().getActionCommand();
if (actionCommand.compareTo(LITERAL) == 0) {
expression = fieldConfig.getExpression();
} else if (actionCommand.compareTo(ATTRIBUTE) == 0) {
expression = dataSourceAttributePanel.getExpression();
} else if (actionCommand.compareTo(FUNCTION) == 0) {
expression = functionPanel.getExpression();
} else if (actionCommand.compareTo(ENVVAR) == 0) {
expression = envVarField.getExpression();
} else if (actionCommand.compareTo(MATHS) == 0) {
expression = mathsExpressionPanel.getExpression();
}
if (expression != null) {
selectedNode.setExpression(expression);
}
// function expression nodes when function parameter has been changed
if (selectedNode.getParent() instanceof ExpressionNode) {
ExpressionNode parentNode = (ExpressionNode) selectedNode.getParent();
if (parentNode != null) {
int index = parentNode.getIndex(selectedNode);
if (parentNode.getExpression() instanceof FunctionExpressionImpl) {
FunctionExpression functionExpression = (FunctionExpression) parentNode.getExpression();
List<Expression> parameterList = functionExpression.getParameters();
parameterList.remove(index);
parameterList.add(index, expression);
} else if (parentNode.getExpression() instanceof MathExpressionImpl) {
MathExpressionImpl mathExpression = (MathExpressionImpl) parentNode.getExpression();
List<Expression> parameterList = new ArrayList<>();
parameterList.add(mathExpression.getExpression1());
parameterList.add(mathExpression.getExpression2());
parameterList.remove(index);
parameterList.add(index, expression);
} else {
FunctionInterfaceUtils.handleFunctionInterface(parentNode, index, expression);
}
parentNode.setDisplayString();
}
}
if (parentObj != null) {
parentObj.dataApplied();
}
updateButtonState(false);
}
use of org.geotools.filter.MathExpressionImpl in project sldeditor by robward-scisys.
the class InterpolationValues 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) {
String displayName = ((Expression) aValue).toString();
if (InterpolationNearest.class.getSimpleName().compareTo(displayName) == 0) {
value = new InterpolationNearest();
} else if (InterpolationBilinear.class.getSimpleName().compareTo(displayName) == 0) {
value = new InterpolationBilinear();
} else if (displayName.startsWith(InterpolationBicubic2.class.getSimpleName())) {
sampleBits = extractSampleBits(INTERPOLATION_BICUBIC2_PATTERN_MATCH, displayName);
value = new InterpolationBicubic2(sampleBits);
} else if (displayName.startsWith(InterpolationBicubic.class.getSimpleName())) {
sampleBits = extractSampleBits(INTERPOLATION_BICUBIC_PATTERN_MATCH, displayName);
value = new InterpolationBicubic(sampleBits);
}
} else if ((aValue instanceof AttributeExpressionImpl) || (aValue instanceof FunctionExpressionImpl) || (aValue instanceof MathExpressionImpl)) {
this.expression = (Expression) aValue;
}
}
use of org.geotools.filter.MathExpressionImpl in project sldeditor by robward-scisys.
the class BatchUpdateFontData method updateFontSize.
/**
* Update font size.
*
* @param updatedFontSize the font size to update tp
*/
public void updateFontSize(int updatedFontSize) {
if (font != null) {
Expression fontSize = font.getSize();
if (!(String.valueOf(updatedFontSize).equals(fontSize.toString()))) {
if (fontSize instanceof LiteralExpressionImpl) {
int updatedSize = Double.valueOf(fontSize.toString()).intValue() + updatedFontSize;
// Make sure we don't get negative sized fonts!
if (updatedSize < 1) {
updatedSize = 1;
}
Expression exp = ff.literal(updatedSize);
font.setSize(exp);
} else if ((fontSize instanceof FunctionExpression) || (fontSize instanceof MathExpressionImpl) || (fontSize instanceof ConstantExpression) || (fontSize instanceof AttributeExpressionImpl)) {
Expression updatedSize = ff.add(fontSize, ff.literal(updatedFontSize));
font.setSize(updatedSize);
}
}
}
}
use of org.geotools.filter.MathExpressionImpl in project sldeditor by robward-scisys.
the class FloatValues 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 Float) {
this.value = (Float) aValue;
} else if (aValue instanceof Double) {
this.value = ((Double) aValue).floatValue();
} else if (aValue instanceof LiteralExpressionImpl) {
LiteralExpressionImpl literal = (LiteralExpressionImpl) aValue;
value = literal.evaluate(value, Float.class);
} else if ((aValue instanceof AttributeExpressionImpl) || (aValue instanceof FunctionExpressionImpl) || (aValue instanceof MathExpressionImpl)) {
this.expression = (Expression) aValue;
}
}
Aggregations