use of com.sldeditor.TreeSelectionData in project sldeditor by robward-scisys.
the class TreeSelectionDataTest method testGetSelection.
/**
* Test method for {@link com.sldeditor.TreeSelectionData#getSelection()}.
*/
@Test
public void testGetSelection() {
TreeSelectionData data = new TreeSelectionData();
assertEquals(SelectedTreeItemEnum.UNKNOWN, data.getSelection());
data.setLayerIndex(5);
assertEquals(SelectedTreeItemEnum.LAYER, data.getSelection());
data.setStyleIndex(3);
assertEquals(SelectedTreeItemEnum.STYLE, data.getSelection());
data.setFeatureTypeStyleIndex(2);
assertEquals(SelectedTreeItemEnum.FEATURETYPESTYLE, data.getSelection());
data.setRuleIndex(0);
assertEquals(SelectedTreeItemEnum.RULE, data.getSelection());
data.setSymbolizerIndex(0);
data.setSelectedPanel(PointSymbolizerDetails.class);
assertEquals(SelectedTreeItemEnum.POINT_SYMBOLIZER, data.getSelection());
data.setSelectedPanel(LineSymbolizerDetails.class);
assertEquals(SelectedTreeItemEnum.LINE_SYMBOLIZER, data.getSelection());
data.setSelectedPanel(PolygonSymbolizerDetails.class);
assertEquals(SelectedTreeItemEnum.POLYGON_SYMBOLIZER, data.getSelection());
data.setSelectedPanel(TextSymbolizerDetails.class);
assertEquals(SelectedTreeItemEnum.TEXT_SYMBOLIZER, data.getSelection());
data.setSelectedPanel(RasterSymbolizerDetails.class);
assertEquals(SelectedTreeItemEnum.RASTER_SYMBOLIZER, data.getSelection());
data.setSelectedPanel(Integer.class);
assertEquals(SelectedTreeItemEnum.UNKNOWN, data.getSelection());
data.setSymbolizerDetailIndex(0);
data.setSelectedPanel(PointFillDetails.class);
assertEquals(SelectedTreeItemEnum.POINT_FILL, data.getSelection());
data.setSelectedPanel(PolygonFillDetails.class);
assertEquals(SelectedTreeItemEnum.POLYGON_FILL, data.getSelection());
data.setSelectedPanel(StrokeDetails.class);
assertEquals(SelectedTreeItemEnum.STROKE, data.getSelection());
data.setSelectedPanel(String.class);
assertEquals(SelectedTreeItemEnum.UNKNOWN, data.getSelection());
}
use of com.sldeditor.TreeSelectionData in project sldeditor by robward-scisys.
the class TreeSelectionDataTest method testGetStyleIndex.
/**
* Test method for {@link com.sldeditor.TreeSelectionData#getStyleIndex()}.
* Test method for {@link com.sldeditor.TreeSelectionData#setStyleIndex(int)}.
*/
@Test
public void testGetStyleIndex() {
TreeSelectionData data = new TreeSelectionData();
assertEquals(-1, data.getStyleIndex());
int actual = 23;
data.setStyleIndex(actual);
assertEquals(actual, data.getStyleIndex());
}
use of com.sldeditor.TreeSelectionData in project sldeditor by robward-scisys.
the class TreeSelectionDataTest method testGetSymbolizerDetailIndex.
/**
* Test method for {@link com.sldeditor.TreeSelectionData#getSymbolizerDetailIndex()}.
* Test method for {@link com.sldeditor.TreeSelectionData#setSymbolizerDetailIndex(int)}.
*/
@Test
public void testGetSymbolizerDetailIndex() {
TreeSelectionData data = new TreeSelectionData();
assertEquals(-1, data.getSymbolizerDetailIndex());
int actual = 65;
data.setSymbolizerDetailIndex(actual);
assertEquals(actual, data.getSymbolizerDetailIndex());
}
use of com.sldeditor.TreeSelectionData in project sldeditor by robward-scisys.
the class TreeSelectionDataTest method testGetSelectedPanel.
/**
* Test method for {@link com.sldeditor.TreeSelectionData#getSelectedPanel()}.
* Test method for {@link com.sldeditor.TreeSelectionData#setSelectedPanel(java.lang.Class)}.
*/
@Test
public void testGetSelectedPanel() {
TreeSelectionData data = new TreeSelectionData();
assertNull(data.getSelectedPanel());
Class<?> actual = String.class;
data.setSelectedPanel(actual);
assertEquals(actual, data.getSelectedPanel());
}
use of com.sldeditor.TreeSelectionData 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);
}
Aggregations