Search in sources :

Example 11 with TreeSelectionData

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());
}
Also used : TreeSelectionData(com.sldeditor.TreeSelectionData) Test(org.junit.Test)

Example 12 with TreeSelectionData

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());
}
Also used : TreeSelectionData(com.sldeditor.TreeSelectionData) Test(org.junit.Test)

Example 13 with TreeSelectionData

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());
}
Also used : TreeSelectionData(com.sldeditor.TreeSelectionData) Test(org.junit.Test)

Example 14 with TreeSelectionData

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());
}
Also used : TreeSelectionData(com.sldeditor.TreeSelectionData) Test(org.junit.Test)

Example 15 with TreeSelectionData

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

Aggregations

TreeSelectionData (com.sldeditor.TreeSelectionData)15 Test (org.junit.Test)14 SLDTreeTools (com.sldeditor.ui.tree.SLDTreeTools)6 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)5 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)5 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)5 RenderSymbolInterface (com.sldeditor.datasource.RenderSymbolInterface)2 PopulateDetailsInterface (com.sldeditor.ui.iface.PopulateDetailsInterface)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 FeatureTypeStyleImpl (org.geotools.styling.FeatureTypeStyleImpl)2 SLDData (com.sldeditor.common.data.SLDData)1 VersionData (com.sldeditor.common.vendoroption.VersionData)1 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)1 GroupIdEnum (com.sldeditor.common.xml.ui.GroupIdEnum)1 SldEditorTest (com.sldeditor.common.xml.ui.SldEditorTest)1 XMLColourMapEntries (com.sldeditor.common.xml.ui.XMLColourMapEntries)1 XMLFieldAttribute (com.sldeditor.common.xml.ui.XMLFieldAttribute)1 XMLFieldBase (com.sldeditor.common.xml.ui.XMLFieldBase)1 XMLFieldDisabled (com.sldeditor.common.xml.ui.XMLFieldDisabled)1