Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / tools / Events / MeasureEvent.java @ 20098

History | View | Annotate | Download (3.75 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.tools.Events;
42

    
43
import java.awt.event.MouseEvent;
44

    
45
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
46

    
47

    
48
/**
49
 * <p><code>MeasureEvent</code> is used to notify the selection of a polyline.</p>
50
 *  
51
 * <p>Stores the information about the 2D vertexes and the {@link GeneralPathX GeneralPathX}
52
 *  between them.</p>
53
 *
54
 * @author Vicente Caballero Navarro
55
 */
56
public class MeasureEvent {
57
        /**
58
         * The polyline, broken down in straight lines, and quadratic and cubic (B?zier) curves.
59
         */
60
        private GeneralPathX gp;
61
        
62
        /**
63
         * Vector with the X coordinates.
64
         */
65
        private Double[] x;
66
        
67
        /**
68
         * Vector with the Y coordinates.
69
         */
70
        private Double[] y;
71
        
72
        /**
73
         * Mouse event that has been the cause of creating this event.
74
         */
75
        private MouseEvent event;
76

    
77
        /**
78
         * <p>Creates a new <code>MeasureEvent</code> with all necessary data.</p>
79
         * <p>The general path is calculated according the enclosed regions of the path alternate between interior
80
         *  and exterior areas are traversed from the outside of the path towards a point inside the region.</p>
81
         *
82
         * @param x vector with the X coordinates
83
         * @param y vector with the Y coordinates
84
         * @param e event that has been the cause of creating this one
85
         */
86
        public MeasureEvent(Double[] x, Double[] y, MouseEvent e) {
87
                this.x = x;
88
                this.y = y;
89
                this.event = e;
90
                gp = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, x.length);
91
                gp.moveTo(x[0].doubleValue(), y[0].doubleValue());
92

    
93
                for (int index = 1; index < x.length; index++) {
94
                        gp.lineTo(x[index].doubleValue(), y[index].doubleValue());
95
                }
96
        }
97

    
98
        /**
99
         * <p>Gets the {@link GeneralPathX GeneralPathX} of the measurement.</p>
100
         *
101
         * @see GeneralPathX
102
         *
103
         * @return geometric path constructed from straight lines, and quadratic and cubic (B?zier) curves
104
         */
105
        public GeneralPathX getGP() {
106
                return gp;
107
        }
108

    
109
        /**
110
         * <p>Sets the {@link GeneralPathX GeneralPathX} of the measurement.</p>
111
         *
112
         * @see GeneralPathX
113
         *
114
         * @param gP geometric path constructed from straight lines, and quadratic and cubic (B?zier) curves
115
         */
116
        public void setGP(GeneralPathX gp) {
117
                this.gp = gp;
118
        }
119

    
120
        /**
121
         * <p>Gets a vector with the X coordinates.</p>
122
         *
123
         * @return vector with the X coordinates
124
         */
125
        public Double[] getXs() {
126
                return x;
127
        }
128

    
129
        /**
130
         * <p>Gets a vector with the Y coordinates.</p>
131
         *
132
         * @return vector with the Y coordinates
133
         */
134
        public Double[] getYs() {
135
                return y;
136
        }
137

    
138
        /**
139
         * <p>Gets the event that has been the cause of creating this one.</p>
140
         * 
141
         * @return mouse event that has been the cause of creating this one
142
         */
143
        public MouseEvent getEvent() {
144
                return event;
145
        }
146
}