Statistics
| Revision:

root / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / raster / ComputeMinMaxShortFilter.java @ 2664

History | View | Annotate | Download (3.05 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

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

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

    
126

    
127
}
128