use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.
the class FieldConfigWindBarbsTest method testGetValue.
/**
* Test method for
* {@link com.sldeditor.ui.detail.vendor.geoserver.marker.windbarb.FieldConfigWindBarbs#getValue(com.sldeditor.ui.detail.GraphicPanelFieldManager, org.opengis.filter.expression.Expression, boolean, boolean)}.
*/
@Test
public void testGetValue() {
// Test it with null values
boolean valueOnly = true;
FieldConfigWindBarbs field = new FieldConfigWindBarbs(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), null, null, null);
field.createUI();
assertNull(field.getStringValue());
GraphicPanelFieldManager fieldConfigManager = null;
Expression symbolType = null;
List<GraphicalSymbol> actualValue = field.getValue(fieldConfigManager, symbolType, false, false);
assertTrue(actualValue.isEmpty());
Class<?> panelId = PointFillDetails.class;
fieldConfigManager = new GraphicPanelFieldManager(panelId);
String actualMarkerSymbol = "solid";
StyleBuilder styleBuilder = new StyleBuilder();
symbolType = styleBuilder.literalExpression(actualMarkerSymbol);
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();
fieldConfigManager.add(colourFieldId, colourField);
FieldIdEnum opacityFieldId = FieldIdEnum.OVERALL_OPACITY;
fieldConfigManager.add(opacityFieldId, opacityField);
FieldIdEnum symbolSelectionFieldId = FieldIdEnum.SYMBOL_TYPE;
fieldConfigManager.add(symbolSelectionFieldId, symbolSelectionField);
// Try without setting any fields
actualValue = field.getValue(fieldConfigManager, symbolType, false, false);
assertNotNull(actualValue);
assertEquals(1, actualValue.size());
Mark actualSymbol = (Mark) actualValue.get(0);
assertTrue(actualSymbol.getWellKnownName().toString().compareTo("windbarbs://default(0)[m/s]") == 0);
}
use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.
the class ExtractGeometryFieldTest method testGetGeometryField.
/**
* Test method for {@link com.sldeditor.ui.detail.ExtractGeometryField#getGeometryField(com.sldeditor.ui.detail.config.FieldConfigPopulation)}.
*/
@Test
public void testGetGeometryField() {
assertNull(ExtractGeometryField.getGeometryField(null));
FieldIdEnum fieldId = FieldIdEnum.GEOMETRY;
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(Geometry.class);
FieldConfigGeometry geometryField = new FieldConfigGeometry(new FieldConfigCommonData(Geometry.class, fieldId, "label", true), "button");
geometryField.createUI();
fieldConfigManager.add(fieldId, geometryField);
FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
// Try valid geometry field name
geometryField.populateField("ValidTestField");
Expression actualExpression = ExtractGeometryField.getGeometryField(obj);
assertNotNull(actualExpression);
// Try invalid geometry field name
geometryField.populateField("");
actualExpression = ExtractGeometryField.getGeometryField(obj);
assertNull(actualExpression);
// Try invalid geometry field name
geometryField.populateField(" ");
actualExpression = ExtractGeometryField.getGeometryField(obj);
assertNull(actualExpression);
// Try when there is no geometry field
obj = new FieldConfigPopulation(fieldConfigManager);
actualExpression = ExtractGeometryField.getGeometryField(obj);
assertNull(actualExpression);
}
use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.
the class FieldConfigBaseTest method testFireDataChanged.
/**
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigBase#fireDataChanged()}.
*/
@Test
public void testFireDataChanged() {
boolean valueOnly = true;
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
String expectedLabel = "test label";
TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, valueOnly));
TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
field.addDataChangedListener(listener);
assertFalse(listener.hasBeenCalled());
Controller.getInstance().setPopulating(true);
field.testFireDataChanged();
assertFalse(listener.hasBeenCalled());
Controller.getInstance().setPopulating(false);
field.testFireDataChanged();
assertTrue(listener.hasBeenCalled());
// Leave the is populating flag as false otherwise a load of tests will fail
}
use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.
the class FieldConfigBaseTest method testExpressionUpdated.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBase#expressionUpdated(org.opengis.filter.expression.Expression)}.
*/
@Test
public void testExpressionUpdated() {
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 expressionName = "test expression";
assertFalse(listener.hasBeenCalled());
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
Expression testExpression = ff.literal(expressionName);
field.expressionUpdated(testExpression);
assertTrue(listener.hasBeenCalled());
assertEquals(ExpressionTypeEnum.E_EXPRESSION, field.getExpressionType());
Expression expression = field.getExpression();
assertTrue(expressionName.compareTo(expression.toString()) == 0);
}
use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.
the class FieldConfigBaseTest method testAddUI.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBase#addUI(java.awt.Component,int, int, int)}.
*/
@Test
public void testAddUI() {
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
String expectedLabel = "test label";
TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
field.addUI(null, 10, 10, 10);
field.createUI();
field.addUI(new JButton(), 10, 10, 10);
}
Aggregations