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