Search in sources :

Example 21 with NamedLayerImpl

use of org.geotools.styling.NamedLayerImpl 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)

Example 22 with NamedLayerImpl

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

the class RenderSymbol method getRenderStyle.

/**
 * Gets the render style.
 *
 * @param selectedSymbol the selected symbol
 * @return the render style
 */
public Style getRenderStyle(SelectedSymbol selectedSymbol) {
    List<StyledLayer> styledLayerList = selectedSymbol.getSld().layers();
    for (StyledLayer styledLayer : styledLayerList) {
        List<Style> styleList = null;
        if (styledLayer instanceof NamedLayerImpl) {
            NamedLayerImpl namedLayer = (NamedLayerImpl) styledLayer;
            styleList = namedLayer.styles();
        } else if (styledLayer instanceof UserLayerImpl) {
            UserLayerImpl userLayer = (UserLayerImpl) styledLayer;
            styleList = userLayer.userStyles();
        }
        if (styleList != null) {
            for (Style style : styleList) {
                FeatureTypeStyle ftsToRender = selectedSymbol.getFeatureTypeStyle();
                Rule ruleToRender = selectedSymbol.getRule();
                // Check to see if style contains the rule to render
                if (shouldRenderSymbol(style, ftsToRender, ruleToRender)) {
                    return renderSymbol(style, ftsToRender, ruleToRender, renderOptions);
                }
            }
        }
    }
    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 23 with NamedLayerImpl

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

the class MapRender method internalRenderStyle.

/**
 * Internal render style.
 */
private void internalRenderStyle() {
    if (!underTest) {
        if (hasError()) {
            mapPane.resetRenderer();
            mapPane.getRenderer().addRenderListener(this);
            resetError();
        }
        wmsEnvVarValues.setImageWidth(mapPane.getWidth());
        wmsEnvVarValues.setImageHeight(mapPane.getHeight());
        MapContent mapContent = mapPane.getMapContent();
        if (mapContent == null) {
            mapContent = new MapContent();
            mapPane.setMapContent(mapContent);
        }
        Map<Object, Object> hints = new HashMap<Object, Object>();
        clearLabelCache();
        hints.put(StreamingRenderer.LABEL_CACHE_KEY, labelCache);
        mapPane.getRenderer().setRendererHints(hints);
        // Add the layers back with the updated style
        StyledLayerDescriptor sld = SelectedSymbol.getInstance().getSld();
        if (sld != null) {
            List<StyledLayer> styledLayerList = sld.layers();
            for (StyledLayer styledLayer : styledLayerList) {
                List<org.geotools.styling.Style> styleList = null;
                if (styledLayer instanceof NamedLayerImpl) {
                    NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
                    styleList = namedLayerImpl.styles();
                } else if (styledLayer instanceof UserLayerImpl) {
                    UserLayerImpl userLayerImpl = (UserLayerImpl) styledLayer;
                    styleList = userLayerImpl.userStyles();
                }
                if (styleList != null) {
                    for (Style style : styleList) {
                        renderSymbol(mapContent, styledLayer, style);
                    }
                }
            }
        }
    }
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) UserLayerImpl(org.geotools.styling.UserLayerImpl) MapContent(org.geotools.map.MapContent) HashMap(java.util.HashMap) StyledLayer(org.geotools.styling.StyledLayer) NamedLayerImpl(org.geotools.styling.NamedLayerImpl) Style(org.opengis.style.Style)

Example 24 with NamedLayerImpl

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

the class LegendManager method createSingleStyleLegend.

/**
 * Creates the legend for a single SLD style.
 *
 * @param styleMap the style map
 * @param selectedStyledLayer the selected styled layer
 * @param selectedStyle the selected style
 */
private void createSingleStyleLegend(Map<String, Style> styleMap, StyledLayer selectedStyledLayer, Style selectedStyle) {
    // A style has been selected
    List<Style> styleList = null;
    if (selectedStyledLayer instanceof NamedLayerImpl) {
        NamedLayerImpl namedLayer = (NamedLayerImpl) selectedStyledLayer;
        styleList = namedLayer.styles();
    } else if (selectedStyledLayer instanceof UserLayerImpl) {
        UserLayerImpl userLayer = (UserLayerImpl) selectedStyledLayer;
        styleList = userLayer.userStyles();
    }
    String styleName;
    if (selectedStyle.getName() != null) {
        styleName = selectedStyle.getName();
    } else {
        styleName = String.format("Style %d", styleList.indexOf(selectedStyle));
    }
    styleMap.put(styleName, selectedStyle);
}
Also used : UserLayerImpl(org.geotools.styling.UserLayerImpl) NamedLayerImpl(org.geotools.styling.NamedLayerImpl) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle)

Example 25 with NamedLayerImpl

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

the class LegendManager method createMultipleStyleLegend.

/**
 * Creates the legend for multiple SLD styles.
 *
 * @param sld the sld
 * @param styleMap the style map
 * @param selectedStyledLayer the selected styled layer
 */
private void createMultipleStyleLegend(StyledLayerDescriptor sld, Map<String, Style> styleMap, StyledLayer selectedStyledLayer) {
    List<StyledLayer> styledLayerList = null;
    if (selectedStyledLayer == null) {
        styledLayerList = sld.layers();
    } else {
        styledLayerList = new ArrayList<StyledLayer>();
        styledLayerList.add(selectedStyledLayer);
    }
    for (StyledLayer styledLayer : styledLayerList) {
        List<Style> styleList = null;
        if (styledLayer instanceof NamedLayerImpl) {
            NamedLayerImpl namedLayer = (NamedLayerImpl) styledLayer;
            styleList = namedLayer.styles();
        } else if (styledLayer instanceof UserLayerImpl) {
            UserLayerImpl userLayer = (UserLayerImpl) styledLayer;
            styleList = userLayer.userStyles();
        }
        if (styleList != null) {
            int count = 1;
            for (Style style : styleList) {
                String styleName;
                if (style.getName() != null) {
                    styleName = style.getName();
                } else {
                    styleName = String.format("Style %d", count);
                }
                styleMap.put(styleName, style);
                count++;
            }
        }
    }
}
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)

Aggregations

NamedLayerImpl (org.geotools.styling.NamedLayerImpl)28 Style (org.geotools.styling.Style)24 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)22 StyledLayer (org.geotools.styling.StyledLayer)22 UserLayerImpl (org.geotools.styling.UserLayerImpl)18 Rule (org.geotools.styling.Rule)16 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)10 Symbolizer (org.geotools.styling.Symbolizer)8 LineSymbolizer (org.geotools.styling.LineSymbolizer)5 PointSymbolizer (org.geotools.styling.PointSymbolizer)5 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)5 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)5 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 TextSymbolizer (org.geotools.styling.TextSymbolizer)3 Test (org.junit.Test)3 RenderSymbolInterface (com.sldeditor.datasource.RenderSymbolInterface)2 ArrayList (java.util.ArrayList)2 FeatureTypeConstraint (org.geotools.styling.FeatureTypeConstraint)2 NamedLayer (org.geotools.styling.NamedLayer)2 TreeSelectionData (com.sldeditor.TreeSelectionData)1