Statistics
| Revision:

root / org.gvsig.toolbox / trunk / org.gvsig.toolbox / org.gvsig.toolbox.algorithm / src / main / java / es / unex / sextante / gridStatistics / neighborhoodFragmentation / NeighborhoodFragmentationAlgorithm.java @ 59

History | View | Annotate | Download (1.08 KB)

1
package es.unex.sextante.gridStatistics.neighborhoodFragmentation;
2

    
3
import java.util.HashMap;
4

    
5
import es.unex.sextante.core.Sextante;
6
import es.unex.sextante.gridStatistics.neighborhood.patternBase.PatternBaseAlgorithm;
7

    
8
public class NeighborhoodFragmentationAlgorithm
9
         extends
10
            PatternBaseAlgorithm {
11

    
12
   @Override
13
   public void defineCharacteristics() {
14

    
15
      setName(Sextante.getText("Fragmentation"));
16
      setGroup(Sextante.getText("Pattern_analysis"));
17
      super.defineCharacteristics();
18

    
19
   }
20

    
21

    
22
   @Override
23
   protected double processValues() {
24

    
25
      int i;
26
      int iCells = 0;
27
      double dValue;
28
      Double value;
29
      final HashMap map = new HashMap();
30

    
31
      for (i = 0; i < m_dValues.length; i++) {
32
         dValue = m_dValues[i];
33
         if (dValue != NO_DATA) {
34
            iCells++;
35
            value = new Double(dValue);
36
            if (!map.containsKey(value)) {
37
               map.put(value, "");
38
            }
39
         }
40
      }
41

    
42
      return (((double) map.size() - 1) / ((double) iCells + 1));
43

    
44
   }
45
}