use of com.sldeditor.ui.detail.config.FieldConfigColour 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.ui.detail.config.FieldConfigColour in project sldeditor by robward-scisys.
the class FieldConfigColourTest method testAttributeSelection.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigColour#attributeSelection(java.lang.String)}.
*/
@Test
public void testAttributeSelection() {
boolean valueOnly = true;
FieldConfigColour field = new FieldConfigColour(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
field.attributeSelection(null);
// Does nothing
}
use of com.sldeditor.ui.detail.config.FieldConfigColour in project sldeditor by robward-scisys.
the class FieldConfigColourTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigColour#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigColour#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
FieldConfigColour field = new FieldConfigColour(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", false));
field.undoAction(null);
field.redoAction(null);
field.createUI();
String colour1 = "#123456";
field.populateExpression(colour1);
String colour2 = "#AABBCC";
field.populateExpression(colour2);
UndoManager.getInstance().undo();
String actualValue = field.getStringValue();
assertTrue(colour1.compareTo(actualValue) == 0);
UndoManager.getInstance().redo();
actualValue = field.getStringValue();
assertTrue(colour2.compareTo(actualValue) == 0);
// Increase the code coverage
field.undoAction(null);
field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
field.redoAction(null);
field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
use of com.sldeditor.ui.detail.config.FieldConfigColour in project sldeditor by robward-scisys.
the class FieldConfigColourTest method testSetEnabled.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigColour#internal_setEnabled(boolean)}. Test
* method for {@link com.sldeditor.ui.detail.config.FieldConfigColour#isEnabled()}.
*/
@Test
public void testSetEnabled() {
// Value only, no attribute/expression dropdown
boolean valueOnly = true;
FieldConfigColour field = new FieldConfigColour(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
// Text field will not have been created
boolean expectedValue = true;
field.internal_setEnabled(expectedValue);
assertFalse(field.isEnabled());
// Create text field
field.createUI();
field.createUI();
assertEquals(expectedValue, field.isEnabled());
expectedValue = false;
field.internal_setEnabled(expectedValue);
assertEquals(expectedValue, field.isEnabled());
// Has attribute/expression dropdown
valueOnly = false;
FieldConfigColour field2 = new FieldConfigColour(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
// Text field will not have been created
expectedValue = true;
field2.internal_setEnabled(expectedValue);
assertFalse(field2.isEnabled());
// Create text field
field2.createUI();
assertEquals(expectedValue, field2.isEnabled());
expectedValue = false;
field2.internal_setEnabled(expectedValue);
// Actual value is coming from the attribute panel, not the text field
assertEquals(!expectedValue, field2.isEnabled());
}
use of com.sldeditor.ui.detail.config.FieldConfigColour in project sldeditor by robward-scisys.
the class FieldConfigMarkerTest method testPopulateFieldOverrideMap.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker#populateFieldOverrideMap(java.lang.Class, com.sldeditor.ui.detail.FieldEnableState)}.
*/
@Test
public void testPopulateFieldOverrideMap() {
// Test it with non null values
FieldIdEnum colourFieldId = FieldIdEnum.FILL_COLOUR;
Class<?> panelId = PointFillDetails.class;
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);
ColourFieldConfig strokeConfig = new ColourFieldConfig(GroupIdEnum.STROKE, FieldIdEnum.STROKE_STROKE_COLOUR, FieldIdEnum.OVERALL_OPACITY, FieldIdEnum.STROKE_FILL_WIDTH);
boolean valueOnly = true;
ColourFieldConfig fillConfig = new ColourFieldConfig(GroupIdEnum.FILL, FieldIdEnum.FILL_COLOUR, FieldIdEnum.OVERALL_OPACITY, FieldIdEnum.STROKE_WIDTH);
FieldConfigMarker field = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), fillConfig, strokeConfig, null);
field.populateFieldOverrideMap(String.class, null);
field.populateFieldOverrideMap(PointSymbolizerDetails.class, null);
}
Aggregations