Search in sources :

Example 16 with NamedLayer

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

the class DefaultSymbols method createNewRaster.

/**
 * Creates the new raster symbol.
 *
 * @return the styled layer descriptor
 */
public static StyledLayerDescriptor createNewRaster() {
    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
    NamedLayer namedLayer = styleFactory.createNamedLayer();
    sld.addStyledLayer(namedLayer);
    Style style = styleFactory.createStyle();
    namedLayer.addStyle(style);
    List<FeatureTypeStyle> ftsList = style.featureTypeStyles();
    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
    ftsList.add(fts);
    Rule rule = styleFactory.createRule();
    fts.rules().add(rule);
    RasterSymbolizer raster = createDefaultRasterSymbolizer();
    rule.symbolizers().add(raster);
    return sld;
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer)

Example 17 with NamedLayer

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

the class NewRasterSLD method create.

/**
 * Creates the symbol.
 *
 * @return the styled layer descriptor
 */
/* (non-Javadoc)
     * @see com.sldeditor.create.NewSLDInterface#create()
     */
@Override
public StyledLayerDescriptor create() {
    StyledLayerDescriptor sld = getStyleFactory().createStyledLayerDescriptor();
    NamedLayer namedLayer = getStyleFactory().createNamedLayer();
    sld.addStyledLayer(namedLayer);
    Style style = getStyleFactory().createStyle();
    namedLayer.addStyle(style);
    List<FeatureTypeStyle> ftsList = style.featureTypeStyles();
    FeatureTypeStyle fts = getStyleFactory().createFeatureTypeStyle();
    ftsList.add(fts);
    Rule rule = getStyleFactory().createRule();
    fts.rules().add(rule);
    RasterSymbolizer raster = DefaultSymbols.createDefaultRasterSymbolizer();
    rule.symbolizers().add(raster);
    return sld;
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer)

Example 18 with NamedLayer

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

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

the class SLDTreeTools method addNewThing.

/**
 * Adds the new thing.
 *
 * @param hint the hint when the are multiple possibilities
 */
public void addNewThing(Class<?> hint) {
    if (symbolTree == null) {
        return;
    }
    TreePath path = symbolTree.getSelectionPath();
    if (path == null) {
        return;
    }
    DefaultMutableTreeNode lastNode = (DefaultMutableTreeNode) path.getLastPathComponent();
    DefaultMutableTreeNode newNode = null;
    Object obj = lastNode.getUserObject();
    // Store current state of the SLD before the add
    Object oldValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
    if (obj instanceof String) {
        StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
        SelectedSymbol.getInstance().createNewSLD(sld);
        if (hint == NamedLayer.class) {
            NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
            SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
            newNode = sldTree.addObject(lastNode, namedLayer, true);
        } else if (hint == UserLayer.class) {
            UserLayer userLayer = DefaultSymbols.createNewUserLayer();
            SelectedSymbol.getInstance().addNewStyledLayer(userLayer);
            newNode = sldTree.addObject(lastNode, userLayer, true);
        }
    } else if (obj instanceof StyledLayerDescriptor) {
        if (hint == NamedLayer.class) {
            NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
            SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
            newNode = sldTree.addObject(lastNode, namedLayer, true);
        } else if (hint == UserLayer.class) {
            UserLayer userLayer = DefaultSymbols.createNewUserLayer();
            SelectedSymbol.getInstance().addNewStyledLayer(userLayer);
            newNode = sldTree.addObject(lastNode, userLayer, true);
        }
    } else if (obj instanceof NamedLayer) {
        Style style = DefaultSymbols.createNewStyle();
        SelectedSymbol.getInstance().addNewStyle(style);
        newNode = sldTree.addObject(lastNode, style, true);
    } else if (obj instanceof UserLayer) {
        Style style = DefaultSymbols.createNewStyle();
        SelectedSymbol.getInstance().addNewStyle(style);
        newNode = sldTree.addObject(lastNode, style, true);
    } else if (obj instanceof Style) {
        FeatureTypeStyle featureTypeStyle = DefaultSymbols.createNewFeatureTypeStyle();
        SelectedSymbol.getInstance().addNewFeatureTypeStyle(featureTypeStyle);
        newNode = sldTree.addObject(lastNode, featureTypeStyle, true);
    } else if (obj instanceof FeatureTypeStyle) {
        Rule rule = DefaultSymbols.createNewRule();
        SelectedSymbol.getInstance().addNewRule(rule);
        newNode = sldTree.addObject(lastNode, rule, 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 : UndoEvent(com.sldeditor.common.undo.UndoEvent) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) 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)

Example 20 with NamedLayer

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

the class SLDExternalImagesTest method createTestPoint.

/**
 * Creates the test point.
 *
 * @param url the url
 * @return the styled layer descriptor
 */
private StyledLayerDescriptor createTestPoint(URL url) {
    StyleBuilder sb = new StyleBuilder();
    StyleFactory styleFactory = sb.getStyleFactory();
    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
    NamedLayer namedLayer = styleFactory.createNamedLayer();
    sld.addStyledLayer(namedLayer);
    Style style = styleFactory.createStyle();
    namedLayer.addStyle(style);
    List<FeatureTypeStyle> ftsList = style.featureTypeStyles();
    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
    ftsList.add(fts);
    Rule rule = styleFactory.createRule();
    fts.rules().add(rule);
    PointSymbolizer point = styleFactory.createPointSymbolizer();
    rule.symbolizers().add(point);
    Graphic graphic = createGraphic(url, styleFactory);
    point.setGraphic(graphic);
    return sld;
}
Also used : StyleFactory(org.geotools.styling.StyleFactory) PointSymbolizer(org.geotools.styling.PointSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) ExternalGraphic(org.geotools.styling.ExternalGraphic) Graphic(org.geotools.styling.Graphic) StyleBuilder(org.geotools.styling.StyleBuilder) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer)

Aggregations

NamedLayer (org.geotools.styling.NamedLayer)51 Style (org.geotools.styling.Style)44 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)44 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)42 Rule (org.geotools.styling.Rule)38 Test (org.junit.Test)34 PointSymbolizer (org.geotools.styling.PointSymbolizer)16 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)15 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)13 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)13 LineSymbolizer (org.geotools.styling.LineSymbolizer)11 StyledLayer (org.geotools.styling.StyledLayer)10 Symbolizer (org.geotools.styling.Symbolizer)8 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)7 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)7 SLDData (com.sldeditor.common.data.SLDData)6 TextSymbolizer (org.geotools.styling.TextSymbolizer)6 FilterFactory (org.opengis.filter.FilterFactory)6 SelectedSymbol (com.sldeditor.common.data.SelectedSymbol)5 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)5