gvsig-raster / org.gvsig.raster.tools / branches / org.gvsig.raster.tools_dataaccess_refactoring / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / tool / filter / mask / MaskFilter.java @ 2331
History | View | Annotate | Download (3.89 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.tools.app.basic.tool.filter.mask; |
23 |
|
24 |
import java.util.ArrayList; |
25 |
|
26 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
27 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
28 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
29 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
30 |
import org.gvsig.fmap.dal.coverage.exception.FilterAddException; |
31 |
import org.gvsig.fmap.dal.coverage.grid.filter.BaseRasterFilter; |
32 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
33 |
import org.gvsig.raster.roi.ROI; |
34 |
|
35 |
/**
|
36 |
* Filtro que aplica una m?scara con la lista de ROIS. Los p?xeles dentro
|
37 |
* de la ROI se ponen al valor de la imagen de origen. Los p?xeles fuera
|
38 |
* de la ROI se ponen a NoData.
|
39 |
*
|
40 |
* @author Nacho Brodin nachobrodin@gmail.com
|
41 |
* @deprecated Exists a plugin with a process which include this functionality
|
42 |
*/
|
43 |
public class MaskFilter extends BaseRasterFilter { |
44 |
public static String[] names = new String[] { "mask" }; |
45 |
protected MaskUI maskUI = null; |
46 |
protected ArrayList<ROI> rois = null; |
47 |
protected boolean inverse = false; |
48 |
|
49 |
//Extent de la ventana de datos y de la imagen completa.
|
50 |
protected Extent bufferExtent = null; |
51 |
protected NoData noData = null; |
52 |
protected double cellsize = 0D; |
53 |
|
54 |
/**
|
55 |
* Constructor
|
56 |
*/
|
57 |
public MaskFilter() {
|
58 |
super();
|
59 |
setName(names[0]);
|
60 |
} |
61 |
|
62 |
public String getGroup() { |
63 |
return "mascaras"; |
64 |
} |
65 |
|
66 |
public String[] getNames() { |
67 |
return names;
|
68 |
} |
69 |
|
70 |
public Params getUIParams(String nameFilter) { |
71 |
Params params = RasterLocator.getManager().createParams( |
72 |
"Panel",
|
73 |
getMaskUI(), |
74 |
-1,
|
75 |
null);
|
76 |
params.setParam( |
77 |
"FilterName",
|
78 |
nameFilter, |
79 |
-1,
|
80 |
null);
|
81 |
return params;
|
82 |
} |
83 |
|
84 |
/**
|
85 |
* Obtiene el interfaz gr?fico para el filtro de m?scara.
|
86 |
* @return MaskUI
|
87 |
*/
|
88 |
private MaskUI getMaskUI() {
|
89 |
if (maskUI == null) { |
90 |
maskUI = new MaskUI();
|
91 |
FLyrRaster raster = (FLyrRaster) getEnv().get("initRaster");
|
92 |
maskUI.setRois(rois); |
93 |
maskUI.setLayer(raster); |
94 |
} |
95 |
return maskUI;
|
96 |
} |
97 |
|
98 |
@SuppressWarnings("unchecked") |
99 |
public void pre() throws FilterAddException { |
100 |
super.pre();
|
101 |
Boolean inverseBoolean = (Boolean)params.get("inverse"); |
102 |
if(inverseBoolean != null) |
103 |
inverse = inverseBoolean.booleanValue(); |
104 |
|
105 |
rois = (ArrayList<ROI>) params.get("rois"); |
106 |
|
107 |
if(raster.getDataExtent() == null) |
108 |
throw new FilterAddException("Buffer extension cannot be null"); |
109 |
|
110 |
bufferExtent = RasterLocator.getManager().getDataStructFactory().createExtent(raster.getDataExtent()); |
111 |
cellsize = raster.getDataExtent().getWidth() / raster.getWidth(); |
112 |
|
113 |
createBufferResult(raster.getDataType(), raster.getBandCount()); |
114 |
} |
115 |
|
116 |
public void process(int x, int y) { |
117 |
} |
118 |
|
119 |
public void post() { |
120 |
rasterResult.setNoDataValue(noData); |
121 |
} |
122 |
|
123 |
public int getInRasterDataType() {return 0;} |
124 |
public int getOutRasterDataType() {return 0;} |
125 |
} |