gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster_dataaccess_refactoring / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / grid / filter / band / ColorTableFilter.java @ 2309
History | View | Annotate | Download (3.73 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.impl.grid.filter.band; |
23 |
|
24 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
25 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
26 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
27 |
import org.gvsig.fmap.dal.coverage.exception.FilterAddException; |
28 |
import org.gvsig.fmap.dal.coverage.grid.filter.BaseRasterFilter; |
29 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
30 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
31 |
import org.gvsig.raster.impl.store.ParamsImpl; |
32 |
import org.gvsig.raster.impl.store.properties.DataStoreColorTable; |
33 |
/**
|
34 |
* <P>
|
35 |
* Clase base para los filtros de tabla de color. Siempre gastar? la banda cero
|
36 |
* del raster para aplicar el filtro ya que la aplicaci?n de tablas suele tener
|
37 |
* sentido solo en raster de una sola banda.
|
38 |
* </P>
|
39 |
* <P>
|
40 |
* La salida siempre es un ARGB.
|
41 |
* </P>
|
42 |
*
|
43 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
44 |
*/
|
45 |
public class ColorTableFilter extends BaseRasterFilter { |
46 |
public static String[] names = new String[] { "colortable" }; |
47 |
protected DataStoreColorTable colorTable = new DataStoreColorTable(); |
48 |
protected boolean hasAlpha = false; |
49 |
|
50 |
/**
|
51 |
* Constructor
|
52 |
*/
|
53 |
public ColorTableFilter() {
|
54 |
super();
|
55 |
setName(names[0]);
|
56 |
} |
57 |
|
58 |
public void pre() throws FilterAddException { |
59 |
super.pre();
|
60 |
|
61 |
colorTable = ((DataStoreColorTable) params.get("colorTable"));
|
62 |
hasAlpha = colorTable.hasAlpha(); |
63 |
|
64 |
//El filtro de tabla de color convierte a ARGB a partir de paleta
|
65 |
ColorInterpretation ci = RasterLocator.getManager().getDataStructFactory().createColorInterpretation( |
66 |
new String[]{ColorInterpretation.RED_BAND, |
67 |
ColorInterpretation.GREEN_BAND, |
68 |
ColorInterpretation.BLUE_BAND, |
69 |
ColorInterpretation.ALPHA_BAND}); |
70 |
transparency.setColorInterpretation(ci); |
71 |
transparency.activeTransparency(); |
72 |
|
73 |
createARGBBufferResult(); |
74 |
} |
75 |
|
76 |
public String getGroup() { |
77 |
return "radiometrico"; |
78 |
} |
79 |
|
80 |
public String[] getNames() { |
81 |
return names;
|
82 |
} |
83 |
|
84 |
public Params getUIParams(String nameFilter) { |
85 |
Params params = new ParamsImpl();
|
86 |
params.setParam("colorTable",
|
87 |
new DataStoreColorTable(colorTable),
|
88 |
-1,
|
89 |
null);
|
90 |
return params;
|
91 |
} |
92 |
|
93 |
public void post() { |
94 |
} |
95 |
|
96 |
public void process(int x, int y) { |
97 |
} |
98 |
|
99 |
public int getOutRasterDataType() { |
100 |
return Buffer.TYPE_BYTE; |
101 |
} |
102 |
|
103 |
public boolean isVisible() { |
104 |
return false; |
105 |
} |
106 |
|
107 |
/**
|
108 |
* Obtiene la tabla de color que se usar? para la aplicaci?n del filtro
|
109 |
* @return GridPalette
|
110 |
*/
|
111 |
public ColorTable getColorTable() {
|
112 |
if ((colorTable == null) || (colorTable.getColorItems() == null)) |
113 |
colorTable = ((DataStoreColorTable) params.get("colorTable"));
|
114 |
return colorTable;
|
115 |
} |
116 |
|
117 |
public int getInRasterDataType() { |
118 |
return 0; |
119 |
} |
120 |
|
121 |
/**
|
122 |
* Define la tabla de color
|
123 |
* @param colorTable the colorTable to set
|
124 |
*/
|
125 |
public void setColorTable(ColorTable colorTable) { |
126 |
this.colorTable = (DataStoreColorTable)colorTable;
|
127 |
} |
128 |
} |