Search in sources :

Example 16 with UserLayerImpl

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

the class UserLayerDetails method updateSymbol.

/**
 * Update symbol.
 *
 * @param changedField the changed field
 */
private void updateSymbol(FieldIdEnum changedField) {
    if (!Controller.getInstance().isPopulating()) {
        UserLayer userLayer = getStyleFactory().createUserLayer();
        String name = fieldConfigVisitor.getText(FieldIdEnum.NAME);
        userLayer.setName(name);
        // Feature type constraints
        List<FeatureTypeConstraint> ftcList = fieldConfigVisitor.getFeatureTypeConstraint(FieldIdEnum.LAYER_FEATURE_CONSTRAINTS);
        if ((ftcList != null) && !ftcList.isEmpty()) {
            FeatureTypeConstraint[] ftcArray = new FeatureTypeConstraint[ftcList.size()];
            userLayer.setLayerFeatureConstraints(ftcList.toArray(ftcArray));
        }
        // Source
        GroupConfigInterface group = getGroup(GroupIdEnum.USER_LAYER_SOURCE);
        if (group != null) {
            MultiOptionGroup userLayerSourceGroup = (MultiOptionGroup) group;
            OptionGroup selectedOption = userLayerSourceGroup.getSelectedOptionGroup();
            switch(selectedOption.getId()) {
                case REMOTE_OWS_OPTION:
                    {
                        RemoteOWS remoteOWS = new RemoteOWSImpl();
                        String service = fieldConfigVisitor.getText(FieldIdEnum.REMOTE_OWS_SERVICE);
                        remoteOWS.setService(service);
                        String onlineResource = fieldConfigVisitor.getText(FieldIdEnum.REMOTE_OWS_ONLINERESOURCE);
                        remoteOWS.setOnlineResource(onlineResource);
                        userLayer.setRemoteOWS(remoteOWS);
                    }
                    break;
                case INLINE_FEATURE_OPTION:
                    {
                        String inlineFeatures = fieldConfigVisitor.getText(FieldIdEnum.INLINE_FEATURE);
                        if ((inlineFeatures != null) && (!inlineFeatures.isEmpty())) {
                            InlineFeatureUtils.setInlineFeatures(userLayer, inlineFeatures);
                        }
                    }
                    break;
                default:
                    break;
            }
        }
        StyledLayer existingStyledLayer = SelectedSymbol.getInstance().getStyledLayer();
        if (existingStyledLayer instanceof UserLayerImpl) {
            UserLayerImpl existingUserLayer = (UserLayerImpl) existingStyledLayer;
            for (Style style : existingUserLayer.userStyles()) {
                userLayer.addUserStyle(style);
            }
        }
        SelectedSymbol.getInstance().replaceStyledLayer(userLayer);
        // reduces creation of datasources
        if (changedField != null) {
            if (changedField == FieldIdEnum.INLINE_FEATURE) {
                DataSourceInterface dataSource = DataSourceFactory.getDataSource();
                if (dataSource != null) {
                    dataSource.updateUserLayers();
                }
            }
        }
        this.fireUpdateSymbol();
    }
}
Also used : RemoteOWS(org.geotools.styling.RemoteOWS) StyledLayer(org.geotools.styling.StyledLayer) RemoteOWSImpl(org.geotools.styling.RemoteOWSImpl) DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) OptionGroup(com.sldeditor.ui.detail.config.base.OptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) UserLayerImpl(org.geotools.styling.UserLayerImpl) Style(org.geotools.styling.Style) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) UserLayer(org.geotools.styling.UserLayer) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)

Example 17 with UserLayerImpl

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

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

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

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

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