Search in sources :

Example 11 with StyledLayer

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

the class UserLayerDetails method populate.

/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.SelectedSymbol)
     */
@Override
public void populate(SelectedSymbol selectedSymbol) {
    if (selectedSymbol != null) {
        StyledLayer styledLayer = selectedSymbol.getStyledLayer();
        if (styledLayer instanceof UserLayerImpl) {
            UserLayerImpl userLayer = (UserLayerImpl) styledLayer;
            fieldConfigVisitor.populateTextField(FieldIdEnum.NAME, userLayer.getName());
            // Feature layer constraint
            List<FeatureTypeConstraint> ftcList = userLayer.layerFeatureConstraints();
            fieldConfigVisitor.populateFieldTypeConstraint(FieldIdEnum.LAYER_FEATURE_CONSTRAINTS, ftcList);
            // Source
            GroupConfigInterface group = getGroup(GroupIdEnum.USER_LAYER_SOURCE);
            if (group != null) {
                MultiOptionGroup userLayerSourceGroup = (MultiOptionGroup) group;
                if (userLayer.getInlineFeatureDatastore() == null) {
                    userLayerSourceGroup.setOption(GroupIdEnum.REMOTE_OWS_OPTION);
                    // Remote OWS
                    String service = "";
                    String onlineResource = "";
                    RemoteOWS remoteOWS = userLayer.getRemoteOWS();
                    if (remoteOWS != null) {
                        service = remoteOWS.getService();
                        onlineResource = remoteOWS.getOnlineResource();
                    }
                    fieldConfigVisitor.populateTextField(FieldIdEnum.REMOTE_OWS_SERVICE, service);
                    fieldConfigVisitor.populateTextField(FieldIdEnum.REMOTE_OWS_ONLINERESOURCE, onlineResource);
                } else {
                    userLayerSourceGroup.setOption(GroupIdEnum.INLINE_FEATURE_OPTION);
                    // Inline features
                    fieldConfigVisitor.populateUserLayer(FieldIdEnum.INLINE_FEATURE, userLayer);
                }
            }
        }
    }
}
Also used : RemoteOWS(org.geotools.styling.RemoteOWS) UserLayerImpl(org.geotools.styling.UserLayerImpl) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) StyledLayer(org.geotools.styling.StyledLayer) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)

Example 12 with StyledLayer

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

the class InlineFeatureUtils method extractUserLayers.

/**
 * Extract user layers from an SLD.
 *
 * @param sld the sld
 * @return the list of user layers
 */
public static List<UserLayer> extractUserLayers(StyledLayerDescriptor sld) {
    List<UserLayer> userLayerList = new ArrayList<UserLayer>();
    if (sld != null) {
        for (StyledLayer layer : sld.layers()) {
            if (layer instanceof UserLayer) {
                UserLayer userLayer = (UserLayer) layer;
                userLayerList.add(userLayer);
            }
        }
    }
    return userLayerList;
}
Also used : StyledLayer(org.geotools.styling.StyledLayer) ArrayList(java.util.ArrayList) UserLayer(org.geotools.styling.UserLayer)

Example 13 with StyledLayer

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

the class SLDTreeTools method setButtonState.

/**
 * Sets the buttons state.
 *
 * @param parentNode the parent node
 * @param selectedNode the new button state
 * @param currentGeometryType the current geometry type
 */
public void setButtonState(DefaultMutableTreeNode parentNode, DefaultMutableTreeNode selectedNode, GeometryTypeEnum currentGeometryType) {
    boolean addButtonEnabled = true;
    boolean removeButtonEnabled = true;
    boolean addNamedLayerButtonEnabled = false;
    boolean addUserLayerButtonEnabled = false;
    boolean showMoveButtons = true;
    boolean hasMoreThan1Item = false;
    boolean isFirstSelected = false;
    boolean isLastSelected = false;
    boolean showLineArrowButtons = false;
    symbolizerButtonState.setGeometryType(currentGeometryType);
    Object obj = null;
    Object parentObj = null;
    if (selectedNode != null) {
        obj = selectedNode.getUserObject();
        if (parentNode != null) {
            parentObj = parentNode.getUserObject();
        }
        if (obj instanceof StyledLayerDescriptor) {
            addNamedLayerButtonEnabled = true;
            addUserLayerButtonEnabled = true;
            addButtonEnabled = false;
        } else if (obj instanceof StyledLayer) {
            if (parentObj != null) {
                StyledLayerDescriptor sld = (StyledLayerDescriptor) parentObj;
                hasMoreThan1Item = sld.layers().size() > 1;
                isFirstSelected = (obj == sld.layers().get(0));
                isLastSelected = (obj == sld.layers().get(sld.layers().size() - 1));
            }
        } else if (obj instanceof Style) {
            if (parentObj != null) {
                if (parentObj instanceof NamedLayerImpl) {
                    NamedLayerImpl namedLayer = (NamedLayerImpl) parentObj;
                    hasMoreThan1Item = namedLayer.styles().size() > 1;
                    isFirstSelected = (obj == namedLayer.styles().get(0));
                    isLastSelected = (obj == namedLayer.styles().get(namedLayer.styles().size() - 1));
                }
            }
        } else if (obj instanceof FeatureTypeStyle) {
            if (parentObj != null) {
                Style style = (Style) parentObj;
                hasMoreThan1Item = style.featureTypeStyles().size() > 1;
                isFirstSelected = (obj == style.featureTypeStyles().get(0));
                isLastSelected = (obj == style.featureTypeStyles().get(style.featureTypeStyles().size() - 1));
            }
        } else if (obj instanceof Rule) {
            symbolizerButtonState.showSymbolizerButtons();
            addButtonEnabled = false;
            if (parentObj != null) {
                FeatureTypeStyle fts = (FeatureTypeStyle) parentObj;
                hasMoreThan1Item = fts.rules().size() > 1;
                isFirstSelected = (obj == fts.rules().get(0));
                isLastSelected = (obj == fts.rules().get(fts.rules().size() - 1));
            }
        } else if (obj instanceof Symbolizer) {
            symbolizerButtonState.showSymbolizerButtons();
            addButtonEnabled = false;
            if (parentObj != null) {
                if (parentObj instanceof Rule) {
                    Rule rule = (Rule) parentObj;
                    hasMoreThan1Item = rule.symbolizers().size() > 1;
                    isFirstSelected = (obj == rule.symbolizers().get(0));
                    isLastSelected = (obj == rule.symbolizers().get(rule.symbolizers().size() - 1));
                }
            }
            showLineArrowButtons = (obj instanceof LineSymbolizer);
        } else {
            addButtonEnabled = false;
            removeButtonEnabled = false;
            showMoveButtons = false;
        }
    }
    btnAddNamedLayerButton.setVisible(addNamedLayerButtonEnabled);
    btnAddUserLayerButton.setVisible(addUserLayerButtonEnabled);
    btnAddButton.setVisible(addButtonEnabled);
    // All symbolizer types are allowed be added to an SLD
    boolean allSymbolizer = symbolizerButtonState.isMarkerVisible(parentObj, obj) || symbolizerButtonState.isLineVisible(parentObj, obj) || symbolizerButtonState.isPolygonVisible(parentObj, obj) || symbolizerButtonState.isRasterVisible(parentObj, obj);
    btnNewMarker.setVisible(allSymbolizer);
    btnNewLine.setVisible(allSymbolizer);
    btnNewImageOutlineLine.setVisible(symbolizerButtonState.isImageOutlineLineVisible(parentObj, obj));
    btnNewPolygon.setVisible(allSymbolizer);
    btnNewImageOutlinePolygon.setVisible(symbolizerButtonState.isImageOutlinePolygonVisible(parentObj, obj));
    btnNewRaster.setVisible(allSymbolizer);
    btnNewText.setVisible(symbolizerButtonState.isTextVisible(parentObj, obj));
    btnRemoveMarker.setVisible(removeButtonEnabled);
    // Up / down buttons
    btnMoveUp.setVisible(showMoveButtons);
    btnMoveUp.setEnabled(hasMoreThan1Item && !isFirstSelected);
    btnMoveDown.setVisible(showMoveButtons);
    btnMoveDown.setEnabled(hasMoreThan1Item && !isLastSelected);
    btnSourceArrowButton.setVisible(showLineArrowButtons);
    btnDestArrowButton.setVisible(showLineArrowButtons);
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) StyledLayer(org.geotools.styling.StyledLayer) NamedLayerImpl(org.geotools.styling.NamedLayerImpl) 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) LineSymbolizer(org.geotools.styling.LineSymbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Symbolizer(org.geotools.styling.Symbolizer) PointSymbolizer(org.geotools.styling.PointSymbolizer) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) TextSymbolizer(org.geotools.styling.TextSymbolizer)

Example 14 with StyledLayer

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

the class NameLayerTreeItem method itemSelected.

/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.tree.item.SLDTreeItemInterface#itemSelected(javax.swing.tree.DefaultMutableTreeNode, java.lang.Object)
     */
@Override
public void itemSelected(DefaultMutableTreeNode node, Object userObject) {
    StyledLayer styledLayer = (StyledLayer) userObject;
    SelectedSymbol.getInstance().setStyledLayer(styledLayer);
}
Also used : StyledLayer(org.geotools.styling.StyledLayer)

Example 15 with StyledLayer

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

Aggregations

StyledLayer (org.geotools.styling.StyledLayer)43 Style (org.geotools.styling.Style)28 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)25 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)22 Rule (org.geotools.styling.Rule)19 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)19 UserLayerImpl (org.geotools.styling.UserLayerImpl)16 Symbolizer (org.geotools.styling.Symbolizer)12 NamedLayer (org.geotools.styling.NamedLayer)10 Test (org.junit.Test)10 PointSymbolizer (org.geotools.styling.PointSymbolizer)9 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)7 LineSymbolizer (org.geotools.styling.LineSymbolizer)6 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)5 IOException (java.io.IOException)4 FeatureTypeConstraint (org.geotools.styling.FeatureTypeConstraint)4 SLDData (com.sldeditor.common.data.SLDData)3 ArrayList (java.util.ArrayList)3 UserLayer (org.geotools.styling.UserLayer)3 SelectedSymbol (com.sldeditor.common.data.SelectedSymbol)2