Statistics
| Revision:

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 / ToLumSaFilter.java @ 2308

History | View | Annotate | Download (3.51 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.dataset.Buffer;
25
import org.gvsig.fmap.dal.coverage.datastruct.Params;
26
import org.gvsig.fmap.dal.coverage.exception.FilterAddException;
27
import org.gvsig.fmap.dal.coverage.grid.filter.BaseRasterFilter;
28
import org.gvsig.raster.impl.store.ParamsImpl;
29
import org.gvsig.raster.util.DefaultColorConversion;
30
/**
31
 * <P>
32
 * Clase base para el filtro de Tono, Saturaci?n y Brillo
33
 * </P>
34
 *
35
 * @author Nacho Brodin (nachobrodin@gmail.com)
36
 */
37
public class ToLumSaFilter extends BaseRasterFilter {
38
        public static String[]            names            = new String[] { "tolumsa" };
39
        protected DefaultColorConversion  colorConversion  = null;
40
        protected int                     out              = Buffer.TYPE_BYTE;
41
        protected double                  hue              = 0;
42
        protected double                  luminosity       = 0;
43
        protected double                  saturation       = 0;
44
        
45
        /**
46
         * Constructor
47
         */
48
        public ToLumSaFilter() {
49
                super();
50
                setName(names[0]);
51
        }
52

    
53
        public void pre() throws FilterAddException {
54
                super.pre();
55
                checkRGBRenderBands();
56
                
57
                if(raster.getDataType() != Buffer.TYPE_BYTE) {
58
                        exec = false;
59
                        raster = rasterResult;
60
                        return;
61
                }
62
                if(params.get("hue") != null)
63
                        hue = ((Double) params.get("hue")).doubleValue();
64
                if(params.get("luminosity") != null)
65
                        luminosity = ((Double) params.get("luminosity")).doubleValue();
66
                if(params.get("saturation") != null)
67
                        saturation = ((Double) params.get("saturation")).doubleValue();
68
                
69
                createARGBBufferResult();
70
                
71
                if(colorConversion == null)
72
                        colorConversion = new DefaultColorConversion();
73
        }
74

    
75
        public String getGroup() {
76
                return "colores";
77
        }
78

    
79
        public String[] getNames() {
80
                return names;
81
        }
82

    
83
        public Params getUIParams(String nameFilter) {
84
                Params params = new ParamsImpl();
85
                params.setParam("hue",
86
                                new Double(hue),
87
                                Params.SLIDER,
88
                                new String[]{ "-180", "180", "0", "10", "50"}); //min, max, valor defecto, intervalo peque?o, intervalo grande;
89
                params.setParam("luminosity",
90
                                new Double(luminosity),
91
                                Params.SLIDER,
92
                                new String[]{ "-100", "100", "0", "10", "50"}); //min, max, valor defecto, intervalo peque?o, intervalo grande;
93
                params.setParam("saturation",
94
                                new Double(saturation),
95
                                Params.SLIDER,
96
                                new String[]{ "-100", "100", "0", "10", "50"}); //min, max, valor defecto, intervalo peque?o, intervalo grande;
97
                return params;
98
        }
99

    
100
        public void post() {
101
        
102
        }
103

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

    
107
        public int getOutRasterDataType() {
108
                return Buffer.TYPE_BYTE;
109
        }
110

    
111
        public boolean isVisible() {
112
                return true;
113
        }
114

    
115
        public int getInRasterDataType() {
116
                return Buffer.TYPE_BYTE;
117
        }
118
}