Revision 2438 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/band/ColorTableListManager.java
ColorTableListManager.java | ||
---|---|---|
21 | 21 |
*/ |
22 | 22 |
package org.gvsig.raster.impl.grid.filter.band; |
23 | 23 |
|
24 |
import java.awt.Color; |
|
25 | 24 |
import java.util.ArrayList; |
26 | 25 |
import java.util.List; |
27 | 26 |
|
28 |
import org.gvsig.fmap.dal.coverage.datastruct.ColorItem; |
|
29 | 27 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
30 | 28 |
import org.gvsig.fmap.dal.coverage.exception.FilterTypeException; |
29 |
import org.gvsig.fmap.dal.coverage.grid.AbstractRasterFilterManager; |
|
31 | 30 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilter; |
32 | 31 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList; |
33 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager; |
|
34 | 32 |
import org.gvsig.fmap.dal.coverage.grid.filter.BaseRasterFilter; |
35 | 33 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
36 |
import org.gvsig.raster.impl.datastruct.ColorItemImpl; |
|
37 | 34 |
import org.gvsig.raster.impl.grid.filter.RasterFilterListManagerImpl; |
38 | 35 |
import org.gvsig.raster.impl.store.ParamImpl; |
39 |
import org.gvsig.raster.impl.store.properties.DataStoreColorTable; |
|
40 |
import org.gvsig.tools.ToolsLocator; |
|
41 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
42 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
43 | 36 |
/** |
44 | 37 |
* Gestor del filtro de aplicaci?n de tablas de color sobre un raster. |
45 | 38 |
* |
46 |
* @version 06/06/2007 |
|
47 | 39 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
48 | 40 |
* |
49 | 41 |
*/ |
50 |
public class ColorTableListManager implements RasterFilterListManager { |
|
51 |
|
|
52 |
protected RasterFilterList filterList = null; |
|
53 |
|
|
42 |
public class ColorTableListManager extends AbstractRasterFilterManager { |
|
43 |
private static String ID = "ColorTable"; |
|
44 |
|
|
54 | 45 |
/** |
55 |
* Registra ColorTableListManager en los puntos de extension de RasterFilter |
|
46 |
* Default constructor. Sets the filter list. |
|
47 |
* @param filterList |
|
56 | 48 |
*/ |
49 |
public ColorTableListManager(RasterFilterList filterList) { |
|
50 |
super(filterList); |
|
51 |
} |
|
52 |
|
|
53 |
public String getManagerID() { |
|
54 |
return ID; |
|
55 |
} |
|
56 |
|
|
57 | 57 |
public static void register() { |
58 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
|
59 |
ExtensionPoint point = extensionPoints.get("RasterFilter"); |
|
60 |
point.append("ColorTable", "", ColorTableListManager.class); |
|
58 |
AbstractRasterFilterManager.register(ID, ColorTableListManager.class); |
|
61 | 59 |
} |
62 | 60 |
|
63 | 61 |
public boolean isDataTypeSupported(int dataType) { |
... | ... | |
70 | 68 |
return null; |
71 | 69 |
} |
72 | 70 |
|
73 |
/** |
|
74 |
* Default constructor. Sets the filter list. |
|
75 |
* @param filterList |
|
76 |
*/ |
|
77 |
public ColorTableListManager(RasterFilterList filterList) { |
|
78 |
this.filterList = filterList; |
|
79 |
} |
|
80 | 71 |
|
81 | 72 |
/** |
82 | 73 |
* Constructor. |
... | ... | |
85 | 76 |
* @param filterListManager |
86 | 77 |
*/ |
87 | 78 |
public ColorTableListManager(RasterFilterListManagerImpl filterListManager) { |
88 |
this.filterList = filterListManager.getFilterList();
|
|
79 |
super(filterListManager.getFilterList());
|
|
89 | 80 |
} |
90 | 81 |
|
91 | 82 |
/** |
... | ... | |
100 | 91 |
|
101 | 92 |
if (filter != null) { |
102 | 93 |
filter.addParam("colorTable", palette); |
103 |
filterList.add(filter);
|
|
94 |
getFilterList().add(filter);
|
|
104 | 95 |
} |
105 | 96 |
} |
106 | 97 |
|
... | ... | |
128 | 119 |
* @param value |
129 | 120 |
* @return |
130 | 121 |
*/ |
131 |
@SuppressWarnings("unchecked") |
|
132 |
private static ColorItem getColorItem(ArrayList list, double value) { |
|
122 |
/*private static ColorItem getColorItem(List<ColorItem> list, double value) { |
|
133 | 123 |
for (int i = 0; i < list.size(); i++) { |
134 | 124 |
if (((ColorItem) list.get(i)).getValue() == value) { |
135 | 125 |
return (ColorItem) list.remove(i); |
... | ... | |
138 | 128 |
return null; |
139 | 129 |
} |
140 | 130 |
|
141 |
@SuppressWarnings("unchecked") |
|
142 | 131 |
public static ColorTable createColorTableFromArray(List<String> lines) { |
143 | 132 |
String pkgBase = "filter.colortable."; |
144 | 133 |
List<String> linesCloned = null; |
145 | 134 |
|
146 | 135 |
if(lines instanceof ArrayList) { |
147 |
linesCloned = (List<String>)((ArrayList) lines).clone(); |
|
136 |
linesCloned = (List<String>)((ArrayList<?>) lines).clone();
|
|
148 | 137 |
} else { |
149 | 138 |
linesCloned = new ArrayList<String>(); |
150 | 139 |
for (int i = 0; i < lines.size(); i++) { |
... | ... | |
155 | 144 |
String paletteName = ""; |
156 | 145 |
int color = 0; |
157 | 146 |
int alpha = 0; |
158 |
ArrayList rows = new ArrayList();
|
|
147 |
List<ColorItem> rows = new ArrayList<ColorItem>();
|
|
159 | 148 |
|
160 | 149 |
ColorItem colorItem = new ColorItemImpl(); |
161 | 150 |
boolean interpolated = false; |
... | ... | |
237 | 226 |
return colorTable; |
238 | 227 |
} |
239 | 228 |
|
240 |
/* |
|
241 |
* (non-Javadoc) |
|
242 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#createFilterListFromStrings(java.util.ArrayList, java.lang.String, int) |
|
243 |
*/ |
|
244 | 229 |
public int createFilterListFromStrings(List<String> filters, String fil, int filteri) throws FilterTypeException { |
245 | 230 |
String pkgBase = "filter.colortable."; |
246 | 231 |
if (fil.startsWith(pkgBase + "active")) { |
... | ... | |
251 | 236 |
|
252 | 237 |
ColorTable colorTable = createColorTableFromArray(filters); |
253 | 238 |
|
254 |
filterList.remove(ColorTableFilter.class);
|
|
239 |
getFilterList().remove(ColorTableFilter.class);
|
|
255 | 240 |
addColorTableFilter(new DataStoreColorTable(colorTable)); |
256 | 241 |
|
257 |
ColorTableFilter ct = (ColorTableFilter) filterList.getFilterByBaseClass(ColorTableFilter.class);
|
|
242 |
ColorTableFilter ct = (ColorTableFilter) getFilterList().getFilterByBaseClass(ColorTableFilter.class);
|
|
258 | 243 |
ct.setExec(exec); |
259 | 244 |
} |
260 | 245 |
return filteri; |
261 | 246 |
} |
262 | 247 |
|
263 |
/* |
|
264 |
* (non-Javadoc) |
|
265 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#getStringsFromFilterList(java.util.ArrayList, org.gvsig.raster.grid.filter.RasterFilter) |
|
266 |
*/ |
|
267 | 248 |
public List<String> getStringsFromFilterList(List<String> filterList, RasterFilter rf) { |
268 | 249 |
if (rf instanceof ColorTableFilter) { |
269 | 250 |
String pkgBase = "filter.colortable."; |
... | ... | |
297 | 278 |
} |
298 | 279 |
} |
299 | 280 |
return filterList; |
300 |
} |
|
281 |
}*/
|
|
301 | 282 |
|
302 |
/* |
|
303 |
* (non-Javadoc) |
|
304 |
* @see org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager#getFilterList() |
|
305 |
*/ |
|
306 |
public RasterFilterList getFilterList() { |
|
307 |
return filterList; |
|
308 |
} |
|
309 |
|
|
310 |
/* |
|
311 |
* (non-Javadoc) |
|
312 |
* @see org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager#setFilterList(org.gvsig.fmap.dal.coverage.grid.RasterFilterList) |
|
313 |
*/ |
|
314 |
public void setFilterList(RasterFilterList filterList) { |
|
315 |
this.filterList = filterList; |
|
316 |
} |
|
317 |
|
|
318 |
/* |
|
319 |
* (non-Javadoc) |
|
320 |
* @see org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager#addFilter(org.gvsig.fmap.dal.coverage.datastruct.Params) |
|
321 |
*/ |
|
322 | 283 |
public void addFilter(Params params) throws FilterTypeException { |
323 | 284 |
addFilter(ColorTableFilter.class, params); |
324 | 285 |
} |
325 | 286 |
|
326 |
/* |
|
327 |
* (non-Javadoc) |
|
328 |
* @see org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager#createFilter(org.gvsig.fmap.dal.coverage.datastruct.Params) |
|
329 |
*/ |
|
330 | 287 |
public RasterFilter createFilter(Params params) { |
331 | 288 |
ColorTable colorTable = ((ColorTable) params.getParamById("colorTable").getDefaultValue()); |
332 | 289 |
|
Also available in: Unified diff