Beispiel #1
0
 /** Clears all features from the selection layer. */
 public void clearSelectedFeatures() {
   ExtendedLayerGraphics selectionLayer =
       (ExtendedLayerGraphics) getSolaLayers().get(SELECTION_LAYER_NAME);
   if (selectionLayer != null && selectionLayer.getFeatureCollection().size() > 0) {
     selectionLayer.removeFeatures(false);
   }
 }
Beispiel #2
0
 /** Retrieves the selected features from the selection layer. */
 public SimpleFeatureSource getSelectedFeatureSource() {
   ExtendedLayerGraphics selectionLayer =
       (ExtendedLayerGraphics) getSolaLayers().get(SELECTION_LAYER_NAME);
   if (selectionLayer != null && selectionLayer.getFeatureCollection().size() > 0) {
     return selectionLayer.getFeatureSource();
   }
   return null;
 }
Beispiel #3
0
 /**
  * Moves the selection layer to the top of the list of layers so that selected objects are always
  * displayed on top of other layers.
  */
 public void moveSelectionLayer() {
   ExtendedLayerGraphics selectionLayer =
       (ExtendedLayerGraphics) getSolaLayers().get(SELECTION_LAYER_NAME);
   if (selectionLayer != null) {
     Layer mapLayer = selectionLayer.getMapLayers().get(0);
     int currentPos = this.getMapContent().layers().indexOf(mapLayer);
     this.getMapContent().moveLayer(currentPos, this.getMapContent().layers().size() - 1);
   }
 }
Beispiel #4
0
 /**
  * Adds the specified feature to the selection layer.
  *
  * @param id The identifier for the feature
  * @param geom The geometry of the feature.
  */
 public void selectFeature(String id, Geometry geom) {
   if (geom != null) {
     ExtendedLayerGraphics selectionLayer =
         (ExtendedLayerGraphics) getSolaLayers().get(SELECTION_LAYER_NAME);
     if (selectionLayer != null) {
       java.util.HashMap<String, Object> fieldValues = new java.util.HashMap<String, Object>();
       fieldValues.put(LAYER_FIELD_GEOMETRY_TYPE, geom.getGeometryType());
       selectionLayer.addFeature(id, geom, fieldValues, false);
     }
   }
 }
Beispiel #5
0
 /**
  * It adds a graphics layer in the map
  *
  * @param layerName layer name
  * @param layerTitle layer title
  * @param geometryType geometry type for this layer
  * @param styleResource the resource name .xml in the location of resources for layer styles. This
  *     resource location is added in the path decided in SLD_RESOURCES {
  * @see org.sola.clients.geotools.ui.layers.SolaFeatureLayer}.
  * @return
  */
 public ExtendedLayerGraphics addLayerGraphics(
     String layerName, String layerTitle, Geometries geometryType, String styleResource) {
   ExtendedLayerGraphics layer = null;
   try {
     layer = new ExtendedLayerGraphics(layerName, geometryType, styleResource);
     layer.setTitle(layerTitle);
     this.addLayer(layer);
   } catch (InitializeLayerException ex) {
     Messaging.getInstance().show(ex.getMessage());
   }
   return layer;
 }
Beispiel #6
0
 /**
  * Initializes the selection layer on the map control. This method should be called after all map
  * layers have been added to ensure the selection layer appears on top of the other SOLA layers.
  */
 public void initializeSelectionLayer() {
   try {
     ExtendedLayerGraphics selectionLayer =
         (ExtendedLayerGraphics) getSolaLayers().get(SELECTION_LAYER_NAME);
     if (selectionLayer == null) {
       selectionLayer =
           new ExtendedLayerGraphics(
               SELECTION_LAYER_NAME,
               Geometries.GEOMETRY,
               SELECTION_SLD_FILE,
               LAYER_FIELD_GEOMETRY_TYPE + ":String");
       selectionLayer.setShowInToc(false);
       this.addLayer(selectionLayer);
     }
   } catch (InitializeLayerException ex) {
     Messaging.getInstance().show(ex.getMessage());
   }
 }