use of org.geotools.filter.FunctionExpressionImpl in project sldeditor by robward-scisys.
the class ExpressionSubPanel method displayExpression.
/**
* Display expression.
*
* @param node the node
*/
private void displayExpression(ExpressionNode node) {
if (panelLiteral.getComponentCount() == 2) {
panelLiteral.remove(1);
}
if (node == null) {
return;
}
fieldConfig = PanelField.getField(ExpressionPanelv2.class, "ExpressionSubPanel.value", node.getType());
if (fieldConfig != null) {
fieldConfig.createUI();
fieldConfig.addDataChangedListener(new UpdateSymbolInterface() {
@Override
public void dataChanged(FieldIdEnum changedField) {
buttonGroup.setSelected(rdbtnLiteral.getModel(), true);
updateButtonState(true);
}
});
panelLiteral.add(fieldConfig.getPanel());
// Reset the fields
dataSourceAttributePanel.setAttribute(null);
functionPanel.setFunction(null);
dataSourceAttributePanel.setDataType(node.getType());
Expression expression = node.getExpression();
if (expression instanceof AttributeExpressionImpl) {
dataSourceAttributePanel.setAttribute(expression);
buttonGroup.setSelected(rdbtnAttribute.getModel(), true);
} else if (expression instanceof EnvFunction) {
envVarField.setEnvironmentVariable(expression);
buttonGroup.setSelected(rdbtnEnvVar.getModel(), true);
} else if (expression instanceof FunctionExpressionImpl) {
functionPanel.setFunction(expression);
buttonGroup.setSelected(rdbtnFunction.getModel(), true);
} else {
fieldConfig.populate(expression);
buttonGroup.setSelected(rdbtnLiteral.getModel(), true);
}
}
Dimension boxSize = box.getPreferredSize();
setPreferredSize(boxSize);
revalidate();
}
use of org.geotools.filter.FunctionExpressionImpl in project sldeditor by robward-scisys.
the class FunctionField method setFunction.
/**
* Sets the function.
*
* @param expression the new attribute
*/
public void setFunction(Expression expression) {
if (expression == null) {
functionComboBox.setSelectedIndex(-1);
} else {
if (expression instanceof FunctionExpressionImpl) {
FunctionExpressionImpl functionExpression = (FunctionExpressionImpl) expression;
FunctionName function = functionExpression.getFunctionName();
String functionName = function.getName();
oldValueObj = functionName;
functionComboBox.setSelectedItem(functionName);
} else {
ConsoleManager.getInstance().error(this, Localisation.getString(FunctionField.class, "DataSourceAttributePanel.error1"));
}
}
}
use of org.geotools.filter.FunctionExpressionImpl 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;
}
}
use of org.geotools.filter.FunctionExpressionImpl 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.FunctionExpressionImpl 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 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;
} else if (expression instanceof ConcatenateFunction) {
ConcatenateFunction concatenateExpression = (ConcatenateFunction) expression;
List<Expression> parameters = new ArrayList<Expression>();
ExpressionNode leftChildNode = (ExpressionNode) node.getChildAt(0);
parameters.add(addExpression(leftChildNode));
ExpressionNode rightChildNode = (ExpressionNode) node.getChildAt(1);
parameters.add(addExpression(rightChildNode));
concatenateExpression.setParameters(parameters);
return concatenateExpression;
}
return null;
}
Aggregations