gvsig-raster / 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 / ColorTableFilter.java @ 162
History | View | Annotate | Download (4.6 KB)
1 | 21 | nbrodin | /* 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 | 55 | nbrodin | import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
25 | 21 | nbrodin | import org.gvsig.fmap.dal.coverage.datastruct.Params; |
26 | 151 | nbrodin | import org.gvsig.fmap.dal.coverage.grid.filter.BaseRasterFilter; |
27 | 124 | nbrodin | import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
28 | 28 | nbrodin | import org.gvsig.raster.impl.DefaultRasterManager; |
29 | 21 | nbrodin | import org.gvsig.raster.impl.buffer.RasterBuffer; |
30 | 71 | nbrodin | import org.gvsig.raster.impl.store.ParamsImpl; |
31 | 162 | nbrodin | import org.gvsig.raster.impl.store.properties.DataStoreColorTable; |
32 | 21 | nbrodin | /**
|
33 | * <P>
|
||
34 | * Clase base para los filtros de tabla de color. Siempre gastar? la banda cero
|
||
35 | * del raster para aplicar el filtro ya que la aplicaci?n de tablas suele tener
|
||
36 | * sentido solo en raster de una sola banda.
|
||
37 | * </P>
|
||
38 | * <P>
|
||
39 | * La salida siempre es un ARGB.
|
||
40 | * </P>
|
||
41 | *
|
||
42 | * @version 06/06/2007
|
||
43 | * @author Nacho Brodin (nachobrodin@gmail.com)
|
||
44 | */
|
||
45 | 151 | nbrodin | public class ColorTableFilter extends BaseRasterFilter { |
46 | 124 | nbrodin | protected Buffer rasterAlpha = null; |
47 | public static String[] names = new String[] { "colortable" }; |
||
48 | 162 | nbrodin | protected DataStoreColorTable colorTable = new DataStoreColorTable(); |
49 | 124 | nbrodin | protected boolean hasAlpha = false; |
50 | 21 | nbrodin | |
51 | /**
|
||
52 | * Constructor
|
||
53 | */
|
||
54 | public ColorTableFilter() {
|
||
55 | super();
|
||
56 | setName(names[0]);
|
||
57 | } |
||
58 | |||
59 | /*
|
||
60 | * (non-Javadoc)
|
||
61 | * @see org.gvsig.raster.grid.filter.RasterFilter#pre()
|
||
62 | */
|
||
63 | public void pre() { |
||
64 | exec = true;
|
||
65 | raster = (RasterBuffer) params.get("raster");
|
||
66 | 162 | nbrodin | colorTable = ((DataStoreColorTable) params.get("colorTable"));
|
67 | 21 | nbrodin | hasAlpha = colorTable.hasAlpha(); |
68 | if (raster != null) { |
||
69 | height = raster.getHeight(); |
||
70 | width = raster.getWidth(); |
||
71 | 30 | nbrodin | rasterResult = DefaultRasterManager.getInstance().createBuffer(Buffer.TYPE_BYTE, raster.getWidth(), raster.getHeight(), 3, true); |
72 | 21 | nbrodin | if (hasAlpha)
|
73 | 30 | nbrodin | rasterAlpha = DefaultRasterManager.getInstance().createBuffer(Buffer.TYPE_BYTE, raster.getWidth(), raster.getHeight(), 1, true); |
74 | 21 | nbrodin | } |
75 | } |
||
76 | |||
77 | /*
|
||
78 | * (non-Javadoc)
|
||
79 | * @see org.gvsig.raster.grid.filter.RasterFilter#getGroup()
|
||
80 | */
|
||
81 | public String getGroup() { |
||
82 | return "radiometrico"; |
||
83 | } |
||
84 | |||
85 | /*
|
||
86 | * (non-Javadoc)
|
||
87 | * @see org.gvsig.raster.grid.filter.RasterFilter#getNames()
|
||
88 | */
|
||
89 | public String[] getNames() { |
||
90 | return names;
|
||
91 | } |
||
92 | |||
93 | /*
|
||
94 | * (non-Javadoc)
|
||
95 | * @see org.gvsig.raster.grid.filter.RasterFilter#getResult(java.lang.String)
|
||
96 | */
|
||
97 | public Object getResult(String name) { |
||
98 | if (name.equals("alphaBand")) |
||
99 | return rasterAlpha;
|
||
100 | |||
101 | if (name.equals("raster")) |
||
102 | return (Object) this.rasterResult; |
||
103 | return null; |
||
104 | } |
||
105 | |||
106 | /*
|
||
107 | * (non-Javadoc)
|
||
108 | * @see org.gvsig.raster.grid.filter.RasterFilter#getUIParams(java.lang.String)
|
||
109 | */
|
||
110 | public Params getUIParams(String nameFilter) { |
||
111 | Params params = new ParamsImpl();
|
||
112 | params.setParam("colorTable",
|
||
113 | 162 | nbrodin | new DataStoreColorTable(colorTable),
|
114 | 21 | nbrodin | -1,
|
115 | null);
|
||
116 | return params;
|
||
117 | } |
||
118 | |||
119 | public void post() { |
||
120 | } |
||
121 | |||
122 | public void process(int x, int y) { |
||
123 | } |
||
124 | |||
125 | /*
|
||
126 | * (non-Javadoc)
|
||
127 | * @see org.gvsig.raster.grid.filter.RasterFilter#getOutRasterDataType()
|
||
128 | */
|
||
129 | public int getOutRasterDataType() { |
||
130 | return Buffer.TYPE_BYTE; |
||
131 | } |
||
132 | |||
133 | /*
|
||
134 | * (non-Javadoc)
|
||
135 | * @see org.gvsig.raster.grid.filter.RasterFilter#isVisible()
|
||
136 | */
|
||
137 | public boolean isVisible() { |
||
138 | return false; |
||
139 | } |
||
140 | |||
141 | /**
|
||
142 | * Obtiene la tabla de color que se usar? para la aplicaci?n del filtro
|
||
143 | * @return GridPalette
|
||
144 | */
|
||
145 | 124 | nbrodin | public ColorTable getColorTable() {
|
146 | 21 | nbrodin | if ((colorTable == null) || (colorTable.getColorItems() == null)) |
147 | 162 | nbrodin | colorTable = ((DataStoreColorTable) params.get("colorTable"));
|
148 | 21 | nbrodin | return colorTable;
|
149 | } |
||
150 | |||
151 | /*
|
||
152 | * (non-Javadoc)
|
||
153 | * @see org.gvsig.raster.grid.filter.RasterFilter#getInRasterDataType()
|
||
154 | */
|
||
155 | public int getInRasterDataType() { |
||
156 | return 0; |
||
157 | } |
||
158 | |||
159 | /**
|
||
160 | * Define la tabla de color
|
||
161 | * @param colorTable the colorTable to set
|
||
162 | */
|
||
163 | 124 | nbrodin | public void setColorTable(ColorTable colorTable) { |
164 | 162 | nbrodin | this.colorTable = (DataStoreColorTable)colorTable;
|
165 | 21 | nbrodin | } |
166 | } |