Search in sources :

Example 16 with SLDTreeTools

use of com.sldeditor.ui.tree.SLDTreeTools in project sldeditor by robward-scisys.

the class SLDTreeToolsTest method testAddNewImageOutlineLine.

/**
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeTools#addNewImageOutlineLine()}.
 */
@Test
public void testAddNewImageOutlineLine() {
    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());
    treeTools.addNewImageOutlineLine();
    DefaultMutableTreeNode imageOutlineNode = (DefaultMutableTreeNode) rasterNode.getChildAt(0);
    assertEquals(LineSymbolizerImpl.class, imageOutlineNode.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 17 with SLDTreeTools

use of com.sldeditor.ui.tree.SLDTreeTools in project sldeditor by robward-scisys.

the class SLDTreeToolsTest method testSetButtonState.

/**
 * Test method for {@link
 * com.sldeditor.ui.tree.SLDTreeTools#setButtonState(javax.swing.tree.DefaultMutableTreeNode,
 * javax.swing.tree.DefaultMutableTreeNode, com.sldeditor.datasource.impl.GeometryTypeEnum)}.
 */
@Test
public void testSetButtonState() {
    SLDTreeTools treeTools = new SLDTreeTools();
    TestSLDTree sldTree = new TestSLDTree(null, treeTools);
    assertNotNull(sldTree);
    treeTools.setButtonState(null, null, null);
}
Also used : SLDTreeTools(com.sldeditor.ui.tree.SLDTreeTools) Test(org.junit.jupiter.api.Test)

Example 18 with SLDTreeTools

use of com.sldeditor.ui.tree.SLDTreeTools in project sldeditor by robward-scisys.

the class SLDTreeToolsTest method testAddNewThingUserLayer.

/**
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeTools#addNewThing()}.
 */
@Test
public void testAddNewThingUserLayer() {
    SLDTreeTools treeTools = new SLDTreeTools();
    TestSLDTree sldTree = new TestSLDTree(null, treeTools);
    treeTools.addNewThing(null);
    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();
    DefaultMutableTreeNode rootNode = sldTree.getRootNode();
    // Check it has no structure below just the root node
    assertEquals(0, rootNode.getChildCount());
    // Add a thing - a quick way of creating sld structure
    // This should add a user layer and select it
    treeTools.addNewThing(UserLayer.class);
    assertEquals(1, rootNode.getChildCount());
    DefaultMutableTreeNode userLayer = (DefaultMutableTreeNode) rootNode.getChildAt(0);
    assertEquals(UserLayerImpl.class, userLayer.getUserObject().getClass());
    // This should add a style and select it
    assertEquals(0, userLayer.getChildCount());
    treeTools.addNewThing(null);
    assertEquals(1, userLayer.getChildCount());
    DefaultMutableTreeNode styleLayer = (DefaultMutableTreeNode) userLayer.getChildAt(0);
    assertEquals(StyleImpl.class, styleLayer.getUserObject().getClass());
    // This should add a feature type style and select it
    assertEquals(0, styleLayer.getChildCount());
    treeTools.addNewThing(null);
    assertEquals(1, styleLayer.getChildCount());
    DefaultMutableTreeNode featureTypeStyle = (DefaultMutableTreeNode) styleLayer.getChildAt(0);
    assertEquals(FeatureTypeStyleImpl.class, featureTypeStyle.getUserObject().getClass());
    // This should add a rule and select it
    assertEquals(0, featureTypeStyle.getChildCount());
    treeTools.addNewThing(null);
    assertEquals(1, featureTypeStyle.getChildCount());
    DefaultMutableTreeNode rule = (DefaultMutableTreeNode) featureTypeStyle.getChildAt(0);
    assertEquals(RuleImpl.class, rule.getUserObject().getClass());
    // This should do nothing
    assertEquals(0, rule.getChildCount());
    treeTools.addNewThing(null);
    assertEquals(0, rule.getChildCount());
    // Undo last add of rule to feature type style
    UndoManager.getInstance().undo();
    DefaultMutableTreeNode featureTypeStyleNode = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(0);
    assertEquals(FeatureTypeStyleImpl.class, featureTypeStyleNode.getUserObject().getClass());
    assertEquals(0, featureTypeStyleNode.getChildCount());
    // Undo last add of rule to feature type style
    UndoManager.getInstance().redo();
    featureTypeStyleNode = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(0);
    assertEquals(FeatureTypeStyleImpl.class, featureTypeStyleNode.getUserObject().getClass());
    assertEquals(1, featureTypeStyleNode.getChildCount());
}
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 19 with SLDTreeTools

use of com.sldeditor.ui.tree.SLDTreeTools in project sldeditor by robward-scisys.

the class SLDTreeToolsTest method testAddNewImageOutlinePolygon.

/**
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeTools#addNewImageOutlinePolygon()}.
 */
@Test
public void testAddNewImageOutlinePolygon() {
    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());
    treeTools.addNewImageOutlinePolygon();
    DefaultMutableTreeNode imageOutlineNode = (DefaultMutableTreeNode) rasterNode.getChildAt(0);
    assertEquals(PolygonSymbolizerImpl.class, imageOutlineNode.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 20 with SLDTreeTools

use of com.sldeditor.ui.tree.SLDTreeTools in project sldeditor by robward-scisys.

the class SLDTreeToolsTest method testAddNewPolygon.

/**
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeTools#addNewPolygon()}.
 */
@Test
public void testAddNewPolygon() {
    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();
    DefaultMutableTreeNode polygonNode = (DefaultMutableTreeNode) rule.getChildAt(0);
    assertEquals(PolygonSymbolizerImpl.class, polygonNode.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)

Aggregations

SLDTreeTools (com.sldeditor.ui.tree.SLDTreeTools)21 Test (org.junit.jupiter.api.Test)20 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)17 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)16 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)16 TreeSelectionData (com.sldeditor.TreeSelectionData)6 RenderSymbolInterface (com.sldeditor.datasource.RenderSymbolInterface)3 ArrayList (java.util.ArrayList)2 FeatureTypeStyleImpl (org.geotools.styling.FeatureTypeStyleImpl)2 SLDData (com.sldeditor.common.data.SLDData)1 SymbolizerDetailsPanel (com.sldeditor.ui.detail.SymbolizerDetailsPanel)1 PopulateDetailsInterface (com.sldeditor.ui.iface.PopulateDetailsInterface)1 SLDTree (com.sldeditor.ui.tree.SLDTree)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)1 RuleImpl (org.geotools.styling.RuleImpl)1 StyleImpl (org.geotools.styling.StyleImpl)1