Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / rendering / FInterval.java @ 1100

History | View | Annotate | Download (2.55 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.fmap.rendering;
42

    
43
/**
44
 * Clase intervalo.
45
 *
46
 * @author Vicente Caballero Navarro
47
 */
48
public class FInterval {
49
        private double from;
50
        private double to;
51

    
52
        /**
53
         * Crea un nuevo FInterval.
54
         *
55
         * @param from Origen.
56
         * @param to Destino.
57
         */
58
        public FInterval(double from, double to) {
59
                this.from = from;
60
                this.to = to;
61
        }
62

    
63
        /**
64
         * Devuelve "true" si el double que se pasa como par?metro esta dentro del
65
         * intervalo.
66
         *
67
         * @param check double a comprobar.
68
         *
69
         * @return "true" si est? dentro del intervalo.
70
         */
71
        public boolean isInInterval(double check) {
72
                return ((check >= from) && (check <= to));
73
        }
74

    
75
        /**
76
         * Devuelve el n?mero de origen.
77
         *
78
         * @return N?mero de inicio.
79
         */
80
        public double getMin() {
81
                return from;
82
        }
83

    
84
        /**
85
         * Devuelve el n?mero final.
86
         *
87
         * @return N?mero final.
88
         */
89
        public double getMax() {
90
                return to;
91
        }
92

    
93
        /**
94
         * Devuelve un string con la informaci?n de inicio y final.
95
         *
96
         * @return String.
97
         */
98
        public String toString() {
99
                return from + "-" + to;
100
        }
101

    
102
        /**
103
         * Crea un FInterval nuevo a partir de un String con el n?mero inicial un
104
         * gui?n y el n?mero final.
105
         *
106
         * @param s String.
107
         *
108
         * @return FInterval nuevo.
109
         */
110
        public static FInterval create(String s) {
111
                String[] str = s.split("-");
112
                FInterval inter = new FInterval(Double.parseDouble(str[0]),
113
                                Double.parseDouble(str[1]));
114

    
115
                return inter;
116
        }
117
}