Search in sources :

Example 51 with Symbolizer

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

the class SLDExternalImages method externalGraphicSymbolVisitor.

/**
 * Find the SLD graphical symbols.
 *
 * @param resourceLocator the resource locator
 * @param sld the sld
 * @param externalImageList the external image list
 * @param process the process
 */
private static void externalGraphicSymbolVisitor(URL resourceLocator, StyledLayerDescriptor sld, List<String> externalImageList, ProcessGraphicSymbolInterface process) {
    if (sld == null) {
        return;
    }
    if (process == null) {
        return;
    }
    for (StyledLayer styledLayer : sld.layers()) {
        List<Style> styles = null;
        if (styledLayer instanceof NamedLayer) {
            NamedLayerImpl namedLayer = (NamedLayerImpl) styledLayer;
            styles = namedLayer.styles();
        } else if (styledLayer instanceof UserLayer) {
            UserLayerImpl userLayer = (UserLayerImpl) styledLayer;
            styles = userLayer.userStyles();
        }
        if (styles != null) {
            for (Style style : styles) {
                for (FeatureTypeStyle fts : style.featureTypeStyles()) {
                    for (Rule rule : fts.rules()) {
                        for (Symbolizer symbolizer : rule.symbolizers()) {
                            if (symbolizer instanceof PointSymbolizer) {
                                PointSymbolizer point = (PointSymbolizer) symbolizer;
                                if (point.getGraphic() != null) {
                                    process.processGraphicalSymbol(resourceLocator, point.getGraphic().graphicalSymbols(), externalImageList);
                                }
                            } else if (symbolizer instanceof LineSymbolizer) {
                                LineSymbolizer line = (LineSymbolizer) symbolizer;
                                updateStroke(resourceLocator, line.getStroke(), externalImageList, process);
                            } else if (symbolizer instanceof PolygonSymbolizer) {
                                PolygonSymbolizer polygon = (PolygonSymbolizer) symbolizer;
                                updateStroke(resourceLocator, polygon.getStroke(), externalImageList, process);
                                updateFill(resourceLocator, polygon.getFill(), externalImageList, process);
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) StyledLayer(org.geotools.styling.StyledLayer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) NamedLayerImpl(org.geotools.styling.NamedLayerImpl) Symbolizer(org.geotools.styling.Symbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) PointSymbolizer(org.geotools.styling.PointSymbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) 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) UserLayer(org.geotools.styling.UserLayer) NamedLayer(org.geotools.styling.NamedLayer)

Example 52 with Symbolizer

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

the class SelectedSymbol method addImageOutlineSymbolizerToRaster.

/**
 * Adds the symbolizer to raster.
 *
 * @param symbolizer the symbolizer
 */
public void addImageOutlineSymbolizerToRaster(Symbolizer symbolizer) {
    Symbolizer selectedSymbolizer = this.symbolData.getSymbolizer();
    if (selectedSymbolizer == null) {
        ConsoleManager.getInstance().error(this, "symbolizer == null");
    } else {
        if (selectedSymbolizer instanceof RasterSymbolizer) {
            RasterSymbolizer rasterSymbolizer = (RasterSymbolizer) selectedSymbolizer;
            rasterSymbolizer.setImageOutline(symbolizer);
        }
    }
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer) Symbolizer(org.geotools.styling.Symbolizer) RasterSymbolizer(org.geotools.styling.RasterSymbolizer)

Example 53 with Symbolizer

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

the class SelectedSymbol method replaceSymbolizer.

/**
 * Replace symbolizer.
 *
 * @param newSymbolizer the new symbolizer
 */
public void replaceSymbolizer(Symbolizer newSymbolizer) {
    if (this.symbolData != null) {
        if (this.symbolData.getRule() != null) {
            List<Symbolizer> symbolizerList = (List<Symbolizer>) this.symbolData.getRule().symbolizers();
            Symbolizer oldSymbolizer = null;
            int indexFound = -1;
            int index = 0;
            for (Symbolizer symbolizer : symbolizerList) {
                if (symbolizer == this.symbolData.getSymbolizer()) {
                    indexFound = index;
                    oldSymbolizer = symbolizer;
                    break;
                } else {
                    index++;
                }
            }
            if (indexFound > -1) {
                symbolizerList.remove(indexFound);
                symbolizerList.add(indexFound, newSymbolizer);
                setSymbolizer(newSymbolizer);
            }
            for (SLDTreeUpdatedInterface listener : treeUpdateListenerList) {
                listener.updateNode(oldSymbolizer, newSymbolizer);
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Symbolizer(org.geotools.styling.Symbolizer) RasterSymbolizer(org.geotools.styling.RasterSymbolizer)

Example 54 with Symbolizer

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

the class SelectedSymbol method removeSymbolizer.

/**
 * Removes the symbolizer.
 *
 * @param symbolizerToDelete the symbolizer to delete
 */
public void removeSymbolizer(Symbolizer symbolizerToDelete) {
    List<Symbolizer> symbolizerList = (List<Symbolizer>) this.symbolData.getRule().symbolizers();
    int indexFound = -1;
    int index = 0;
    for (Symbolizer symbolizer : symbolizerList) {
        if (symbolizer == symbolizerToDelete) {
            indexFound = index;
            break;
        } else {
            index++;
        }
    }
    if (indexFound > -1) {
        symbolizerList.remove(indexFound);
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Symbolizer(org.geotools.styling.Symbolizer) RasterSymbolizer(org.geotools.styling.RasterSymbolizer)

Example 55 with Symbolizer

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

the class StyleDetails method updateSymbol.

/**
 * Update symbol.
 */
private void updateSymbol() {
    if (!Controller.getInstance().isPopulating()) {
        StandardData standardData = getStandardData();
        boolean isDefault = fieldConfigVisitor.getBoolean(FieldIdEnum.DEFAULT_STYLE);
        Style existingStyle = SelectedSymbol.getInstance().getStyle();
        if (existingStyle != null) {
            List<org.opengis.style.FeatureTypeStyle> newFTSList = new ArrayList<org.opengis.style.FeatureTypeStyle>();
            for (org.opengis.style.FeatureTypeStyle fts : existingStyle.featureTypeStyles()) {
                newFTSList.add(fts);
            }
            Symbolizer defaultSymbolizer = null;
            Style newStyle = (Style) getStyleFactory().style(standardData.name, standardData.description, isDefault, newFTSList, defaultSymbolizer);
            SelectedSymbol.getInstance().replaceStyle(newStyle);
            this.fireUpdateSymbol();
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Style(org.geotools.styling.Style) Symbolizer(org.geotools.styling.Symbolizer)

Aggregations

Symbolizer (org.geotools.styling.Symbolizer)65 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)30 LineSymbolizer (org.geotools.styling.LineSymbolizer)29 PointSymbolizer (org.geotools.styling.PointSymbolizer)28 Rule (org.geotools.styling.Rule)22 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)20 Style (org.geotools.styling.Style)19 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)16 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)15 TextSymbolizer (org.geotools.styling.TextSymbolizer)15 StyledLayer (org.geotools.styling.StyledLayer)12 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)12 JsonObject (com.google.gson.JsonObject)11 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)10 NamedLayer (org.geotools.styling.NamedLayer)8 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)8 JsonElement (com.google.gson.JsonElement)7 Stroke (org.geotools.styling.Stroke)6 JsonArray (com.google.gson.JsonArray)5