use of org.opengis.style.PolygonSymbolizer in project geotoolkit by Geomatys.
the class SEforSLD110Test method testPolygonSymbolizer.
@Test
public void testPolygonSymbolizer() throws JAXBException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_SE_SYMBOL_POLYGON);
assertNotNull(obj);
JAXBElement<org.geotoolkit.se.xml.v110.PolygonSymbolizerType> jax = (JAXBElement<org.geotoolkit.se.xml.v110.PolygonSymbolizerType>) obj;
PolygonSymbolizer polySymbol = TRANSFORMER_GT.visit(jax.getValue());
assertNotNull(polySymbol);
assertEquals(polySymbol.getGeometryPropertyName(), valueGeom);
assertEquals(Units.FOOT, polySymbol.getUnitOfMeasure());
assertNotNull(polySymbol.getStroke());
assertEquals(floatValue(polySymbol.getStroke().getWidth()), 13f, DELTA);
assertEquals(floatValue(polySymbol.getStroke().getOpacity()), 0.4f, DELTA);
assertEquals(stringValue(polySymbol.getStroke().getLineJoin()), "bevel");
assertEquals(stringValue(polySymbol.getStroke().getLineCap()), "butt");
assertEquals(floatValue(polySymbol.getStroke().getDashOffset()), 2.3f, DELTA);
assertEquals(colorValue(polySymbol.getStroke().getColor()), ObjectConverters.convert("#FF0000", Color.class));
assertEquals(floatValue(polySymbol.getFill().getOpacity()), 1.0f, DELTA);
assertEquals(colorValue(polySymbol.getFill().getColor()), ObjectConverters.convert("#0000FF", Color.class));
// Write test
JAXBElement<org.geotoolkit.se.xml.v110.PolygonSymbolizerType> pvt = TRANSFORMER_OGC.visit(polySymbol, null);
assertNotNull(pvt);
assertEquals(pvt.getValue().getGeometry(), null);
assertNotNull(pvt.getValue().getStroke());
assertNotNull(pvt.getValue().getFill());
MARSHALLER.marshal(pvt, TEST_FILE_SE_SYMBOL_POLYGON);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.opengis.style.PolygonSymbolizer in project geotoolkit by Geomatys.
the class Styles method defaultPolygon.
// ////////////////////////////////////////////////////////////////////
// POLYGON SYMBOLIZER ////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////
public static MutableStyle defaultPolygon() {
final PolygonSymbolizer symbol = DEFAULT_POLYGON_SYMBOLIZER;
final MutableStyle style = SF.style(symbol);
return style;
}
use of org.opengis.style.PolygonSymbolizer in project geotoolkit by Geomatys.
the class GTtoSE100Transformer method visit.
/**
* Transform a GT raster symbolizer in jaxb raster symbolizer.
*/
@Override
public JAXBElement<org.geotoolkit.sld.xml.v100.RasterSymbolizer> visit(final RasterSymbolizer raster, final Object data) {
final org.geotoolkit.sld.xml.v100.RasterSymbolizer tst = sld_factory_v100.createRasterSymbolizer();
tst.setGeometry(visitGeometryType(raster.getGeometryPropertyName()));
if (raster.getChannelSelection() != null) {
tst.setChannelSelection(visit(raster.getChannelSelection(), null));
}
if (raster.getColorMap() != null) {
tst.setColorMap(visit(raster.getColorMap(), null));
}
if (raster.getContrastEnhancement() != null) {
tst.setContrastEnhancement(visit(raster.getContrastEnhancement(), null));
}
if (raster.getImageOutline() != null) {
final org.geotoolkit.sld.xml.v100.ImageOutline iot = sld_factory_v100.createImageOutline();
if (raster.getImageOutline() instanceof LineSymbolizer) {
final LineSymbolizer ls = (LineSymbolizer) raster.getImageOutline();
iot.setLineSymbolizer(visit(ls, null).getValue());
tst.setImageOutline(iot);
} else if (raster.getImageOutline() instanceof PolygonSymbolizer) {
final PolygonSymbolizer ps = (PolygonSymbolizer) raster.getImageOutline();
iot.setPolygonSymbolizer(visit(ps, null).getValue());
tst.setImageOutline(iot);
}
}
tst.setOpacity(visitExpression(raster.getOpacity()));
if (raster.getOverlapBehavior() != null) {
tst.setOverlapBehavior(visit(raster.getOverlapBehavior(), null));
}
if (raster.getShadedRelief() != null) {
tst.setShadedRelief(visit(raster.getShadedRelief(), null));
}
return sld_factory_v100.createRasterSymbolizer(tst);
}
use of org.opengis.style.PolygonSymbolizer in project geotoolkit by Geomatys.
the class GTtoSE100Transformer method visit.
/**
* Transform a GT rule in jaxb rule or OnlineResource
*/
@Override
public org.geotoolkit.sld.xml.v100.Rule visit(final Rule rule, final Object data) {
final org.geotoolkit.sld.xml.v100.Rule rt = sld_factory_v100.createRule();
rt.setName(rule.getName());
if (rule.getDescription() != null) {
if (rule.getDescription().getAbstract() != null)
rt.setAbstract(rule.getDescription().getAbstract().toString());
if (rule.getDescription().getTitle() != null)
rt.setTitle(rule.getDescription().getTitle().toString());
}
if (rule.isElseFilter()) {
rt.setElseFilter(sld_factory_v100.createElseFilter());
} 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) {
// TODO provide jaxb parsing for unknowned symbolizers
// rt.getSymbolizer().add( visit((ExtensionSymbolizer)symbol,null));
}
}
return rt;
}
use of org.opengis.style.PolygonSymbolizer in project geotoolkit by Geomatys.
the class GTtoSE110Transformer method visit.
/**
* Transform a GT raster symbolizer in jaxb raster symbolizer.
*/
@Override
public JAXBElement<RasterSymbolizerType> visit(final RasterSymbolizer raster, final Object data) {
final RasterSymbolizerType tst = se_factory.createRasterSymbolizerType();
tst.setName(raster.getName());
tst.setDescription(visit(raster.getDescription(), null));
tst.setUom(visitUOM(raster.getUnitOfMeasure()));
tst.setGeometry(visitExpression(raster.getGeometry()));
if (raster.getChannelSelection() != null) {
tst.setChannelSelection(visit(raster.getChannelSelection(), null));
}
if (raster.getColorMap() != null) {
tst.setColorMap(visit(raster.getColorMap(), null));
}
if (raster.getContrastEnhancement() != null) {
tst.setContrastEnhancement(visit(raster.getContrastEnhancement(), null));
}
if (raster.getImageOutline() != null) {
final ImageOutlineType iot = se_factory.createImageOutlineType();
if (raster.getImageOutline() instanceof LineSymbolizer) {
final LineSymbolizer ls = (LineSymbolizer) raster.getImageOutline();
iot.setLineSymbolizer(visit(ls, null).getValue());
tst.setImageOutline(iot);
} else if (raster.getImageOutline() instanceof PolygonSymbolizer) {
final PolygonSymbolizer ps = (PolygonSymbolizer) raster.getImageOutline();
iot.setPolygonSymbolizer(visit(ps, null).getValue());
tst.setImageOutline(iot);
}
}
tst.setOpacity(visitExpression(raster.getOpacity()));
if (raster.getOverlapBehavior() != null) {
tst.setOverlapBehavior(visit(raster.getOverlapBehavior(), null));
}
if (raster.getShadedRelief() != null) {
tst.setShadedRelief(visit(raster.getShadedRelief(), null));
}
return se_factory.createRasterSymbolizer(tst);
}
Aggregations