Search in sources :

Example 86 with Rule

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

the class DefaultSymbols method createNewPolygon.

/**
 * Creates a new polygon symbol.
 *
 * @return the styled layer descriptor
 */
public static StyledLayerDescriptor createNewPolygon() {
    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);
    PolygonSymbolizer polygon = createDefaultPolygonSymbolizer();
    rule.symbolizers().add(polygon);
    return sld;
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) 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 87 with Rule

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

the class SymbolizerDetailsPanel method getMinimumVersion.

/**
 * Gets the minimum version vendor option present in the SLD.
 *
 * @param parentObj the parent obj
 * @param sldObj the sld obj
 * @param vendorOptionsPresentList the vendor options present list
 */
public void getMinimumVersion(Object parentObj, Object sldObj, List<VendorOptionPresent> vendorOptionsPresentList) {
    Class<?> parentClass = null;
    Class<?> classSelected = sldObj.getClass();
    if (sldObj instanceof StyledLayerDescriptor) {
    // No parent
    } else if (sldObj instanceof StyledLayer) {
        parentClass = StyledLayerDescriptor.class;
    } else if (sldObj instanceof Style) {
        parentClass = StyledLayer.class;
    } else if (sldObj instanceof FeatureTypeStyle) {
        parentClass = Style.class;
    } else if (sldObj instanceof Rule) {
        parentClass = FeatureTypeStyle.class;
    } else if (sldObj instanceof Symbolizer) {
        parentClass = Rule.class;
    }
    internal_getMinimumVersion(parentObj, sldObj, vendorOptionsPresentList, parentClass, classSelected);
    if (sldObj instanceof PointSymbolizerImpl) {
        PointSymbolizerImpl pointSymbolizer = (PointSymbolizerImpl) sldObj;
        parentClass = PointSymbolizerImpl.class;
        classSelected = FillImpl.class;
        internal_getMinimumVersion(pointSymbolizer, pointSymbolizer.getGraphic(), vendorOptionsPresentList, parentClass, classSelected);
    } else if (sldObj instanceof LineSymbolizerImpl) {
        LineSymbolizerImpl lineSymbolizer = (LineSymbolizerImpl) sldObj;
        parentClass = LineSymbolizerImpl.class;
        classSelected = StrokeImpl.class;
        internal_getMinimumVersion(lineSymbolizer, lineSymbolizer.getStroke(), vendorOptionsPresentList, parentClass, classSelected);
    } else if (sldObj instanceof PolygonSymbolizerImpl) {
        PolygonSymbolizerImpl polygonSymbolizer = (PolygonSymbolizerImpl) sldObj;
        parentClass = PolygonSymbolizerImpl.class;
        classSelected = FillImpl.class;
        internal_getMinimumVersion(polygonSymbolizer, polygonSymbolizer.getFill(), vendorOptionsPresentList, parentClass, classSelected);
        classSelected = StrokeImpl.class;
        internal_getMinimumVersion(polygonSymbolizer, polygonSymbolizer.getStroke(), vendorOptionsPresentList, parentClass, classSelected);
    } else if (sldObj instanceof TextSymbolizerImpl) {
        TextSymbolizerImpl textSymbolizer = (TextSymbolizerImpl) sldObj;
        parentClass = Rule.class;
        classSelected = TextSymbolizerImpl.class;
        internal_getMinimumVersion(parentObj, textSymbolizer, vendorOptionsPresentList, parentClass, classSelected);
    } else if (sldObj instanceof RasterSymbolizerImpl) {
        RasterSymbolizerImpl rasterSymbolizer = (RasterSymbolizerImpl) sldObj;
        parentClass = Rule.class;
        classSelected = RasterSymbolizerImpl.class;
        internal_getMinimumVersion(parentObj, rasterSymbolizer, vendorOptionsPresentList, parentClass, classSelected);
    }
}
Also used : TextSymbolizerImpl(org.geotools.styling.TextSymbolizerImpl) StyledLayer(org.geotools.styling.StyledLayer) LineSymbolizerImpl(org.geotools.styling.LineSymbolizerImpl) StrokeImpl(org.geotools.styling.StrokeImpl) Symbolizer(org.geotools.styling.Symbolizer) RasterSymbolizerImpl(org.geotools.styling.RasterSymbolizerImpl) PolygonSymbolizerImpl(org.geotools.styling.PolygonSymbolizerImpl) 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) PointSymbolizerImpl(org.geotools.styling.PointSymbolizerImpl)

Example 88 with Rule

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

the class RenderSymbol method getRenderStyle.

/**
 * Gets the render style.
 *
 * @param selectedSymbol the selected symbol
 * @return the render style
 */
public Style getRenderStyle(SelectedSymbol selectedSymbol) {
    List<StyledLayer> styledLayerList = selectedSymbol.getSld().layers();
    for (StyledLayer styledLayer : styledLayerList) {
        List<Style> styleList = null;
        if (styledLayer instanceof NamedLayerImpl) {
            NamedLayerImpl namedLayer = (NamedLayerImpl) styledLayer;
            styleList = namedLayer.styles();
        } else if (styledLayer instanceof UserLayerImpl) {
            UserLayerImpl userLayer = (UserLayerImpl) styledLayer;
            styleList = userLayer.userStyles();
        }
        if (styleList != null) {
            for (Style style : styleList) {
                FeatureTypeStyle ftsToRender = selectedSymbol.getFeatureTypeStyle();
                Rule ruleToRender = selectedSymbol.getRule();
                // Check to see if style contains the rule to render
                if (shouldRenderSymbol(style, ftsToRender, ruleToRender)) {
                    return renderSymbol(style, ftsToRender, ruleToRender, renderOptions);
                }
            }
        }
    }
    return null;
}
Also used : UserLayerImpl(org.geotools.styling.UserLayerImpl) StyledLayer(org.geotools.styling.StyledLayer) NamedLayerImpl(org.geotools.styling.NamedLayerImpl) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule)

Example 89 with Rule

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

the class SLDTreeSymbolizerButtonStateTest method testRaster.

/**
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#setGeometryType(com.sldeditor.datasource.impl.GeometryTypeEnum)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isMarkerVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isLineVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isPolygonVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isRasterVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isTextVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isImageOutlineLineVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isImageOutlinePolygonVisible(java.lang.Object, java.lang.Object)}.
 */
@Test
public void testRaster() {
    SLDTreeSymbolizerButtonState obj = new SLDTreeSymbolizerButtonState();
    obj.setGeometryType(GeometryTypeEnum.RASTER);
    obj.showSymbolizerButtons();
    assertFalse(obj.isLineVisible(null, null));
    assertFalse(obj.isMarkerVisible(null, null));
    assertFalse(obj.isPolygonVisible(null, null));
    assertFalse(obj.isRasterVisible(null, null));
    assertFalse(obj.isTextVisible(null, null));
    assertFalse(obj.isImageOutlineLineVisible(null, null));
    assertFalse(obj.isImageOutlinePolygonVisible(null, null));
    Rule rule = DefaultSymbols.createNewRule();
    assertTrue(obj.isRasterVisible(null, rule));
    assertTrue(obj.isTextVisible(null, rule));
    RasterSymbolizer raster = DefaultSymbols.createDefaultRasterSymbolizer();
    assertTrue(obj.isImageOutlineLineVisible(null, raster));
    assertTrue(obj.isImageOutlinePolygonVisible(null, raster));
    raster.setImageOutline(DefaultSymbols.createDefaultLineSymbolizer());
    assertFalse(obj.isImageOutlineLineVisible(null, raster));
    assertFalse(obj.isImageOutlinePolygonVisible(null, raster));
    raster.setImageOutline(DefaultSymbols.createDefaultPolygonSymbolizer());
    assertFalse(obj.isImageOutlineLineVisible(null, raster));
    assertFalse(obj.isImageOutlinePolygonVisible(null, raster));
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer) SLDTreeSymbolizerButtonState(com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState) Rule(org.geotools.styling.Rule) Test(org.junit.Test)

Example 90 with Rule

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

Aggregations

Rule (org.geotools.styling.Rule)110 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)65 Style (org.geotools.styling.Style)60 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)51 Test (org.junit.Test)48 NamedLayer (org.geotools.styling.NamedLayer)38 PointSymbolizer (org.geotools.styling.PointSymbolizer)28 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)26 LineSymbolizer (org.geotools.styling.LineSymbolizer)24 Symbolizer (org.geotools.styling.Symbolizer)22 StyledLayer (org.geotools.styling.StyledLayer)19 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)16 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)16 TextSymbolizer (org.geotools.styling.TextSymbolizer)15 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)13 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)11 ArrayList (java.util.ArrayList)11 Filter (org.opengis.filter.Filter)11 UserLayerImpl (org.geotools.styling.UserLayerImpl)10 DataSourceAttributeData (com.sldeditor.datasource.attribute.DataSourceAttributeData)8