root / trunk / extensions / extRasterTools-SE / src / org / gvsig / raster / filter / mask / MaskListManager.java @ 22424
History | View | Annotate | Download (5.04 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.raster.filter.mask; |
20 |
|
21 |
import java.util.ArrayList; |
22 |
|
23 |
import org.gvsig.raster.dataset.Params; |
24 |
import org.gvsig.raster.grid.filter.FilterTypeException; |
25 |
import org.gvsig.raster.grid.filter.IRasterFilterListManager; |
26 |
import org.gvsig.raster.grid.filter.RasterFilter; |
27 |
import org.gvsig.raster.grid.filter.RasterFilterList; |
28 |
import org.gvsig.raster.grid.filter.RasterFilterListManager; |
29 |
import org.gvsig.raster.grid.filter.RegistrableFilterListener; |
30 |
import org.gvsig.raster.util.extensionPoints.ExtensionPoint; |
31 |
|
32 |
/**
|
33 |
* Gestor de los filtros de mascara. Los filtros de m?scara generan una
|
34 |
* capa enmascarando con regiones de inter?s. Las zonas fuera del ROI se
|
35 |
* pondr?n a NoData.
|
36 |
*
|
37 |
* 14/03/2008
|
38 |
* @author Nacho Brodin nachobrodin@gmail.com
|
39 |
*/
|
40 |
public class MaskListManager implements IRasterFilterListManager { |
41 |
protected RasterFilterList filterList = null; |
42 |
|
43 |
/**
|
44 |
* Constructor. Asigna la lista de filtros y el manager.
|
45 |
* @param filterListManager
|
46 |
*/
|
47 |
public MaskListManager(RasterFilterListManager filterListManager) {
|
48 |
this.filterList = filterListManager.getFilterList();
|
49 |
} |
50 |
|
51 |
/**
|
52 |
* Registrar los manager en los puntos de extension
|
53 |
*/
|
54 |
public static void register() { |
55 |
ExtensionPoint extensionPoint = ExtensionPoint.getExtensionPoint("RasterFilter");
|
56 |
extensionPoint.register("Mask", MaskListManager.class);
|
57 |
} |
58 |
|
59 |
/**
|
60 |
* A?ade un filtro de m?scara
|
61 |
* @param rois Lista de ROIs
|
62 |
* @param noData Valor a asignar fuera de las ROI
|
63 |
* @param inverse Inversa
|
64 |
* @throws FilterTypeException
|
65 |
*/
|
66 |
public void addMaskFilter(ArrayList rois, Double noData, Boolean inverse, Boolean transp) throws FilterTypeException { |
67 |
RasterFilter filter = new MaskByteFilter();
|
68 |
|
69 |
//Cuando el filtro esta creado, tomamos los valores y lo a?adimos a la pila
|
70 |
if (filter != null) { |
71 |
filter.addParam("rois", rois);
|
72 |
filter.addParam("nodata", noData);
|
73 |
filter.addParam("inverse", inverse);
|
74 |
filter.addParam("transparency", transp);
|
75 |
filterList.add(filter); |
76 |
} |
77 |
} |
78 |
|
79 |
/*
|
80 |
* (non-Javadoc)
|
81 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#getRasterFilterList()
|
82 |
*/
|
83 |
public ArrayList getRasterFilterList() { |
84 |
ArrayList filters = new ArrayList(); |
85 |
filters.add(MaskFilter.class); |
86 |
return filters;
|
87 |
} |
88 |
|
89 |
/*
|
90 |
* (non-Javadoc)
|
91 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#addFilter(java.lang.Class, org.gvsig.raster.dataset.Params)
|
92 |
*/
|
93 |
public void addFilter(Class classFilter, Params params) throws FilterTypeException { |
94 |
if (classFilter.equals(MaskFilter.class)) {
|
95 |
ArrayList rois = new ArrayList(); |
96 |
Boolean inverse = new Boolean(false); |
97 |
Boolean transp = new Boolean(false); |
98 |
Double nodata = new Double(-99999); |
99 |
|
100 |
Params paramsUI = null;
|
101 |
for (int i = 0; i < params.getNumParams(); i++) { |
102 |
if (params.getParam(i).id.equals("Panel") && |
103 |
params.getParam(i).defaultValue instanceof RegistrableFilterListener) {
|
104 |
paramsUI = ((RegistrableFilterListener) params.getParam(i).defaultValue).getParams(); |
105 |
} |
106 |
} |
107 |
|
108 |
if (paramsUI != null) { |
109 |
for (int i = 0; i < paramsUI.getNumParams(); i++) { |
110 |
if (paramsUI.getParam(i).id.equals("rois")) |
111 |
rois = (ArrayList) paramsUI.getParam(i).defaultValue;
|
112 |
if (paramsUI.getParam(i).id.equals("inverse")) |
113 |
inverse = (Boolean) paramsUI.getParam(i).defaultValue;
|
114 |
if (paramsUI.getParam(i).id.equals("nodata")) |
115 |
nodata = (Double) paramsUI.getParam(i).defaultValue;
|
116 |
if (paramsUI.getParam(i).id.equals("transparency")) |
117 |
transp = (Boolean) paramsUI.getParam(i).defaultValue;
|
118 |
} |
119 |
} |
120 |
addMaskFilter(rois, nodata, inverse, transp); |
121 |
} |
122 |
} |
123 |
|
124 |
/*
|
125 |
* (non-Javadoc)
|
126 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#createFilterListFromStrings(java.util.ArrayList, java.lang.String, int)
|
127 |
*/
|
128 |
public int createFilterListFromStrings(ArrayList filters, String fil, int filteri) throws FilterTypeException { |
129 |
return filteri;
|
130 |
} |
131 |
|
132 |
/*
|
133 |
* (non-Javadoc)
|
134 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#getStringsFromFilterList(java.util.ArrayList, org.gvsig.raster.grid.filter.RasterFilter)
|
135 |
*/
|
136 |
public ArrayList getStringsFromFilterList(ArrayList filterList, RasterFilter rf) { |
137 |
return filterList;
|
138 |
} |
139 |
} |