Search in sources :

Example 61 with StyledLayerDescriptor

use of org.geotools.styling.StyledLayerDescriptor in project sldeditor by robward-scisys.

the class PointFillDetailsTest method testFillDetailsPoint.

/**
 * Test method for {@link
 * com.sldeditor.ui.detail.PointFillDetailsTest#FillDetails(java.lang.Class,
 * com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 */
@Test
public void testFillDetailsPoint() {
    PointFillDetails panel = new PointFillDetails();
    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 expectedNameValue = "rule test value";
    rule.setName(expectedNameValue);
    PointSymbolizer symbolizer = DefaultSymbols.createDefaultPointSymbolizer();
    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);
    double expectedAngle = 14.5;
    FieldConfigDouble angleField = (FieldConfigDouble) fieldDataManager.get(FieldIdEnum.ANGLE);
    angleField.populateField(expectedAngle);
    FieldConfigSlider opacityField = (FieldConfigSlider) fieldDataManager.get(FieldIdEnum.OVERALL_OPACITY);
    double opacity = 0.15;
    opacityField.populateField(opacity);
    panel.dataChanged(FieldIdEnum.UNKNOWN);
    double actualValue = angleField.getDoubleValue();
    assertTrue(Math.abs(actualValue - expectedAngle) < 0.01);
    assertTrue(panel.isDataPresent());
    actualValue = opacityField.getDoubleValue();
    assertTrue(Math.abs(actualValue - opacity) < 0.01);
    // Reset to default value
    panel.preLoadSymbol();
    actualValue = angleField.getDoubleValue();
    assertTrue(Math.abs(actualValue - 0.0) < 0.01);
    actualValue = opacityField.getDoubleValue();
    assertTrue(Math.abs(actualValue - 1.0) < 0.01);
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) PointFillDetails(com.sldeditor.ui.detail.PointFillDetails) NamedLayer(org.geotools.styling.NamedLayer) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.jupiter.api.Test)

Example 62 with StyledLayerDescriptor

use of org.geotools.styling.StyledLayerDescriptor in project sldeditor by robward-scisys.

the class SLDTreeToolsTest method testMoveItemSymbolizer.

/**
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeTools#moveItem(boolean)}.
 */
@Test
public void testMoveItemSymbolizer() {
    SLDTreeTools treeTools = new SLDTreeTools();
    TestSLDTree sldTree = new TestSLDTree(null, treeTools);
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    // Start off with just a top level SLD and no structure below it
    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
    SelectedSymbol.getInstance().setSld(sld);
    sldTree.populateSLD();
    sldTree.selectFirstSymbol();
    treeTools.addNewThing(NamedLayer.class);
    treeTools.addNewThing(null);
    treeTools.addNewThing(null);
    treeTools.addNewThing(null);
    DefaultMutableTreeNode rootNode = sldTree.getRootNode();
    // Make sure we have a rule selected
    DefaultMutableTreeNode rule = (DefaultMutableTreeNode) rootNode.getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(0);
    assertEquals(RuleImpl.class, rule.getUserObject().getClass());
    assertEquals(0, rule.getChildCount());
    treeTools.addNewPolygon();
    treeTools.addNewMarker();
    treeTools.addNewLine();
    treeTools.addNewText();
    assertEquals(4, rule.getChildCount());
    // Now have 4 symbolizers for the rule
    DefaultMutableTreeNode symbolizer = (DefaultMutableTreeNode) rule.getChildAt(0);
    assertEquals(PolygonSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(1);
    assertEquals(PointSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(2);
    assertEquals(LineSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(3);
    assertEquals(TextSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    // The last text symbolizer is selected as it was the last added
    treeTools.moveItem(true);
    // Tree has been repopulated so the root node has changed so get hold of rule node again
    rule = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(0);
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(0);
    assertEquals(PolygonSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(1);
    assertEquals(PointSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(2);
    assertEquals(TextSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(3);
    assertEquals(LineSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    // The last text symbolizer is selected as it was the last added
    TreeSelectionData data = new TreeSelectionData();
    data.setLayerIndex(0);
    data.setStyleIndex(0);
    data.setFeatureTypeStyleIndex(0);
    data.setRuleIndex(0);
    data.setSymbolizerIndex(2);
    data.setSelectedPanel(TextSymbolizerDetails.class);
    sldTree.selectTreeItem(data);
    treeTools.moveItem(true);
    data.setSymbolizerIndex(1);
    sldTree.selectTreeItem(data);
    treeTools.moveItem(true);
    // Tree has been repopulated so the root node has changed so get hold of rule node again
    rule = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(0);
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(0);
    assertEquals(TextSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(1);
    assertEquals(PolygonSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(2);
    assertEquals(PointSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(3);
    assertEquals(LineSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    // Now try and move to index -1, everything should still be the same
    data.setSymbolizerIndex(0);
    sldTree.selectTreeItem(data);
    treeTools.moveItem(true);
    // Tree has been repopulated so the root node has changed so get hold of rule node again
    rule = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(0);
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(0);
    assertEquals(TextSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(1);
    assertEquals(PolygonSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(2);
    assertEquals(PointSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(3);
    assertEquals(LineSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    // Now try and move to index -1, everything should still be the same
    data.setSymbolizerIndex(0);
    sldTree.selectTreeItem(data);
    treeTools.moveItem(false);
    data.setSymbolizerIndex(1);
    sldTree.selectTreeItem(data);
    treeTools.moveItem(false);
    data.setSymbolizerIndex(2);
    sldTree.selectTreeItem(data);
    treeTools.moveItem(false);
    // Tree has been repopulated so the root node has changed so get hold of rule node again
    rule = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(0);
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(0);
    assertEquals(PolygonSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(1);
    assertEquals(PointSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(2);
    assertEquals(LineSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(3);
    assertEquals(TextSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    data.setSymbolizerIndex(3);
    sldTree.selectTreeItem(data);
    treeTools.moveItem(false);
    // Tree has been repopulated so the root node has changed so get hold of rule node again
    rule = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(0);
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(0);
    assertEquals(PolygonSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(1);
    assertEquals(PointSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(2);
    assertEquals(LineSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(3);
    assertEquals(TextSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    // Undo the last valid move
    UndoManager.getInstance().undo();
    // Tree has been repopulated so the root node has changed so get hold of rule node again
    rule = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(0);
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(0);
    assertEquals(PolygonSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(1);
    assertEquals(PointSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(2);
    assertEquals(TextSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(3);
    assertEquals(LineSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    // Redo the last valid move
    UndoManager.getInstance().redo();
    // Tree has been repopulated so the root node has changed so get hold of rule node again
    rule = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(0);
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(0);
    assertEquals(PolygonSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(1);
    assertEquals(PointSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(2);
    assertEquals(LineSymbolizerImpl.class, symbolizer.getUserObject().getClass());
    symbolizer = (DefaultMutableTreeNode) rule.getChildAt(3);
    assertEquals(TextSymbolizerImpl.class, symbolizer.getUserObject().getClass());
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) TreeSelectionData(com.sldeditor.TreeSelectionData) SLDTreeTools(com.sldeditor.ui.tree.SLDTreeTools) Test(org.junit.jupiter.api.Test)

Example 63 with StyledLayerDescriptor

use of org.geotools.styling.StyledLayerDescriptor in project sldeditor by robward-scisys.

the class SLDTreeToolsTest method testAddRaster.

/**
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeTools#addRaster()}.
 */
@Test
public void testAddRaster() {
    SLDTreeTools treeTools = new SLDTreeTools();
    TestSLDTree sldTree = new TestSLDTree(null, treeTools);
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    // Start off with just a top level SLD and no structure below it
    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
    SelectedSymbol.getInstance().setSld(sld);
    sldTree.populateSLD();
    sldTree.selectFirstSymbol();
    treeTools.addNewThing(NamedLayer.class);
    treeTools.addNewThing(null);
    treeTools.addNewThing(null);
    treeTools.addNewThing(null);
    DefaultMutableTreeNode rootNode = sldTree.getRootNode();
    // Make sure we have a rule selected
    DefaultMutableTreeNode rule = (DefaultMutableTreeNode) rootNode.getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(0);
    assertEquals(RuleImpl.class, rule.getUserObject().getClass());
    assertEquals(0, rule.getChildCount());
    treeTools.addNewRaster();
    DefaultMutableTreeNode rasterNode = (DefaultMutableTreeNode) rule.getChildAt(0);
    assertEquals(RasterSymbolizerImpl.class, rasterNode.getUserObject().getClass());
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) SLDTreeTools(com.sldeditor.ui.tree.SLDTreeTools) Test(org.junit.jupiter.api.Test)

Example 64 with StyledLayerDescriptor

use of org.geotools.styling.StyledLayerDescriptor in project sldeditor by robward-scisys.

the class SLDTreeToolsTest method testMoveItemFeatureTypeStyles.

/**
 * Check Feature Type Styles Test method for {@link
 * com.sldeditor.ui.tree.SLDTreeTools#moveItem(boolean)}.
 */
@Test
public void testMoveItemFeatureTypeStyles() {
    SLDTreeTools treeTools = new SLDTreeTools();
    TestSLDTree sldTree = new TestSLDTree(null, treeTools);
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    // Start off with just a top level SLD and no structure below it
    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
    SelectedSymbol.getInstance().setSld(sld);
    sldTree.populateSLD();
    sldTree.selectFirstSymbol();
    treeTools.addNewThing(NamedLayer.class);
    treeTools.addNewThing(null);
    treeTools.addNewThing(null);
    DefaultMutableTreeNode rootNode = sldTree.getRootNode();
    DefaultMutableTreeNode featureTypeStyle1Node = (DefaultMutableTreeNode) rootNode.getChildAt(0).getChildAt(0).getChildAt(0);
    FeatureTypeStyleImpl featureTypeStyle1 = (FeatureTypeStyleImpl) featureTypeStyle1Node.getUserObject();
    String expectedFeatureTypeStyle1 = "feature type style 1";
    featureTypeStyle1.setName(expectedFeatureTypeStyle1);
    TreeSelectionData data = new TreeSelectionData();
    data.setLayerIndex(0);
    data.setStyleIndex(0);
    sldTree.selectTreeItem(data);
    treeTools.addNewThing(null);
    DefaultMutableTreeNode featureTypeStyle2Node = (DefaultMutableTreeNode) rootNode.getChildAt(0).getChildAt(0).getChildAt(1);
    FeatureTypeStyleImpl featureTypeStyle2 = (FeatureTypeStyleImpl) featureTypeStyle2Node.getUserObject();
    String expectedFeatureTypeStyle2 = "feature type style 2";
    featureTypeStyle2.setName(expectedFeatureTypeStyle2);
    // Have 2 styles
    data = new TreeSelectionData();
    data.setLayerIndex(0);
    data.setStyleIndex(0);
    data.setFeatureTypeStyleIndex(1);
    sldTree.selectTreeItem(data);
    // Move style 2 so that they are reversed
    treeTools.moveItem(true);
    DefaultMutableTreeNode testNode = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(0);
    FeatureTypeStyleImpl testStyle = (FeatureTypeStyleImpl) testNode.getUserObject();
    assertTrue(testStyle.getName().compareTo(expectedFeatureTypeStyle2) == 0);
    // Try and move 'style 2' up to index -1 which is invalid, result should be same as last
    // time
    data.setFeatureTypeStyleIndex(0);
    sldTree.selectTreeItem(data);
    treeTools.moveItem(true);
    testNode = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(0);
    testStyle = (FeatureTypeStyleImpl) testNode.getUserObject();
    assertTrue(testStyle.getName().compareTo(expectedFeatureTypeStyle2) == 0);
    // Move it back
    data.setFeatureTypeStyleIndex(0);
    sldTree.selectTreeItem(data);
    treeTools.moveItem(false);
    testNode = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(1);
    testStyle = (FeatureTypeStyleImpl) testNode.getUserObject();
    assertTrue(testStyle.getName().compareTo(expectedFeatureTypeStyle2) == 0);
    // Move it beyond the end of the list, should be the same answer as before
    data.setFeatureTypeStyleIndex(1);
    sldTree.selectTreeItem(data);
    treeTools.moveItem(false);
    testNode = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(1);
    testStyle = (FeatureTypeStyleImpl) testNode.getUserObject();
    assertTrue(testStyle.getName().compareTo(expectedFeatureTypeStyle2) == 0);
    // Undo the last valid move
    UndoManager.getInstance().undo();
    testNode = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(0);
    testStyle = (FeatureTypeStyleImpl) testNode.getUserObject();
    assertTrue(testStyle.getName().compareTo(expectedFeatureTypeStyle2) == 0);
    // Redo the last valid move
    UndoManager.getInstance().redo();
    testNode = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(1);
    testStyle = (FeatureTypeStyleImpl) testNode.getUserObject();
    assertTrue(testStyle.getName().compareTo(expectedFeatureTypeStyle2) == 0);
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) TreeSelectionData(com.sldeditor.TreeSelectionData) FeatureTypeStyleImpl(org.geotools.styling.FeatureTypeStyleImpl) SLDTreeTools(com.sldeditor.ui.tree.SLDTreeTools) Test(org.junit.jupiter.api.Test)

Example 65 with StyledLayerDescriptor

use of org.geotools.styling.StyledLayerDescriptor in project sldeditor by robward-scisys.

the class SLDTreeToolsTest method testRemoveItem.

/**
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeTools#removeItem()}.
 */
@Test
public void testRemoveItem() {
    SLDTreeTools treeTools = new SLDTreeTools();
    TestRenderSymbolInterface renderSymbol = new TestRenderSymbolInterface();
    List<RenderSymbolInterface> renderList = new ArrayList<RenderSymbolInterface>();
    renderList.add(renderSymbol);
    TestSLDTree sldTree = new TestSLDTree(renderList, treeTools);
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    // Start off with just a top level SLD and no structure below it
    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
    SelectedSymbol.getInstance().setSld(sld);
    sldTree.populateSLD();
    sldTree.selectFirstSymbol();
    // Named layer
    treeTools.addNewThing(NamedLayer.class);
    // Style
    treeTools.addNewThing(null);
    // Feature type style
    treeTools.addNewThing(null);
    // Rule
    treeTools.addNewThing(null);
    DefaultMutableTreeNode rootNode = sldTree.getRootNode();
    // Make sure we have a rule selected
    DefaultMutableTreeNode rule = (DefaultMutableTreeNode) rootNode.getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(0);
    assertEquals(RuleImpl.class, rule.getUserObject().getClass());
    assertEquals(0, rule.getChildCount());
    treeTools.addNewText();
    rule = (DefaultMutableTreeNode) rootNode.getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(0);
    assertEquals(RuleImpl.class, rule.getUserObject().getClass());
    assertEquals(1, rule.getChildCount());
    // The selected item (text symbolizer) is removed
    treeTools.removeItem();
    assertTrue(renderSymbol.hasRenderSymbolBeenCalled());
    rule = (DefaultMutableTreeNode) rootNode.getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(0);
    assertEquals(RuleImpl.class, rule.getUserObject().getClass());
    assertEquals(0, rule.getChildCount());
    // The selected item (rule) is removed
    treeTools.removeItem();
    assertTrue(renderSymbol.hasRenderSymbolBeenCalled());
    DefaultMutableTreeNode featureTypeStyle = (DefaultMutableTreeNode) rootNode.getChildAt(0).getChildAt(0).getChildAt(0);
    assertEquals(FeatureTypeStyleImpl.class, featureTypeStyle.getUserObject().getClass());
    assertEquals(0, featureTypeStyle.getChildCount());
    // The selected item (style) is removed
    treeTools.removeItem();
    assertTrue(renderSymbol.hasRenderSymbolBeenCalled());
    DefaultMutableTreeNode style = (DefaultMutableTreeNode) rootNode.getChildAt(0).getChildAt(0);
    assertEquals(StyleImpl.class, style.getUserObject().getClass());
    assertEquals(0, style.getChildCount());
    // The selected item (named layer) is removed
    treeTools.removeItem();
    assertTrue(renderSymbol.hasRenderSymbolBeenCalled());
    DefaultMutableTreeNode namedLayer = (DefaultMutableTreeNode) rootNode.getChildAt(0);
    assertEquals(NamedLayerImpl.class, namedLayer.getUserObject().getClass());
    assertEquals(0, namedLayer.getChildCount());
    // The selected item (styled layer descriptor) is removed
    treeTools.removeItem();
    assertTrue(renderSymbol.hasRenderSymbolBeenCalled());
    assertEquals(0, rootNode.getChildCount());
    treeTools.removeItem();
    assertEquals(0, rootNode.getChildCount());
    assertFalse(renderSymbol.hasRenderSymbolBeenCalled());
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) RenderSymbolInterface(com.sldeditor.datasource.RenderSymbolInterface) ArrayList(java.util.ArrayList) SLDTreeTools(com.sldeditor.ui.tree.SLDTreeTools) Test(org.junit.jupiter.api.Test)

Aggregations

StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)134 Test (org.junit.jupiter.api.Test)80 Rule (org.geotools.styling.Rule)54 Style (org.geotools.styling.Style)52 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)50 NamedLayer (org.geotools.styling.NamedLayer)48 SLDData (com.sldeditor.common.data.SLDData)25 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)24 File (java.io.File)22 StyledLayer (org.geotools.styling.StyledLayer)21 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)19 SLDDataInterface (com.sldeditor.common.SLDDataInterface)17 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)17 SLDTreeTools (com.sldeditor.ui.tree.SLDTreeTools)17 StyleWrapper (com.sldeditor.common.data.StyleWrapper)16 IOException (java.io.IOException)16 PointSymbolizer (org.geotools.styling.PointSymbolizer)16 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)15 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)13 DataSourceAttributeData (com.sldeditor.datasource.attribute.DataSourceAttributeData)12