/**
  * Create FeatureSchema using union of all keys from all selected primitives
  *
  * @param prims
  * @return
  */
 private FeatureSchema createSchema(Collection<OsmPrimitive> prims) {
   Set<String> keys = new HashSet<>();
   for (OsmPrimitive prim : prims) {
     keys.addAll(prim.getKeys().keySet());
   }
   FeatureSchema schema = new FeatureSchema();
   schema.addAttribute("__GEOMETRY__", AttributeType.GEOMETRY);
   for (String key : keys) {
     schema.addAttribute(key, AttributeType.STRING);
   }
   return schema;
 }
  protected void copySelectedAttributes() {
    this.attributes = new FeatureSchema();

    for (int i = 0; i < tempAttributes.getAttributeCount(); i++) {
      for (int i2 = 0; i2 < this.onlyTypes.length; i2++) {
        if (this.tempAttributes.getAttributeType(i) == this.onlyTypes[i2]) {
          this.attributes.addAttribute(
              tempAttributes.getAttributeName(i), tempAttributes.getAttributeType(i));
        }
      }
    }
  }
 public int getNumOfAttributes() {
   return attributes.getAttributeCount();
 }
 /** @return the attribute-name as a String. */
 public String getAttribute() {
   if (attributes.getAttributeCount() > 0)
     return this.attributes.getAttributeName(this.attributeBox.getSelectedIndex());
   return null;
 }
Example #5
0
 public static FeatureSchema createGeometryMsgFeatureSchema() {
   FeatureSchema featureSchema = new FeatureSchema();
   featureSchema.addAttribute("GEOMETRY", AttributeType.GEOMETRY);
   featureSchema.addAttribute(MESG_ATTR_NAME, AttributeType.STRING);
   return featureSchema;
 }
Example #6
0
 public void addAttribute(String attributeName, AttributeType attributeType, String accessType) {
   super.addAttribute(attributeName, attributeType);
   int attributeIndex = getAttributeIndex(attributeName);
   attributeAccess.add(attributeIndex, accessType);
 }
Example #7
0
  /**
   * sustituye el esquema de JUMP por un esquema automático de Geopista. Para una integración
   * rápida. SOLO PARA PRUEBAS
   *
   * @param feature
   */
  public static GeopistaFeature vampiriceSchema(Feature feature) {
    FeatureSchema fSchema = feature.getSchema();
    GeopistaSchema gSchema = new GeopistaSchema();
    //		 crea el atributo

    Table defTable = new Table("DatosCapa", "Tabla de la BBDD para esta capa.");
    for (int i = 0; i < fSchema.getAttributeCount(); i++) {
      // define Dominio, Columna y añade al esquema
      Domain defDomain;
      if (fSchema.getAttributeType(i) == AttributeType.DOUBLE
          || fSchema.getAttributeType(i) == AttributeType.FLOAT) {
        defDomain = new NumberDomain("?[-INF:INF]", "Default Double Number.");
      } else if (fSchema.getAttributeType(i) == AttributeType.INTEGER
          || fSchema.getAttributeType(i) == AttributeType.LONG) {
        // Definir patron para excluir los decimales.
        defDomain = new NumberDomain("?[-INF:INF]", "Default Integer Number");

      } else {
        defDomain = new StringDomain("?[.*]", "Dominio por defecto.");
      }
      Column col =
          new Column(fSchema.getAttributeName(i), "Columna automática.", defTable, defDomain);
      gSchema.addAttribute(
          fSchema.getAttributeName(i), fSchema.getAttributeType(i), col, READ_WRITE);
    }
    GeopistaFeature gFeature = new GeopistaFeature(gSchema);
    for (int i = 0; i < fSchema.getAttributeCount(); i++) {
      gFeature.setAttribute(fSchema.getAttributeName(i), feature.getAttribute(i));
    }
    return gFeature;
  }
  // Sample to test the class
  public static void main(String[] args) {
    final LayerManager lm = new LayerManager();

    // Schema containing a single Geometry attribute
    FeatureSchema fs1 = new FeatureSchema();
    fs1.addAttribute("GEOMETRY", AttributeType.GEOMETRY);
    com.vividsolutions.jump.feature.FeatureDataset ds1 =
        new com.vividsolutions.jump.feature.FeatureDataset(fs1);
    lm.addLayer("", "LayerWithJustGeometry", ds1);

    // Schema containing a Geometry and a String attributes
    FeatureSchema fs2 = new FeatureSchema();
    fs2.addAttribute("GEOMETRY", AttributeType.GEOMETRY);
    fs2.addAttribute("Name", AttributeType.STRING);
    com.vividsolutions.jump.feature.FeatureDataset ds2 =
        new com.vividsolutions.jump.feature.FeatureDataset(fs2);
    lm.addLayer("", "LayerWithStringAttribute", ds2);

    // Schema containing a Geometry, a String and a Integer attributes
    FeatureSchema fs3 = new FeatureSchema();
    fs3.addAttribute("GEOMETRY", AttributeType.GEOMETRY);
    fs3.addAttribute("Name", AttributeType.STRING);
    fs3.addAttribute("Age", AttributeType.INTEGER);
    com.vividsolutions.jump.feature.FeatureDataset ds3 =
        new com.vividsolutions.jump.feature.FeatureDataset(fs3);
    lm.addLayer("", "LayerWithNumericAttribute", ds3);

    // MultiInputDialog usage demonstration
    final MultiInputDialog d = new MultiInputDialog(null, "Title!", true);
    d.setInset(2);
    d.addSubTitle("Subtitle 1");
    d.addLabel("This is just a label");
    d.addTextField("Name", "", 24, null, "");
    d.addPositiveIntegerField("Age", 0, 6, "");
    d.addNonNegativeDoubleField("Salary", 0, 12, "");
    d.addComboBox(
        "Occupation",
        "Cadre",
        java.util.Arrays.asList("Manager", "Developper", "Technician", "Secretary"),
        "");
    d.indentLabel("Occupation");
    d.addSubTitle("Layer and attribute selection");
    AttributeTypeFilter STRING_FILTER = new AttributeTypeFilter(AttributeTypeFilter.STRING);
    AttributeTypeFilter NUMERIC_FILTER = AttributeTypeFilter.NUMERIC_FILTER;
    AttributeTypeFilter NOGEOM_FILTER = AttributeTypeFilter.NO_GEOMETRY_FILTER;
    AttributeTypeFilter ALL_FILTER = AttributeTypeFilter.ALL_FILTER;
    final JComboBox typeChooser =
        d.addComboBox(
            "Choose Attribute Type",
            "ALL",
            Arrays.asList(STRING_FILTER, NUMERIC_FILTER, ALL_FILTER, NOGEOM_FILTER),
            "");
    final JComboBox layerChooser = d.addLayerComboBox("LayerField", null, "ToolTip", lm);
    final JComboBox attributeChooser =
        d.addAttributeComboBox("Attribute field", "LayerField", NUMERIC_FILTER, "");
    typeChooser.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            AttributeTypeFilter atf = (AttributeTypeFilter) typeChooser.getSelectedItem();
            layerChooser.setModel(new DefaultComboBoxModel(atf.filter(lm).toArray(new Layer[0])));
          }
        });

    d.addSeparator();
    final JCheckBox jcb = d.addCheckBox("Display icon", false, "");
    JButton button = d.addButton("Switch image panel");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (d.infoPanel.getDescription().equals("")) {
              d.infoPanel.setDescription(
                  "Description of the dialog box.\nThis description must be helpful for the user. I must give meaningful information about which parameters are mandatory, optional, what they represent and which value they can take.");
              d.getConsole().flashMessage("Add description");
            } else {
              d.infoPanel.setDescription("");
              d.getConsole().flashMessage("Remove description");
            }
            d.pack();
          }
        });
    jcb.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (jcb.isSelected()) {
              d.infoPanel.setIcon(
                  new ImageIcon(
                      com.vividsolutions.jump.workbench.ui.images.IconLoader.class.getResource(
                          "Butt.gif")));
              d.getConsole().flashMessage("Add image");
            } else {
              d.infoPanel.setIcon(null);
              d.getConsole().flashMessage("Remove image");
            }
            d.pack();
          }
        });
    JButton button2 = d.addButton("Second button", "OK", "");
    GUIUtil.centreOnScreen(d);
    d.setVisible(true);
    //        System.out.println(d.getLayer("LayerField"));
    System.exit(0);
  }
  private JButton getGraticuleButton() {
    jButtonGraticule =
        new JButton(
            I18N.get(
                MobileExtractPlugin.PluginMobileExtracti18n,
                MobilePluginI18NResource.MobileExtractPanel03_crearCuadricula));

    LayerManager layerManager = context.getLayerManager();
    Layer graticuleLayer = layerManager.getLayer(GraticuleCreatorEngine.getGraticuleName());

    // si ya existe una capa cuadrícula significa que se trata de un fichero importado previamente a
    // ejecutar el asistente
    if (graticuleLayer != null) {
      jButtonGraticule.setEnabled(false);

      if (bCuadriculaCreada == true) {
        // solo ejecutamos este código una vez
        return jButtonGraticule;
      }

      FeatureCollectionWrapper graticuleCollectionWrapper =
          graticuleLayer.getFeatureCollectionWrapper();
      FeatureSchema featureSchema = graticuleCollectionWrapper.getFeatureSchema();

      // cuadriculas visionadas
      IViewport viewport = (IViewport) context.getLayerViewPanel().getViewport();
      Envelope viewEnvelope = viewport.getEnvelopeInModelCoordinates();
      List<Feature> graticuleFeatures = graticuleCollectionWrapper.query(viewEnvelope);
      // ordenamos por distancia al origen las features
      List<SortedFeature> sortedGraticuleFeatures = new ArrayList<SortedFeature>();
      Feature feature = null;
      SortedFeature sortFeat = null;
      for (Iterator iterator = graticuleFeatures.iterator(); iterator.hasNext(); ) {
        feature = (Feature) iterator.next();
        sortFeat = new SortedFeature(feature);
        sortedGraticuleFeatures.add(sortFeat);
      }
      Collections.sort(sortedGraticuleFeatures);

      // borramos el resto de cuadrículas
      graticuleCollectionWrapper.clear();
      graticuleCollectionWrapper.addAll(graticuleFeatures);
      Envelope newWrapperEnvelope = graticuleCollectionWrapper.getEnvelope();

      // zoom al envelope actual
      try {
        viewport.zoom(newWrapperEnvelope);
      } catch (NoninvertibleTransformException e) {
        log.warn("No se ha podido alcanzar el zoom " + newWrapperEnvelope);
      }

      // ajustamos la ventana al envelope de la cuadrícula
      resizeViewToEnvelope(context, newWrapperEnvelope, viewport);

      // guardamos las propiedades gráficas de la extracción
      Envelope featEnvelope =
          sortedGraticuleFeatures.get(0).getFeature().getGeometry().getEnvelopeInternal();
      Double featWidth = featEnvelope.getWidth();
      Double featHeight = featEnvelope.getHeight();
      Double minX = newWrapperEnvelope.getMinX();
      Double minY = newWrapperEnvelope.getMinY();
      Coordinate coordCorner = new Coordinate(minX, minY);
      blackboard.put(GraticuleCreatorPlugIn.SOUTHWEST_CORNER_OF_LEFT_LAYER, coordCorner);
      blackboard.put(GraticuleCreatorPlugIn.CELL_SIDE_LENGTH_X, featWidth);
      blackboard.put(GraticuleCreatorPlugIn.CELL_SIDE_LENGTH_Y, featHeight);
      Integer numCeldasAncho = (int) (newWrapperEnvelope.getWidth() / featWidth);
      Integer numCeldasAlto = (int) (newWrapperEnvelope.getHeight() / featHeight);
      blackboard.put(GraticuleCreatorPlugIn.LAYER_WIDTH_IN_CELLS, numCeldasAncho);
      blackboard.put(GraticuleCreatorPlugIn.LAYER_HEIGHT_IN_CELLS, numCeldasAlto);

      // creamos celdas para los espacios en blanco
      if (sortedGraticuleFeatures.size() < numCeldasAncho * numCeldasAlto) {
        Double curMinX = minX;
        Double curMinY = minY;
        Double fMinX = 0.0;
        GeometryFactory geoFact = new GeometryFactory();
        Feature newFeature = null;
        for (int i = 0; i < sortedGraticuleFeatures.size(); i++) {
          sortFeat = sortedGraticuleFeatures.get(i);
          feature = sortFeat.getFeature();
          fMinX = feature.getGeometry().getEnvelopeInternal().getMinX();
          if (curMinX.doubleValue() != fMinX.doubleValue()) {
            // creamos la feature
            newFeature = (Feature) feature.clone();
            Coordinate[] coordArray = {
              new Coordinate(curMinX, curMinY),
              new Coordinate(curMinX + featWidth, curMinY),
              new Coordinate(curMinX + featWidth, curMinY + featHeight),
              new Coordinate(curMinX, curMinY + featHeight),
              new Coordinate(curMinX, curMinY)
            };

            newFeature.setGeometry(
                geoFact.createPolygon(geoFact.createLinearRing(coordArray), null));
            sortedGraticuleFeatures.add(i, new SortedFeature(newFeature));
            graticuleCollectionWrapper.add(newFeature);
          }
          // para lo último
          else if ((i == sortedGraticuleFeatures.size() - 1)
              && ((minX + (featWidth * numCeldasAncho)) != (fMinX + featWidth))) {
            curMinX = fMinX + featWidth;
            newFeature = (Feature) feature.clone();
            Coordinate[] coordArray = {
              new Coordinate(curMinX, curMinY),
              new Coordinate(curMinX + featWidth, curMinY),
              new Coordinate(curMinX + featWidth, curMinY + featHeight),
              new Coordinate(curMinX, curMinY + featHeight),
              new Coordinate(curMinX, curMinY)
            };

            newFeature.setGeometry(
                geoFact.createPolygon(geoFact.createLinearRing(coordArray), null));
            sortedGraticuleFeatures.add(
                sortedGraticuleFeatures.size(), new SortedFeature(newFeature));
            graticuleCollectionWrapper.add(newFeature);
            continue;
          }

          if (((i + 1) % numCeldasAncho) != 0) {
            curMinX = curMinX + featWidth;
          } else { // ultima celda de cada fila
            curMinX = minX;
            curMinY += featHeight;
          }
        }
      }

      // añadimos el atributo cellid
      featureSchema.addAttribute(GraticuleCreatorEngine.ATR_CELL_ID, AttributeType.INTEGER);
      int k = 1;
      Object[] featAttribs = null;
      Object[] newFeatAttribs = null;
      for (Iterator iterator = sortedGraticuleFeatures.iterator(); iterator.hasNext(); k++) {
        feature = ((SortedFeature) iterator.next()).getFeature();
        featAttribs = feature.getAttributes();
        newFeatAttribs = new Object[featAttribs.length + 1];
        for (int i = 0; i < featAttribs.length; i++) {
          newFeatAttribs[i] = featAttribs[i];
        }
        newFeatAttribs[newFeatAttribs.length - 1] = k;
        feature.setAttributes(newFeatAttribs);
      }
      // pintamos el atributo en la capa
      LabelStyle labelStyle = graticuleLayer.getLabelStyle();
      labelStyle.setColor(Color.RED);
      labelStyle.setHeight(labelStyle.getHeight() * 4);
      labelStyle.setAttribute(GraticuleCreatorEngine.ATR_CELL_ID);
      labelStyle.setEnabled(true);

      // evitamos que se modifiquen las cuadrículas
      graticuleLayer.setEditable(false);
      graticuleLayer.fireAppearanceChanged();

      bCuadriculaCreada = true;
    }
    // llamada al graticulePlugin
    else {
      jButtonGraticule.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent e) {
              GraticuleCreatorPlugIn graticulePlugin = new GraticuleCreatorPlugIn();
              try {
                graticulePlugin.execute(context);
              } catch (Exception e1) {
                e1.printStackTrace();
              }
              wizardContext.inputChanged(); // indicamos que ya se puede habilitar el boton
            }
          });
    }

    return jButtonGraticule;
  }
Example #10
0
  /**
   * Write a dbf file with the information from the featureCollection.
   *
   * @param featureCollection column data from collection
   * @param fname name of the dbf file to write to
   */
  void writeDbf(FeatureCollection featureCollection, String fname) throws Exception {
    DbfFileWriter dbf;
    FeatureSchema fs;
    int t;
    int f;
    int u;
    int num;

    fs = featureCollection.getFeatureSchema();

    // -1 because one of the columns is geometry
    DbfFieldDef[] fields = new DbfFieldDef[fs.getAttributeCount() - 1];

    // dbf column type and size
    f = 0;

    for (t = 0; t < fs.getAttributeCount(); t++) {
      AttributeType columnType = fs.getAttributeType(t);
      String columnName = fs.getAttributeName(t);

      if (columnType == AttributeType.INTEGER) {
        fields[f] = new DbfFieldDef(columnName, 'N', 16, 0);
        f++;
      } else if (columnType == AttributeType.DOUBLE) {
        fields[f] = new DbfFieldDef(columnName, 'N', 33, 16);
        f++;
      } else if (columnType == AttributeType.STRING) {
        int maxlength = findMaxStringLength(featureCollection, t);

        if (maxlength > 255) {
          throw new Exception(
              "ShapefileWriter does not support strings longer than 255 characters");
        }

        fields[f] = new DbfFieldDef(columnName, 'C', maxlength, 0);
        f++;
      } else if (columnType == AttributeType.DATE) {
        fields[f] = new DbfFieldDef(columnName, 'D', 8, 0);
        f++;
      } else if (columnType == AttributeType.GEOMETRY) {
        // do nothing - the .shp file handles this
      } else {
        throw new Exception("Shapewriter: unsupported AttributeType found in featurecollection.");
      }
    }

    // write header
    dbf = new DbfFileWriter(fname);
    dbf.writeHeader(fields, featureCollection.size());

    // write rows
    num = featureCollection.size();

    List features = featureCollection.getFeatures();

    for (t = 0; t < num; t++) {
      // System.out.println("dbf: record "+t);
      Feature feature = (Feature) features.get(t);
      Vector DBFrow = new Vector();

      // make data for each column in this feature (row)
      for (u = 0; u < fs.getAttributeCount(); u++) {
        AttributeType columnType = fs.getAttributeType(u);

        if (columnType == AttributeType.INTEGER) {
          Object a = feature.getAttribute(u);

          if (a == null) {
            DBFrow.add(new Integer(0));
          } else {
            DBFrow.add((Integer) a);
          }
        } else if (columnType == AttributeType.DOUBLE) {
          Object a = feature.getAttribute(u);

          if (a == null) {
            DBFrow.add(new Double(0.0));
          } else {
            DBFrow.add((Double) a);
          }
        } else if (columnType == AttributeType.DATE) {
          Object a = feature.getAttribute(u);
          if (a == null) {
            DBFrow.add("");
          } else {
            DBFrow.add(DbfFile.DATE_PARSER.format((Date) a));
          }
        } else if (columnType == AttributeType.STRING) {
          Object a = feature.getAttribute(u);

          if (a == null) {
            DBFrow.add(new String(""));
          } else {
            // MD 16 jan 03 - added some defensive programming
            if (a instanceof String) {
              DBFrow.add(a);
            } else {
              DBFrow.add(a.toString());
            }
          }
        }
      }

      dbf.writeRecord(DBFrow);
    }

    dbf.close();
  }
  private FeatureDataset classifyAndCreatePlot(TaskMonitor monitor, final PlugInContext context)
      throws Exception {

    monitor.report(this.sCalculateBreaks);
    // =============== get DATA and prepare ==============/
    FeatureSchema fs = this.fc.getFeatureSchema();
    AttributeType type = null;
    if ((fs.getAttributeType(this.selAttribute) == AttributeType.DOUBLE)
        || (fs.getAttributeType(this.selAttribute) == AttributeType.INTEGER)) {
      // -- move on
      type = fs.getAttributeType(this.selAttribute);
    } else {
      // System.out.println("ClassifyAttributesPlugIn: wrong datatype of chosen attribute");
      context.getWorkbenchFrame().warnUser(sWrongDataType);
      return null;
    }

    int size = getFeatureCollectionSize(this.fc, this.selAttribute, this.nullAsZero);
    if (size < 3) {
      return null;
    }
    this.ranges = Math.min(this.ranges, size);

    double[] data = new double[size];
    double[][] plotdata = new double[2][size]; // for drawing 1-D scatter plot
    int[] fID = new int[size];
    int i = 0;
    for (Iterator iter = fc.iterator(); iter.hasNext(); ) {
      Feature f = (Feature) iter.next();
      if (f.getAttribute(this.selAttribute) == null && !nullAsZero) continue;
      fID[i] = f.getID();
      plotdata[1][i] = 1;
      Object val = f.getAttribute(this.selAttribute);
      if (type == AttributeType.DOUBLE) {
        if (val == null) data[i] = 0.0;
        else data[i] = ((Double) val).doubleValue();
      } else if (type == AttributeType.INTEGER) {
        if (val == null) data[i] = 0;
        else data[i] = ((Integer) val).intValue();
      }
      plotdata[0][i] = data[i];
      i++;
    }
    /*
    //-- some testdata
    double[][] plotdata2 = new double[2][8];
    double[] data2 = { -2, 4, 6, 5, 0, 10, 7, 1 };
    double[] axis2 =  {  1, 1, 1, 1, 1, 1, 1, 1 };
    plotdata2[0] = data2;
    plotdata2[1] = axis2;
    */

    if (monitor.isCancelRequested()) {
      return null;
    }

    // =============== find breaks according to chosen method ==============/
    double[] limits = null;

    if (this.useKmeans == false) {
      if (this.selClassifier == Classifier1D.EQUAL_NUMBER) {
        limits = Classifier1D.classifyEqualNumber(data, this.ranges);
      } else if (this.selClassifier == Classifier1D.EQUAL_RANGE) {
        limits = Classifier1D.classifyEqualRange(data, this.ranges);
      } else if (this.selClassifier == Classifier1D.MEAN_STDEV) {
        limits = Classifier1D.classifyMeanStandardDeviation(data, this.ranges);
      } else if (this.selClassifier == Classifier1D.MAX_BREAKS) {
        limits = Classifier1D.classifyMaxBreaks(data, this.ranges);
      } else if (this.selClassifier == Classifier1D.JENKS_BREAKS) {
        limits = Classifier1D.classifyNaturalBreaks(data, this.ranges);
      }
    } else {
      if (this.selClassifier == Classifier1D.EQUAL_NUMBER) {
        limits = Classifier1D.classifyKMeansOnExistingBreaks(data, this.ranges, 3);
      } else if (this.selClassifier == Classifier1D.EQUAL_RANGE) {
        limits = Classifier1D.classifyKMeansOnExistingBreaks(data, this.ranges, 2);
      } else if (this.selClassifier == Classifier1D.MEAN_STDEV) {
        limits = Classifier1D.classifyKMeansOnExistingBreaks(data, this.ranges, 4);
      } else if (this.selClassifier == Classifier1D.MAX_BREAKS) {
        limits = Classifier1D.classifyKMeansOnExistingBreaks(data, this.ranges, 1);
      } else if (this.selClassifier == Classifier1D.JENKS_BREAKS) {
        limits = Classifier1D.classifyKMeansOnExistingBreaks(data, this.ranges, 5);
      }
    }

    if (monitor.isCancelRequested()) {
      return null;
    }

    monitor.report(this.sDisplayBreaks);
    // =============== plot data and class breaks ==============/
    // -- do display here - in case we later want to allow interactive editing of the limits

    // -- reformat limits
    double[][] limits2show = new double[2][limits.length];
    // -- due to bug in jmathplot add limits twice if only three classes = 2breaks are sought
    if (limits.length == 2) {
      limits2show = new double[2][limits.length * 2];
    }
    for (int j = 0; j < limits.length; j++) {
      limits2show[0][j] = limits[j]; // x-axis
      limits2show[1][j] =
          Math.floor(
              i / (4.0 * this.ranges)); // y-axis, estimate height of "bar" from number of items
      // limits2show[1][j]= 1;
      // -- due to bug in jmathplot add limits twice if only three classes are sought
      if (limits.length == 2) {
        limits2show[0][limits.length + j] = limits[j];
        limits2show[1][limits.length + j] = Math.floor(i / (4.0 * this.ranges));
      }
    }

    // =============== plot data and class breaks ==============/
    // -- create plots
    /*final Plot2DPanelOJ*/ plot = new Plot2DPanelOJ();
    plot.addHistogramPlotOJ(
        this.selAttribute, data, this.ranges * 3, context, selLayer, this.selAttribute);
    plot.addScatterPlotOJ(this.sDatapoints, plotdata, fID, context, this.selLayer);
    plot.addBarPlot(this.sClassbreaks, limits2show);
    plot.plotToolBar.setVisible(true);
    plot.setAxisLabel(0, this.selAttribute);
    plot.setAxisLabel(1, this.sCount);
    plot.addLegend("SOUTH");

    // [mmichaud 2012-04-09] Moved in run method after the addLayer method
    // to avoid the problem of the focus change

    // JInternalFrame frame = new JInternalFrame(this.sHistogram);
    // frame.setLayout(new BorderLayout());
    // frame.add(plot, BorderLayout.CENTER);
    // frame.setClosable(true);
    // frame.setResizable(true);
    // frame.setMaximizable(true);
    // frame.setSize(450, 450);
    // frame.setVisible(true);

    // context.getWorkbenchFrame().addInternalFrame(frame);

    // =============== classify data ==============/
    if (monitor.isCancelRequested()) {
      return null;
    }
    monitor.report(this.sClassifying);
    int[] classes = Classifier1D.classifyData(data, limits);
    // double[] classes = org.math.array.StatisticSample.one(data.length);
    // context.getWorkbenchFrame().warnUser("classification not yet implemented");

    // =============== add field ==============/
    if (monitor.isCancelRequested()) {
      return null;
    }
    monitor.report(sAddingField);

    FeatureDataset fd = null;
    ArrayList outData = new ArrayList();
    FeatureSchema targetFSnew = null;
    int count = 0;
    Iterator iterp = fc.iterator();
    String attname = this.selAttribute + "_" + this.selClassifier;
    while (iterp.hasNext()) {
      // count=count+1;
      //	    	if(monitor != null){
      //	    	    monitor.report("item: " + count + " of " + size);
      //	    	}
      Feature p = (Feature) iterp.next();
      Object val = p.getAttribute(this.selAttribute);
      if (val == null && !this.nullAsZero) continue;
      else count++;
      if (count == 1) {
        FeatureSchema targetFs = p.getSchema();
        targetFSnew = FeatureSchemaTools.copyFeatureSchema(targetFs);
        if (targetFSnew.hasAttribute(attname)) {
          // attribute will be overwriten
        } else {
          // add attribute
          targetFSnew.addAttribute(attname, AttributeType.INTEGER);
        }
      }
      // -- evaluate value for every polygon
      Feature fcopy = FeatureSchemaTools.copyFeature(p, targetFSnew);
      // fcopy.setAttribute(this.selClassifier, new Integer(classes[count-1]));
      fcopy.setAttribute(attname, new Integer(classes[count - 1]));
      outData.add(fcopy);
    }
    fd = new FeatureDataset(targetFSnew);
    fd.addAll(outData);
    return fd;
  }