Search in sources :

Example 31 with StyleFactoryImpl

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

the class ExtentModelTest method testUpdateExtent.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel#updateExtent(org.geotools.styling.FeatureTypeConstraint)}.
 */
@Test
public void testUpdateExtent() {
    ExtentModel model = new ExtentModel(null);
    Extent[] extentArray = null;
    model.populate(extentArray);
    extentArray = new Extent[2];
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    extentArray[0] = styleFactory.createExtent("extent 1", "1 1 1 1");
    extentArray[1] = styleFactory.createExtent("extent 2", "2 2 2 2");
    model.populate(extentArray);
    FeatureTypeConstraint ftc = styleFactory.createFeatureTypeConstraint("feature type name", Filter.INCLUDE, null);
    model.updateExtent(null);
    model.updateExtent(ftc);
    assertNotNull(ftc.getExtents());
    assertEquals(2, ftc.getExtents().length);
}
Also used : FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) ExtentModel(com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel) Extent(org.geotools.styling.Extent) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) Test(org.junit.Test)

Example 32 with StyleFactoryImpl

use of org.geotools.styling.StyleFactoryImpl 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.Test)

Example 33 with StyleFactoryImpl

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

the class SLDTreeToolsTest method testMoveItemRules.

/**
 * Check Rules Test method for {@link com.sldeditor.ui.tree.SLDTreeTools#moveItem(boolean)}.
 */
@Test
public void testMoveItemRules() {
    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();
    DefaultMutableTreeNode rule1Node = (DefaultMutableTreeNode) rootNode.getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(0);
    RuleImpl rule1 = (RuleImpl) rule1Node.getUserObject();
    String expectedRule1 = "rule 1";
    rule1.setName(expectedRule1);
    TreeSelectionData data = new TreeSelectionData();
    data.setLayerIndex(0);
    data.setStyleIndex(0);
    data.setFeatureTypeStyleIndex(0);
    sldTree.selectTreeItem(data);
    treeTools.addNewThing(null);
    DefaultMutableTreeNode rule2Node = (DefaultMutableTreeNode) rootNode.getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(1);
    RuleImpl rule2 = (RuleImpl) rule2Node.getUserObject();
    String expectedRule2 = "rule 2";
    rule2.setName(expectedRule2);
    // Have 2 styles
    data = new TreeSelectionData();
    data.setLayerIndex(0);
    data.setStyleIndex(0);
    data.setFeatureTypeStyleIndex(0);
    data.setRuleIndex(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).getChildAt(0);
    RuleImpl testRule = (RuleImpl) testNode.getUserObject();
    assertTrue(testRule.getName().compareTo(expectedRule2) == 0);
    // Try and move 'style 2' up to index -1 which is invalid, result should be same as last
    // time
    data.setRuleIndex(0);
    sldTree.selectTreeItem(data);
    treeTools.moveItem(true);
    testNode = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(0);
    testRule = (RuleImpl) testNode.getUserObject();
    assertTrue(testRule.getName().compareTo(expectedRule2) == 0);
    // Move it back
    data.setRuleIndex(0);
    sldTree.selectTreeItem(data);
    treeTools.moveItem(false);
    testNode = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(1);
    testRule = (RuleImpl) testNode.getUserObject();
    assertTrue(testRule.getName().compareTo(expectedRule2) == 0);
    // Move it beyond the end of the list, should be the same answer as before
    data.setRuleIndex(1);
    sldTree.selectTreeItem(data);
    treeTools.moveItem(false);
    testNode = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(1);
    testRule = (RuleImpl) testNode.getUserObject();
    assertTrue(testRule.getName().compareTo(expectedRule2) == 0);
    // Undo the last valid move
    UndoManager.getInstance().undo();
    testNode = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(0);
    testRule = (RuleImpl) testNode.getUserObject();
    assertTrue(testRule.getName().compareTo(expectedRule2) == 0);
    // Redo the last valid move
    UndoManager.getInstance().redo();
    testNode = (DefaultMutableTreeNode) sldTree.getRootNode().getChildAt(0).getChildAt(0).getChildAt(0).getChildAt(1);
    testRule = (RuleImpl) testNode.getUserObject();
    assertTrue(testRule.getName().compareTo(expectedRule2) == 0);
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) TreeSelectionData(com.sldeditor.TreeSelectionData) RuleImpl(org.geotools.styling.RuleImpl) SLDTreeTools(com.sldeditor.ui.tree.SLDTreeTools) Test(org.junit.Test)

Example 34 with StyleFactoryImpl

use of org.geotools.styling.StyleFactoryImpl 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.Test)

Example 35 with StyleFactoryImpl

use of org.geotools.styling.StyleFactoryImpl 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.Test)

Aggregations

StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)43 Test (org.junit.Test)43 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)23 SLDTreeTools (com.sldeditor.ui.tree.SLDTreeTools)16 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)16 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)12 ArrayList (java.util.ArrayList)11 FilterFactory (org.opengis.filter.FilterFactory)11 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)10 Rule (org.geotools.styling.Rule)8 RasterSymbolizerDetails (com.sldeditor.ui.detail.RasterSymbolizerDetails)7 NamedLayer (org.geotools.styling.NamedLayer)7 Style (org.geotools.styling.Style)7 VendorOptionPresent (com.sldeditor.common.vendoroption.minversion.VendorOptionPresent)6 TreeSelectionData (com.sldeditor.TreeSelectionData)5 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)5 MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)5 Box (javax.swing.Box)5 ChannelSelection (org.geotools.styling.ChannelSelection)5 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)4