Search in sources :

Example 41 with LineSymbolizer

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

the class SLDExternalImages method externalGraphicSymbolVisitor.

/**
 * Find the SLD graphical symbols.
 *
 * @param resourceLocator the resource locator
 * @param sld the sld
 * @param externalImageList the external image list
 * @param process the process
 */
private static void externalGraphicSymbolVisitor(URL resourceLocator, StyledLayerDescriptor sld, List<String> externalImageList, ProcessGraphicSymbolInterface process) {
    if (sld == null) {
        return;
    }
    if (process == null) {
        return;
    }
    for (StyledLayer styledLayer : sld.layers()) {
        List<Style> styles = null;
        if (styledLayer instanceof NamedLayer) {
            NamedLayerImpl namedLayer = (NamedLayerImpl) styledLayer;
            styles = namedLayer.styles();
        } else if (styledLayer instanceof UserLayer) {
            UserLayerImpl userLayer = (UserLayerImpl) styledLayer;
            styles = userLayer.userStyles();
        }
        if (styles != null) {
            for (Style style : styles) {
                for (FeatureTypeStyle fts : style.featureTypeStyles()) {
                    for (Rule rule : fts.rules()) {
                        for (Symbolizer symbolizer : rule.symbolizers()) {
                            if (symbolizer instanceof PointSymbolizer) {
                                PointSymbolizer point = (PointSymbolizer) symbolizer;
                                if (point.getGraphic() != null) {
                                    process.processGraphicalSymbol(resourceLocator, point.getGraphic().graphicalSymbols(), externalImageList);
                                }
                            } else if (symbolizer instanceof LineSymbolizer) {
                                LineSymbolizer line = (LineSymbolizer) symbolizer;
                                updateStroke(resourceLocator, line.getStroke(), externalImageList, process);
                            } else if (symbolizer instanceof PolygonSymbolizer) {
                                PolygonSymbolizer polygon = (PolygonSymbolizer) symbolizer;
                                updateStroke(resourceLocator, polygon.getStroke(), externalImageList, process);
                                updateFill(resourceLocator, polygon.getFill(), externalImageList, process);
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) StyledLayer(org.geotools.styling.StyledLayer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) NamedLayerImpl(org.geotools.styling.NamedLayerImpl) Symbolizer(org.geotools.styling.Symbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) PointSymbolizer(org.geotools.styling.PointSymbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) 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) UserLayer(org.geotools.styling.UserLayer) NamedLayer(org.geotools.styling.NamedLayer)

Example 42 with LineSymbolizer

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

the class StrokeDetails method populate.

/**
 * Populate.
 *
 * @param selectedSymbol the selected symbol
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.selectedsymbol.SelectedSymbol)
     */
@Override
public void populate(SelectedSymbol selectedSymbol) {
    Stroke stroke = null;
    if (selectedSymbol != null) {
        symbolizer = selectedSymbol.getSymbolizer();
        if (symbolizer instanceof PointSymbolizer) {
            PointSymbolizer pointSymbolizer = (PointSymbolizer) symbolizer;
            Graphic graphic = pointSymbolizer.getGraphic();
            List<GraphicalSymbol> graphicalSymbols = graphic.graphicalSymbols();
            if (graphicalSymbols.size() > 0) {
                GraphicalSymbol symbol = graphicalSymbols.get(0);
                if (symbol instanceof MarkImpl) {
                    MarkImpl markerSymbol = (MarkImpl) symbol;
                    stroke = markerSymbol.getStroke();
                }
            }
        } else if (symbolizer instanceof LineSymbolizer) {
            LineSymbolizer lineSymbol = (LineSymbolizer) symbolizer;
            stroke = lineSymbol.getStroke();
        } else if (symbolizer instanceof PolygonSymbolizer) {
            PolygonSymbolizer polygonSymbol = (PolygonSymbolizer) symbolizer;
            stroke = polygonSymbol.getStroke();
        }
    }
    Class<?> symbolizerClass = null;
    if (symbolizer != null) {
        symbolizerClass = symbolizer.getClass();
    }
    populateStroke(symbolizerClass, stroke);
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) GraphicStroke(org.opengis.style.GraphicStroke) Stroke(org.geotools.styling.Stroke) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Graphic(org.geotools.styling.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) LineSymbolizer(org.geotools.styling.LineSymbolizer) MarkImpl(org.geotools.styling.MarkImpl)

Example 43 with LineSymbolizer

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

the class StrokeDetails method updateSymbol.

/**
 * Update symbol.
 */
private void updateSymbol() {
    if (!Controller.getInstance().isPopulating()) {
        Stroke stroke = getStroke();
        if (symbolizer instanceof PointSymbolizer) {
            PointSymbolizer pointSymbol = (PointSymbolizer) symbolizer;
            Graphic graphic = pointSymbol.getGraphic();
            GraphicalSymbol symbol = graphic.graphicalSymbols().get(0);
            if (symbol instanceof MarkImpl) {
                MarkImpl markerSymbol = (MarkImpl) symbol;
                markerSymbol.setStroke(stroke);
                SelectedSymbol.getInstance().replaceSymbolizer(pointSymbol);
                this.fireUpdateSymbol();
            }
        } else if (symbolizer instanceof LineSymbolizer) {
            LineSymbolizer lineSymbol = (LineSymbolizer) symbolizer;
            lineSymbol.setStroke(stroke);
            SelectedSymbol.getInstance().replaceSymbolizer(lineSymbol);
            this.fireUpdateSymbol();
        } else if (symbolizer instanceof PolygonSymbolizer) {
            PolygonSymbolizer polygonSymbol = (PolygonSymbolizer) symbolizer;
            polygonSymbol.setStroke(stroke);
            SelectedSymbol.getInstance().replaceSymbolizer(polygonSymbol);
            this.fireUpdateSymbol();
        }
    }
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) GraphicStroke(org.opengis.style.GraphicStroke) Stroke(org.geotools.styling.Stroke) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Graphic(org.geotools.styling.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) LineSymbolizer(org.geotools.styling.LineSymbolizer) MarkImpl(org.geotools.styling.MarkImpl)

Example 44 with LineSymbolizer

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

the class CreateInternalDataSource method internal_determineGeometryType.

/**
 * Internal determine geometry type.
 *
 * @param sld the sld
 * @return the geometry type enum
 */
protected GeometryTypeEnum internal_determineGeometryType(StyledLayerDescriptor sld) {
    GeometryTypeEnum geometryType = GeometryTypeEnum.UNKNOWN;
    if (sld != null) {
        List<StyledLayer> styledLayerList = sld.layers();
        int pointCount = 0;
        int lineCount = 0;
        int polygonCount = 0;
        int rasterCount = 0;
        for (StyledLayer styledLayer : styledLayerList) {
            List<Style> styleList = null;
            if (styledLayer instanceof NamedLayerImpl) {
                NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
                styleList = namedLayerImpl.styles();
            } else if (styledLayer instanceof UserLayerImpl) {
                UserLayerImpl userLayerImpl = (UserLayerImpl) styledLayer;
                styleList = userLayerImpl.userStyles();
            }
            if (styleList != null) {
                for (Style style : styleList) {
                    for (FeatureTypeStyle fts : style.featureTypeStyles()) {
                        for (Rule rule : fts.rules()) {
                            for (org.opengis.style.Symbolizer symbolizer : rule.symbolizers()) {
                                if (symbolizer instanceof PointSymbolizer) {
                                    pointCount++;
                                } else if (symbolizer instanceof LineSymbolizer) {
                                    lineCount++;
                                } else if (symbolizer instanceof PolygonSymbolizer) {
                                    polygonCount++;
                                } else if (symbolizer instanceof RasterSymbolizer) {
                                    rasterCount++;
                                }
                            }
                        }
                    }
                }
            }
        }
        if (polygonCount > 0) {
            geometryType = GeometryTypeEnum.POLYGON;
        } else if (lineCount > 0) {
            geometryType = GeometryTypeEnum.LINE;
        } else if (pointCount > 0) {
            geometryType = GeometryTypeEnum.POINT;
        } else if (rasterCount > 0) {
            geometryType = GeometryTypeEnum.RASTER;
        }
    }
    return geometryType;
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) StyledLayer(org.geotools.styling.StyledLayer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) NamedLayerImpl(org.geotools.styling.NamedLayerImpl) Point(com.vividsolutions.jts.geom.Point) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) 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 45 with LineSymbolizer

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

the class ExtractAttributes method visit.

/**
 * (non-Javadoc)
 *
 * @see org.geotools.styling.visitor.DuplicatingStyleVisitor#visit(org.geotools.styling.LineSymbolizer)
 */
public void visit(LineSymbolizer line) {
    LineSymbolizer copy = sf.getDefaultLineSymbolizer();
    copy.setGeometry(copy(LineString.class, line.getGeometry()));
    copy.setUnitOfMeasure(line.getUnitOfMeasure());
    copy.setStroke(copy(line.getStroke()));
    copy.getOptions().putAll(line.getOptions());
    copy.setPerpendicularOffset(line.getPerpendicularOffset());
    if (STRICT && !copy.equals(line)) {
        throw new IllegalStateException("Was unable to duplicate provided LineSymbolizer:" + line);
    }
    pages.push(copy);
}
Also used : LineString(com.vividsolutions.jts.geom.LineString) LineSymbolizer(org.geotools.styling.LineSymbolizer)

Aggregations

LineSymbolizer (org.geotools.styling.LineSymbolizer)51 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)24 PointSymbolizer (org.geotools.styling.PointSymbolizer)23 Test (org.junit.Test)18 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)17 Style (org.geotools.styling.Style)17 Rule (org.geotools.styling.Rule)16 Symbolizer (org.geotools.styling.Symbolizer)15 Stroke (org.geotools.styling.Stroke)12 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)10 TextSymbolizer (org.geotools.styling.TextSymbolizer)10 NamedLayer (org.geotools.styling.NamedLayer)9 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)7 StyledLayer (org.geotools.styling.StyledLayer)5 JsonObject (com.google.gson.JsonObject)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 Graphic (org.geotools.styling.Graphic)4 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)4 SelectedSymbol (com.sldeditor.common.data.SelectedSymbol)3 SLDTreeLeafLine (com.sldeditor.common.tree.leaf.SLDTreeLeafLine)3