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