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());
}
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);
}
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());
}
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());
}
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());
}
Aggregations