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 / ModeManager.java @ 2443
History | View | Annotate | Download (3.81 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 java.util.ArrayList; |
25 |
import java.util.List; |
26 |
|
27 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
28 |
import org.gvsig.fmap.dal.coverage.exception.FilterTypeException; |
29 |
import org.gvsig.fmap.dal.coverage.grid.AbstractRasterFilterManager; |
30 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilter; |
31 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList; |
32 |
import org.gvsig.raster.impl.grid.filter.RasterFilterListManagerImpl; |
33 |
import org.gvsig.raster.impl.store.ParamImpl; |
34 |
|
35 |
/**
|
36 |
* Gestor de la pila de filtros para el filtro de moda.
|
37 |
*
|
38 |
* @author Nacho Brodin nachobrodin@gmail.com
|
39 |
*/
|
40 |
public class ModeManager extends AbstractRasterFilterManager { |
41 |
private static String ID = "Moda"; |
42 |
|
43 |
/**
|
44 |
* Default constructor. Sets the filter list.
|
45 |
* @param filterList
|
46 |
*/
|
47 |
public ModeManager(RasterFilterList filterList) {
|
48 |
super(filterList);
|
49 |
} |
50 |
|
51 |
public String getManagerID() { |
52 |
return ID;
|
53 |
} |
54 |
|
55 |
public static void register() { |
56 |
AbstractRasterFilterManager.register(ID, ModeManager.class); |
57 |
} |
58 |
|
59 |
/**
|
60 |
* Constructor. Asigna la lista de filtros y el manager.
|
61 |
* @param filterListManager
|
62 |
*/
|
63 |
public ModeManager(RasterFilterListManagerImpl filterListManager) {
|
64 |
super(filterListManager.getFilterList());
|
65 |
} |
66 |
|
67 |
public boolean isDataTypeSupported(int dataType) { |
68 |
return true; |
69 |
} |
70 |
|
71 |
public Class<?> getFilterClassByID(String id) { |
72 |
if(id.compareTo("moda") == 0) |
73 |
return ModeFilter.class;
|
74 |
return null; |
75 |
} |
76 |
|
77 |
/**
|
78 |
* A?ade un filtro de moda a la pila de filtros.
|
79 |
* @param sideLong
|
80 |
* @throws FilterTypeException
|
81 |
*/
|
82 |
public void addModeFilter(int sideLong) throws FilterTypeException { |
83 |
RasterFilter filter = new ModeByteFilter();
|
84 |
|
85 |
//Cuando el filtro esta creado, tomamos los valores y lo a?adimos a la pila
|
86 |
|
87 |
if (filter != null) { |
88 |
filter.addParam("sideLong", new Integer(sideLong)); |
89 |
getFilterList().add(filter); |
90 |
} |
91 |
} |
92 |
|
93 |
public List<Class<?>> getRasterFilterList() { |
94 |
List<Class<?>> filters = new ArrayList<Class<?>>(); |
95 |
filters.add(ModeFilter.class); |
96 |
return filters;
|
97 |
} |
98 |
|
99 |
public void addFilter(Class<?> classFilter, Params params) throws FilterTypeException { |
100 |
if (ModeFilter.class.isAssignableFrom(classFilter)) {
|
101 |
int sideLong = 0; |
102 |
for (int i = 0; i < params.getNumParams(); i++) { |
103 |
if (((ParamImpl)params.getParam(i)).getId().equals("sideLong") && |
104 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Integer) |
105 |
sideLong = ((Integer) ((ParamImpl)params.getParam(i)).getDefaultValue()).intValue();
|
106 |
} |
107 |
addModeFilter(sideLong); |
108 |
} |
109 |
} |
110 |
|
111 |
public void addFilter(Params params) throws FilterTypeException { |
112 |
addFilter(ModeFilter.class, params); |
113 |
} |
114 |
|
115 |
public RasterFilter createFilter(Params params) {
|
116 |
if( params.getParamById("sideLong") != null) { |
117 |
int sideLong = ((Integer) params.getParamById("sideLong").getDefaultValue()).intValue(); |
118 |
RasterFilter filter = new ModeByteFilter();
|
119 |
filter.addParam("sideLong", new Integer(sideLong)); |
120 |
return filter;
|
121 |
} |
122 |
return null; |
123 |
} |
124 |
|
125 |
} |