Statistics
| Revision:

root / trunk / libraries / libRaster / src / org / gvsig / raster / grid / filter / bands / ColorTableFilter.java @ 17874

History | View | Annotate | Download (3.86 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.raster.grid.filter.bands;
20

    
21
import org.gvsig.raster.buffer.RasterBuffer;
22
import org.gvsig.raster.dataset.IBuffer;
23
import org.gvsig.raster.dataset.Params;
24
import org.gvsig.raster.grid.GridPalette;
25
import org.gvsig.raster.grid.filter.RasterFilter;
26
/**
27
 * <P>
28
 * Clase base para los filtros de tabla de color. Siempre gastar? la banda cero
29
 * del raster para aplicar el filtro ya que la aplicaci?n de tablas suele tener
30
 * sentido solo en raster de una sola banda.
31
 * </P>
32
 * <P>
33
 * La salida siempre es un ARGB.
34
 * </P>
35
 *
36
 * @version 06/06/2007
37
 * @author Nacho Brodin (nachobrodin@gmail.com)
38
 */
39
public class ColorTableFilter extends RasterFilter {
40
        protected IBuffer      rasterAlpha  = null;
41
        public static String[] names        = new String[] { "colortable" };
42
        protected GridPalette  colorTable   = new GridPalette();
43

    
44
        /**
45
         * Constructor
46
         */
47
        public ColorTableFilter() {
48
                super();
49
                setName(names[0]);
50
        }
51

    
52
        /*
53
         * (non-Javadoc)
54
         * @see org.gvsig.raster.grid.filter.RasterFilter#pre()
55
         */
56
        public void pre() {
57
                exec = true;
58
                raster = (RasterBuffer) params.get("raster");
59
                if(raster != null) {
60
                        height = raster.getHeight();
61
                        width = raster.getWidth();
62
                        rasterResult = RasterBuffer.getBuffer(IBuffer.TYPE_BYTE, raster.getWidth(), raster.getHeight(), 3, true);
63
                        rasterAlpha = RasterBuffer.getBuffer(IBuffer.TYPE_BYTE, raster.getWidth(), raster.getHeight(), 1, true);
64
                }
65
                colorTable = ((GridPalette) params.get("colorTable"));
66
        }
67

    
68
        /*
69
         * (non-Javadoc)
70
         * @see org.gvsig.raster.grid.filter.RasterFilter#getGroup()
71
         */
72
        public String getGroup() {
73
                return "radiometrico";
74
        }
75

    
76
        /*
77
         * (non-Javadoc)
78
         * @see org.gvsig.raster.grid.filter.RasterFilter#getNames()
79
         */
80
        public String[] getNames() {
81
                return names;
82
        }
83

    
84
        /*
85
         * (non-Javadoc)
86
         * @see org.gvsig.raster.grid.filter.RasterFilter#getResult(java.lang.String)
87
         */
88
        public Object getResult(String name) {
89
                if (name.equals("raster"))
90
                        return (Object) this.rasterResult;
91
                return null;
92
        }
93

    
94
        /*
95
         * (non-Javadoc)
96
         * @see org.gvsig.raster.grid.filter.RasterFilter#getUIParams(java.lang.String)
97
         */
98
        public Params getUIParams(String nameFilter) {
99
                Params params = new Params();
100
                params.setParam("colorTable",
101
                                new GridPalette(colorTable),
102
                                -1,
103
                                null);
104
                return params;
105
        }
106

    
107
        public void post() {
108
                mergeBufferTransparency(rasterAlpha);
109

    
110
                // En caso de que nadie apunte a raster, se liberar? su memoria.
111
                raster = null;
112
        }
113

    
114
        public void process(int x, int y) {
115
        }
116

    
117
        /*
118
         * (non-Javadoc)
119
         * @see org.gvsig.raster.grid.filter.RasterFilter#getOutRasterDataType()
120
         */
121
        public int getOutRasterDataType() {
122
                return IBuffer.TYPE_BYTE;
123
        }
124

    
125
        /*
126
         * (non-Javadoc)
127
         * @see org.gvsig.raster.grid.filter.RasterFilter#isVisible()
128
         */
129
        public boolean isVisible() {
130
                return false;
131
        }
132

    
133
        /**
134
         * Obtiene la tabla de color que se usar? para la aplicaci?n del filtro
135
         * @return GridPalette
136
         */
137
        public GridPalette getColorTable() {
138
                return colorTable;
139
        }
140

    
141
        /*
142
         * (non-Javadoc)
143
         * @see org.gvsig.raster.grid.filter.RasterFilter#getInRasterDataType()
144
         */
145
        public int getInRasterDataType() {
146
                return 0;
147
        }
148
}