Revision 12333 trunk/libraries/libRaster/src/org/gvsig/raster/grid/filter/bands/ColorTableListManager.java
ColorTableListManager.java | ||
---|---|---|
27 | 27 |
import org.gvsig.raster.grid.filter.RasterFilter; |
28 | 28 |
import org.gvsig.raster.grid.filter.RasterFilterList; |
29 | 29 |
import org.gvsig.raster.grid.filter.RasterFilterListManager; |
30 |
import org.gvsig.raster.grid.filter.enhancement.BrightnessFilter; |
|
31 |
import org.gvsig.raster.grid.filter.enhancement.ContrastFilter; |
|
30 | 32 |
import org.gvsig.raster.shared.ColorTable; |
31 | 33 |
import org.gvsig.raster.util.extensionPoints.ExtensionPoints; |
32 | 34 |
import org.gvsig.raster.util.extensionPoints.ExtensionPointsSingleton; |
33 | 35 |
|
34 | 36 |
/** |
35 | 37 |
* Gestor del filtro de aplicaci?n de tablas de color sobre un raster. |
36 |
*
|
|
38 |
* |
|
37 | 39 |
* @version 06/06/2007 |
38 | 40 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
39 | 41 |
* |
... | ... | |
51 | 53 |
/** |
52 | 54 |
* Constructor. |
53 | 55 |
* Asigna la lista de filtros y el managener global. |
54 |
*
|
|
56 |
* |
|
55 | 57 |
* @param filterListManager |
56 | 58 |
*/ |
57 | 59 |
public ColorTableListManager(RasterFilterListManager filterListManager) { |
... | ... | |
85 | 87 |
} |
86 | 88 |
|
87 | 89 |
public void addFilter(Class classFilter, Params params) { |
88 |
|
|
90 |
if (classFilter.equals(ColorTableFilter.class)) { |
|
91 |
GridPalette colorTable = null; |
|
92 |
for (int i = 0; i < params.getNumParams(); i++) { |
|
93 |
if (params.getParam(i).id.equals("colorTable")) |
|
94 |
colorTable = (GridPalette) params.getParam(i).defaultValue; |
|
95 |
} |
|
96 |
addColorTableFilter(colorTable); |
|
97 |
} |
|
89 | 98 |
} |
90 | 99 |
|
91 | 100 |
/* |
... | ... | |
94 | 103 |
*/ |
95 | 104 |
public int createFilterListFromStrings(ArrayList filters, String fil, int filteri) { |
96 | 105 |
if(fil.startsWith("filter.colortable.active")) { |
97 |
|
|
106 |
|
|
98 | 107 |
boolean exec = true; |
99 | 108 |
if((RasterFilterListManager.getValue(fil).equals("false"))) |
100 | 109 |
exec = false; |
101 |
|
|
102 |
ColorTable colorTable = new ColorTable();
|
|
110 |
|
|
111 |
ColorTable colorTable = new ColorTable(); |
|
103 | 112 |
int lengthList = 0; |
104 |
|
|
113 |
|
|
105 | 114 |
filters.remove(0); |
106 |
for(int prop = 0; prop < filters.size() ; prop++) {
|
|
115 |
for(int prop = 0; prop < filters.size() ; prop++) { |
|
107 | 116 |
String elem = (String) filters.get(prop); |
108 | 117 |
if(elem.startsWith("filter.colortable.type")) { |
109 | 118 |
colorTable.setType(Integer.parseInt(RasterFilterListManager.getValue(elem))); |
110 | 119 |
filters.remove(prop); |
111 | 120 |
prop--; |
112 | 121 |
} |
113 |
|
|
122 |
|
|
114 | 123 |
if(elem.startsWith("filter.colortable.values")) { |
115 | 124 |
String[] listString = RasterFilterListManager.getValue(elem).split(" "); |
116 | 125 |
int[] listInt = new int[listString.length]; |
... | ... | |
120 | 129 |
filters.remove(prop); |
121 | 130 |
prop--; |
122 | 131 |
} |
123 |
|
|
132 |
|
|
124 | 133 |
if(elem.startsWith("filter.colortable.range")) { |
125 | 134 |
String[] listString = RasterFilterListManager.getValue(elem).split(" "); |
126 | 135 |
lengthList = listString.length; |
127 | 136 |
if(colorTable.getType() == IBuffer.TYPE_BYTE || colorTable.getType() == IBuffer.TYPE_SHORT || colorTable.getType() == IBuffer.TYPE_INT) { |
128 | 137 |
int[] listInt = new int[listString.length]; |
129 | 138 |
for(int i = 0; i < listString.length; i++) |
130 |
listInt[i] = Integer.parseInt(listString[i]);
|
|
139 |
listInt[i] = Integer.parseInt(listString[i]); |
|
131 | 140 |
colorTable.setIntRange(listInt); |
132 | 141 |
} else { |
133 | 142 |
double[] listDouble = new double[listString.length]; |
134 | 143 |
for(int i = 0; i < listString.length; i++) |
135 |
listDouble[i] = Double.parseDouble(listString[i]);
|
|
144 |
listDouble[i] = Double.parseDouble(listString[i]); |
|
136 | 145 |
colorTable.setDoubleRange(listDouble); |
137 | 146 |
} |
138 | 147 |
filters.remove(prop); |
139 | 148 |
prop--; |
140 | 149 |
} |
141 |
|
|
150 |
|
|
142 | 151 |
if(elem.startsWith("filter.colortable.names")) { |
143 | 152 |
String[] listString = RasterFilterListManager.getValue(elem).split(" "); |
144 | 153 |
if(listString.length == 0) { |
... | ... | |
150 | 159 |
filters.remove(prop); |
151 | 160 |
prop--; |
152 | 161 |
} |
153 |
|
|
154 |
}
|
|
162 |
|
|
163 |
} |
|
155 | 164 |
filterList.remove(ColorTableFilter.class); |
156 |
addColorTableFilter(new GridPalette(colorTable));
|
|
157 |
|
|
165 |
addColorTableFilter(new GridPalette(colorTable)); |
|
166 |
|
|
158 | 167 |
ColorTableFilter ct = (ColorTableFilter)filterList.getFilterByBaseClass(ColorTableFilter.class); |
159 | 168 |
ct.setExec(exec); |
160 | 169 |
} |
... | ... | |
171 | 180 |
else |
172 | 181 |
filterList.add("filter.colortable.active=false"); |
173 | 182 |
filterList.add("filter.colortable.type=" + colorTable.getType()); |
174 |
|
|
183 |
|
|
175 | 184 |
String range = ""; |
176 | 185 |
if(colorTable.getType() == IBuffer.TYPE_BYTE || colorTable.getType() == IBuffer.TYPE_SHORT || colorTable.getType() == IBuffer.TYPE_INT) { |
177 | 186 |
for(int i = 0; i < colorTable.getIntRange().length; i++) |
... | ... | |
181 | 190 |
range += colorTable.getDoubleRange()[i] + " "; |
182 | 191 |
} |
183 | 192 |
filterList.add("filter.colortable.range=" + range); |
184 |
|
|
193 |
|
|
185 | 194 |
String values = ""; |
186 | 195 |
for(int i = 0; i < colorTable.getColorTable().length; i++) |
187 | 196 |
values += colorTable.getColorTable()[i] + " "; |
188 | 197 |
filterList.add("filter.colortable.values=" + values); |
189 |
|
|
198 |
|
|
190 | 199 |
String names = ""; |
191 | 200 |
for(int i = 0; i < colorTable.getNameClass().length; i++) |
192 | 201 |
names += colorTable.getNameClass()[i] + " "; |
Also available in: Unified diff