Search in sources :

Example 21 with FieldConfigSymbolType

use of com.sldeditor.ui.detail.config.FieldConfigSymbolType in project sldeditor by robward-scisys.

the class FieldConfigSymbolTypeTest method testUndoAction.

/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigSymbolType#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigSymbolType#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    UndoManager.getInstance().setPopulationCheck(Controller.getInstance());
    boolean valueOnly = true;
    FieldConfigSymbolType field = new FieldConfigSymbolType(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly, false));
    field.undoAction(null);
    field.redoAction(null);
    field.createUI();
    field.createUI();
    FieldConfigMarker marker = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.ANGLE, "label", valueOnly, false), null, null, null);
    marker.createUI();
    List<ValueComboBoxData> dataList = new ArrayList<ValueComboBoxData>();
    dataList.add(new ValueComboBoxData("key 1", "Value 1", FieldConfigMarker.class));
    dataList.add(new ValueComboBoxData("key 2", "Value 2", FieldConfigMarker.class));
    dataList.add(new ValueComboBoxData("key 3", "Value 3", FieldConfigMarker.class));
    List<ValueComboBoxDataGroup> combinedSymbolList = new ArrayList<ValueComboBoxDataGroup>();
    combinedSymbolList.add(new ValueComboBoxDataGroup(dataList));
    field.createUI();
    field.addField(marker);
    field.populate(null, combinedSymbolList);
    String expectedValue2 = "key 2";
    field.populateExpression(expectedValue2);
    String actualValue2 = field.getStringValue();
    assertTrue(actualValue2.compareTo(field.getStringValue()) == 0);
    ValueComboBoxData actualValueObj2 = field.getEnumValue();
    assertNotNull(actualValueObj2.getKey());
    assertTrue(actualValueObj2.getKey().compareTo(expectedValue2) == 0);
    String expectedValue3 = "key 1";
    field.populateField(expectedValue3);
    String actualValue3 = field.getStringValue();
    assertTrue(expectedValue3.compareTo(actualValue3) == 0);
    String expectedValue4 = "key 3";
    field.populateField(expectedValue4);
    String actualValue4 = field.getStringValue();
    assertTrue(expectedValue4.compareTo(actualValue4) == 0);
    UndoManager.getInstance().undo();
    String actualValue = field.getStringValue();
    assertTrue(expectedValue3.compareTo(actualValue) == 0);
    UndoManager.getInstance().redo();
    actualValue = field.getStringValue();
    assertTrue(expectedValue4.compareTo(actualValue) == 0);
    // Increase the code coverage
    field.undoAction(null);
    field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(23)));
    field.redoAction(null);
    field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(54)));
    UndoManager.getInstance().setPopulationCheck(null);
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) ValueComboBoxDataGroup(com.sldeditor.ui.widgets.ValueComboBoxDataGroup) FieldConfigMarker(com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) ArrayList(java.util.ArrayList) FieldConfigSymbolType(com.sldeditor.ui.detail.config.FieldConfigSymbolType) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) Test(org.junit.jupiter.api.Test)

Example 22 with FieldConfigSymbolType

use of com.sldeditor.ui.detail.config.FieldConfigSymbolType in project sldeditor by robward-scisys.

the class FieldConfigSymbolTypeTest method testSetEnabled.

/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigSymbolType#internalSetEnabled(boolean)}. Test
 * method for {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#isEnabled()}.
 */
@Test
public void testSetEnabled() {
    // Value only, no attribute/expression dropdown
    boolean valueOnly = true;
    FieldConfigSymbolType field = new FieldConfigSymbolType(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly, false));
    // Text field will not have been created
    boolean expectedValue = true;
    field.internalSetEnabled(expectedValue);
    assertFalse(field.isEnabled());
    // Create text field
    field.createUI();
    assertEquals(expectedValue, field.isEnabled());
    expectedValue = false;
    field.internalSetEnabled(expectedValue);
    assertEquals(expectedValue, field.isEnabled());
    // Has attribute/expression dropdown
    valueOnly = false;
    FieldConfigSymbolType field2 = new FieldConfigSymbolType(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly, false));
    // Text field will not have been created
    expectedValue = true;
    field2.internalSetEnabled(expectedValue);
    assertFalse(field2.isEnabled());
    // Create text field
    field2.createUI();
    assertEquals(expectedValue, field2.isEnabled());
    expectedValue = false;
    field2.internalSetEnabled(expectedValue);
    // Actual value is coming from the attribute panel, not the text field
    assertEquals(!expectedValue, field2.isEnabled());
}
Also used : FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigSymbolType(com.sldeditor.ui.detail.config.FieldConfigSymbolType) Test(org.junit.jupiter.api.Test)

Example 23 with FieldConfigSymbolType

use of com.sldeditor.ui.detail.config.FieldConfigSymbolType in project sldeditor by robward-scisys.

the class FieldConfigFilenameTest method testGetFill.

/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename#getFill(org.opengis.style.GraphicFill,
 * com.sldeditor.ui.detail.GraphicPanelFieldManager)}.
 */
@Test
public void testGetFill() {
    boolean valueOnly = true;
    FieldConfigFilename field = new FieldConfigFilename(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly, false), null, null, null);
    GraphicFill graphicFill = null;
    GraphicPanelFieldManager fieldConfigManager = null;
    assertNull(field.getFill(graphicFill, fieldConfigManager));
    Class<?> panelId = PointFillDetails.class;
    FieldIdEnum colourFieldId = FieldIdEnum.FILL_COLOUR;
    FieldConfigColour colourField = new FieldConfigColour(new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
    colourField.createUI();
    String expectedColourValue = "#012345";
    colourField.setTestValue(FieldIdEnum.UNKNOWN, expectedColourValue);
    double expectedOpacityValue = 0.72;
    FieldConfigSlider opacityField = new FieldConfigSlider(new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
    opacityField.createUI();
    opacityField.populateField(expectedOpacityValue);
    FieldConfigBase symbolSelectionField = new FieldConfigSymbolType(new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
    symbolSelectionField.createUI();
    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);
    field.createUI();
    StyleBuilder styleBuilder = new StyleBuilder();
    graphicFill = styleBuilder.createGraphic();
    Fill actualValue = field.getFill(graphicFill, fieldConfigManager);
    assertTrue(actualValue.getOpacity().toString().compareTo(String.valueOf(expectedOpacityValue)) == 0);
}
Also used : Fill(org.geotools.styling.Fill) GraphicFill(org.opengis.style.GraphicFill) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) StyleBuilder(org.geotools.styling.StyleBuilder) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) FieldConfigFilename(com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename) GraphicFill(org.opengis.style.GraphicFill) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour) PointFillDetails(com.sldeditor.ui.detail.PointFillDetails) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) FieldConfigSymbolType(com.sldeditor.ui.detail.config.FieldConfigSymbolType) Test(org.junit.jupiter.api.Test)

Aggregations

FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)23 Test (org.junit.jupiter.api.Test)23 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)21 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)14 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)14 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)13 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)12 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)12 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)11 ColourFieldConfig (com.sldeditor.ui.detail.ColourFieldConfig)9 FieldConfigMarker (com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker)9 StyleBuilder (org.geotools.styling.StyleBuilder)9 Mark (org.geotools.styling.Mark)7 Expression (org.opengis.filter.expression.Expression)4 GraphicalSymbol (org.opengis.style.GraphicalSymbol)4 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)3 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)3 ValueComboBoxDataGroup (com.sldeditor.ui.widgets.ValueComboBoxDataGroup)3 ArrayList (java.util.ArrayList)3 StrokeDetails (com.sldeditor.ui.detail.StrokeDetails)2