Search in sources :

Example 41 with FeatureTypeStyle

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

the class FeatureTypeStyleDetails method updateSymbol.

/**
 * Update symbol.
 */
private void updateSymbol() {
    if (!Controller.getInstance().isPopulating()) {
        StandardData standardData = getStandardData();
        Expression transformation = fieldConfigVisitor.getExpression(FieldIdEnum.TRANSFORMATION);
        FeatureTypeStyle existingFTS = SelectedSymbol.getInstance().getFeatureTypeStyle();
        if (existingFTS != null) {
            List<org.opengis.style.Rule> newRuleList = new ArrayList<org.opengis.style.Rule>();
            for (org.opengis.style.Rule rule : existingFTS.rules()) {
                newRuleList.add(rule);
            }
            FeatureTypeStyle fts = (FeatureTypeStyle) getStyleFactory().featureTypeStyle(standardData.name, (org.opengis.style.Description) standardData.description, existingFTS.getFeatureInstanceIDs(), existingFTS.featureTypeNames(), existingFTS.semanticTypeIdentifiers(), newRuleList);
            if (transformation != null) {
                fts.setTransformation(transformation);
            }
            if (vendorOptionFTSFactory != null) {
                vendorOptionFTSFactory.updateSymbol(fts);
            }
            SelectedSymbol.getInstance().replaceFeatureTypeStyle(fts);
            this.fireUpdateSymbol();
        }
    }
}
Also used : Expression(org.opengis.filter.expression.Expression) ArrayList(java.util.ArrayList) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle)

Example 42 with FeatureTypeStyle

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

the class VOGeoServerFTSComposite method getMinimumVersion.

/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.iface.PopulateDetailsInterface#getMinimumVersion(java.lang.Object,
     * java.util.List)
     */
@Override
public void getMinimumVersion(Object parentObj, Object sldObj, List<VendorOptionPresent> vendorOptionsPresentList) {
    if (sldObj instanceof FeatureTypeStyle) {
        FeatureTypeStyle fts = (FeatureTypeStyle) sldObj;
        Map<String, String> options = fts.getOptions();
        if (options.containsKey(FeatureTypeStyle.COMPOSITE)) {
            VendorOptionPresent voPresent = new VendorOptionPresent(sldObj, getVendorOptionInfo());
            vendorOptionsPresentList.add(voPresent);
        }
    }
}
Also used : VendorOptionPresent(com.sldeditor.common.vendoroption.minversion.VendorOptionPresent) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle)

Example 43 with FeatureTypeStyle

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

the class VOGeoServerFTSCompositeBase method getMinimumVersion.

/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.iface.PopulateDetailsInterface#getMinimumVersion(java.lang.Object,
     * java.util.List)
     */
@Override
public void getMinimumVersion(Object parentObj, Object sldObj, List<VendorOptionPresent> vendorOptionsPresentList) {
    if (sldObj instanceof FeatureTypeStyle) {
        FeatureTypeStyle fts = (FeatureTypeStyle) sldObj;
        Map<String, String> options = fts.getOptions();
        if (options.containsKey(FeatureTypeStyle.COMPOSITE_BASE)) {
            VendorOptionPresent voPresent = new VendorOptionPresent(sldObj, getVendorOptionInfo());
            vendorOptionsPresentList.add(voPresent);
        }
    }
}
Also used : VendorOptionPresent(com.sldeditor.common.vendoroption.minversion.VendorOptionPresent) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle)

Example 44 with FeatureTypeStyle

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

the class SLDTreeTools method removeItem.

/**
 * Removes the item.
 */
public void removeItem() {
    if (symbolTree == null) {
        return;
    }
    TreePath path = symbolTree.getSelectionPath();
    if (path == null) {
        return;
    }
    DefaultMutableTreeNode lastNode = (DefaultMutableTreeNode) path.getLastPathComponent();
    Object obj = lastNode.getUserObject();
    // CHECKSTYLE:OFF
    Object oldValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
    if (obj instanceof NamedLayer) {
        SelectedSymbol.getInstance().removeUserNamedLayer((NamedLayer) obj);
        removeTreeNode(lastNode);
    } else if (obj instanceof UserLayer) {
        SelectedSymbol.getInstance().removeUserNamedLayer((UserLayer) obj);
        removeTreeNode(lastNode);
    } else if (obj instanceof Style) {
        SelectedSymbol.getInstance().removeStyle((Style) obj);
        removeTreeNode(lastNode);
    } else if (obj instanceof FeatureTypeStyle) {
        SelectedSymbol.getInstance().removeFeatureTypeStyle((FeatureTypeStyle) obj);
        removeTreeNode(lastNode);
    } else if (obj instanceof Rule) {
        SelectedSymbol.getInstance().removeRule((Rule) obj);
        removeTreeNode(lastNode);
    } else if (obj instanceof Symbolizer) {
        DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) lastNode.getParent();
        if (parentNode != null) {
            if (parentNode.getUserObject() instanceof RasterSymbolizer) {
                SelectedSymbol.getInstance().removeRasterImageOutline((RasterSymbolizer) parentNode.getUserObject());
            } else {
                SelectedSymbol.getInstance().removeSymbolizer((Symbolizer) obj);
            }
            removeTreeNode(lastNode);
        }
    } else {
        return;
    }
    SLDTreeManager.getInstance().rebuildTree((SLDTree) sldTree);
    // Re-render the symbol
    if (renderList != null) {
        for (RenderSymbolInterface render : renderList) {
            render.renderSymbol();
        }
    }
    Object newValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
    UndoManager.getInstance().addUndoEvent(new UndoEvent(sldTree.getUndoObject(), getClass().getName(), oldValueObj, newValueObj));
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer) UndoEvent(com.sldeditor.common.undo.UndoEvent) TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) RenderSymbolInterface(com.sldeditor.datasource.RenderSymbolInterface) 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) 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 45 with FeatureTypeStyle

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

Aggregations

FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)110 Style (org.geotools.styling.Style)81 Rule (org.geotools.styling.Rule)65 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)43 Test (org.junit.Test)42 NamedLayer (org.geotools.styling.NamedLayer)38 PointSymbolizer (org.geotools.styling.PointSymbolizer)24 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)22 StyledLayer (org.geotools.styling.StyledLayer)21 LineSymbolizer (org.geotools.styling.LineSymbolizer)20 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)17 Symbolizer (org.geotools.styling.Symbolizer)16 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)15 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)14 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)12 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)12 TextSymbolizer (org.geotools.styling.TextSymbolizer)12 UserLayerImpl (org.geotools.styling.UserLayerImpl)12 ArrayList (java.util.ArrayList)11 LineStyle (org.polymap.core.style.model.feature.LineStyle)11