Search in sources :

Example 16 with PointSymbolizer

use of org.opengis.style.PointSymbolizer in project geotoolkit by Geomatys.

the class StyleCacheTest method pointCacheTest.

@Test
public void pointCacheTest() throws Exception {
    // test that we have a static cache
    PointSymbolizer point = SF.pointSymbolizer();
    CachedPointSymbolizer cached = (CachedPointSymbolizer) GO2Utilities.getCached(point, null);
    assertTrue(cached.isStatic());
    assertEquals(VisibilityState.VISIBLE, cached.isStaticVisible());
    assertTrue(cached.isVisible(null));
    BufferedImage buffer1 = cached.getImage(null, 5f, null);
    BufferedImage buffer2 = cached.getImage(null, 5f, null);
    // we must have exactly the same object
    assertTrue(buffer1 == buffer2);
    // test svg external image ----------------------------------------------
    ExternalGraphic ext = SF.externalGraphic("/org/geotoolkit/display2d/sample.svg", "image/svg");
    List<GraphicalSymbol> gs = new ArrayList<GraphicalSymbol>();
    gs.add(ext);
    point = SF.pointSymbolizer(SF.graphic(gs, DEFAULT_GRAPHIC_OPACITY, FF.literal(12), DEFAULT_GRAPHIC_ROTATION, DEFAULT_ANCHOR_POINT, DEFAULT_DISPLACEMENT), null);
    cached = (CachedPointSymbolizer) GO2Utilities.getCached(point, null);
    assertFalse(cached.isStatic());
    assertEquals(VisibilityState.DYNAMIC, cached.isStaticVisible());
    assertTrue(cached.isVisible(null));
    BufferedImage buffer = cached.getImage(null, 1, null);
    assertNotNull(buffer);
    assertEquals(buffer.getWidth(), 12);
    assertEquals(buffer.getHeight(), 12);
    // different size
    point = SF.pointSymbolizer(SF.graphic(gs, DEFAULT_GRAPHIC_OPACITY, FF.literal(24), DEFAULT_GRAPHIC_ROTATION, DEFAULT_ANCHOR_POINT, DEFAULT_DISPLACEMENT), null);
    cached = (CachedPointSymbolizer) GO2Utilities.getCached(point, null);
    assertFalse(cached.isStatic());
    assertEquals(VisibilityState.DYNAMIC, cached.isStaticVisible());
    assertTrue(cached.isVisible(null));
    buffer = cached.getImage(null, 1, null);
    assertNotNull(buffer);
    assertEquals(buffer.getWidth(), 24);
    assertEquals(buffer.getHeight(), 24);
}
Also used : PointSymbolizer(org.opengis.style.PointSymbolizer) CachedPointSymbolizer(org.geotoolkit.display2d.style.CachedPointSymbolizer) GraphicalSymbol(org.opengis.style.GraphicalSymbol) ArrayList(java.util.ArrayList) CachedPointSymbolizer(org.geotoolkit.display2d.style.CachedPointSymbolizer) ExternalGraphic(org.opengis.style.ExternalGraphic) BufferedImage(java.awt.image.BufferedImage) Test(org.junit.Test)

Example 17 with PointSymbolizer

use of org.opengis.style.PointSymbolizer in project geotoolkit by Geomatys.

the class SE100toGTTransformer method visitRule.

/**
 * Trasnform SLD v1.0 rule in GT Rule.
 */
public MutableRule visitRule(final org.geotoolkit.sld.xml.v100.Rule rt) {
    final MutableRule rule = styleFactory.rule();
    rule.setName(rt.getName());
    final InternationalString title = (rt.getTitle() == null) ? null : new SimpleInternationalString(rt.getTitle());
    final InternationalString abs = (rt.getAbstract() == null) ? null : new SimpleInternationalString(rt.getAbstract());
    rule.setDescription(styleFactory.description(title, abs));
    rule.setElseFilter(rt.getElseFilter() != null);
    rule.setFilter(visitFilter(rt.getFilter()));
    rule.setLegendGraphic(visitLegend(rt.getLegendGraphic()));
    rule.setMaxScaleDenominator((rt.getMaxScaleDenominator() == null) ? Double.MAX_VALUE : rt.getMaxScaleDenominator());
    rule.setMinScaleDenominator((rt.getMinScaleDenominator() == null) ? 0 : rt.getMinScaleDenominator());
    if (rt.getSymbolizer() == null || rt.getSymbolizer().isEmpty()) {
    } else {
        for (final JAXBElement<? extends org.geotoolkit.sld.xml.v100.SymbolizerType> jax : rt.getSymbolizer()) {
            final org.geotoolkit.sld.xml.v100.SymbolizerType st = jax.getValue();
            if (st == null) {
                continue;
            }
            if (st instanceof org.geotoolkit.sld.xml.v100.PointSymbolizer) {
                final org.geotoolkit.sld.xml.v100.PointSymbolizer pst = (org.geotoolkit.sld.xml.v100.PointSymbolizer) st;
                rule.symbolizers().add(visit(pst));
            } else if (st instanceof org.geotoolkit.sld.xml.v100.LineSymbolizer) {
                final org.geotoolkit.sld.xml.v100.LineSymbolizer pst = (org.geotoolkit.sld.xml.v100.LineSymbolizer) st;
                rule.symbolizers().add(visit(pst));
            } else if (st instanceof org.geotoolkit.sld.xml.v100.PolygonSymbolizer) {
                final org.geotoolkit.sld.xml.v100.PolygonSymbolizer pst = (org.geotoolkit.sld.xml.v100.PolygonSymbolizer) st;
                rule.symbolizers().add(visit(pst));
            } else if (st instanceof org.geotoolkit.sld.xml.v100.TextSymbolizer) {
                final org.geotoolkit.sld.xml.v100.TextSymbolizer pst = (org.geotoolkit.sld.xml.v100.TextSymbolizer) st;
                rule.symbolizers().add(visit(pst));
            } else if (st instanceof org.geotoolkit.sld.xml.v100.RasterSymbolizer) {
                final org.geotoolkit.sld.xml.v100.RasterSymbolizer pst = (org.geotoolkit.sld.xml.v100.RasterSymbolizer) st;
                rule.symbolizers().add(visit(pst));
            }
        }
    }
    return rule;
}
Also used : PointSymbolizer(org.opengis.style.PointSymbolizer) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) RasterSymbolizer(org.opengis.style.RasterSymbolizer) MutableRule(org.geotoolkit.style.MutableRule) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) TextSymbolizer(org.opengis.style.TextSymbolizer) LineSymbolizer(org.opengis.style.LineSymbolizer)

Example 18 with PointSymbolizer

use of org.opengis.style.PointSymbolizer in project geotoolkit by Geomatys.

the class GTtoSE110Transformer method visit.

/**
 * Transform a GT rule in jaxb rule or OnlineResource
 */
@Override
public Object visit(final Rule rule, final Object data) {
    if (rule.getOnlineResource() != null) {
        // we store only the online resource
        return visit(rule.getOnlineResource(), null);
    }
    final RuleType rt = se_factory.createRuleType();
    rt.setName(rule.getName());
    rt.setDescription(visit(rule.getDescription(), null));
    if (rule.isElseFilter()) {
        rt.setElseFilter(se_factory.createElseFilterType());
    } else if (rule.getFilter() != null) {
        rt.setFilter(apply(rule.getFilter()));
    }
    if (rule.getLegend() != null) {
        rt.setLegendGraphic(visit(rule.getLegend(), null));
    }
    rt.setMaxScaleDenominator(rule.getMaxScaleDenominator());
    rt.setMinScaleDenominator(rule.getMinScaleDenominator());
    for (final Symbolizer symbol : rule.symbolizers()) {
        if (symbol instanceof LineSymbolizer) {
            rt.getSymbolizer().add(visit((LineSymbolizer) symbol, null));
        } else if (symbol instanceof PolygonSymbolizer) {
            rt.getSymbolizer().add(visit((PolygonSymbolizer) symbol, null));
        } else if (symbol instanceof PointSymbolizer) {
            rt.getSymbolizer().add(visit((PointSymbolizer) symbol, null));
        } else if (symbol instanceof RasterSymbolizer) {
            rt.getSymbolizer().add(visit((RasterSymbolizer) symbol, null));
        } else if (symbol instanceof TextSymbolizer) {
            rt.getSymbolizer().add(visit((TextSymbolizer) symbol, null));
        } else if (symbol instanceof ExtensionSymbolizer) {
            ((List) rt.getSymbolizer()).add(visit((ExtensionSymbolizer) symbol, null));
        }
    }
    return rt;
}
Also used : RasterSymbolizer(org.opengis.style.RasterSymbolizer) PointSymbolizer(org.opengis.style.PointSymbolizer) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) TextSymbolizer(org.opengis.style.TextSymbolizer) LineSymbolizer(org.opengis.style.LineSymbolizer) RuleType(org.geotoolkit.se.xml.v110.RuleType) ExtensionSymbolizer(org.opengis.style.ExtensionSymbolizer) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) RasterSymbolizer(org.opengis.style.RasterSymbolizer) TextSymbolizer(org.opengis.style.TextSymbolizer) ExtensionSymbolizer(org.opengis.style.ExtensionSymbolizer) PointSymbolizer(org.opengis.style.PointSymbolizer) LineSymbolizer(org.opengis.style.LineSymbolizer) Symbolizer(org.opengis.style.Symbolizer)

Example 19 with PointSymbolizer

use of org.opengis.style.PointSymbolizer in project geotoolkit by Geomatys.

the class Styles method defaultPoint.

// ////////////////////////////////////////////////////////////////////
// POINT SYMBOLIZER //////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////
public static MutableStyle defaultPoint() {
    final PointSymbolizer symbol = DEFAULT_POINT_SYMBOLIZER;
    final MutableStyle style = SF.style(symbol);
    return style;
}
Also used : PointSymbolizer(org.opengis.style.PointSymbolizer) MutableStyle(org.geotoolkit.style.MutableStyle)

Example 20 with PointSymbolizer

use of org.opengis.style.PointSymbolizer in project geotoolkit by Geomatys.

the class Styles method ttfPoint.

public static MutableStyle ttfPoint() throws URISyntaxException {
    // general informations
    final String name = "mySymbol";
    final Description desc = DEFAULT_DESCRIPTION;
    // use the default geometry of the feature
    final String geometry = null;
    final Unit unit = Units.POINT;
    // the visual element
    final Expression size = FF.literal(32);
    final Expression opacity = LITERAL_ONE_FLOAT;
    final Expression rotation = LITERAL_ONE_FLOAT;
    final AnchorPoint anchor = DEFAULT_ANCHOR_POINT;
    final Displacement disp = DEFAULT_DISPLACEMENT;
    final List<GraphicalSymbol> symbols = new ArrayList<GraphicalSymbol>();
    final Stroke stroke = SF.stroke(Color.BLACK, 1);
    final Fill fill = SF.fill(Color.RED);
    final ExternalMark external = SF.externalMark(SF.onlineResource(IconBuilder.FONTAWESOME.toURI()), "ttf", FontAwesomeIcons.ICON_DICE.codePointAt(0));
    final Mark mark = SF.mark(external, fill, stroke);
    symbols.add(mark);
    final Graphic graphic = SF.graphic(symbols, opacity, size, rotation, anchor, disp);
    final PointSymbolizer symbolizer = SF.pointSymbolizer(name, geometry, desc, unit, graphic);
    final MutableStyle style = SF.style(symbolizer);
    return style;
}
Also used : PointSymbolizer(org.opengis.style.PointSymbolizer) Stroke(org.opengis.style.Stroke) GraphicStroke(org.opengis.style.GraphicStroke) Fill(org.opengis.style.Fill) GraphicFill(org.opengis.style.GraphicFill) Description(org.opengis.style.Description) Graphic(org.opengis.style.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) ArrayList(java.util.ArrayList) ExternalMark(org.opengis.style.ExternalMark) Mark(org.opengis.style.Mark) Unit(javax.measure.Unit) Displacement(org.opengis.style.Displacement) AnchorPoint(org.opengis.style.AnchorPoint) ExternalMark(org.opengis.style.ExternalMark) MutableStyle(org.geotoolkit.style.MutableStyle) Expression(org.opengis.filter.Expression)

Aggregations

PointSymbolizer (org.opengis.style.PointSymbolizer)21 Graphic (org.opengis.style.Graphic)12 GraphicalSymbol (org.opengis.style.GraphicalSymbol)12 ArrayList (java.util.ArrayList)11 Mark (org.opengis.style.Mark)10 MutableStyle (org.geotoolkit.style.MutableStyle)9 Fill (org.opengis.style.Fill)7 LineSymbolizer (org.opengis.style.LineSymbolizer)7 PolygonSymbolizer (org.opengis.style.PolygonSymbolizer)7 Stroke (org.opengis.style.Stroke)7 Test (org.junit.Test)6 Expression (org.opengis.filter.Expression)6 Unit (javax.measure.Unit)5 AnchorPoint (org.opengis.style.AnchorPoint)5 Description (org.opengis.style.Description)5 Displacement (org.opengis.style.Displacement)5 TextSymbolizer (org.opengis.style.TextSymbolizer)5 RasterSymbolizer (org.opengis.style.RasterSymbolizer)4 Color (java.awt.Color)3 BufferedImage (java.awt.image.BufferedImage)3