Search in sources :

Example 71 with FieldIdEnum

use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.

the class FieldConfigBaseTest method testGetFieldId.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigBase#getFieldId()}.
 */
@Test
public void testGetFieldId() {
    boolean valueOnly = true;
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, "test label", valueOnly));
    assertEquals(expectedFieldId, field.getFieldId());
}
Also used : FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) Test(org.junit.Test)

Example 72 with FieldIdEnum

use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.

the class FieldConfigBaseTest method testPopulateExpressionExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBase#populate(org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBase#populate(org.opengis.filter.expression.Expression, org.opengis.filter.expression.Expression)}.
 */
@Test
public void testPopulateExpressionExpression() {
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    String expectedLabel = "test label";
    TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
    AttributeSelection attributeSelectionPanel = AttributeSelection.createAttributes(String.class, field, false);
    field.testAttributeSelectionPanel(attributeSelectionPanel);
    TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
    field.addDataChangedListener(listener);
    assertFalse(listener.hasBeenCalled());
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    // Test function
    DefaultFunctionFactory functionFactory = new DefaultFunctionFactory();
    FunctionName functionName = null;
    for (FunctionName func : functionFactory.getFunctionNames()) {
        if (func.getName() == "greaterThan") {
            functionName = func;
            break;
        }
    }
    assertNotNull(functionName);
    Expression testExpression = ff.function(functionName.getFunctionName(), ff.literal(1), ff.literal(2));
    field.populate(testExpression);
    // Updated because the attribute pulldown changed
    assertTrue(listener.hasBeenCalled());
    assertEquals(ExpressionTypeEnum.E_EXPRESSION, field.getExpressionType());
    Expression expression = field.getExpression();
    assertTrue(expression.toString().startsWith(functionName.getName()));
    // Attribute expression wrapped in a literal expression
    String testAttributeName = "test attribute";
    NameImpl name = new NameImpl(testAttributeName);
    AttributeExpressionImpl attributeExpression = new AttributeExpressionImpl(name);
    Expression literalExpression = ff.literal(attributeExpression);
    field.populate(literalExpression);
    assertEquals(ExpressionTypeEnum.E_ATTRIBUTE, field.getExpressionType());
// Process Function
// ProcessFunctionFactory factory = new ProcessFunctionFactory();
// FunctionTableModel functionParameterTableModel = new FunctionTableModel();
// ProcessFunction processFunction = functionParameterTableModel.getExpression(factory);
// field.populate(processFunction);
// assertEquals(ExpressionTypeEnum.E_VALUE, field.getExpressionType());
}
Also used : FunctionName(org.opengis.filter.capability.FunctionName) NameImpl(org.geotools.feature.NameImpl) DefaultFunctionFactory(org.geotools.filter.function.DefaultFunctionFactory) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) AttributeSelection(com.sldeditor.ui.attribute.AttributeSelection) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Example 73 with FieldIdEnum

use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.

the class FieldConfigBaseTest method testAttributeUpdated.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBase#attributeUpdated(java.lang.String)}.
 */
@Test
public void testAttributeUpdated() {
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    String expectedLabel = "test label";
    TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
    TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
    field.addDataChangedListener(listener);
    String attributeName = "test attribute";
    assertFalse(listener.hasBeenCalled());
    field.attributeUpdated(attributeName);
    assertTrue(listener.hasBeenCalled());
    assertEquals(ExpressionTypeEnum.E_ATTRIBUTE, field.getExpressionType());
    Expression expression = field.getExpression();
    assertTrue(expression instanceof AttributeExpressionImpl);
    assertTrue(attributeName.compareTo(expression.toString()) == 0);
}
Also used : Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) Test(org.junit.Test)

Example 74 with FieldIdEnum

use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.

the class FieldConfigBaseTest method testIsASingleValue.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigBase#isASingleValue()}.
 */
@Test
public void testIsASingleValue() {
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    String expectedLabel = "test label";
    TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
    assertTrue(field.isASingleValue());
}
Also used : FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) Test(org.junit.Test)

Example 75 with FieldIdEnum

use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.

the class FieldConfigMarkerTest method testGetFieldList.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker#getFieldList(com.sldeditor.ui.detail.GraphicPanelFieldManager)}.
 */
@Test
public void testGetFieldList() {
    Class<?> panelId = PointFillDetails.class;
    // Test it with non null values
    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();
    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);
    boolean valueOnly = true;
    ColourFieldConfig fillConfig = new ColourFieldConfig(GroupIdEnum.FILL, FieldIdEnum.FILL_COLOUR, FieldIdEnum.OVERALL_OPACITY, FieldIdEnum.STROKE_WIDTH);
    ColourFieldConfig strokeConfig = new ColourFieldConfig(GroupIdEnum.STROKE, FieldIdEnum.STROKE_STROKE_COLOUR, FieldIdEnum.OVERALL_OPACITY, FieldIdEnum.STROKE_FILL_WIDTH);
    FieldConfigMarker field = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), fillConfig, strokeConfig, null);
    assertTrue(field.getFieldList(null).isEmpty());
    Map<FieldIdEnum, FieldConfigBase> actualFieldList = field.getFieldList(fieldConfigManager);
    assertFalse(actualFieldList.isEmpty());
    assertEquals(5, actualFieldList.size());
}
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) PointFillDetails(com.sldeditor.ui.detail.PointFillDetails) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) FieldConfigSymbolType(com.sldeditor.ui.detail.config.FieldConfigSymbolType) Test(org.junit.Test)

Aggregations

FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)83 Test (org.junit.Test)55 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)54 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)33 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)28 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)27 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)17 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)16 StyleBuilder (org.geotools.styling.StyleBuilder)14 ColourFieldConfig (com.sldeditor.ui.detail.ColourFieldConfig)13 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)13 Geometry (com.vividsolutions.jts.geom.Geometry)13 Expression (org.opengis.filter.expression.Expression)13 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)12 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)12 GroupIdEnum (com.sldeditor.common.xml.ui.GroupIdEnum)10 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)8 ArrayList (java.util.ArrayList)8 Mark (org.geotools.styling.Mark)7 StrokeDetails (com.sldeditor.ui.detail.StrokeDetails)6