root / trunk / libraries / libRaster / src / org / gvsig / raster / grid / filter / bands / NoDataListManager.java @ 17123
History | View | Annotate | Download (6.05 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 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.grid.filter.bands; |
20 |
|
21 |
import java.util.ArrayList; |
22 |
|
23 |
import org.gvsig.raster.RasterLibrary; |
24 |
import org.gvsig.raster.dataset.Params; |
25 |
import org.gvsig.raster.grid.filter.FilterTypeException; |
26 |
import org.gvsig.raster.grid.filter.IRasterFilterListManager; |
27 |
import org.gvsig.raster.grid.filter.RasterFilter; |
28 |
import org.gvsig.raster.grid.filter.RasterFilterList; |
29 |
import org.gvsig.raster.grid.filter.RasterFilterListManager; |
30 |
import org.gvsig.raster.util.extensionPoints.ExtensionPoints; |
31 |
import org.gvsig.raster.util.extensionPoints.ExtensionPointsSingleton; |
32 |
/**
|
33 |
* Gestor del filtro de valores NoData sobre un raster.
|
34 |
*
|
35 |
* @version 04/12/2007
|
36 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
37 |
*/
|
38 |
public class NoDataListManager implements IRasterFilterListManager { |
39 |
|
40 |
protected RasterFilterList filterList = null; |
41 |
private RasterFilterListManager filterListManager = null; |
42 |
|
43 |
public static void register() { |
44 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
45 |
extensionPoints.add("RasterFilter", "NoDataManager", NoDataListManager.class); |
46 |
} |
47 |
|
48 |
/**
|
49 |
* Constructor.
|
50 |
* Asigna la lista de filtros y el managener global.
|
51 |
*
|
52 |
* @param filterListManager
|
53 |
*/
|
54 |
public NoDataListManager(RasterFilterListManager filterListManager) {
|
55 |
this.filterListManager = filterListManager;
|
56 |
this.filterList = filterListManager.getFilterList();
|
57 |
} |
58 |
|
59 |
/**
|
60 |
* A?ade un filtro de NoData a la pila de filtros.
|
61 |
* @param ladoVentana
|
62 |
* @throws FilterTypeException
|
63 |
*/
|
64 |
public void addNoDataFilter(Double noDataValue) throws FilterTypeException { |
65 |
RasterFilter filter = new NoDataByteFilter();
|
66 |
|
67 |
//Cuando el filtro esta creado, tomamos los valores y lo a?adimos a la pila
|
68 |
|
69 |
if (filter != null) { |
70 |
filter.addParam("noDataValue", noDataValue);
|
71 |
filter.addParam("Transparency", filterListManager.getFilterList().getEnvParam("Transparency")); |
72 |
filterList.add(filter); |
73 |
} |
74 |
} |
75 |
|
76 |
/*
|
77 |
* (non-Javadoc)
|
78 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#getRasterFilterList()
|
79 |
*/
|
80 |
public ArrayList getRasterFilterList() { |
81 |
ArrayList filters = new ArrayList(); |
82 |
filters.add(NoDataFilter.class); |
83 |
return filters;
|
84 |
} |
85 |
|
86 |
public void addFilter(Class classFilter, Params params) throws FilterTypeException { |
87 |
if (classFilter.equals(NoDataFilter.class)) {
|
88 |
Double noDataValue = Double.valueOf(RasterLibrary.noDataValue); |
89 |
for (int i = 0; i < params.getNumParams(); i++) { |
90 |
if (params.getParam(i).id.equals("noDataValue")) |
91 |
noDataValue = Double.valueOf(((Integer) params.getParam(i).defaultValue).doubleValue()); |
92 |
} |
93 |
addNoDataFilter(noDataValue); |
94 |
} |
95 |
} |
96 |
|
97 |
/*
|
98 |
* (non-Javadoc)
|
99 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#createFilterListFromStrings(java.util.ArrayList, java.lang.String, int)
|
100 |
*/
|
101 |
public int createFilterListFromStrings(ArrayList filters, String fil, int filteri) { |
102 |
/*
|
103 |
String pkgBase = "filter.colortable.";
|
104 |
if (fil.startsWith(pkgBase + "active")) {
|
105 |
boolean exec = true;
|
106 |
if ((RasterFilterListManager.getValue(fil).equals("false")))
|
107 |
exec = false;
|
108 |
filters.remove(0);
|
109 |
|
110 |
ColorTable colorTable = createColorTableFromArray(filters);
|
111 |
|
112 |
filterList.remove(NoDataFilter.class);
|
113 |
addColorTableFilter(new GridPalette(colorTable));
|
114 |
|
115 |
NoDataFilter ct = (NoDataFilter) filterList.getFilterByBaseClass(NoDataFilter.class);
|
116 |
ct.setExec(exec);
|
117 |
}
|
118 |
*/
|
119 |
return filteri;
|
120 |
} |
121 |
|
122 |
/*
|
123 |
* (non-Javadoc)
|
124 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#getStringsFromFilterList(java.util.ArrayList, org.gvsig.raster.grid.filter.RasterFilter)
|
125 |
*/
|
126 |
public ArrayList getStringsFromFilterList(ArrayList filterList, RasterFilter rf) { |
127 |
/*
|
128 |
if (rf instanceof NoDataFilter) {
|
129 |
String pkgBase = "filter.colortable.";
|
130 |
NoDataFilter colorTableFilter = (NoDataFilter) rf;
|
131 |
ColorTable colorTable = (ColorTable) colorTableFilter.getParam("colorTable");
|
132 |
if (colorTable != null) {
|
133 |
if (colorTableFilter.isExec())
|
134 |
filterList.add(pkgBase + "active=true");
|
135 |
else
|
136 |
filterList.add(pkgBase + "active=false");
|
137 |
|
138 |
filterList.add(pkgBase + "name=" + colorTable.getName());
|
139 |
filterList.add(pkgBase + "interpolated=" + colorTable.isInterpolated());
|
140 |
|
141 |
for (int i = 0; i < colorTable.getColorItems().size(); i++) {
|
142 |
ColorItem colorItem = (ColorItem) colorTable.getColorItems().get(i);
|
143 |
filterList.add(pkgBase + "color" + i + ".value=" + colorItem.getValue());
|
144 |
filterList.add(pkgBase + "color" + i + ".name=" + colorItem.getNameClass());
|
145 |
Color c = colorItem.getColor();
|
146 |
filterList.add(pkgBase + "color" + i + ".rgb=" + c.getRed() + "," + c.getGreen() + "," + c.getBlue());
|
147 |
filterList.add(pkgBase + "color" + i + ".interpolated=" + colorItem.getInterpolated());
|
148 |
}
|
149 |
|
150 |
for (int i = 0; i < colorTable.getColorItems().size(); i++) {
|
151 |
ColorItem colorItem = (ColorItem) colorTable.getColorItems().get(i);
|
152 |
filterList.add(pkgBase + "alpha" + i + ".value=" + colorItem.getValue());
|
153 |
Color c = colorItem.getColor();
|
154 |
filterList.add(pkgBase + "alpha" + i + ".a=" + c.getAlpha());
|
155 |
filterList.add(pkgBase + "alpha" + i + ".interpolated=" + colorItem.getInterpolated());
|
156 |
}
|
157 |
}
|
158 |
}
|
159 |
*/
|
160 |
return filterList;
|
161 |
} |
162 |
} |