+ protected void addFeatureSource(String layerId,
+ FeatureSource<SimpleFeatureType, SimpleFeature> featureSource,
+ Object style) {
+ if (style == null)
+ style = StylingUtils.createLineStyle("BLACK", 1);
+
+ MapLayer mapLayer = new DefaultMapLayer(featureSource, (Style) style);
+ addMapLayer(layerId, mapLayer);
+ }
+
+ protected void addMapLayer(String layerId, MapLayer mapLayer) {
+ mapLayers.put(layerId, mapLayer);
+ mapPane.getMapContext().addLayer(mapLayer);
+ }
+
+ public void addLayer(String layerId, Collection<?> collection, Object style) {
+ if (style == null)
+ style = StylingUtils.createLineStyle("BLACK", 1);
+ MapLayer mapLayer = new DefaultMapLayer(collection, (Style) style);
+ addMapLayer(layerId, mapLayer);
+ }
+
+ public void setStyle(String layerId, Object style) {
+ mapLayers.get(layerId).setStyle((Style) style);
+ }
+
+ public void setAreaOfInterest(ReferencedEnvelope areaOfInterest) {
+ // mapPane.getMapContext().setAreaOfInterest(areaOfInterest);
+ CoordinateReferenceSystem crs = mapPane.getMapContext()
+ .getCoordinateReferenceSystem();
+
+ ReferencedEnvelope toDisplay;
+ if (crs != null)
+ try {
+ toDisplay = areaOfInterest.transform(crs, true);
+ } catch (Exception e) {
+ throw new ArgeoException("Cannot reproject " + areaOfInterest,
+ e);
+ }
+ else
+ toDisplay = areaOfInterest;
+ mapPane.setDisplayArea(toDisplay);
+ }
+
+ public void setCoordinateReferenceSystem(String crs) {
+ try {
+ CoordinateReferenceSystem crsObj = CRS.decode(crs);
+ mapPane.getMapContext().setCoordinateReferenceSystem(crsObj);
+ mapPane.repaint();
+ } catch (Exception e) {
+ throw new ArgeoException("Cannot set CRS '" + crs + "'", e);
+ }
+