Search in sources :

Example 46 with GraphicPanelFieldManager

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

the class GraphicPanelFieldManagerTest method testRemoveField.

/**
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#removeField(com.sldeditor.ui.detail.config.FieldConfigBase)}.
 */
@Test
public void testRemoveField() {
    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.removeField(null);
    // Does n't exists yet
    mgr.removeField(stringField);
    mgr.addField(stringField);
    FieldIdEnum actualFieldId = mgr.getFieldEnum(expectedPanelId, stringField);
    assertEquals(stringField, mgr.getData(expectedPanelId, actualFieldId));
    mgr.removeField(stringField);
    actualFieldId = mgr.getFieldEnum(expectedPanelId, stringField);
    assertEquals(FieldIdEnum.UNKNOWN, actualFieldId);
}
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 47 with GraphicPanelFieldManager

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

the class GraphicPanelFieldManagerTest method testAddMultiOptionGroup.

/**
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#addMultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)}.
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#getMultiOptionGroup(java.lang.Class, com.sldeditor.common.xml.ui.GroupIdEnum)}.
 */
@Test
public void testAddMultiOptionGroup() {
    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);
    MultiOptionGroup multiOption = new MultiOptionGroup();
    GroupIdEnum expectedGroupId = GroupIdEnum.FILLSYMBOL;
    multiOption.setId(expectedGroupId);
    mgr.addMultiOptionGroup(multiOption);
    MultiOptionGroup actualValue = mgr.getMultiOptionGroup(null, null);
    assertNull(actualValue);
    actualValue = mgr.getMultiOptionGroup(expectedPanelId, expectedGroupId);
    assertEquals(multiOption, actualValue);
}
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) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) GroupIdEnum(com.sldeditor.common.xml.ui.GroupIdEnum) Test(org.junit.Test)

Example 48 with GraphicPanelFieldManager

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

the class GraphicPanelFieldManagerTest method testAddGraphicPanelFieldManager.

/**
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#add(com.sldeditor.ui.detail.GraphicPanelFieldManager)}.
 */
@Test
public void testAddGraphicPanelFieldManager() {
    // Set up manager 1
    Class<?> expectedPanelId = StrokeDetails.class;
    GraphicPanelFieldManager mgr1 = new GraphicPanelFieldManager(expectedPanelId);
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(String.class, expectedFieldId, "test label", false), "button text");
    mgr1.addField(stringField);
    assertTrue(mgr1.getFields(FieldConfigBoolean.class).isEmpty());
    assertEquals(1, mgr1.getFields(FieldConfigString.class).size());
    // Set up manager 2
    Class<?> expectedPanelId2 = PointFillDetails.class;
    GraphicPanelFieldManager mgr2 = new GraphicPanelFieldManager(expectedPanelId2);
    FieldIdEnum expectedFieldId2 = FieldIdEnum.ANGLE;
    FieldConfigDouble doubleField = new FieldConfigDouble(new FieldConfigCommonData(Double.class, expectedFieldId2, "test label", false));
    mgr2.addField(doubleField);
    assertEquals(1, mgr2.getFields(FieldConfigDouble.class).size());
    // Add manager 2 to manager 1
    mgr1.add(mgr2);
    FieldIdEnum actualFieldId = mgr1.getFieldEnum(expectedPanelId, stringField);
    assertEquals(expectedFieldId, actualFieldId);
    actualFieldId = mgr1.getFieldEnum(expectedPanelId2, doubleField);
    assertEquals(expectedFieldId2, actualFieldId);
}
Also used : FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) StrokeDetails(com.sldeditor.ui.detail.StrokeDetails) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) PointFillDetails(com.sldeditor.ui.detail.PointFillDetails) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 49 with GraphicPanelFieldManager

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

the class GraphicPanelFieldManagerTest method testGraphicPanelFieldManager.

/**
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#GraphicPanelFieldManager(java.lang.Class)}.
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#get(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#get(com.sldeditor.common.xml.ui.FieldIdEnum)}.
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#getFieldEnum(java.lang.Class, com.sldeditor.ui.detail.config.FieldConfigBase)}.
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#getComponentId()}.
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#addField(com.sldeditor.ui.detail.config.FieldConfigBase)}.
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#add(com.sldeditor.ui.detail.config.FieldId, com.sldeditor.ui.detail.config.FieldConfigBase)}.
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#getData(java.lang.Class, com.sldeditor.ui.detail.config.FieldId)}.
 */
@Test
public void testGraphicPanelFieldManager() {
    // Try with a null panel id
    GraphicPanelFieldManager mgr = new GraphicPanelFieldManager(null);
    assertNull(mgr.get(FieldIdEnum.FILTER));
    Class<?> expectedPanelId = StrokeDetails.class;
    mgr = new GraphicPanelFieldManager(expectedPanelId);
    assertEquals(FieldIdEnum.UNKNOWN, mgr.getFieldEnum(PointFillDetails.class, null));
    assertEquals(expectedPanelId, mgr.getComponentId());
    // Now try with a field
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(String.class, expectedFieldId, "test label", false), "button text");
    mgr.addField(null);
    mgr.addField(stringField);
    FieldIdEnum actualFieldId = mgr.getFieldEnum(expectedPanelId, stringField);
    assertEquals(expectedFieldId, actualFieldId);
    assertNull(mgr.getData(null, null));
    assertNull(mgr.getData(expectedPanelId, null));
    assertEquals(stringField, mgr.getData(expectedPanelId, actualFieldId));
}
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) PointFillDetails(com.sldeditor.ui.detail.PointFillDetails) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 50 with GraphicPanelFieldManager

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

the class LineSymbolizerDetailsTest method testLineSymbolizerDetails.

/**
 * Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#LineSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 * Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 * Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#getFieldDataManager()}.
 * Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#isDataPresent()}.
 * Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#preLoadSymbol()}.
 */
@Test
public void testLineSymbolizerDetails() {
    LineSymbolizerDetails panel = new LineSymbolizerDetails();
    panel.populate(null);
    // Set up test data
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    SelectedSymbol.getInstance().createNewSLD(sld);
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    String expectedNameLayerValue = "named layer test value";
    namedLayer.setName(expectedNameLayerValue);
    Style style = DefaultSymbols.createNewStyle();
    String expectedNameStyleValue = "style test value";
    style.setName(expectedNameStyleValue);
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    String expectedNameFTSValue = "feature type style test value";
    fts.setName(expectedNameFTSValue);
    style.featureTypeStyles().add(fts);
    Rule rule = DefaultSymbols.createNewRule();
    String expectedRuleValue = "rule test value";
    rule.setName(expectedRuleValue);
    LineSymbolizer symbolizer = DefaultSymbols.createDefaultLineSymbolizer();
    String expectedNameValue = "symbolizer test value";
    symbolizer.setName(expectedNameValue);
    rule.symbolizers().add(symbolizer);
    fts.rules().add(rule);
    sld.layers().add(namedLayer);
    SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyle(style);
    SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
    SelectedSymbol.getInstance().setRule(rule);
    SelectedSymbol.getInstance().setSymbolizer(symbolizer);
    panel.populate(SelectedSymbol.getInstance());
    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);
    panel.dataChanged(null);
    FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
    assertNull(nameField);
    assertTrue(panel.isDataPresent());
    // Reset to default value
    panel.preLoadSymbol();
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) LineSymbolizerDetails(com.sldeditor.ui.detail.LineSymbolizerDetails) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) LineSymbolizer(org.geotools.styling.LineSymbolizer) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Aggregations

GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)53 Test (org.junit.Test)51 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)34 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)33 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)23 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)18 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)17 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)16 StyleBuilder (org.geotools.styling.StyleBuilder)16 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)16 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)15 NamedLayer (org.geotools.styling.NamedLayer)15 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)14 Style (org.geotools.styling.Style)14 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)13 Rule (org.geotools.styling.Rule)13 ColourFieldConfig (com.sldeditor.ui.detail.ColourFieldConfig)12 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)12 Geometry (com.vividsolutions.jts.geom.Geometry)12 StrokeDetails (com.sldeditor.ui.detail.StrokeDetails)9