use of org.opengis.filter.capability.FunctionName in project sldeditor by robward-scisys.
the class FunctionManager method getFunctionNameList.
/**
* Gets the function name list for the given parameter type A
* expectedType of null returns all functions.
*
* @param expectedType the expected type, restrict functions with this return type
* @param functionNameFilterList the function name filter list
* @return the function name list
*/
@Override
public List<FunctionName> getFunctionNameList(Class<?> expectedType, List<FunctionNameFilterInterface> functionNameFilterList) {
if (expectedType == null) {
return functionNameList;
}
if (functionNameFilterList == null) {
functionNameFilterList = new ArrayList<FunctionNameFilterInterface>();
functionNameFilterList.add(new FunctionNameFilterAll());
}
List<FunctionName> list = new ArrayList<FunctionName>();
List<Class<?>> allowedTypes = allowedTypeMap.get(expectedType);
if (allowedTypes != null) {
for (FunctionName functionName : functionNameList) {
Class<?> returnType = functionName.getReturn().getType();
if (allowedTypes.contains(returnType) && matchesFilter(functionName, functionNameFilterList)) {
list.add(functionName);
}
}
}
return list;
}
use of org.opengis.filter.capability.FunctionName in project sldeditor by robward-scisys.
the class DefaultSymbols method createArrow.
/**
* Creates the arrow.
*
* @return the point symbolizer containing the arrow
*/
public static PointSymbolizer createArrow(boolean isSourceArrow) {
FunctionName angleFunction = null;
FunctionName locationFunction = null;
if (isSourceArrow) {
angleFunction = FilterFunction_startAngle.NAME;
locationFunction = FilterFunction_startPoint.NAME;
} else {
angleFunction = FilterFunction_endAngle.NAME;
locationFunction = FilterFunction_endPoint.NAME;
}
return createArrow(angleFunction, locationFunction, DEFAULT_ARROW_SYMBOL, isSourceArrow);
}
use of org.opengis.filter.capability.FunctionName in project sldeditor by robward-scisys.
the class RenderTransformationDialog method displayBuiltInProcessFunction.
/**
* Display built in process function.
*
* @param selectedValue the selected value
* @return true, if successful
*/
private boolean displayBuiltInProcessFunction(String selectedValue) {
String functionNameString;
// Strip off the prefix
functionNameString = SelectedProcessFunction.extractLocalFunctionName(selectedValue);
for (FunctionName name : factory.getFunctionNames()) {
if (name.getName().compareToIgnoreCase(functionNameString) == 0) {
functionList.setSelectedValue(functionNameString, true);
functionParameterTableModel.populate(name, existingProcessFunction);
return true;
}
}
return false;
}
use of org.opengis.filter.capability.FunctionName in project sldeditor by robward-scisys.
the class FieldConfigBaseTest method testPopulateExpressionExpression.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBase#populate(org.opengis.filter.expression.Expression)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBase#populate(org.opengis.filter.expression.Expression, org.opengis.filter.expression.Expression)}.
*/
@Test
public void testPopulateExpressionExpression() {
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
String expectedLabel = "test label";
TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
AttributeSelection attributeSelectionPanel = AttributeSelection.createAttributes(String.class, field, false);
field.testAttributeSelectionPanel(attributeSelectionPanel);
TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
field.addDataChangedListener(listener);
assertFalse(listener.hasBeenCalled());
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
// Test function
DefaultFunctionFactory functionFactory = new DefaultFunctionFactory();
FunctionName functionName = null;
for (FunctionName func : functionFactory.getFunctionNames()) {
if (func.getName() == "greaterThan") {
functionName = func;
break;
}
}
assertNotNull(functionName);
Expression testExpression = ff.function(functionName.getFunctionName(), ff.literal(1), ff.literal(2));
field.populate(testExpression);
// Updated because the attribute pulldown changed
assertTrue(listener.hasBeenCalled());
assertEquals(ExpressionTypeEnum.E_EXPRESSION, field.getExpressionType());
Expression expression = field.getExpression();
assertTrue(expression.toString().startsWith(functionName.getName()));
// Attribute expression wrapped in a literal expression
String testAttributeName = "test attribute";
NameImpl name = new NameImpl(testAttributeName);
AttributeExpressionImpl attributeExpression = new AttributeExpressionImpl(name);
Expression literalExpression = ff.literal(attributeExpression);
field.populate(literalExpression);
assertEquals(ExpressionTypeEnum.E_ATTRIBUTE, field.getExpressionType());
// Process Function
// ProcessFunctionFactory factory = new ProcessFunctionFactory();
// FunctionTableModel functionParameterTableModel = new FunctionTableModel();
// ProcessFunction processFunction = functionParameterTableModel.getExpression(factory);
// field.populate(processFunction);
// assertEquals(ExpressionTypeEnum.E_VALUE, field.getExpressionType());
}
use of org.opengis.filter.capability.FunctionName in project sldeditor by robward-scisys.
the class BuiltInProcessFunctionTest method testExtractParametersFunctionName.
/**
* Test method for
* {@link com.sldeditor.rendertransformation.BuiltInProcessFunction#extractParameters(org.opengis.filter.capability.FunctionName, org.geotools.process.function.ProcessFunction)}.
*/
@Test
public void testExtractParametersFunctionName() {
BuiltInProcessFunction obj = new BuiltInProcessFunction();
List<ProcessFunctionParameterValue> valueList = obj.extractParameters(null, null);
assertTrue(valueList.isEmpty());
ProcessFunctionFactory processFunctionFactory = new ProcessFunctionFactory();
List<FunctionName> functionNameList = processFunctionFactory.getFunctionNames();
for (FunctionName functionName : functionNameList) {
valueList = obj.extractParameters(functionName, null);
assertEquals(functionName.getArguments().size(), valueList.size());
for (int index = 0; index < functionName.getArguments().size(); index++) {
Parameter<?> expectedParameter = functionName.getArguments().get(index);
ProcessFunctionParameterValue actualParameter = valueList.get(index);
assertTrue(functionName.getName(), expectedParameter.getName().compareTo(actualParameter.name) == 0);
assertEquals(functionName.getName(), expectedParameter.getType(), actualParameter.type);
assertTrue(functionName.getName(), expectedParameter.getType().getSimpleName().compareTo(actualParameter.dataType) == 0);
assertEquals(functionName.getName(), !expectedParameter.isRequired(), actualParameter.optional);
assertEquals(functionName.getName(), expectedParameter.getMinOccurs(), actualParameter.minOccurences);
assertEquals(functionName.getName(), expectedParameter.getMaxOccurs(), actualParameter.maxOccurences);
}
}
System.out.println(String.format("Tested %d functions", functionNameList.size()));
}
Aggregations