Search in sources :

Example 11 with RasterSymbolizer

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

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

the class SLDTreeTools method addNewRaster.

/**
 * Adds the new raster symbolizer.
 */
public void addNewRaster() {
    if (symbolTree == null) {
        return;
    }
    // Store current state of the SLD before the add
    Object oldValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
    RasterSymbolizer newRasterSymbolizer = DefaultSymbols.createDefaultRasterSymbolizer();
    DefaultMutableTreeNode ruleNode = getRuleTreeNode();
    SelectedSymbol.getInstance().addSymbolizerToRule(newRasterSymbolizer);
    DefaultMutableTreeNode newNode = sldTree.addObject(ruleNode, newRasterSymbolizer, true);
    // Select the item just added
    if (newNode != null) {
        SLDTreeManager.getInstance().rebuildTree((SLDTree) sldTree);
        TreePath newPath = getPath(newNode);
        symbolTree.setSelectionPath(newPath);
        // Store current state of the SLD after the add
        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) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreePath(javax.swing.tree.TreePath)

Example 13 with RasterSymbolizer

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

Example 14 with RasterSymbolizer

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

the class SLDTree method handleRasterSymbolizer.

/**
 * Handle raster symbolizer.
 *
 * @param symbolizer the symbolizer
 * @param symbolizerTreeNode the symbolizer tree node
 */
private void handleRasterSymbolizer(Symbolizer symbolizer, DefaultMutableTreeNode symbolizerTreeNode) {
    // Handle the image outline symbolizer for raster symbols
    Symbolizer outlineSymbolizer = ((RasterSymbolizer) symbolizer).getImageOutline();
    if (outlineSymbolizer instanceof LineSymbolizer) {
        LineSymbolizer outlineLineSymbolizer = (LineSymbolizer) outlineSymbolizer;
        if (outlineLineSymbolizer != null) {
            DefaultMutableTreeNode symbolizerImageOutlineLineNode = addObject(symbolizerTreeNode, outlineLineSymbolizer, true);
            addObject(symbolizerImageOutlineLineNode, SLDTreeLeafFactory.getInstance().getStroke(outlineLineSymbolizer), true);
        }
    } else if (outlineSymbolizer instanceof PolygonSymbolizer) {
        PolygonSymbolizer outlinePolygonSymbolizer = (PolygonSymbolizer) outlineSymbolizer;
        if (outlinePolygonSymbolizer != null) {
            DefaultMutableTreeNode symbolizerImageOutlinePolygonNode = addObject(symbolizerTreeNode, outlinePolygonSymbolizer, true);
            addObject(symbolizerImageOutlinePolygonNode, SLDTreeLeafFactory.getInstance().getFill(outlinePolygonSymbolizer), true);
            addObject(symbolizerImageOutlinePolygonNode, SLDTreeLeafFactory.getInstance().getStroke(outlinePolygonSymbolizer), true);
        }
    }
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) 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)

Example 15 with RasterSymbolizer

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

the class SLDTreeSymbolizerButtonState method isImageOutlineLineVisible.

/**
 * Checks if image outline line button is visible.
 *
 * @param parentObj the parent obj
 * @param obj the obj
 * @return true, if is image outline line visible
 */
public boolean isImageOutlineLineVisible(Object parentObj, Object obj) {
    boolean enabled = false;
    if (overallEnableSymbolizersOverride) {
        if (obj instanceof RasterSymbolizer) {
            RasterSymbolizer raster = (RasterSymbolizer) obj;
            enabled = (raster.getImageOutline() == null) && (geometryType == GeometryTypeEnum.RASTER);
        }
    }
    return enabled;
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer)

Aggregations

RasterSymbolizer (org.geotools.styling.RasterSymbolizer)29 Test (org.junit.Test)12 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)10 Rule (org.geotools.styling.Rule)10 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)10 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)9 Style (org.geotools.styling.Style)9 RasterSymbolizerDetails (com.sldeditor.ui.detail.RasterSymbolizerDetails)7 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)7 MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)7 ChannelSelection (org.geotools.styling.ChannelSelection)7 LineSymbolizer (org.geotools.styling.LineSymbolizer)7 PointSymbolizer (org.geotools.styling.PointSymbolizer)7 NamedLayer (org.geotools.styling.NamedLayer)6 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)6 Symbolizer (org.geotools.styling.Symbolizer)6 Box (javax.swing.Box)5 FilterFactory (org.opengis.filter.FilterFactory)5 MalformedURLException (java.net.MalformedURLException)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4