use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.
the class FieldConfigBaseTest method testGetFieldId.
/**
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigBase#getFieldId()}.
*/
@Test
public void testGetFieldId() {
boolean valueOnly = true;
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, "test label", valueOnly));
assertEquals(expectedFieldId, field.getFieldId());
}
use of com.sldeditor.common.xml.ui.FieldIdEnum 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 com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.
the class FieldConfigBaseTest method testAttributeUpdated.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBase#attributeUpdated(java.lang.String)}.
*/
@Test
public void testAttributeUpdated() {
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
String expectedLabel = "test label";
TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
field.addDataChangedListener(listener);
String attributeName = "test attribute";
assertFalse(listener.hasBeenCalled());
field.attributeUpdated(attributeName);
assertTrue(listener.hasBeenCalled());
assertEquals(ExpressionTypeEnum.E_ATTRIBUTE, field.getExpressionType());
Expression expression = field.getExpression();
assertTrue(expression instanceof AttributeExpressionImpl);
assertTrue(attributeName.compareTo(expression.toString()) == 0);
}
use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.
the class FieldConfigBaseTest method testIsASingleValue.
/**
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigBase#isASingleValue()}.
*/
@Test
public void testIsASingleValue() {
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
String expectedLabel = "test label";
TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
assertTrue(field.isASingleValue());
}
use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.
the class FieldConfigMarkerTest method testGetFieldList.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker#getFieldList(com.sldeditor.ui.detail.GraphicPanelFieldManager)}.
*/
@Test
public void testGetFieldList() {
Class<?> panelId = PointFillDetails.class;
// Test it with non null values
FieldIdEnum colourFieldId = FieldIdEnum.FILL_COLOUR;
FieldConfigColour colourField = new FieldConfigColour(new FieldConfigCommonData(panelId, colourFieldId, "", false));
colourField.createUI();
String expectedColourValue = "#012345";
colourField.setTestValue(null, expectedColourValue);
double expectedOpacityValue = 0.72;
FieldConfigSlider opacityField = new FieldConfigSlider(new FieldConfigCommonData(panelId, colourFieldId, "", false));
opacityField.createUI();
opacityField.populateField(expectedOpacityValue);
FieldConfigBase symbolSelectionField = new FieldConfigSymbolType(new FieldConfigCommonData(panelId, colourFieldId, "", false));
symbolSelectionField.createUI();
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(panelId);
fieldConfigManager.add(colourFieldId, colourField);
FieldIdEnum opacityFieldId = FieldIdEnum.OVERALL_OPACITY;
fieldConfigManager.add(opacityFieldId, opacityField);
FieldIdEnum symbolSelectionFieldId = FieldIdEnum.SYMBOL_TYPE;
fieldConfigManager.add(symbolSelectionFieldId, symbolSelectionField);
boolean valueOnly = true;
ColourFieldConfig fillConfig = new ColourFieldConfig(GroupIdEnum.FILL, FieldIdEnum.FILL_COLOUR, FieldIdEnum.OVERALL_OPACITY, FieldIdEnum.STROKE_WIDTH);
ColourFieldConfig strokeConfig = new ColourFieldConfig(GroupIdEnum.STROKE, FieldIdEnum.STROKE_STROKE_COLOUR, FieldIdEnum.OVERALL_OPACITY, FieldIdEnum.STROKE_FILL_WIDTH);
FieldConfigMarker field = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), fillConfig, strokeConfig, null);
assertTrue(field.getFieldList(null).isEmpty());
Map<FieldIdEnum, FieldConfigBase> actualFieldList = field.getFieldList(fieldConfigManager);
assertFalse(actualFieldList.isEmpty());
assertEquals(5, actualFieldList.size());
}
Aggregations