gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / grid / filter / correction / ModeFilter.java @ 2438
History | View | Annotate | Download (3.15 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.impl.grid.filter.correction; |
23 |
|
24 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
25 |
import org.gvsig.fmap.dal.coverage.exception.FilterAddException; |
26 |
import org.gvsig.fmap.dal.coverage.grid.filter.BaseRasterFilter; |
27 |
import org.gvsig.raster.impl.store.ParamsImpl; |
28 |
|
29 |
/**
|
30 |
* Clase base para los filtros de moda.
|
31 |
*
|
32 |
* @author Nacho Brodin nachobrodin@gmail.com
|
33 |
*/
|
34 |
public class ModeFilter extends BaseRasterFilter { |
35 |
public static String[] names = new String[] {"moda"}; |
36 |
/**
|
37 |
* Variable para guardar el lado de la ventana de filtrado
|
38 |
*/
|
39 |
protected int sideWindow = 0; |
40 |
protected int sizeWindow = 0; |
41 |
protected int halfSide = 0; |
42 |
protected int count = 0; |
43 |
|
44 |
|
45 |
public ModeFilter() {
|
46 |
super();
|
47 |
setName(names[0]);
|
48 |
} |
49 |
|
50 |
public void pre() throws FilterAddException { |
51 |
super.pre();
|
52 |
|
53 |
sideWindow = ((Integer) params.get("sideLong")).intValue(); |
54 |
|
55 |
//El lado de la ventana debe ser positivo e impar.
|
56 |
sideWindow = Math.abs(sideWindow);
|
57 |
if (sideWindow % 2 == 0) |
58 |
sideWindow++; |
59 |
sizeWindow = sideWindow * sideWindow; |
60 |
halfSide = (sideWindow - 1) >> 1; |
61 |
|
62 |
createBufferResult(raster.getDataType(), raster.getBandCount()); |
63 |
} |
64 |
|
65 |
public void post() { |
66 |
// En caso de que nadie apunte a raster, se liberar? su memoria.
|
67 |
raster = null;
|
68 |
} |
69 |
|
70 |
public String getGroup() { |
71 |
return "espaciales"; |
72 |
} |
73 |
|
74 |
public int getInRasterDataType() { |
75 |
return 0; |
76 |
} |
77 |
|
78 |
public String[] getNames() { |
79 |
return names;
|
80 |
} |
81 |
|
82 |
public int getOutRasterDataType() { |
83 |
return 0; |
84 |
} |
85 |
|
86 |
public Params getUIParams(String nameFilter) { |
87 |
if(params != null) { |
88 |
Object obj = params.get("sideLong"); |
89 |
if(obj != null && obj instanceof Integer) { |
90 |
sideWindow = ((Integer)obj).intValue();
|
91 |
sideWindow = Math.abs(sideWindow);
|
92 |
} |
93 |
} |
94 |
Params params = new ParamsImpl();
|
95 |
params.setParam("sideLong",
|
96 |
new Integer(sideWindow), |
97 |
Params.SLIDER, |
98 |
new String[] {"1", "10", "0", "1", "5" }); //min, max, valor defecto, intervalo peque?o, intervalo grande; |
99 |
return params;
|
100 |
} |
101 |
|
102 |
public void process(int x, int y) { |
103 |
} |
104 |
|
105 |
/**
|
106 |
* Obtiene el tama?o del lado de la ventana
|
107 |
* @return entero que representa el tama?o del lado de la
|
108 |
* ventana en p?xeles
|
109 |
*/
|
110 |
public int getSideWindow() { |
111 |
return sideWindow;
|
112 |
} |
113 |
} |