use of org.opengis.style.PointSymbolizer in project geotoolkit by Geomatys.
the class InlineImageTest method readImage.
@Test
public void readImage() throws Exception {
final BufferedImage image = new BufferedImage(20, 10, BufferedImage.TYPE_INT_ARGB);
final String geometry = null;
final ExternalGraphic external = SF.externalGraphic(new ImageIcon(image), Collections.EMPTY_LIST);
final Graphic graphic = SF.graphic(Collections.singletonList((GraphicalSymbol) external), LITERAL_ONE_FLOAT, LITERAL_ONE_FLOAT, LITERAL_ONE_FLOAT, DEFAULT_ANCHOR_POINT, DEFAULT_DISPLACEMENT);
final PointSymbolizer ips = SF.pointSymbolizer("", geometry, DEFAULT_DESCRIPTION, Units.POINT, graphic);
final MutableStyle style = SF.style(ips);
final File f = File.createTempFile("sld", ".xml");
f.deleteOnExit();
final StyleXmlIO io = new StyleXmlIO();
io.writeStyle(f, style, Specification.StyledLayerDescriptor.V_1_1_0);
final MutableStyle result = io.readStyle(f, Specification.SymbologyEncoding.V_1_1_0);
final Symbolizer s = result.featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
assertTrue(s instanceof PointSymbolizer);
final PointSymbolizer ps = (PointSymbolizer) s;
final ExternalGraphic eg = (ExternalGraphic) ps.getGraphic().graphicalSymbols().get(0);
assertNotNull(eg);
final Icon ri = eg.getInlineContent();
assertNotNull(ri);
assertEquals(20, ri.getIconWidth());
assertEquals(10, ri.getIconHeight());
}
use of org.opengis.style.PointSymbolizer in project geotoolkit by Geomatys.
the class SEforSLD100Test method testPointSymbolizer.
@Test
public void testPointSymbolizer() throws JAXBException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_SE_SYMBOL_POINT);
assertNotNull(obj);
JAXBElement<org.geotoolkit.sld.xml.v100.PointSymbolizer> jax = (JAXBElement<org.geotoolkit.sld.xml.v100.PointSymbolizer>) obj;
PointSymbolizer pointSymbol = TRANSFORMER_GT.visit(jax.getValue());
assertNotNull(pointSymbol);
assertEquals(pointSymbol.getGeometryPropertyName(), valueGeom);
assertEquals(Units.POINT, pointSymbol.getUnitOfMeasure());
assertNotNull(pointSymbol.getGraphic());
assertEquals(floatValue(pointSymbol.getGraphic().getOpacity()), 0.7f, DELTA);
assertEquals(floatValue(pointSymbol.getGraphic().getRotation()), 110f, DELTA);
assertEquals(floatValue(pointSymbol.getGraphic().getSize()), 32f, DELTA);
Mark mark = (Mark) pointSymbol.getGraphic().graphicalSymbols().get(0);
assertEquals(stringValue(mark.getWellKnownName()), "square");
assertEquals(floatValue(mark.getStroke().getWidth()), 13f, DELTA);
assertEquals(floatValue(mark.getStroke().getOpacity()), 0.4f, DELTA);
assertEquals(stringValue(mark.getStroke().getLineJoin()), "bevel");
assertEquals(stringValue(mark.getStroke().getLineCap()), "butt");
assertEquals(floatValue(mark.getStroke().getDashOffset()), 2.3f, DELTA);
assertEquals(stringValue(mark.getStroke().getColor()), "#404040");
assertEquals(floatValue(mark.getFill().getOpacity()), 1.0f, DELTA);
assertEquals(stringValue(mark.getFill().getColor()), "#808080");
// Write test
JAXBElement<org.geotoolkit.sld.xml.v100.PointSymbolizer> pvt = TRANSFORMER_OGC.visit(pointSymbol, null);
assertNotNull(pvt);
assertEquals(pvt.getValue().getGeometry().getPropertyName().getContent(), "");
org.geotoolkit.sld.xml.v100.Graphic gra = pvt.getValue().getGraphic();
assertNotNull(gra.getOpacity());
assertNotNull(gra.getRotation());
assertNotNull(gra.getSize());
assertEquals(gra.getExternalGraphicOrMark().size(), 1);
assertNotNull(pvt.getValue().getGraphic());
assertEquals(pvt.getValue().getGeometry().getPropertyName().getContent(), "");
MARSHALLER.marshal(pvt, TEST_FILE_SE_SYMBOL_POINT);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.opengis.style.PointSymbolizer in project geotoolkit by Geomatys.
the class SEforSLD110Test method testFillInterpolation.
// //////////////////////////////////////////////////////////////////////////
// JAXB TEST UNMARSHELLING FOR USER CASES //////////////////////////////////
// //////////////////////////////////////////////////////////////////////////
@Test
public void testFillInterpolation() throws JAXBException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_SE_FILL_INTERPOLATION);
assertNotNull(obj);
JAXBElement<org.geotoolkit.se.xml.v110.PointSymbolizerType> jax = (JAXBElement<org.geotoolkit.se.xml.v110.PointSymbolizerType>) obj;
PointSymbolizer pointSymbol = TRANSFORMER_GT.visit(jax.getValue());
assertNotNull(pointSymbol);
assertEquals(pointSymbol.getGeometryPropertyName(), valueGeom);
assertEquals(Units.POINT, pointSymbol.getUnitOfMeasure());
assertNotNull(pointSymbol.getGraphic());
Graphic graphic = pointSymbol.getGraphic();
Mark mark = (Mark) graphic.graphicalSymbols().get(0);
Expression color = mark.getFill().getColor();
assertTrue(color instanceof Interpolate);
POOL.recycle(UNMARSHALLER);
}
use of org.opengis.style.PointSymbolizer in project geotoolkit by Geomatys.
the class Styles method imagePoint.
public static MutableStyle imagePoint() 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(12);
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 GraphicalSymbol external = SF.externalGraphic(SF.onlineResource(Styles.class.getResource("/data/fish.png").toURI()), "image/png", null);
symbols.add(external);
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;
}
use of org.opengis.style.PointSymbolizer in project geotoolkit by Geomatys.
the class Styles method ttfPoint2.
public static MutableStyle ttfPoint2() 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(12);
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 Expression external = FF.literal("ttf:Dialog?char=0x2A");
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