Search in sources :

Example 1 with FieldConfigMarker

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

the class FieldConfigSymbolTypeTest method testUndoActionSuppress.

@Test
public void testUndoActionSuppress() {
    UndoManager.getInstance().setPopulationCheck(Controller.getInstance());
    boolean valueOnly = true;
    FieldConfigSymbolType field = new FieldConfigSymbolType(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly, true));
    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);
    int undoSizeList = UndoManager.getInstance().getUndoListSize();
    String expectedValue2 = "key 2";
    field.populateExpression(expectedValue2);
    String actualValue2 = field.getStringValue();
    assertTrue(actualValue2.compareTo(field.getStringValue()) == 0);
    assertEquals(undoSizeList, UndoManager.getInstance().getUndoListSize());
}
Also used : 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 2 with FieldConfigMarker

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

the class FieldConfigSymbolTypeTest method testGenerateExpression.

/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigSymbolType#generateExpression()}. Test method for
 * {@link
 * com.sldeditor.ui.detail.config.FieldConfigSymbolType#populateExpression(java.lang.Object,
 * org.opengis.filter.expression.Expression)}. Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigSymbolType#populateField(java.lang.String)}. Test
 * method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigSymbolType#setTestValue(com.sldeditor.ui.detail.config.FieldId,
 * java.lang.String)}. Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigSymbolType#getEnumValue()}. Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigSymbolType#FieldConfigSymbolType(java.lang.Class,
 * com.sldeditor.ui.detail.config.FieldId, java.lang.String, boolean)}. Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigSymbolType#getStringValue()}. Test method for
 * {@link
 * com.sldeditor.ui.detail.config.FieldConfigSymbolType#addField(com.sldeditor.ui.detail.config.symboltype.SymbolTypeInterface)}.
 */
@Test
public void testGenerateExpression() {
    boolean valueOnly = true;
    FieldConfigSymbolType field = new FieldConfigSymbolType(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly, false));
    field.populateExpression(null);
    field.setTestValue(FieldIdEnum.UNKNOWN, (String) null);
    assertNull(field.getEnumValue());
    assertNull(field.getSelectedValueObj());
    assertNull(field.getSelectedValue());
    field.createUI();
    String expectedValue1 = "circle";
    field.populateExpression(expectedValue1);
    String actualValue1 = field.getStringValue();
    assertNull(actualValue1);
    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", String.class));
    dataList.add(new ValueComboBoxData("key 2", "Value 2", Integer.class));
    dataList.add(new ValueComboBoxData("key 3", "Value 3", Boolean.class));
    List<ValueComboBoxDataGroup> combinedSymbolList = new ArrayList<ValueComboBoxDataGroup>();
    combinedSymbolList.add(new ValueComboBoxDataGroup(dataList));
    field.createUI();
    field.addField(marker);
    field.populate(null, combinedSymbolList);
    field.populateExpression(expectedValue1);
    actualValue1 = field.getStringValue();
    assertNull(actualValue1);
    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.setTestValue(null, 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);
    String expectedValue5 = "key 2";
    field.setSelectedItem(expectedValue5);
    String actualValue5 = field.getStringValue();
    assertTrue(expectedValue5.compareTo(actualValue5) == 0);
    ValueComboBoxData actualValueObj5 = field.getSelectedValueObj();
    assertNotNull(actualValueObj5.getKey());
    assertTrue(actualValueObj5.getKey().compareTo(expectedValue5) == 0);
    Class<?> actualValue6 = field.getSelectedValue();
    assertEquals(Integer.class, actualValue6);
}
Also used : ValueComboBoxDataGroup(com.sldeditor.ui.widgets.ValueComboBoxDataGroup) ArrayList(java.util.ArrayList) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) FieldConfigMarker(com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigSymbolType(com.sldeditor.ui.detail.config.FieldConfigSymbolType) Test(org.junit.jupiter.api.Test)

Example 3 with FieldConfigMarker

use of com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker 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, false));
    colourField.createUI();
    String expectedColourValue = "#012345";
    colourField.setTestValue(null, 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();
    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, false), fillConfig, strokeConfig, null);
    field.populateFieldOverrideMap(String.class, null);
    field.populateFieldOverrideMap(PointSymbolizerDetails.class, null);
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) FieldConfigMarker(com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker) ColourFieldConfig(com.sldeditor.ui.detail.ColourFieldConfig) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) PointFillDetails(com.sldeditor.ui.detail.PointFillDetails) FieldConfigSymbolType(com.sldeditor.ui.detail.config.FieldConfigSymbolType) Test(org.junit.jupiter.api.Test)

Example 4 with FieldConfigMarker

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

the class FieldConfigMarkerTest method testGetColourExpression.

/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker#getColourExpression()}.
 */
@Test
public void testGetColourExpression() {
    boolean valueOnly = true;
    FieldConfigMarker field = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly, false), null, null, null);
    assertNull(field.getColourExpression());
}
Also used : FieldConfigMarker(com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.jupiter.api.Test)

Example 5 with FieldConfigMarker

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

the class FieldConfigMarkerTest method testAttributeSelection.

/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker#attributeSelection(java.lang.String)}.
 */
@Test
public void testAttributeSelection() {
    boolean valueOnly = true;
    FieldConfigMarker field = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly, false), null, null, null);
    field.attributeSelection("field");
// Does nothing
}
Also used : FieldConfigMarker(com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.jupiter.api.Test)

Aggregations

FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)23 FieldConfigMarker (com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker)23 Test (org.junit.jupiter.api.Test)23 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)9 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)6 ColourFieldConfig (com.sldeditor.ui.detail.ColourFieldConfig)6 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)6 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)6 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)6 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)6 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)5 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)4 ValueComboBoxDataGroup (com.sldeditor.ui.widgets.ValueComboBoxDataGroup)4 ArrayList (java.util.ArrayList)4 StyleBuilder (org.geotools.styling.StyleBuilder)4 Mark (org.geotools.styling.Mark)3 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)1 GroupConfig (com.sldeditor.ui.detail.config.base.GroupConfig)1 LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)1