Search in sources :

Example 1 with MutableFeatureTypeStyle

use of org.geotoolkit.style.MutableFeatureTypeStyle in project geotoolkit by Geomatys.

the class ColorModelTest method createStyle.

private static MutableStyle createStyle(final Color... colors) {
    final MutableStyle style = SF.style();
    for (Color c : colors) {
        final MutableFeatureTypeStyle fts = SF.featureTypeStyle();
        final GraphicalSymbol gs = SF.mark(MARK_CIRCLE, SF.fill(c), SF.stroke(c, 1));
        final PointSymbolizer symbol = SF.pointSymbolizer(SF.graphic(Collections.singletonList(gs), LITERAL_ONE_FLOAT, LITERAL_ONE_FLOAT, LITERAL_ZERO_FLOAT, DEFAULT_ANCHOR_POINT, DEFAULT_DISPLACEMENT), null);
        fts.rules().add(SF.rule(symbol));
        style.featureTypeStyles().add(fts);
    }
    return style;
}
Also used : PointSymbolizer(org.opengis.style.PointSymbolizer) MutableStyle(org.geotoolkit.style.MutableStyle) Color(java.awt.Color) MutableFeatureTypeStyle(org.geotoolkit.style.MutableFeatureTypeStyle) GraphicalSymbol(org.opengis.style.GraphicalSymbol)

Example 2 with MutableFeatureTypeStyle

use of org.geotoolkit.style.MutableFeatureTypeStyle in project geotoolkit by Geomatys.

the class SEforSLD100Test method testFTS.

@Test
public void testFTS() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_SE_FTS);
    assertNotNull(obj);
    FeatureTypeStyle jax = (FeatureTypeStyle) obj;
    MutableFeatureTypeStyle fts = TRANSFORMER_GT.visitFTS(jax);
    assertNotNull(fts);
    assertEquals(fts.getName(), valueName);
    assertEquals(fts.getDescription().getTitle().toString(), valueTitle);
    assertEquals(fts.getDescription().getAbstract().toString(), valueAbstract);
    assertEquals(fts.featureTypeNames().iterator().next().toString(), valueFTN);
    assertEquals(fts.rules().size(), 3);
    assertEquals(fts.semanticTypeIdentifiers().size(), 6);
    Iterator<SemanticType> ite = fts.semanticTypeIdentifiers().iterator();
    assertEquals(ite.next(), SemanticType.ANY);
    assertEquals(ite.next(), SemanticType.POINT);
    assertEquals(ite.next(), SemanticType.LINE);
    assertEquals(ite.next(), SemanticType.POLYGON);
    assertEquals(ite.next(), SemanticType.TEXT);
    assertEquals(ite.next(), SemanticType.RASTER);
    // Write test
    FeatureTypeStyle pvt = TRANSFORMER_OGC.visit(fts, null);
    assertNotNull(pvt);
    assertEquals(pvt.getName(), valueName);
    assertEquals(pvt.getTitle(), valueTitle);
    assertEquals(pvt.getAbstract(), valueAbstract);
    assertEquals(pvt.getFeatureTypeName(), valueFTN);
    assertEquals(pvt.getRule().size(), 3);
    assertEquals(pvt.getSemanticTypeIdentifier().size(), 6);
    assertEquals(pvt.getSemanticTypeIdentifier().get(0), "generic:any");
    assertEquals(pvt.getSemanticTypeIdentifier().get(1), "generic:point");
    assertEquals(pvt.getSemanticTypeIdentifier().get(2), "generic:line");
    assertEquals(pvt.getSemanticTypeIdentifier().get(3), "generic:polygon");
    assertEquals(pvt.getSemanticTypeIdentifier().get(4), "generic:text");
    assertEquals(pvt.getSemanticTypeIdentifier().get(5), "generic:raster");
    MARSHALLER.marshal(pvt, TEST_FILE_SE_FTS);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) SemanticType(org.opengis.style.SemanticType) MutableFeatureTypeStyle(org.geotoolkit.style.MutableFeatureTypeStyle) MutableFeatureTypeStyle(org.geotoolkit.style.MutableFeatureTypeStyle) FeatureTypeStyle(org.geotoolkit.sld.xml.v100.FeatureTypeStyle) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test)

Example 3 with MutableFeatureTypeStyle

use of org.geotoolkit.style.MutableFeatureTypeStyle in project geotoolkit by Geomatys.

the class SEforSLD110Test method testFTS.

@Test
public void testFTS() throws JAXBException, FactoryException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_SE_FTS);
    assertNotNull(obj);
    JAXBElement<?> jax = (JAXBElement<?>) obj;
    MutableFeatureTypeStyle fts = TRANSFORMER_GT.visitFTS(jax.getValue());
    assertNotNull(fts);
    assertEquals(fts.getName(), valueName);
    assertEquals(fts.getDescription().getTitle().toString(), valueTitle);
    assertEquals(fts.getDescription().getAbstract().toString(), valueAbstract);
    assertEquals(fts.featureTypeNames().iterator().next().tip().toString(), valueFTN);
    assertEquals(fts.rules().size(), 3);
    assertEquals(fts.semanticTypeIdentifiers().size(), 6);
    Iterator<SemanticType> ite = fts.semanticTypeIdentifiers().iterator();
    assertEquals(ite.next(), SemanticType.ANY);
    assertEquals(ite.next(), SemanticType.POINT);
    assertEquals(ite.next(), SemanticType.LINE);
    assertEquals(ite.next(), SemanticType.POLYGON);
    assertEquals(ite.next(), SemanticType.TEXT);
    assertEquals(ite.next(), SemanticType.RASTER);
    // Write test
    CoverageStyleType pvt = (CoverageStyleType) TRANSFORMER_OGC.visit(fts, null);
    assertNotNull(pvt);
    assertEquals(pvt.getName(), valueName);
    assertEquals(String.valueOf(pvt.getDescription().getTitle()), valueTitle);
    assertEquals(String.valueOf(pvt.getDescription().getAbstract()), valueAbstract);
    assertTrue(pvt.getCoverageName().contains(valueFTN));
    assertEquals(pvt.getRuleOrOnlineResource().size(), 3);
    assertEquals(pvt.getSemanticTypeIdentifier().size(), 6);
    assertEquals(pvt.getSemanticTypeIdentifier().get(0), "generic:any");
    assertEquals(pvt.getSemanticTypeIdentifier().get(1), "generic:point");
    assertEquals(pvt.getSemanticTypeIdentifier().get(2), "generic:line");
    assertEquals(pvt.getSemanticTypeIdentifier().get(3), "generic:polygon");
    assertEquals(pvt.getSemanticTypeIdentifier().get(4), "generic:text");
    assertEquals(pvt.getSemanticTypeIdentifier().get(5), "generic:raster");
    MARSHALLER.marshal(new ObjectFactory().createCoverageStyle(pvt), TEST_FILE_SE_FTS);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) SemanticType(org.opengis.style.SemanticType) ObjectFactory(org.geotoolkit.se.xml.v110.ObjectFactory) MutableFeatureTypeStyle(org.geotoolkit.style.MutableFeatureTypeStyle) CoverageStyleType(org.geotoolkit.se.xml.v110.CoverageStyleType) JAXBElement(javax.xml.bind.JAXBElement) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test)

Example 4 with MutableFeatureTypeStyle

use of org.geotoolkit.style.MutableFeatureTypeStyle in project geotoolkit by Geomatys.

the class CopyStyleVisitor method visit.

@Override
public MutableStyle visit(Style style, Object data) {
    final MutableStyle copy = SF.style();
    copy.setDefault(style.isDefault());
    copy.setDefaultSpecification(style.getDefaultSpecification());
    copy.setDescription(style.getDescription());
    copy.setName(style.getName());
    for (FeatureTypeStyle fts : style.featureTypeStyles()) {
        copy.featureTypeStyles().add((MutableFeatureTypeStyle) fts.accept(this, data));
    }
    return copy;
}
Also used : MutableStyle(org.geotoolkit.style.MutableStyle) MutableFeatureTypeStyle(org.geotoolkit.style.MutableFeatureTypeStyle) FeatureTypeStyle(org.opengis.style.FeatureTypeStyle)

Example 5 with MutableFeatureTypeStyle

use of org.geotoolkit.style.MutableFeatureTypeStyle in project geotoolkit by Geomatys.

the class CopyStyleVisitor method visit.

@Override
public MutableFeatureTypeStyle visit(FeatureTypeStyle fts, Object data) {
    final MutableFeatureTypeStyle copy = SF.featureTypeStyle();
    copy.semanticTypeIdentifiers().addAll(fts.semanticTypeIdentifiers());
    copy.setDescription(fts.getDescription());
    copy.setFeatureInstanceIDs(fts.getFeatureInstanceIDs());
    copy.setName(fts.getName());
    copy.setOnlineResource(fts.getOnlineResource());
    for (Rule r : fts.rules()) {
        copy.rules().add((MutableRule) r.accept(this, data));
    }
    return copy;
}
Also used : MutableFeatureTypeStyle(org.geotoolkit.style.MutableFeatureTypeStyle) MutableRule(org.geotoolkit.style.MutableRule) Rule(org.opengis.style.Rule)

Aggregations

MutableFeatureTypeStyle (org.geotoolkit.style.MutableFeatureTypeStyle)15 MutableStyle (org.geotoolkit.style.MutableStyle)9 MutableRule (org.geotoolkit.style.MutableRule)6 FeatureTypeStyle (org.opengis.style.FeatureTypeStyle)3 JAXBElement (javax.xml.bind.JAXBElement)2 JAXBException (javax.xml.bind.JAXBException)2 Marshaller (javax.xml.bind.Marshaller)2 Unmarshaller (javax.xml.bind.Unmarshaller)2 SimpleInternationalString (org.apache.sis.util.SimpleInternationalString)2 CoverageStyleType (org.geotoolkit.se.xml.v110.CoverageStyleType)2 Test (org.junit.Test)2 Feature (org.opengis.feature.Feature)2 Rule (org.opengis.style.Rule)2 SemanticType (org.opengis.style.SemanticType)2 Symbolizer (org.opengis.style.Symbolizer)2 InternationalString (org.opengis.util.InternationalString)2 Color (java.awt.Color)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1