Search in sources :

Example 6 with ExternalGraphic

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

the class ListingPropertyVisitor method visit.

@Override
public Object visit(final Graphic graphic, Object data) {
    final AnchorPoint ac = graphic.getAnchorPoint();
    if (ac != null) {
        data = ac.accept(this, data);
    }
    final Displacement disp = graphic.getDisplacement();
    if (disp != null) {
        data = disp.accept(this, data);
    }
    final Expression opa = graphic.getOpacity();
    if (opa != null) {
        visit(opa, (Collection<String>) data);
    }
    final Expression rot = graphic.getRotation();
    if (rot != null) {
        visit(rot, (Collection<String>) data);
    }
    final Expression size = graphic.getSize();
    if (size != null) {
        visit(size, (Collection<String>) data);
    }
    final List<GraphicalSymbol> symbols = graphic.graphicalSymbols();
    if (symbols != null) {
        for (GraphicalSymbol gs : symbols) {
            if (gs instanceof Mark) {
                data = ((Mark) gs).accept(this, data);
            } else if (gs instanceof ExternalGraphic) {
                data = ((ExternalGraphic) gs).accept(this, data);
            }
        }
    }
    return data;
}
Also used : AnchorPoint(org.opengis.style.AnchorPoint) Expression(org.opengis.filter.Expression) GraphicalSymbol(org.opengis.style.GraphicalSymbol) Mark(org.opengis.style.Mark) ExternalMark(org.opengis.style.ExternalMark) ExternalGraphic(org.opengis.style.ExternalGraphic) Displacement(org.opengis.style.Displacement)

Example 7 with ExternalGraphic

use of org.opengis.style.ExternalGraphic 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)

Aggregations

ExternalGraphic (org.opengis.style.ExternalGraphic)7 GraphicalSymbol (org.opengis.style.GraphicalSymbol)6 Mark (org.opengis.style.Mark)4 BufferedImage (java.awt.image.BufferedImage)3 Test (org.junit.Test)3 Expression (org.opengis.filter.Expression)3 ExternalMark (org.opengis.style.ExternalMark)3 AnchorPoint (org.opengis.style.AnchorPoint)2 Displacement (org.opengis.style.Displacement)2 PointSymbolizer (org.opengis.style.PointSymbolizer)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Icon (javax.swing.Icon)1 ImageIcon (javax.swing.ImageIcon)1 CachedExternal (org.geotoolkit.display2d.style.CachedExternal)1 CachedPointSymbolizer (org.geotoolkit.display2d.style.CachedPointSymbolizer)1 ExternalGraphicType (org.geotoolkit.se.xml.v110.ExternalGraphicType)1 GraphicType (org.geotoolkit.se.xml.v110.GraphicType)1 LegendGraphicType (org.geotoolkit.se.xml.v110.LegendGraphicType)1 StyleXmlIO (org.geotoolkit.sld.xml.StyleXmlIO)1