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