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