Esempio n. 1
0
 /** forget about any existing map/layer */
 public void clearMap() {
   if (_myLayer != null) {
     // remove ourselves from the map
     if (_myMap != null) {
       _myMap.removeLayer(_myLayer);
     }
     _myLayer.dispose();
     _myLayer = null;
   }
   _myMap = null;
 }
Esempio n. 2
0
  public static void legendAction() {
    try {
      LegendColorTable.countTable = 0;
      Layer layer = content.layers().get(content.layers().size() - 1);
      SimpleFeatureSource featureSource = (SimpleFeatureSource) layer.getFeatureSource();
      String fieldName = getFieldForColour(featureSource);

      if (fieldName != null && fieldName.length() > 0) {

        Style style = createStyle(featureSource, fieldName);

        content.removeLayer(layer);
        Layer newLayer = new FeatureLayer(featureSource, style);
        content.addLayer(newLayer);

      } else throw new NullPointerException("Error occured during making legend");

    } catch (ArrayIndexOutOfBoundsException ex) {
      JOptionPane.showMessageDialog(null, "No layers are added !");
    } catch (Exception ex) {
      ex.printStackTrace();
      // JOptionPane.showMessageDialog(null, ex.getMessage());
    }
  }