use of org.geotoolkit.style.MutableStyle 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;
}
use of org.geotoolkit.style.MutableStyle in project geotoolkit by Geomatys.
the class SE100toGTTransformer method visitUserStyle.
// Style, FTS and Rule-------------------------------------------------------
/**
* Transform a SLD v1.0 userstyle in GT style.
*/
public MutableStyle visitUserStyle(final org.geotoolkit.sld.xml.v100.UserStyle us) {
if (us == null) {
return null;
} else {
final MutableStyle mls = styleFactory.style();
mls.setName(us.getName());
final InternationalString title = (us.getTitle() == null) ? null : new SimpleInternationalString(us.getTitle());
final InternationalString abs = (us.getAbstract() == null) ? null : new SimpleInternationalString(us.getAbstract());
mls.setDescription(styleFactory.description(title, abs));
final Boolean def = us.isIsDefault();
mls.setDefault((def != null) ? def : false);
final List<org.geotoolkit.sld.xml.v100.FeatureTypeStyle> ftss = us.getFeatureTypeStyle();
for (final org.geotoolkit.sld.xml.v100.FeatureTypeStyle obj : ftss) {
final MutableFeatureTypeStyle fts = visitFTS(obj);
mls.featureTypeStyles().add(fts);
}
return mls;
}
}
use of org.geotoolkit.style.MutableStyle in project geotoolkit by Geomatys.
the class SE110toGTTransformer method visitUserStyle.
// Style, FTS and Rule-------------------------------------------------------
/**
* Transform a SLD v1.1 userstyle in GT style.
*/
public MutableStyle visitUserStyle(final org.geotoolkit.sld.xml.v110.UserStyle us) throws FactoryException {
if (us == null) {
return null;
} else {
final MutableStyle mls = styleFactory.style();
mls.setName(us.getName());
mls.setDescription(visitDescription(us.getDescription()));
final Boolean def = us.isIsDefault();
mls.setDefault((def != null) ? def : false);
final List<Object> ftss = us.getFeatureTypeStyleOrCoverageStyleOrOnlineResource();
for (final Object obj : ftss) {
MutableFeatureTypeStyle fts = visitFTS(obj);
mls.featureTypeStyles().add(fts);
}
return mls;
}
}
use of org.geotoolkit.style.MutableStyle in project geotoolkit by Geomatys.
the class MapBuilder method createFeatureLayer.
/**
* Create a default feature map layer with a feature collection and a style.
* @param collection layer data collection
* @return FeatureMapLayer
* @deprecated use createLayer method instead
*/
@Deprecated
public static MapLayer createFeatureLayer(final FeatureSet collection) {
MutableStyle style;
String name = "";
String title = null;
String abstrat = null;
try {
final FeatureType type = collection.getType();
name = type.getName().tip().toString();
title = name;
abstrat = type.getName().toString();
style = RandomStyleBuilder.createDefaultVectorStyle(type);
} catch (DataStoreException ex) {
style = ((MutableStyleFactory) DefaultFactories.forBuildin(StyleFactory.class)).style(RandomStyleBuilder.createRandomPointSymbolizer());
}
final MapLayer maplayer = new MapLayer();
maplayer.setData(collection);
maplayer.setStyle(style);
maplayer.setIdentifier(name);
maplayer.setTitle(title);
maplayer.setAbstract(abstrat);
maplayer.setOpacity(1.0);
return maplayer;
}
use of org.geotoolkit.style.MutableStyle in project geotoolkit by Geomatys.
the class WMCUtilities method getMapContext.
/**
* Create a Geotk {@link MapContext} embeding layers described by given wmc.
*
* @param root The {@link ViewContextType}, root markup of the wmc.
* @return a {@link MapContext} containing layers extracted from wmc.
*/
public static MapLayers getMapContext(ViewContextType root) {
ArgumentChecks.ensureNonNull("ViewContextType", root);
CoordinateReferenceSystem srs = CommonCRS.WGS84.normalizedGeographic();
final MapLayers context = MapBuilder.createContext();
// Get needed markups
GeneralType general = root.getGeneral();
LayerListType layers = root.getLayerList();
if (general != null) {
// Retrieve enveloppe for the map context.
BoundingBoxType bbox = general.getBoundingBox();
try {
srs = AbstractCRS.castOrCopy(CRS.forCode(bbox.getSRS())).forConvention(AxesConvention.RIGHT_HANDED);
} catch (FactoryException ex) {
Logger.getLogger("org.geotoolkit.wmc").log(Level.SEVERE, null, ex);
}
final double width = bbox.getMaxx().subtract(bbox.getMinx()).doubleValue();
final double height = bbox.getMaxy().subtract(bbox.getMiny()).doubleValue();
Envelope aoi = new Envelope2D(srs, bbox.getMinx().doubleValue(), bbox.getMiny().doubleValue(), width, height);
SimpleInternationalString title = new SimpleInternationalString(general.getTitle());
SimpleInternationalString description = new SimpleInternationalString((general.getAbstract() == null) ? "No description" : general.getAbstract());
context.setTitle(title);
context.setAbstract(description);
context.setAreaOfInterest(aoi);
}
// set context general values
context.setIdentifier(root.getId());
// fill context with layers
for (final LayerType layerType : layers.getLayer()) {
// build server from parameters.
final ServerType serverType = layerType.getServer();
final DataStore server;
final String serviceId = getServiceId(serverType.getService().value());
final GenericName layerName = NamesExt.valueOf(layerType.getName());
try {
final URL serviceURL = new URL(serverType.getOnlineResource().getHref());
final DataStoreProvider factory = DataStores.getProviderById(serviceId);
final ParameterValueGroup parameters = factory.getOpenParameters().createValue();
parameters.parameter("identifier").setValue(serviceId);
parameters.parameter("version").setValue(serverType.getVersion());
parameters.parameter("url").setValue(serviceURL);
server = factory.open(parameters);
} catch (Exception ex) {
Logger.getLogger("org.geotoolkit.wmc").log(Level.SEVERE, null, ex);
continue;
}
try {
Resource resource = server.findResource(layerName.toString());
if (resource instanceof FeatureSet) {
final FeatureSet featureSet = (FeatureSet) resource;
final MutableStyle style = RandomStyleBuilder.createRandomVectorStyle(featureSet.getType());
final MapLayer layer = MapBuilder.createLayer(featureSet);
layer.setStyle(style);
context.getComponents().add(layer);
} else if (resource instanceof GridCoverageResource) {
final MapLayer mapLayer = MapBuilder.createCoverageLayer((GridCoverageResource) resource);
context.getComponents().add(mapLayer);
}
} catch (DataStoreException ex) {
Logger.getLogger("org.geotoolkit.wmc").log(Level.SEVERE, null, ex);
continue;
}
}
return context;
}
Aggregations