Search in sources :

Example 6 with PolygonSymbolizer

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

Example 7 with PolygonSymbolizer

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;
}
Also used : MutableStyle(org.geotoolkit.style.MutableStyle) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer)

Example 8 with PolygonSymbolizer

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);
}
Also used : PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) LineSymbolizer(org.opengis.style.LineSymbolizer)

Example 9 with PolygonSymbolizer

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;
}
Also used : RasterSymbolizer(org.opengis.style.RasterSymbolizer) PointSymbolizer(org.opengis.style.PointSymbolizer) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) TextSymbolizer(org.opengis.style.TextSymbolizer) LineSymbolizer(org.opengis.style.LineSymbolizer) ExtensionSymbolizer(org.opengis.style.ExtensionSymbolizer) ExtensionSymbolizer(org.opengis.style.ExtensionSymbolizer) PointSymbolizer(org.opengis.style.PointSymbolizer) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) LineSymbolizer(org.opengis.style.LineSymbolizer) RasterSymbolizer(org.opengis.style.RasterSymbolizer) TextSymbolizer(org.opengis.style.TextSymbolizer) Symbolizer(org.opengis.style.Symbolizer)

Example 10 with PolygonSymbolizer

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);
}
Also used : PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) LineSymbolizer(org.opengis.style.LineSymbolizer) ImageOutlineType(org.geotoolkit.se.xml.v110.ImageOutlineType) RasterSymbolizerType(org.geotoolkit.se.xml.v110.RasterSymbolizerType)

Aggregations

PolygonSymbolizer (org.opengis.style.PolygonSymbolizer)20 LineSymbolizer (org.opengis.style.LineSymbolizer)9 MutableStyle (org.geotoolkit.style.MutableStyle)8 Fill (org.opengis.style.Fill)8 PointSymbolizer (org.opengis.style.PointSymbolizer)7 Stroke (org.opengis.style.Stroke)7 Expression (org.opengis.filter.Expression)6 RasterSymbolizer (org.opengis.style.RasterSymbolizer)5 TextSymbolizer (org.opengis.style.TextSymbolizer)5 ArrayList (java.util.ArrayList)4 MapLayer (org.apache.sis.portrayal.MapLayer)4 MapLayers (org.apache.sis.portrayal.MapLayers)4 Test (org.junit.Test)4 Symbolizer (org.opengis.style.Symbolizer)4 Unit (javax.measure.Unit)3 FeatureTypeBuilder (org.apache.sis.feature.builder.FeatureTypeBuilder)3 CanvasDef (org.geotoolkit.display2d.service.CanvasDef)3 SceneDef (org.geotoolkit.display2d.service.SceneDef)3 Feature (org.opengis.feature.Feature)3 FeatureType (org.opengis.feature.FeatureType)3