Java Code Examples for org.geotools.styling.StyleFactory#createPolygonSymbolizer()

The following examples show how to use org.geotools.styling.StyleFactory#createPolygonSymbolizer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StyleGenerator.java    From constellation with Apache License 2.0 6 votes vote down vote up
private static Rule makeFillRule() {
    final FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory();
    final StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();

    // create a partially opaque outline stroke
    final Stroke stroke = styleFactory.createStroke(
            filterFactory.literal(Color.BLACK),
            filterFactory.literal(1),
            filterFactory.literal(.5)
    );

    // create a partially opaque fill
    Fill fill = styleFactory.createFill(
            filterFactory.literal(COLORS.next()),
            filterFactory.literal(.5)
    );

    // setting the geometryPropertyName arg to null signals that we want to draw the default geometry of features
    final PolygonSymbolizer sym = styleFactory.createPolygonSymbolizer(stroke, fill, null);

    final Rule rule = styleFactory.createRule();
    rule.symbolizers().add(sym);

    return rule;
}
 
Example 2
Source File: FeatureLayerConfigurationPersistencyTest.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings({"deprecation"})
private static Style createStyle() {
    StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(null);
    FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(null);
    PolygonSymbolizer symbolizer = styleFactory.createPolygonSymbolizer();
    Fill fill = styleFactory.createFill(
            filterFactory.literal("#FFAA00"),
            filterFactory.literal(0.5)
    );
    symbolizer.setFill(fill);
    Rule rule = styleFactory.createRule();
    rule.setSymbolizers(new Symbolizer[]{symbolizer});
    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
    fts.setRules(new Rule[]{rule});

    Style style = styleFactory.createStyle();
    style.addFeatureTypeStyle(fts);
    return style;
}
 
Example 3
Source File: StyleGenerator.java    From constellation with Apache License 2.0 5 votes vote down vote up
private static Style createPolygonStyle() {
    final StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();
    final FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory();

    // create a partially opaque outline stroke
    final Stroke stroke = styleFactory.createStroke(
            filterFactory.literal(Color.BLACK),
            filterFactory.literal(1),
            filterFactory.literal(.5)
    );

    // create a partially opaque fill
    final Fill fill = styleFactory.createFill(
            filterFactory.literal(COLORS.next()),
            filterFactory.literal(.5)
    );

    // setting the geometryPropertyName arg to null signals that we want to draw the default geometry of features
    final PolygonSymbolizer sym = styleFactory.createPolygonSymbolizer(stroke, fill, null);

    // make rule
    final Rule rule = styleFactory.createRule();
    rule.symbolizers().add(sym);

    final FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(new Rule[]{rule});
    final Style style = styleFactory.createStyle();
    style.getDescription().setTitle("Polygon Style");
    style.featureTypeStyles().add(fts);

    return style;
}
 
Example 4
Source File: StyleGenerator.java    From constellation with Apache License 2.0 5 votes vote down vote up
private static Style createLineStyle() {
    final StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();
    final FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory();

    // create a partially opaque outline stroke
    final Stroke stroke = styleFactory.createStroke(
            filterFactory.literal(Color.WHITE),
            filterFactory.literal(1),
            filterFactory.literal(.5)
    );

    // create a partially opaque fill
    final Fill fill = styleFactory.createFill(
            filterFactory.literal(Color.RED),
            filterFactory.literal(.25)
    );

    // setting the geometryPropertyName arg to null signals that we want to draw the default geometry of features
    final PolygonSymbolizer sym = styleFactory.createPolygonSymbolizer(stroke, fill, null);

    // make rule
    final Rule rule = styleFactory.createRule();
    rule.symbolizers().add(sym);

    final FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(new Rule[]{rule});
    final Style style = styleFactory.createStyle();
    style.getDescription().setTitle("Line Style");
    style.featureTypeStyles().add(fts);

    return style;
}
 
Example 5
Source File: SLDExternalImagesTest.java    From sldeditor with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Creates the test polygon.
 *
 * @param url the url
 * @return the styled layer descriptor
 */
private StyledLayerDescriptor createTestPolygon(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);

    PolygonSymbolizer polygon = styleFactory.createPolygonSymbolizer();

    rule.symbolizers().add(polygon);

    Graphic graphicFill1 = createGraphic(url, styleFactory);
    Graphic graphicFill2 = createGraphic(url, styleFactory);
    Graphic graphicStroke = createGraphic(url, styleFactory);
    Fill fill = styleFactory.createFill(null, null, null, graphicFill1);

    polygon.setFill(fill);

    Stroke stroke =
            styleFactory.createStroke(
                    null, null, null, null, null, null, null, graphicFill2, graphicStroke);
    polygon.setStroke(stroke);

    return sld;
}