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 / enhancement / GrayScaleFilter.java @ 2348
History | View | Annotate | Download (2.92 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.enhancement; |
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 |
/**
|
30 |
* <P>
|
31 |
* Clase base para los filtros de conversi?n a escala de gris
|
32 |
* </P>
|
33 |
*
|
34 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
35 |
*/
|
36 |
public class GrayScaleFilter extends BaseRasterFilter { |
37 |
public static final int R = 0; |
38 |
public static final int G = 1; |
39 |
public static final int B = 2; |
40 |
public static final int RGB = 3; |
41 |
public static final int GRAY = 4; |
42 |
public static final int UNDEFINED = -1; |
43 |
public static String[] names = new String[] { GrayScaleManager.ID }; |
44 |
protected int type = UNDEFINED; |
45 |
|
46 |
/**
|
47 |
* Constructor
|
48 |
*/
|
49 |
public GrayScaleFilter() {
|
50 |
super();
|
51 |
setName(names[0]);
|
52 |
} |
53 |
|
54 |
public void pre() throws FilterAddException { |
55 |
super.pre();
|
56 |
|
57 |
type = ((Integer)params.get("typeBand")).intValue(); |
58 |
|
59 |
if(type == RGB && raster.getBandCount() < 3) |
60 |
type = R; |
61 |
|
62 |
createARGBBufferResult(); |
63 |
} |
64 |
|
65 |
public String getGroup() { |
66 |
return "colores"; |
67 |
} |
68 |
|
69 |
public String[] getNames() { |
70 |
return names;
|
71 |
} |
72 |
|
73 |
public Params getUIParams(String nameFilter) { |
74 |
if(type == UNDEFINED) {
|
75 |
if(this.params != null) { |
76 |
Object obj = this.params.get("typeBand"); |
77 |
if(obj != null) |
78 |
type = ((Integer)obj).intValue();
|
79 |
} |
80 |
} |
81 |
|
82 |
Params params = RasterLocator.getManager().createParams( |
83 |
"typeBand",
|
84 |
new Integer(R), |
85 |
Params.CHOICE, |
86 |
new String[]{ "R", "G", "B", "RGB", "GRAY"}); |
87 |
|
88 |
return params;
|
89 |
} |
90 |
|
91 |
public void post() { |
92 |
} |
93 |
|
94 |
public void process(int x, int y) { |
95 |
} |
96 |
|
97 |
public int getOutRasterDataType() { |
98 |
return Buffer.TYPE_BYTE; |
99 |
} |
100 |
|
101 |
public boolean isVisible() { |
102 |
return true; |
103 |
} |
104 |
|
105 |
public int getInRasterDataType() { |
106 |
return Buffer.TYPE_BYTE; |
107 |
} |
108 |
} |