Statistics
| Revision:

gvsig-raster / org.gvsig.raster.cache / trunk / org.gvsig.raster.cache / org.gvsig.raster.cache.lib.impl / deprecated / buffer / impl / histogram / HistogramClassImpl.java @ 1939

History | View | Annotate | Download (3.18 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.cache.buffer.impl.histogram;
23

    
24
import org.gvsig.raster.cache.buffer.histogram.HistogramClass;
25

    
26

    
27
/**
28
 * Clase que define un intervalo de datos. Es util para cosas como el calculo de histogramas
29
 * con tipo de datos en coma flotante en el cual hay que dividir los intervalos en
30
 * clases. Las clases se tendr?n en cuenta como un intervalo el cual el menor es cerrado y el 
31
 * mayor abierto, es decir
32
 * <PRE>
33
 * En las clases:
34
 * 0-1000
35
 * 1000-2000
36
 * los intervalos son 
37
 * [0, 1000 [  de 0-999.9p
38
 * [1000, 2000[ de 1000-1999.9p
39
 * </PRE>
40
 *  
41
 * @author Nacho Brodin (nachobrodin@gmail.com)
42
 *
43
 */
44
public class HistogramClassImpl implements HistogramClass {        
45
        private double         value = 0D;
46
        private double         min = 0D;
47
        private double         max = 0D;
48

    
49
        /**
50
         * Constructor.
51
         * @param a Entero que representa al un valor de la clase
52
         * @param b Entero que representa al un valor de la clase
53
         */
54
        public HistogramClassImpl(double a, double b){
55
                this.max = (a >= b) ? a : b;
56
                this.min = (a <= b) ? a : b;
57
        }
58
        
59
        /**
60
         * Comprueba si el valor pasado por par?metro est? dentro del intervalo
61
         * @param value Valor a comprobar
62
         * @return true si est? dentro del intervalo y false si no lo est?
63
         */
64
        public boolean isIn(double value){
65
                return (value >= min && value < max);
66
        }
67
        
68
        /**
69
         * Obtiene el valor m?ximo de la clase
70
         * @return Entero que representa al valor m?ximo de la clase
71
         */
72
        public double getMax() {
73
                return max;
74
        }
75
        
76
        /**
77
         * Asigna el valor m?ximo de la clase
78
         * @param max Entero que representa al valor m?ximo de la clase
79
         */
80
        public void setMax(double max) {
81
                this.max = max;
82
        }
83
        
84
        /**
85
         * Obtiene el valor m?nimo de la clase
86
         * @return Entero que representa al valor m?nimo de la clase
87
         */
88
        public double getMin() {
89
                return min;
90
        }
91
        
92
        /**
93
         * ASigna el valor m?nimo de la clase
94
         * @param min Entero que representa al valor m?nimo de la clase
95
         */
96
        public void setMin(double min) {
97
                this.min = min;
98
        }
99

    
100
        /**
101
         * Obtiene el valor de la clase
102
         * @return double con el valor
103
         */
104
        public double getValue() {
105
                return value;
106
        }
107

    
108
        /**
109
         * Asigna el valor de la clase
110
         * @param double con el valor
111
         */
112
        public void setValue(double value) {
113
                this.value = value;
114
        }        
115
        
116
        /**
117
         * Incrementa en n el valor especificado
118
         * @param double n
119
         */
120
        public void increment(double n) {
121
                this.value += n;
122
        }
123
}