use of com.sldeditor.ui.detail.config.FieldConfigPopulation in project sldeditor by robward-scisys.
the class FieldConfigPopulationTest method testString.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateTextField(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateTextField(com.sldeditor.common.xml.ui.FieldIdEnum, java.lang.String)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getText(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getText(com.sldeditor.common.xml.ui.FieldIdEnum)}.
*/
@Test
public void testString() {
FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(Geometry.class, fieldId, "label", true), "button text");
stringField.createUI();
fieldConfigManager.add(fieldId, stringField);
FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
String expectedValue = "test string";
obj.populateTextField(fieldId, expectedValue);
assertTrue(expectedValue.compareTo(obj.getText(fieldId)) == 0);
// This shouldn't work as it does not know about the field
FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
assertTrue("".compareTo(obj.getText(wrongFieldEnum)) == 0);
// Try with null
obj.populateTextField(fieldId, null);
obj.populateTextField(wrongFieldEnum, expectedValue);
}
use of com.sldeditor.ui.detail.config.FieldConfigPopulation in project sldeditor by robward-scisys.
the class FieldConfigPopulationTest method testColourMap.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateColourMapField(com.sldeditor.common.xml.ui.FieldIdEnum, org.geotools.styling.ColorMap)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getColourMap(com.sldeditor.common.xml.ui.FieldIdEnum)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getColourMap(com.sldeditor.ui.detail.config.FieldId)}.
*/
@Test
public void testColourMap() {
FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
FieldConfigColourMap colourMapField = new FieldConfigColourMap(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
colourMapField.createUI();
fieldConfigManager.add(fieldId, colourMapField);
ColorMap expectedValue = new ColorMapImpl();
ColorMapEntry entry = new ColorMapEntryImpl();
StyleBuilder styleBuilder = new StyleBuilder();
entry.setColor(styleBuilder.colorExpression(Color.PINK));
entry.setQuantity(styleBuilder.literalExpression(2.3));
expectedValue.addColorMapEntry(entry);
FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
obj.populateColourMapField(fieldId, expectedValue);
assertEquals(expectedValue.getColorMapEntries().length, obj.getColourMap(fieldId).getColorMapEntries().length);
// This shouldn't work as it does not know about the field
FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
obj.populateColourMapField(wrongFieldEnum, expectedValue);
assertNull(obj.getColourMap(wrongFieldEnum));
}
use of com.sldeditor.ui.detail.config.FieldConfigPopulation in project sldeditor by robward-scisys.
the class FieldConfigPopulationTest method testIsTreeDataUpdated.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#isTreeDataUpdated()}. Test method
* for {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#resetTreeDataUpdated()}.
*/
@Test
public void testIsTreeDataUpdated() {
FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(Geometry.class, fieldId, "label", true), "button text");
stringField.createUI();
fieldConfigManager.add(fieldId, stringField);
FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
assertFalse(obj.isTreeDataUpdated());
// Set data
String expectedValue = "test string";
obj.populateTextField(fieldId, expectedValue);
assertTrue(expectedValue.compareTo(obj.getText(fieldId)) == 0);
assertFalse(obj.isTreeDataUpdated());
// Simulate a key being pressed
expectedValue = "test string1";
stringField.populateField(expectedValue);
// Data is different so flag should have changed
assertTrue(expectedValue.compareTo(obj.getText(fieldId)) == 0);
assertTrue(obj.isTreeDataUpdated());
obj.resetTreeDataUpdated();
assertFalse(obj.isTreeDataUpdated());
// Populate the same data again and the flag should not have changed
obj.populateTextField(fieldId, expectedValue);
assertTrue(expectedValue.compareTo(obj.getText(fieldId)) == 0);
assertFalse(obj.isTreeDataUpdated());
}
use of com.sldeditor.ui.detail.config.FieldConfigPopulation in project sldeditor by robward-scisys.
the class FieldConfigPopulationTest method testFont.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateFontField(com.sldeditor.common.xml.ui.FieldIdEnum, org.geotools.styling.Font)}.
*/
@Test
public void testFont() {
FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
FieldConfigFont fontField = new FieldConfigFont(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
fontField.createUI();
fieldConfigManager.add(fieldId, fontField);
FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
StyleBuilder styleBuilder = new StyleBuilder();
Font expectedValue = styleBuilder.createFont(java.awt.Font.decode(null));
obj.populateFontField(fieldId, expectedValue);
// This shouldn't work as it does not know about the field
FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
obj.populateFontField(wrongFieldEnum, expectedValue);
}
use of com.sldeditor.ui.detail.config.FieldConfigPopulation in project sldeditor by robward-scisys.
the class FieldConfigPopulationTest method testColour.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateColourField(com.sldeditor.ui.detail.config.FieldId, org.opengis.filter.expression.Expression, org.opengis.filter.expression.Expression)}.
*/
@Test
public void testColour() {
FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
FieldConfigColour colourField = new FieldConfigColour(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
colourField.createUI();
colourField.createUI();
fieldConfigManager.add(fieldId, colourField);
FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
StyleBuilder styleBuilder = new StyleBuilder();
Expression colour = styleBuilder.colorExpression(Color.red);
obj.populateColourField(fieldId, colour);
FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
obj.populateColourField(wrongFieldEnum, colour);
}
Aggregations