Search in sources :

Example 96 with FieldConfigCommonData

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

the class FieldConfigTransformationTest method testCreateCopy.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#createCopy(com.sldeditor.ui.detail.config.FieldConfigBase)}.
 */
@Test
public void testCreateCopy() {
    boolean valueOnly = true;
    class TestFieldConfigTransformation extends FieldConfigTransformation {

        public TestFieldConfigTransformation(FieldConfigCommonData commonData, String editButtonText, String clearButtonText) {
            super(commonData, editButtonText, clearButtonText);
        }

        public FieldConfigPopulate callCreateCopy(FieldConfigBase fieldConfigBase) {
            return createCopy(fieldConfigBase);
        }
    }
    TestFieldConfigTransformation field = new TestFieldConfigTransformation(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), "edit", "clear");
    FieldConfigTransformation copy = (FieldConfigTransformation) field.callCreateCopy(null);
    assertNull(copy);
    copy = (FieldConfigTransformation) field.callCreateCopy(field);
    assertEquals(field.getFieldId(), copy.getFieldId());
    assertTrue(field.getLabel().compareTo(copy.getLabel()) == 0);
    assertEquals(field.isValueOnly(), copy.isValueOnly());
}
Also used : FieldConfigTransformation(com.sldeditor.ui.detail.config.transform.FieldConfigTransformation) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 97 with FieldConfigCommonData

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

the class FieldConfigTransformationTest method testGenerateExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#populateExpression(java.lang.Object)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#generateExpression()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#getProcessFunction()}.
 */
@Test
public void testGenerateExpression() {
    boolean valueOnly = true;
    class TestFieldConfigTransformation extends FieldConfigTransformation {

        public TestFieldConfigTransformation(FieldConfigCommonData commonData, String editButtonText, String clearButtonText) {
            super(commonData, editButtonText, clearButtonText);
        }

        public Expression callGenerateExpression() {
            return generateExpression();
        }
    }
    TestFieldConfigTransformation field = new TestFieldConfigTransformation(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), "edit", "clear");
    Expression actualExpression = field.callGenerateExpression();
    assertNull(actualExpression);
    field.createUI();
    String expectedValue1 = "test string value";
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue1);
    actualExpression = field.callGenerateExpression();
    assertNull(actualExpression);
    // Strings are ignored when calling populateExpression
    String expectedValue2 = "test string value as expression";
    field.populateExpression(expectedValue2);
    actualExpression = field.callGenerateExpression();
    assertNull(actualExpression);
    // Create process function
    String testData = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + "<StyledLayerDescriptor version=\"1.0.0\" xsi:schemaLocation=\"http://www.opengis.net/sld StyledLayerDescriptor.xsd\" xmlns=\"http://www.opengis.net/sld\" xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + "<ogc:Function name=\"vec:PointStacker\">" + "<ogc:Function name=\"parameter\">" + "  <ogc:Literal>data</ogc:Literal>" + "</ogc:Function>" + "<ogc:Function name=\"parameter\">" + "  <ogc:Literal>cellSize</ogc:Literal>" + "  <ogc:Literal>30</ogc:Literal>" + "</ogc:Function>" + "<ogc:Function name=\"parameter\">" + "  <ogc:Literal>outputBBOX</ogc:Literal>" + "  <ogc:Function name=\"env\">" + "        <ogc:Literal>wms_bbox</ogc:Literal>" + "  </ogc:Function>" + "</ogc:Function>" + "<ogc:Function name=\"parameter\">" + "  <ogc:Literal>outputWidth</ogc:Literal>" + "  <ogc:Function name=\"env\">" + "        <ogc:Literal>wms_width</ogc:Literal>" + "  </ogc:Function>" + "</ogc:Function>" + "<ogc:Function name=\"parameter\">" + " <ogc:Literal>outputHeight</ogc:Literal>" + "  <ogc:Function name=\"env\">" + "        <ogc:Literal>wms_height</ogc:Literal>" + "  </ogc:Function>" + " </ogc:Function>" + "</ogc:Function>" + "</StyledLayerDescriptor>";
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder;
    ProcessFunction processFunction = null;
    try {
        builder = factory.newDocumentBuilder();
        InputSource is = new InputSource(new StringReader(testData));
        Document doc = builder.parse(is);
        ExpressionDOMParser parser = new ExpressionDOMParser(CommonFactoryFinder.getFilterFactory2(null));
        processFunction = (ProcessFunction) parser.expression(doc.getDocumentElement().getFirstChild());
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    field.populateExpression((ProcessFunction) null);
    field.populateExpression(processFunction);
    actualExpression = field.callGenerateExpression();
    String expectedValue3 = ParameterFunctionUtils.getString(processFunction);
    String string = actualExpression.toString();
    assertTrue(expectedValue3.compareTo(string) != 0);
    assertEquals(processFunction, field.getProcessFunction());
}
Also used : InputSource(org.xml.sax.InputSource) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) IOException(java.io.IOException) Document(org.w3c.dom.Document) SAXException(org.xml.sax.SAXException) FieldConfigTransformation(com.sldeditor.ui.detail.config.transform.FieldConfigTransformation) ProcessFunction(org.geotools.process.function.ProcessFunction) Expression(org.opengis.filter.expression.Expression) DocumentBuilder(javax.xml.parsers.DocumentBuilder) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) StringReader(java.io.StringReader) ExpressionDOMParser(org.geotools.filter.ExpressionDOMParser) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Test(org.junit.Test)

Example 98 with FieldConfigCommonData

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

the class GraphicPanelFieldManagerTest method testGetFields.

/**
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#getFields(java.lang.Class)}.
 */
@Test
public void testGetFields() {
    GraphicPanelFieldManager mgr = new GraphicPanelFieldManager(null);
    assertTrue(mgr.getFields(null).isEmpty());
    Class<?> expectedPanelId = StrokeDetails.class;
    mgr = new GraphicPanelFieldManager(expectedPanelId);
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(String.class, expectedFieldId, "test label", false), "button text");
    mgr.addField(stringField);
    assertTrue(mgr.getFields(FieldConfigBoolean.class).isEmpty());
    assertEquals(1, mgr.getFields(FieldConfigString.class).size());
}
Also used : FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) StrokeDetails(com.sldeditor.ui.detail.StrokeDetails) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 99 with FieldConfigCommonData

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

the class GraphicPanelFieldManagerTest method testAddGroup.

/**
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#getGroup(java.lang.Class, com.sldeditor.common.xml.ui.GroupIdEnum)}.
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#addGroup(com.sldeditor.ui.detail.config.base.GroupConfig)}.
 */
@Test
public void testAddGroup() {
    Class<?> expectedPanelId = StrokeDetails.class;
    GraphicPanelFieldManager mgr = new GraphicPanelFieldManager(expectedPanelId);
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(String.class, expectedFieldId, "test label", false), "button text");
    mgr.addField(stringField);
    GroupConfig multiOption = new GroupConfig();
    GroupIdEnum expectedGroupId = GroupIdEnum.FILLSYMBOL;
    multiOption.setId(expectedGroupId);
    mgr.addGroup(multiOption);
    GroupConfigInterface actualValue = mgr.getGroup(null, null);
    assertNull(actualValue);
    actualValue = mgr.getGroup(expectedPanelId, expectedGroupId);
    assertEquals(multiOption, actualValue);
}
Also used : FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) StrokeDetails(com.sldeditor.ui.detail.StrokeDetails) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) GroupIdEnum(com.sldeditor.common.xml.ui.GroupIdEnum) Test(org.junit.Test)

Example 100 with FieldConfigCommonData

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

the class FieldConfigArrowTest method testAttributeSelection.

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

Aggregations

FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)322 Test (org.junit.Test)316 Geometry (com.vividsolutions.jts.geom.Geometry)69 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)54 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)44 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)38 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)34 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)24 StyleBuilder (org.geotools.styling.StyleBuilder)24 FieldConfigMarker (com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker)22 UndoEvent (com.sldeditor.common.undo.UndoEvent)20 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)20 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)20 Expression (org.opengis.filter.expression.Expression)20 FieldConfigWindBarbs (com.sldeditor.ui.detail.vendor.geoserver.marker.windbarb.FieldConfigWindBarbs)18 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)17 FieldConfigTTF (com.sldeditor.ui.detail.config.symboltype.ttf.FieldConfigTTF)17 FieldConfigFilename (com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename)16 FieldConfigArrow (com.sldeditor.ui.detail.vendor.geoserver.marker.arrow.FieldConfigArrow)16 FieldConfigWKT (com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.FieldConfigWKT)16