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;
}
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);
}
Aggregations