Search in sources :

Example 1 with SymbolizerDetailsPanel

use of com.sldeditor.ui.detail.SymbolizerDetailsPanel in project sldeditor by robward-scisys.

the class SLDTreeTest method testSLDTree.

/**
 * Test method for {@link com.sldeditor.ui.tree.SLDTree#SLDTree(java.util.List)} using values.
 * Test method for
 * {@link com.sldeditor.ui.tree.SLDTree#addSymbolSelectedListener(com.sldeditor.ui.iface.SymbolizerSelectedInterface)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTree#selectFirstSymbol()}. Test method for
 * {@link com.sldeditor.ui.tree.SLDTree#selectTreeItem(com.sldeditor.TreeSelectionData)}. Test
 * method for {@link com.sldeditor.ui.tree.SLDTree#getSelectedSymbolPanel()}. Test method for
 * {@link com.sldeditor.ui.tree.SLDTree#leafSelected()}.
 */
@Test
public void testSLDTree() {
    List<RenderSymbolInterface> renderList = null;
    SLDTreeTools treeTools = new SLDTreeTools();
    SLDTree tree1 = new SLDTree(renderList, treeTools);
    URL url = SLDTreeTest.class.getResource("/test/polygon_line_point.sld");
    String sldContents = readFile(new File(url.getFile()).getAbsolutePath());
    SLDData sldData = new SLDData(null, sldContents);
    StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
    SelectedSymbol.getInstance().setSld(sld);
    SymbolizerDetailsPanel symbolizerSelectedPanel = new SymbolizerDetailsPanel(null, null);
    tree1.addSymbolSelectedListener(symbolizerSelectedPanel);
    tree1.populateSLD();
    // Nothing selected at this stage
    tree1.leafSelected();
    PopulateDetailsInterface panel = tree1.getSelectedSymbolPanel();
    assertNull(panel);
    // Select top level node
    tree1.selectFirstSymbol();
    tree1.leafSelected();
    panel = tree1.getSelectedSymbolPanel();
    assertEquals(EmptyPanel.class, panel.getClass());
    // Select layer
    TreeSelectionData selectedTreeData = new TreeSelectionData();
    selectedTreeData.setLayerIndex(0);
    assertTrue(tree1.selectTreeItem(selectedTreeData));
    panel = tree1.getSelectedSymbolPanel();
    assertEquals(NamedLayerDetails.class, panel.getClass());
    // Select style
    selectedTreeData.setStyleIndex(0);
    assertTrue(tree1.selectTreeItem(selectedTreeData));
    panel = tree1.getSelectedSymbolPanel();
    assertEquals(StyleDetails.class, panel.getClass());
    // Select feature type style
    selectedTreeData.setFeatureTypeStyleIndex(0);
    assertTrue(tree1.selectTreeItem(selectedTreeData));
    panel = tree1.getSelectedSymbolPanel();
    assertEquals(FeatureTypeStyleDetails.class, panel.getClass());
    // Select rule
    selectedTreeData.setRuleIndex(0);
    assertTrue(tree1.selectTreeItem(selectedTreeData));
    panel = tree1.getSelectedSymbolPanel();
    assertEquals(RuleDetails.class, panel.getClass());
    // Select polygon symbolizer
    selectedTreeData.setSelectedPanel(PolygonSymbolizerDetails.class);
    selectedTreeData.setSymbolizerIndex(0);
    assertTrue(tree1.selectTreeItem(selectedTreeData));
    panel = tree1.getSelectedSymbolPanel();
    assertEquals(PolygonSymbolizerDetails.class, panel.getClass());
    // Select line symbolizer
    selectedTreeData.setSelectedPanel(LineSymbolizerDetails.class);
    selectedTreeData.setRuleIndex(1);
    assertTrue(tree1.selectTreeItem(selectedTreeData));
    panel = tree1.getSelectedSymbolPanel();
    assertEquals(LineSymbolizerDetails.class, panel.getClass());
    // Select point symbolizer
    selectedTreeData.setSelectedPanel(PointSymbolizerDetails.class);
    selectedTreeData.setRuleIndex(2);
    assertTrue(tree1.selectTreeItem(selectedTreeData));
    panel = tree1.getSelectedSymbolPanel();
    assertEquals(PointSymbolizerDetails.class, panel.getClass());
    // Select text symbolizer
    selectedTreeData.setSelectedPanel(TextSymbolizerDetails.class);
    selectedTreeData.setSymbolizerIndex(1);
    assertTrue(tree1.selectTreeItem(selectedTreeData));
    panel = tree1.getSelectedSymbolPanel();
    assertEquals(TextSymbolizerDetails.class, panel.getClass());
    // Select raster symbolizer
    selectedTreeData.setSelectedPanel(RasterSymbolizerDetails.class);
    selectedTreeData.setSymbolizerIndex(2);
    assertTrue(tree1.selectTreeItem(selectedTreeData));
    panel = tree1.getSelectedSymbolPanel();
    assertEquals(RasterSymbolizerDetails.class, panel.getClass());
    // Select polygon symbolizer / fill
    selectedTreeData.setSelectedPanel(PolygonFillDetails.class);
    selectedTreeData.setSymbolizerIndex(0);
    selectedTreeData.setSymbolizerDetailIndex(0);
    selectedTreeData.setRuleIndex(0);
    assertTrue(tree1.selectTreeItem(selectedTreeData));
    panel = tree1.getSelectedSymbolPanel();
    assertEquals(PolygonFillDetails.class, panel.getClass());
    // Select polygon symbolizer / stroke
    selectedTreeData.setSelectedPanel(StrokeDetails.class);
    selectedTreeData.setSymbolizerDetailIndex(1);
    assertTrue(tree1.selectTreeItem(selectedTreeData));
    panel = tree1.getSelectedSymbolPanel();
    assertEquals(StrokeDetails.class, panel.getClass());
    // Select point symbolizer / fill
    selectedTreeData.setSelectedPanel(PointFillDetails.class);
    selectedTreeData.setRuleIndex(2);
    selectedTreeData.setSymbolizerIndex(0);
    selectedTreeData.setSymbolizerDetailIndex(0);
    assertTrue(tree1.selectTreeItem(selectedTreeData));
    panel = tree1.getSelectedSymbolPanel();
    assertEquals(PointFillDetails.class, panel.getClass());
    // Select line symbolizer / stroke
    selectedTreeData.setSelectedPanel(StrokeDetails.class);
    selectedTreeData.setRuleIndex(1);
    selectedTreeData.setSymbolizerIndex(0);
    selectedTreeData.setSymbolizerDetailIndex(0);
    assertTrue(tree1.selectTreeItem(selectedTreeData));
    panel = tree1.getSelectedSymbolPanel();
    assertEquals(StrokeDetails.class, panel.getClass());
    // Error cases
    selectedTreeData.setSymbolizerDetailIndex(-2);
    assertFalse(tree1.selectTreeItem(selectedTreeData));
    selectedTreeData.setSymbolizerDetailIndex(1);
    assertFalse(tree1.selectTreeItem(selectedTreeData));
}
Also used : SLDData(com.sldeditor.common.data.SLDData) SLDTree(com.sldeditor.ui.tree.SLDTree) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) TreeSelectionData(com.sldeditor.TreeSelectionData) RenderSymbolInterface(com.sldeditor.datasource.RenderSymbolInterface) SymbolizerDetailsPanel(com.sldeditor.ui.detail.SymbolizerDetailsPanel) File(java.io.File) SLDTreeTools(com.sldeditor.ui.tree.SLDTreeTools) URL(java.net.URL) PopulateDetailsInterface(com.sldeditor.ui.iface.PopulateDetailsInterface) Test(org.junit.Test)

Example 2 with SymbolizerDetailsPanel

use of com.sldeditor.ui.detail.SymbolizerDetailsPanel in project sldeditor by robward-scisys.

the class SingleSymbolUI method getSymbolizerDetailsPanel.

/**
 * Gets the symbolizer details panel.
 *
 * @return the marker details panel
 */
private JPanel getSymbolizerDetailsPanel() {
    if (panelSymbolizerDetails == null) {
        List<RenderSymbolInterface> rendererList = new ArrayList<RenderSymbolInterface>();
        rendererList.add(RenderPanelFactory.getRenderer(SingleSymbolUI.class.getName()));
        rendererList.add(LegendManager.getInstance().getRendererUpdate());
        rendererList.add(SLDEditorFile.getInstance());
        rendererList.add(RenderPanelFactory.getMapRenderer());
        panelSymbolizerDetails = new SymbolizerDetailsPanel(rendererList, getSymbolTree());
    }
    return panelSymbolizerDetails;
}
Also used : RenderSymbolInterface(com.sldeditor.datasource.RenderSymbolInterface) ArrayList(java.util.ArrayList) SymbolizerDetailsPanel(com.sldeditor.ui.detail.SymbolizerDetailsPanel)

Aggregations

RenderSymbolInterface (com.sldeditor.datasource.RenderSymbolInterface)2 SymbolizerDetailsPanel (com.sldeditor.ui.detail.SymbolizerDetailsPanel)2 TreeSelectionData (com.sldeditor.TreeSelectionData)1 SLDData (com.sldeditor.common.data.SLDData)1 PopulateDetailsInterface (com.sldeditor.ui.iface.PopulateDetailsInterface)1 SLDTree (com.sldeditor.ui.tree.SLDTree)1 SLDTreeTools (com.sldeditor.ui.tree.SLDTreeTools)1 File (java.io.File)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)1 Test (org.junit.Test)1