Statistics
| Revision:

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

History | View | Annotate | Download (3.5 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.IRasterDataSource;
24
import org.gvsig.raster.dataset.Params;
25
import org.gvsig.raster.grid.filter.RasterFilter;
26
import org.gvsig.raster.util.ColorConversion;
27
/**
28
 * <P>
29
 * Clase base para los filtros de conversi?n de HSL a RGB. La entrada ser? 
30
 * siempre un raster de 3 bandas que ser?n tomadas como HSL.
31
 * </P>
32
 *
33
 * @version 06/06/2007
34
 * @author Nacho Brodin (nachobrodin@gmail.com)
35
 */
36
public class HSLToRGBFilter extends RasterFilter {
37
        protected IBuffer          rasterAlpha      = null;
38
        public static String[]     names            = new String[] { "hsltorgb" };
39
        protected ColorConversion  colorConversion  = null;
40

    
41
        /**
42
         * Constructor
43
         */
44
        public HSLToRGBFilter() {
45
                super();
46
                setName(names[0]);
47
        }
48

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

    
65
        /*
66
         * (non-Javadoc)
67
         * @see org.gvsig.raster.grid.filter.RasterFilter#getGroup()
68
         */
69
        public String getGroup() {
70
                return "colores";
71
        }
72

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

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

    
91
        /*
92
         * (non-Javadoc)
93
         * @see org.gvsig.raster.grid.filter.RasterFilter#getUIParams(java.lang.String)
94
         */
95
        public Params getUIParams(String nameFilter) {
96
                Params params = new Params();
97
                return params;
98
        }
99

    
100
        public void post() {
101
        
102
        }
103

    
104
        public void process(int x, int y) {
105
        }
106

    
107
        /*
108
         * (non-Javadoc)
109
         * @see org.gvsig.raster.grid.filter.RasterFilter#getOutRasterDataType()
110
         */
111
        public int getOutRasterDataType() {
112
                return IBuffer.TYPE_BYTE;
113
        }
114

    
115
        /*
116
         * (non-Javadoc)
117
         * @see org.gvsig.raster.grid.filter.RasterFilter#isVisible()
118
         */
119
        public boolean isVisible() {
120
                IRasterDataSource datasource = (IRasterDataSource)getEnv().get("MultiRasterDataset");
121
                return (datasource != null && datasource.getBandCount() >= 3);
122
        }
123

    
124
        /*
125
         * (non-Javadoc)
126
         * @see org.gvsig.raster.grid.filter.RasterFilter#getInRasterDataType()
127
         */
128
        public int getInRasterDataType() {
129
                return IBuffer.TYPE_BYTE;
130
        }
131
}