Search in sources :

Example 1 with RenderSymbolInterface

use of com.sldeditor.datasource.RenderSymbolInterface in project sldeditor by robward-scisys.

the class SLDTreeTools method addArrow.

/**
 * Adds the arrow.
 *
 * @param isSourceArrow the is source arrow
 */
private void addArrow(boolean isSourceArrow) {
    if (symbolTree == null) {
        return;
    }
    // Store current state of the SLD before the add
    Object oldValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
    PointSymbolizer pointSymbolizer = DefaultSymbols.createArrow(isSourceArrow);
    DefaultMutableTreeNode ruleNode = getRuleTreeNode();
    SelectedSymbol.getInstance().addSymbolizerToRule(pointSymbolizer);
    DefaultMutableTreeNode newNode = sldTree.addObject(ruleNode, pointSymbolizer, true);
    // Select the item just added
    if (newNode != null) {
        sldTree.addObject(newNode, SLDTreeLeafFactory.getInstance().getFill(pointSymbolizer), true);
        SLDTreeManager.getInstance().rebuildTree((SLDTree) sldTree);
        // Re-render the symbol
        if (renderList != null) {
            for (RenderSymbolInterface render : renderList) {
                render.renderSymbol();
            }
        }
        // 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) PointSymbolizer(org.geotools.styling.PointSymbolizer) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) RenderSymbolInterface(com.sldeditor.datasource.RenderSymbolInterface)

Example 2 with RenderSymbolInterface

use of com.sldeditor.datasource.RenderSymbolInterface 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 3 with RenderSymbolInterface

use of com.sldeditor.datasource.RenderSymbolInterface in project sldeditor by robward-scisys.

the class SingleLegendUI method getRendererList.

/**
 * Gets the renderer list.
 *
 * @return the renderer list
 */
private List<RenderSymbolInterface> getRendererList() {
    if (rendererList == null) {
        rendererList = new ArrayList<>();
        RenderSymbolInterface renderer = RenderPanelFactory.getRenderer(SingleLegendUI.class.getName());
        rendererList.add(renderer);
        rendererList.add(getLegendPanel());
    }
    return rendererList;
}
Also used : RenderSymbolInterface(com.sldeditor.datasource.RenderSymbolInterface)

Example 4 with RenderSymbolInterface

use of com.sldeditor.datasource.RenderSymbolInterface in project sldeditor by robward-scisys.

the class SingleSymbolUI method getRendererList.

/**
 * Gets the renderer list.
 *
 * @return the renderer list
 */
private List<RenderSymbolInterface> getRendererList() {
    if (rendererList == null) {
        rendererList = new ArrayList<>();
        RenderSymbolInterface renderer = RenderPanelFactory.getRenderer(SingleSymbolUI.class.getName());
        rendererList.add(renderer);
    }
    return rendererList;
}
Also used : RenderSymbolInterface(com.sldeditor.datasource.RenderSymbolInterface)

Example 5 with RenderSymbolInterface

use of com.sldeditor.datasource.RenderSymbolInterface in project sldeditor by robward-scisys.

the class RenderPanelFactory method addSLDOutputListener.

/**
 * Adds the sld output listener.
 *
 * @param sldOutput the sld output
 */
public static void addSLDOutputListener(SLDOutputInterface sldOutput) {
    for (Entry<String, RenderSymbolInterface> entry : symbolRenderPanelMap.entrySet()) {
        RenderSymbolInterface render = entry.getValue();
        render.addSLDOutputListener(sldOutput);
    }
}
Also used : RenderSymbolInterface(com.sldeditor.datasource.RenderSymbolInterface)

Aggregations

RenderSymbolInterface (com.sldeditor.datasource.RenderSymbolInterface)14 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)6 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)5 Test (org.junit.jupiter.api.Test)5 PointSymbolizer (org.geotools.styling.PointSymbolizer)4 UndoEvent (com.sldeditor.common.undo.UndoEvent)3 SLDTree (com.sldeditor.ui.tree.SLDTree)3 SLDTreeTools (com.sldeditor.ui.tree.SLDTreeTools)3 ArrayList (java.util.ArrayList)3 LineSymbolizer (org.geotools.styling.LineSymbolizer)3 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)3 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)3 Symbolizer (org.geotools.styling.Symbolizer)3 TreeSelectionData (com.sldeditor.TreeSelectionData)2 SLDData (com.sldeditor.common.data.SLDData)2 SymbolizerDetailsPanel (com.sldeditor.ui.detail.SymbolizerDetailsPanel)2 PopulateDetailsInterface (com.sldeditor.ui.iface.PopulateDetailsInterface)2 File (java.io.File)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2