Search in sources :

Example 1 with FieldConfigColour

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);
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) GraphicalSymbol(org.opengis.style.GraphicalSymbol) StyleBuilder(org.geotools.styling.StyleBuilder) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) Mark(org.geotools.styling.Mark) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Expression(org.opengis.filter.expression.Expression) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigWindBarbs(com.sldeditor.ui.detail.vendor.geoserver.marker.windbarb.FieldConfigWindBarbs) 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.Test)

Example 2 with FieldConfigColour

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
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour) Test(org.junit.Test)

Example 3 with FieldConfigColour

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"));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour) Test(org.junit.Test)

Example 4 with FieldConfigColour

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());
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour) Test(org.junit.Test)

Example 5 with FieldConfigColour

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);
}
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.Test)

Aggregations

FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)33 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)24 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)23 Test (org.junit.Test)22 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)17 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)16 Expression (org.opengis.filter.expression.Expression)15 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)14 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)13 Mark (org.geotools.styling.Mark)13 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)12 ColourFieldConfig (com.sldeditor.ui.detail.ColourFieldConfig)11 StyleBuilder (org.geotools.styling.StyleBuilder)11 GraphicalSymbol (org.opengis.style.GraphicalSymbol)11 Geometry (com.vividsolutions.jts.geom.Geometry)9 Fill (org.geotools.styling.Fill)8 GraphicFill (org.opengis.style.GraphicFill)8 FieldConfigMarker (com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker)6 ArrayList (java.util.ArrayList)6 Stroke (org.geotools.styling.Stroke)5