Statistics
| Revision:

svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / raster / ComputeMinMaxShortFilter.java @ 2312

History | View | Annotate | Download (3.08 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 * 
4
 * Copyright (C) 2004-5. 
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 * 
22
 * cresques@gmail.com
23
 */
24
package org.cresques.io.raster;
25

    
26
import java.awt.Image;
27

    
28
/**
29
 * Calcula el m?ximo y el m?nimo de un raster.
30
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
31
 */
32
public class ComputeMinMaxShortFilter extends ComputeMinMaxFilter {
33
        
34
        /**
35
         * Constructor
36
         *
37
         */
38
        public ComputeMinMaxShortFilter(){
39
                super();
40
        }
41
                        
42
        /* (non-Javadoc)
43
         * @see org.cresques.io.raster.IRasterFilter#pre()
44
         */
45
        public void pre(){
46
                //Obtenci?n de par?metros
47
                
48
                this.raster = (RasterBuf)params.get("raster");
49
                                
50
                height = raster.getHeight();
51
                width = raster.getWidth();
52
                super.pre();
53
        }
54
        
55
        /* (non-Javadoc)
56
         * @see org.cresques.io.raster.IRasterFilter#process(int, int)
57
         */
58
        public void process(int x, int y) {
59
                raster.getElemInt(x, y, px);
60

    
61
                int pxBand = px[0]; 
62
                if(pxBand<min[0]){
63
                        secondMin[0] = min[0];
64
                        min[0] = pxBand;
65
                }else if(pxBand < secondMin[0] && pxBand!=min[0])
66
                        secondMin[0] = pxBand;
67
                        
68
                if(pxBand>max[0]){
69
                        secondMax[0] = max[0];
70
                        max[0] = pxBand;
71
                }else if(pxBand > secondMax[0] && pxBand!=max[0])
72
                        secondMax[0] = pxBand;
73
                
74
                pxBand = px[1]; 
75
                if(pxBand<min[1]){
76
                        secondMin[1] = min[1];
77
                        min[1] = pxBand;
78
                }else if(pxBand < secondMin[1] && pxBand!=min[1])
79
                        secondMin[1] = pxBand;
80
                
81
                if(pxBand>max[1]){
82
                        secondMax[1] = max[1];
83
                        max[1] = pxBand;
84
                }else if(pxBand > secondMax[1] && pxBand!=max[1])
85
                        secondMax[1] = pxBand;
86
                
87
                pxBand = px[2];
88
                if(pxBand<min[2]){
89
                        secondMin[2] = min[2];
90
                        min[2] = pxBand;
91
                }else if(pxBand < secondMin[2] && pxBand!=min[2])
92
                        secondMin[2] = pxBand;
93
                
94
                if(pxBand>max[2]){
95
                        secondMax[2] = max[2];
96
                        max[2] = pxBand;
97
                }else if(pxBand > secondMax[2] && pxBand!=max[2])
98
                        secondMax[2] = pxBand;
99
        }
100
        
101
        /* (non-Javadoc)
102
         * @see org.cresques.io.raster.IRasterFilter#getInRasterDataType()
103
         */
104
        public int getInRasterDataType(){
105
                return RasterBuf.TYPE_SHORT;
106
        }
107
        
108
        /* (non-Javadoc)
109
         * @see org.cresques.io.raster.IRasterFilter#getOutRasterDataType()
110
         */
111
        public int getOutRasterDataType(){
112
                return RasterBuf.TYPE_SHORT;
113
        }
114
        
115
        /* (non-Javadoc)
116
         * @see org.cresques.io.raster.IRasterFilter#post()
117
         */
118
        public void post(){
119
                super.post();
120
        };
121
        
122
        /* (non-Javadoc)
123
         * @see org.cresques.io.raster.RasterFilter#processLine(int)
124
         */
125
        public void processLine(int y){};
126

    
127

    
128
}
129