Search in sources :

Example 16 with LineSymbolizer

use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.

the class SLDTree method populateSLD.

/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.tree.UpdateTreeStructureInterface#populateSLD()
     */
@Override
public void populateSLD() {
    reset();
    SelectedSymbol selectedSymbol = SelectedSymbol.getInstance();
    if (selectedSymbol != null) {
        StyledLayerDescriptor sld = selectedSymbol.getSld();
        rootNode.setUserObject(sld);
        treeModel.nodeChanged(rootNode);
        if (sld != null) {
            List<StyledLayer> styledLayerList = sld.layers();
            if (styledLayerList != null) {
                for (StyledLayer styledLayer : styledLayerList) {
                    DefaultMutableTreeNode styledLayerTreeNode = null;
                    List<Style> styleList = null;
                    if (styledLayer instanceof NamedLayerImpl) {
                        NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
                        styleList = namedLayerImpl.styles();
                        styledLayerTreeNode = addObject(rootNode, namedLayerImpl, true);
                    } else if (styledLayer instanceof UserLayerImpl) {
                        UserLayerImpl userLayerImpl = (UserLayerImpl) styledLayer;
                        styleList = userLayerImpl.userStyles();
                        styledLayerTreeNode = addObject(rootNode, userLayerImpl, true);
                    }
                    if (styleList != null) {
                        for (Style style : styleList) {
                            DefaultMutableTreeNode styleTreeNode = addObject(styledLayerTreeNode, style, true);
                            for (FeatureTypeStyle fts : style.featureTypeStyles()) {
                                DefaultMutableTreeNode ftsTreeNode = addObject(styleTreeNode, fts, true);
                                for (Rule rule : fts.rules()) {
                                    DefaultMutableTreeNode ruleTreeNode = addObject(ftsTreeNode, rule, true);
                                    for (Symbolizer symbolizer : rule.symbolizers()) {
                                        DefaultMutableTreeNode symbolizerTreeNode = addObject(ruleTreeNode, symbolizer, true);
                                        if ((symbolizer instanceof PointSymbolizer) || (symbolizer instanceof PolygonSymbolizer)) {
                                            addObject(symbolizerTreeNode, SLDTreeLeafFactory.getInstance().getFill(symbolizer), true);
                                        }
                                        if ((symbolizer instanceof PolygonSymbolizer) || (symbolizer instanceof LineSymbolizer)) {
                                            addObject(symbolizerTreeNode, SLDTreeLeafFactory.getInstance().getStroke(symbolizer), true);
                                        }
                                        if (symbolizer instanceof RasterSymbolizer) {
                                            handleRasterSymbolizer(symbolizer, symbolizerTreeNode);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : SelectedSymbol(com.sldeditor.common.data.SelectedSymbol) PointSymbolizer(org.geotools.styling.PointSymbolizer) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) StyledLayer(org.geotools.styling.StyledLayer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) NamedLayerImpl(org.geotools.styling.NamedLayerImpl) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Symbolizer(org.geotools.styling.Symbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) PointSymbolizer(org.geotools.styling.PointSymbolizer) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) UserLayerImpl(org.geotools.styling.UserLayerImpl) LineSymbolizer(org.geotools.styling.LineSymbolizer) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule)

Example 17 with LineSymbolizer

use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.

the class SLDTree method handleRasterSymbolizer.

/**
 * Handle raster symbolizer.
 *
 * @param symbolizer the symbolizer
 * @param symbolizerTreeNode the symbolizer tree node
 */
private void handleRasterSymbolizer(Symbolizer symbolizer, DefaultMutableTreeNode symbolizerTreeNode) {
    // Handle the image outline symbolizer for raster symbols
    Symbolizer outlineSymbolizer = ((RasterSymbolizer) symbolizer).getImageOutline();
    if (outlineSymbolizer instanceof LineSymbolizer) {
        LineSymbolizer outlineLineSymbolizer = (LineSymbolizer) outlineSymbolizer;
        if (outlineLineSymbolizer != null) {
            DefaultMutableTreeNode symbolizerImageOutlineLineNode = addObject(symbolizerTreeNode, outlineLineSymbolizer, true);
            addObject(symbolizerImageOutlineLineNode, SLDTreeLeafFactory.getInstance().getStroke(outlineLineSymbolizer), true);
        }
    } else if (outlineSymbolizer instanceof PolygonSymbolizer) {
        PolygonSymbolizer outlinePolygonSymbolizer = (PolygonSymbolizer) outlineSymbolizer;
        if (outlinePolygonSymbolizer != null) {
            DefaultMutableTreeNode symbolizerImageOutlinePolygonNode = addObject(symbolizerTreeNode, outlinePolygonSymbolizer, true);
            addObject(symbolizerImageOutlinePolygonNode, SLDTreeLeafFactory.getInstance().getFill(outlinePolygonSymbolizer), true);
            addObject(symbolizerImageOutlinePolygonNode, SLDTreeLeafFactory.getInstance().getStroke(outlinePolygonSymbolizer), true);
        }
    }
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Symbolizer(org.geotools.styling.Symbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) PointSymbolizer(org.geotools.styling.PointSymbolizer) RasterSymbolizer(org.geotools.styling.RasterSymbolizer)

Example 18 with LineSymbolizer

use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.

the class SLDExternalImagesTest method createTestLine.

/**
 * Creates the test line.
 *
 * @param url the url
 * @return the styled layer descriptor
 */
private StyledLayerDescriptor createTestLine(URL url) {
    StyleBuilder sb = new StyleBuilder();
    StyleFactory styleFactory = sb.getStyleFactory();
    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
    NamedLayer namedLayer = styleFactory.createNamedLayer();
    sld.addStyledLayer(namedLayer);
    Style style = styleFactory.createStyle();
    namedLayer.addStyle(style);
    List<FeatureTypeStyle> ftsList = style.featureTypeStyles();
    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
    ftsList.add(fts);
    Rule rule = styleFactory.createRule();
    fts.rules().add(rule);
    LineSymbolizer line = styleFactory.createLineSymbolizer();
    rule.symbolizers().add(line);
    Graphic graphicFill = createGraphic(url, styleFactory);
    Graphic graphicStroke = createGraphic(url, styleFactory);
    Stroke stroke = styleFactory.createStroke(null, null, null, null, null, null, null, graphicFill, graphicStroke);
    line.setStroke(stroke);
    return sld;
}
Also used : StyleFactory(org.geotools.styling.StyleFactory) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) Stroke(org.geotools.styling.Stroke) ExternalGraphic(org.geotools.styling.ExternalGraphic) Graphic(org.geotools.styling.Graphic) LineSymbolizer(org.geotools.styling.LineSymbolizer) StyleBuilder(org.geotools.styling.StyleBuilder) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer)

Example 19 with LineSymbolizer

use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.

the class SelectedSymbolTest method testGetGraphic.

/**
 * Test method for {@link com.sldeditor.common.data.SelectedSymbol#getGraphic()}.
 */
@Test
public void testGetGraphic() {
    SelectedSymbol.destroyInstance();
    SelectedSymbol instance = SelectedSymbol.getInstance();
    // CHECKSTYLE:OFF
    Rule rule = DefaultSymbols.createNewRule();
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    Style style = DefaultSymbols.createNewStyle();
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    PolygonSymbolizer symbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    // CHECKSTYLE:ON
    instance.createNewSLD(sld);
    instance.setSld(sld);
    System.out.println("Select named layer");
    instance.addNewStyledLayer(namedLayer);
    instance.setStyledLayer(namedLayer);
    instance.addNewStyle(style);
    instance.setStyle(style);
    instance.addNewFeatureTypeStyle(fts);
    instance.setFeatureTypeStyle(fts);
    instance.addNewRule(rule);
    instance.setRule(rule);
    instance.addSymbolizerToRule(symbolizer);
    instance.setSymbolizer(symbolizer);
    Graphic graphic = getGraphic(symbolizer);
    assertNull(graphic);
    Fill graphicFill = DefaultSymbols.createDefaultGraphicFill();
    PolygonSymbolizer newSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    newSymbolizer.setFill(graphicFill);
    instance.addSymbolizerToRule(newSymbolizer);
    instance.setSymbolizer(newSymbolizer);
    graphic = getGraphic(newSymbolizer);
    assertNotNull(graphic);
    assertTrue(instance.hasFill());
    assertTrue(instance.hasStroke());
    LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
    instance.addSymbolizerToRule(lineSymbolizer);
    instance.setSymbolizer(lineSymbolizer);
    graphic = getGraphic(lineSymbolizer);
    assertNull(graphic);
    assertFalse(instance.hasFill());
    assertTrue(instance.hasStroke());
    PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
    instance.addSymbolizerToRule(pointSymbolizer);
    instance.setSymbolizer(pointSymbolizer);
    graphic = getGraphic(pointSymbolizer);
    assertNotNull(graphic);
    assertTrue(instance.hasFill());
    assertFalse(instance.hasStroke());
}
Also used : SelectedSymbol(com.sldeditor.common.data.SelectedSymbol) PointSymbolizer(org.geotools.styling.PointSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) Fill(org.geotools.styling.Fill) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Graphic(org.geotools.styling.Graphic) LineSymbolizer(org.geotools.styling.LineSymbolizer) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer) Test(org.junit.Test)

Example 20 with LineSymbolizer

use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.

the class SLDTreeLeafFactoryTest method testUpdateStroke.

/**
 * Test method for
 * {@link com.sldeditor.common.tree.leaf.SLDTreeLeafFactory#updateStroke(boolean, org.opengis.style.Symbolizer)}.
 */
@Test
public void testUpdateStroke() {
    assertNull(SLDTreeLeafFactory.getInstance().updateStroke(true, null));
    PolygonSymbolizer polygonSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(false, polygonSymbolizer), styleFactory.getDefaultStroke());
    assertTrue(SLDTreeLeafFactory.getInstance().updateStroke(true, polygonSymbolizer) != null);
    PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
    assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(false, pointSymbolizer), styleFactory.getDefaultStroke());
    assertTrue(SLDTreeLeafFactory.getInstance().updateStroke(true, pointSymbolizer) != null);
    LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
    assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(false, lineSymbolizer), styleFactory.getDefaultStroke());
    assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(true, lineSymbolizer), styleFactory.getDefaultStroke());
    TextSymbolizer textSymbolizer = DefaultSymbols.createDefaultTextSymbolizer();
    assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(false, textSymbolizer), styleFactory.getDefaultStroke());
    assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(true, textSymbolizer), styleFactory.getDefaultStroke());
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) TextSymbolizer(org.geotools.styling.TextSymbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) Test(org.junit.Test)

Aggregations

LineSymbolizer (org.geotools.styling.LineSymbolizer)51 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)24 PointSymbolizer (org.geotools.styling.PointSymbolizer)23 Test (org.junit.Test)18 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)17 Style (org.geotools.styling.Style)17 Rule (org.geotools.styling.Rule)16 Symbolizer (org.geotools.styling.Symbolizer)15 Stroke (org.geotools.styling.Stroke)12 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)10 TextSymbolizer (org.geotools.styling.TextSymbolizer)10 NamedLayer (org.geotools.styling.NamedLayer)9 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)7 StyledLayer (org.geotools.styling.StyledLayer)5 JsonObject (com.google.gson.JsonObject)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 Graphic (org.geotools.styling.Graphic)4 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)4 SelectedSymbol (com.sldeditor.common.data.SelectedSymbol)3 SLDTreeLeafLine (com.sldeditor.common.tree.leaf.SLDTreeLeafLine)3