Search in sources :

Example 11 with UserLayerImpl

use of org.geotools.styling.UserLayerImpl 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 12 with UserLayerImpl

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

the class SLDUtils method findEquivalentSymbolizer.

/**
 * Find equivalent symbolizer in another SLD.
 *
 * @param otherSLD the other SLD
 * @param styledLayerIndex the styled layer index
 * @param isNamedLayer the is named layer
 * @param styleIndex the style index
 * @param ftsIndex the fts index
 * @param ruleIndex the rule index
 * @param symbolizerIndex the symbolizer index
 * @return the symbolizer
 */
private static Symbolizer findEquivalentSymbolizer(StyledLayerDescriptor otherSLD, int styledLayerIndex, boolean isNamedLayer, int styleIndex, int ftsIndex, int ruleIndex, int symbolizerIndex) {
    if (otherSLD != null) {
        List<StyledLayer> styledLayerList = otherSLD.layers();
        if (styledLayerList != null) {
            try {
                StyledLayer styledLayer = styledLayerList.get(styledLayerIndex);
                List<Style> styleList = null;
                if (isNamedLayer) {
                    NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
                    styleList = namedLayerImpl.styles();
                } else {
                    UserLayerImpl userLayerImpl = (UserLayerImpl) styledLayer;
                    styleList = userLayerImpl.userStyles();
                }
                if (styleList != null) {
                    Style style = styleList.get(styleIndex);
                    FeatureTypeStyle fts = style.featureTypeStyles().get(ftsIndex);
                    Rule rule = fts.rules().get(ruleIndex);
                    return rule.symbolizers().get(symbolizerIndex);
                }
            } catch (IndexOutOfBoundsException exception) {
            // Do nothing
            }
        }
    }
    return null;
}
Also used : UserLayerImpl(org.geotools.styling.UserLayerImpl) StyledLayer(org.geotools.styling.StyledLayer) NamedLayerImpl(org.geotools.styling.NamedLayerImpl) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule)

Example 13 with UserLayerImpl

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

the class SLDUtils method findEquivalentRule.

/**
 * Find equivalent rule.
 *
 * @param otherSLD the other SLD
 * @param styledLayerIndex the styled layer index
 * @param isNamedLayer the is named layer
 * @param styleIndex the style index
 * @param ftsIndex the fts index
 * @param ruleIndex the rule index
 * @return the rule
 */
private static Rule findEquivalentRule(StyledLayerDescriptor otherSLD, int styledLayerIndex, boolean isNamedLayer, int styleIndex, int ftsIndex, int ruleIndex) {
    if (otherSLD != null) {
        List<StyledLayer> styledLayerList = otherSLD.layers();
        if (styledLayerList != null) {
            try {
                StyledLayer styledLayer = styledLayerList.get(styledLayerIndex);
                List<Style> styleList = null;
                if (isNamedLayer) {
                    NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
                    styleList = namedLayerImpl.styles();
                } else {
                    UserLayerImpl userLayerImpl = (UserLayerImpl) styledLayer;
                    styleList = userLayerImpl.userStyles();
                }
                if (styleList != null) {
                    Style style = styleList.get(styleIndex);
                    FeatureTypeStyle fts = style.featureTypeStyles().get(ftsIndex);
                    return fts.rules().get(ruleIndex);
                }
            } catch (IndexOutOfBoundsException exception) {
            // Do nothing
            }
        }
    }
    return null;
}
Also used : UserLayerImpl(org.geotools.styling.UserLayerImpl) StyledLayer(org.geotools.styling.StyledLayer) NamedLayerImpl(org.geotools.styling.NamedLayerImpl) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle)

Example 14 with UserLayerImpl

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

the class SLDUtils method findSymbolizer.

/**
 * Find symbolizer.
 *
 * @param sld the sld
 * @param symbolizerToFind the symbolizer to find
 * @param otherSLD the other SLD
 * @return the symbolizer
 */
public static Symbolizer findSymbolizer(StyledLayerDescriptor sld, Symbolizer symbolizerToFind, StyledLayerDescriptor otherSLD) {
    List<StyledLayer> styledLayerList = sld.layers();
    if (styledLayerList != null) {
        int styledLayerIndex = 0;
        int styleIndex = 0;
        int ftsIndex = 0;
        int ruleIndex = 0;
        int symbolizerIndex = 0;
        boolean isNamedLayer = true;
        for (StyledLayer styledLayer : styledLayerList) {
            List<Style> styleList = null;
            if (styledLayer instanceof NamedLayerImpl) {
                NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
                styleList = namedLayerImpl.styles();
                isNamedLayer = true;
            } else if (styledLayer instanceof UserLayerImpl) {
                UserLayerImpl userLayerImpl = (UserLayerImpl) styledLayer;
                styleList = userLayerImpl.userStyles();
                isNamedLayer = false;
            }
            if (styleList != null) {
                styleIndex = 0;
                for (Style style : styleList) {
                    ftsIndex = 0;
                    for (FeatureTypeStyle fts : style.featureTypeStyles()) {
                        ruleIndex = 0;
                        for (Rule rule : fts.rules()) {
                            symbolizerIndex = 0;
                            for (org.opengis.style.Symbolizer symbolizer : rule.symbolizers()) {
                                if (symbolizer == symbolizerToFind) {
                                    return findEquivalentSymbolizer(otherSLD, styledLayerIndex, isNamedLayer, styleIndex, ftsIndex, ruleIndex, symbolizerIndex);
                                }
                                symbolizerIndex++;
                            }
                            ruleIndex++;
                        }
                        ftsIndex++;
                    }
                    styleIndex++;
                }
            }
            styledLayerIndex++;
        }
    }
    return null;
}
Also used : StyledLayer(org.geotools.styling.StyledLayer) NamedLayerImpl(org.geotools.styling.NamedLayerImpl) UserLayerImpl(org.geotools.styling.UserLayerImpl) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule)

Example 15 with UserLayerImpl

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

the class SelectedSymbol method removeStyle.

/**
 * Removes the style.
 *
 * @param styleToDelete the style to delete
 */
public void removeStyle(Style styleToDelete) {
    List<Style> styleList = null;
    if (this.symbolData.getStyledLayer() instanceof NamedLayerImpl) {
        NamedLayerImpl namedLayer = (NamedLayerImpl) this.symbolData.getStyledLayer();
        styleList = namedLayer.styles();
    } else if (this.symbolData.getStyledLayer() instanceof UserLayerImpl) {
        UserLayerImpl userLayer = (UserLayerImpl) this.symbolData.getStyledLayer();
        styleList = userLayer.userStyles();
    }
    if (styleList != null) {
        int indexFound = -1;
        int index = 0;
        for (Style style : styleList) {
            if (style == styleToDelete) {
                indexFound = index;
                break;
            } else {
                index++;
            }
        }
        if (indexFound > -1) {
            styleList.remove(indexFound);
        }
    }
}
Also used : UserLayerImpl(org.geotools.styling.UserLayerImpl) NamedLayerImpl(org.geotools.styling.NamedLayerImpl) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle)

Aggregations

UserLayerImpl (org.geotools.styling.UserLayerImpl)21 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)18 Style (org.geotools.styling.Style)18 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)17 StyledLayer (org.geotools.styling.StyledLayer)16 Rule (org.geotools.styling.Rule)10 Symbolizer (org.geotools.styling.Symbolizer)5 LineSymbolizer (org.geotools.styling.LineSymbolizer)3 PointSymbolizer (org.geotools.styling.PointSymbolizer)3 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)3 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)3 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)3 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)2 MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)2 FeatureTypeConstraint (org.geotools.styling.FeatureTypeConstraint)2 RemoteOWS (org.geotools.styling.RemoteOWS)2 UserLayer (org.geotools.styling.UserLayer)2 SelectedSymbol (com.sldeditor.common.data.SelectedSymbol)1 DataSourceInterface (com.sldeditor.datasource.DataSourceInterface)1 OptionGroup (com.sldeditor.ui.detail.config.base.OptionGroup)1