Search in sources :

Example 6 with Graphic

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

the class StyleCacheTest method GraphicCacheTest.

@Test
public void GraphicCacheTest() throws Exception {
    // Test a complex graphic
    final Expression Lookup = FF.property("POP_CNTRY");
    final List<InterpolationPoint> values = new ArrayList<InterpolationPoint>();
    // test color interpolation ---------------------------------------------
    values.clear();
    values.add(new DefaultInterpolationPoint(0d, FF.literal(3d)));
    values.add(new DefaultInterpolationPoint(500000000d, FF.literal(50d)));
    Interpolate interpolate = new DefaultInterpolate(Lookup, values, Method.COLOR, Mode.CUBIC, null);
    List<GraphicalSymbol> symbols = new ArrayList<GraphicalSymbol>();
    symbols.add(SF.mark(StyleConstants.MARK_CIRCLE, SF.fill(Color.RED), SF.stroke()));
    Graphic graphic = SF.graphic(symbols, StyleConstants.DEFAULT_GRAPHIC_OPACITY, interpolate, StyleConstants.DEFAULT_GRAPHIC_ROTATION, StyleConstants.DEFAULT_ANCHOR_POINT, StyleConstants.DEFAULT_DISPLACEMENT);
    CachedGraphic cached = CachedGraphic.cache(graphic);
    assertFalse(cached.isStatic());
    assertEquals(VisibilityState.DYNAMIC, cached.isStaticVisible());
}
Also used : DefaultInterpolationPoint(org.geotoolkit.style.function.DefaultInterpolationPoint) InterpolationPoint(org.geotoolkit.style.function.InterpolationPoint) DefaultInterpolate(org.geotoolkit.style.function.DefaultInterpolate) Interpolate(org.geotoolkit.style.function.Interpolate) CachedGraphic(org.geotoolkit.display2d.style.CachedGraphic) Expression(org.opengis.filter.Expression) Graphic(org.opengis.style.Graphic) CachedGraphic(org.geotoolkit.display2d.style.CachedGraphic) ExternalGraphic(org.opengis.style.ExternalGraphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) ArrayList(java.util.ArrayList) DefaultInterpolate(org.geotoolkit.style.function.DefaultInterpolate) DefaultInterpolationPoint(org.geotoolkit.style.function.DefaultInterpolationPoint) Test(org.junit.Test)

Example 7 with Graphic

use of org.opengis.style.Graphic 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 8 with Graphic

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

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

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

Graphic (org.opengis.style.Graphic)29 ArrayList (java.util.ArrayList)16 Expression (org.opengis.filter.Expression)16 GraphicalSymbol (org.opengis.style.GraphicalSymbol)15 ExternalGraphic (org.opengis.style.ExternalGraphic)13 PointSymbolizer (org.opengis.style.PointSymbolizer)13 Unit (javax.measure.Unit)10 Description (org.opengis.style.Description)10 Stroke (org.opengis.style.Stroke)10 Fill (org.opengis.style.Fill)9 MutableStyle (org.geotoolkit.style.MutableStyle)8 AnchorPoint (org.opengis.style.AnchorPoint)8 Displacement (org.opengis.style.Displacement)8 Mark (org.opengis.style.Mark)8 LineSymbolizer (org.opengis.style.LineSymbolizer)5 Test (org.junit.Test)4 PolygonSymbolizer (org.opengis.style.PolygonSymbolizer)4 FeatureSet (org.apache.sis.storage.FeatureSet)3 SimpleInternationalString (org.apache.sis.util.SimpleInternationalString)3 Feature (org.opengis.feature.Feature)3