Search in sources :

Example 6 with PointSymbolizer

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());
}
Also used : ImageIcon(javax.swing.ImageIcon) PointSymbolizer(org.opengis.style.PointSymbolizer) MutableStyle(org.geotoolkit.style.MutableStyle) Graphic(org.opengis.style.Graphic) ExternalGraphic(org.opengis.style.ExternalGraphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) StyleXmlIO(org.geotoolkit.sld.xml.StyleXmlIO) Icon(javax.swing.Icon) ImageIcon(javax.swing.ImageIcon) ExternalGraphic(org.opengis.style.ExternalGraphic) File(java.io.File) BufferedImage(java.awt.image.BufferedImage) PointSymbolizer(org.opengis.style.PointSymbolizer) Symbolizer(org.opengis.style.Symbolizer) Test(org.junit.Test)

Example 7 with PointSymbolizer

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);
}
Also used : PointSymbolizer(org.opengis.style.PointSymbolizer) Marshaller(javax.xml.bind.Marshaller) Mark(org.opengis.style.Mark) JAXBElement(javax.xml.bind.JAXBElement) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test)

Example 8 with PointSymbolizer

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);
}
Also used : PointSymbolizer(org.opengis.style.PointSymbolizer) Graphic(org.opengis.style.Graphic) Mark(org.opengis.style.Mark) JAXBElement(javax.xml.bind.JAXBElement) Interpolate(org.geotoolkit.style.function.Interpolate) Expression(org.opengis.filter.Expression) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test)

Example 9 with PointSymbolizer

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;
}
Also used : PointSymbolizer(org.opengis.style.PointSymbolizer) Description(org.opengis.style.Description) Graphic(org.opengis.style.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) ArrayList(java.util.ArrayList) Unit(javax.measure.Unit) Displacement(org.opengis.style.Displacement) AnchorPoint(org.opengis.style.AnchorPoint) MutableStyle(org.geotoolkit.style.MutableStyle) Expression(org.opengis.filter.Expression)

Example 10 with PointSymbolizer

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