svn-gvsig-desktop / branches / v2_0_0_prep / libFMap_mapcontrol / src / org / gvsig / fmap / mapcontrol / tools / Events / MeasureEvent.java @ 21203
History | View | Annotate | Download (3.89 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 org.gvsig.fmap.mapcontrol.tools.Events; |
42 |
|
43 |
import java.awt.event.MouseEvent; |
44 |
|
45 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
46 |
|
47 |
/**
|
48 |
* <p><code>MeasureEvent</code> is used to notify the selection of a polyline.</p>
|
49 |
*
|
50 |
* <p>Stores the information about the 2D vertexes and the {@link GeneralPathX GeneralPathX}
|
51 |
* between them.</p>
|
52 |
*
|
53 |
* @author Vicente Caballero Navarro
|
54 |
*/
|
55 |
public class MeasureEvent { |
56 |
/**
|
57 |
* The polyline, broken down in straight lines, and quadratic and cubic (B?zier) curves.
|
58 |
*/
|
59 |
private GeneralPathX gp;
|
60 |
|
61 |
/**
|
62 |
* Vector with the X coordinates.
|
63 |
*/
|
64 |
private Double[] x; |
65 |
|
66 |
/**
|
67 |
* Vector with the Y coordinates.
|
68 |
*/
|
69 |
private Double[] y; |
70 |
|
71 |
/**
|
72 |
* Mouse event that has been the cause of creating this event.
|
73 |
*/
|
74 |
private MouseEvent event; |
75 |
|
76 |
/**
|
77 |
* <p>Creates a new <code>MeasureEvent</code> with all necessary data.</p>
|
78 |
* <p>The general path is calculated according the enclosed regions of the path alternate between interior
|
79 |
* and exterior areas are traversed from the outside of the path towards a point inside the region.</p>
|
80 |
*
|
81 |
* @param x vector with the X coordinates
|
82 |
* @param y vector with the Y coordinates
|
83 |
* @param e event that has been the cause of creating this one
|
84 |
*/
|
85 |
public MeasureEvent(Double[] x, Double[] y, MouseEvent e) { |
86 |
this.x = x;
|
87 |
this.y = y;
|
88 |
this.event = e;
|
89 |
gp = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, x.length);
|
90 |
gp.moveTo(x[0].doubleValue(), y[0].doubleValue()); |
91 |
|
92 |
for (int index = 1; index < x.length; index++) { |
93 |
gp.lineTo(x[index].doubleValue(), y[index].doubleValue()); |
94 |
} |
95 |
} |
96 |
|
97 |
/**
|
98 |
* <p>Gets the {@link GeneralPathX GeneralPathX} of the measurement.</p>
|
99 |
*
|
100 |
* @see GeneralPathX
|
101 |
*
|
102 |
* @return geometric path constructed from straight lines, and quadratic and cubic (B?zier) curves
|
103 |
*/
|
104 |
public GeneralPathX getGP() {
|
105 |
return gp;
|
106 |
} |
107 |
|
108 |
/**
|
109 |
* <p>Sets the {@link GeneralPathX GeneralPathX} of the measurement.</p>
|
110 |
*
|
111 |
* @see GeneralPathX
|
112 |
*
|
113 |
* @param gP geometric path constructed from straight lines, and quadratic and cubic (B?zier) curves
|
114 |
*/
|
115 |
public void setGP(GeneralPathX gp) { |
116 |
this.gp = gp;
|
117 |
} |
118 |
|
119 |
/**
|
120 |
* <p>Gets a vector with the X coordinates.</p>
|
121 |
*
|
122 |
* @return vector with the X coordinates
|
123 |
*/
|
124 |
public Double[] getXs() { |
125 |
return x;
|
126 |
} |
127 |
|
128 |
/**
|
129 |
* <p>Gets a vector with the Y coordinates.</p>
|
130 |
*
|
131 |
* @return vector with the Y coordinates
|
132 |
*/
|
133 |
public Double[] getYs() { |
134 |
return y;
|
135 |
} |
136 |
|
137 |
/**
|
138 |
* <p>Gets the event that has been the cause of creating this one.</p>
|
139 |
*
|
140 |
* @return mouse event that has been the cause of creating this one
|
141 |
*/
|
142 |
public MouseEvent getEvent() { |
143 |
return event;
|
144 |
} |
145 |
} |