root / branches / pilotoDWG / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / FArc2D.java @ 1514
History | View | Annotate | Download (4.53 KB)
1 |
/*
|
---|---|
2 |
* Created on 09-feb-2005
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
21 |
USA.
|
22 |
*
|
23 |
* For more information, contact:
|
24 |
*
|
25 |
* Generalitat Valenciana
|
26 |
* Conselleria d'Infraestructures i Transport
|
27 |
* Av. Blasco Ib??ez, 50
|
28 |
* 46010 VALENCIA
|
29 |
* SPAIN
|
30 |
*
|
31 |
* +34 963862235
|
32 |
* gvsig@gva.es
|
33 |
* www.gvsig.gva.es
|
34 |
*
|
35 |
* or
|
36 |
*
|
37 |
* IVER T.I. S.A
|
38 |
* Salamanca 50
|
39 |
* 46005 Valencia
|
40 |
* Spain
|
41 |
*
|
42 |
* +34 963163400
|
43 |
* dac@iver.es
|
44 |
*/
|
45 |
package com.iver.cit.gvsig.fmap.core; |
46 |
|
47 |
import java.awt.geom.Point2D; |
48 |
import java.awt.geom.Rectangle2D; |
49 |
import java.util.ArrayList; |
50 |
|
51 |
/**
|
52 |
* DOCUMENT ME!
|
53 |
*
|
54 |
* @author Vicente Caballero Navarro
|
55 |
*/
|
56 |
public class FArc2D extends FPolyline2D { |
57 |
private Point2D center; |
58 |
|
59 |
/**
|
60 |
* DOCUMENT ME!
|
61 |
*
|
62 |
* @param gpx
|
63 |
*/
|
64 |
public FArc2D(GeneralPathX gpx,Point2D c) { |
65 |
super(gpx);
|
66 |
center=c; |
67 |
} |
68 |
/* (non-Javadoc)
|
69 |
* @see com.iver.cit.gvsig.fmap.core.FShape#cloneFShape()
|
70 |
*/
|
71 |
public FShape cloneFShape() {
|
72 |
FArc2D arc=new FArc2D((GeneralPathX) gp.clone(),center);
|
73 |
return arc;
|
74 |
} |
75 |
/**
|
76 |
* DOCUMENT ME!
|
77 |
*
|
78 |
* @return DOCUMENT ME!
|
79 |
*/
|
80 |
public Handler[] getHandlers() { |
81 |
ArrayList handlers = new ArrayList(); |
82 |
Rectangle2D rect = this.getBounds2D(); |
83 |
//Point2D init=new Point2D.Double(gp.pointCoords[0],gp.pointCoords[1]);
|
84 |
//Point2D end=new Point2D.Double(gp.pointCoords[gp.numCoords-2],gp.pointCoords[gp.numCoords-1]);
|
85 |
//Point2D center=new Point2D.Double((gp.pointCoords[gp.numCoords/2]),(end.getY()+gp.pointCoords[gp.numCoords/2+1])/2);
|
86 |
|
87 |
//handlers.add(new InitHandler(0, init.getX(), init.getY()));
|
88 |
handlers.add(new CenterHandler(1, center.getX(), center.getY())); |
89 |
//handlers.add(new EndHandler(2, end.getX(), end.getY()));
|
90 |
//handlers.add(new RadioHandler(3, rect.getCenterX(), rect.getY()));
|
91 |
//handlers.add(new RadioHandler(3, rect.getCenterX(), rect.getMaxY()));
|
92 |
|
93 |
return (Handler[]) handlers.toArray(new Handler[0]); |
94 |
} |
95 |
/**
|
96 |
* DOCUMENT ME!
|
97 |
*
|
98 |
* @author Vicente Caballero Navarro
|
99 |
*/
|
100 |
class CenterHandler extends AbstractHandler { |
101 |
/**
|
102 |
* Crea un nuevo PointHandler.
|
103 |
*
|
104 |
* @param i DOCUMENT ME!
|
105 |
* @param x DOCUMENT ME!
|
106 |
* @param y DOCUMENT ME!
|
107 |
*/
|
108 |
public CenterHandler(int i, double x, double y) { |
109 |
point = new Point2D.Double(x, y); |
110 |
index = i; |
111 |
} |
112 |
|
113 |
/**
|
114 |
* DOCUMENT ME!
|
115 |
*
|
116 |
* @param x DOCUMENT ME!
|
117 |
* @param y DOCUMENT ME!
|
118 |
*
|
119 |
* @return DOCUMENT ME!
|
120 |
*/
|
121 |
public void move(double x, double y) { |
122 |
//p1.setLocation(p1.getX()+x,p1.getY()+y);
|
123 |
center=new Point2D.Double(center.getX()+x,center.getY()+y); |
124 |
//p3.setLocation(p3.getX()+x,p3.getY()+y);
|
125 |
for (int i=0;i<gp.numCoords/2;i++){ |
126 |
gp.pointCoords[i*2]+=x;
|
127 |
gp.pointCoords[i*2+1]+=y; |
128 |
} |
129 |
} |
130 |
} |
131 |
|
132 |
/**
|
133 |
* DOCUMENT ME!
|
134 |
*
|
135 |
* @author Vicente Caballero Navarro
|
136 |
*/
|
137 |
class InitHandler extends AbstractHandler { |
138 |
/**
|
139 |
* Crea un nuevo PointHandler.
|
140 |
*
|
141 |
* @param i DOCUMENT ME!
|
142 |
* @param x DOCUMENT ME!
|
143 |
* @param y DOCUMENT ME!
|
144 |
*/
|
145 |
public InitHandler(int i, double x, double y) { |
146 |
point = new Point2D.Double(x, y); |
147 |
index = i; |
148 |
} |
149 |
|
150 |
/**
|
151 |
* DOCUMENT ME!
|
152 |
*
|
153 |
* @param x DOCUMENT ME!
|
154 |
* @param y DOCUMENT ME!
|
155 |
*
|
156 |
* @return DOCUMENT ME!
|
157 |
*/
|
158 |
public void move(double x, double y) { |
159 |
gp.pointCoords[0]+=x;
|
160 |
gp.pointCoords[1]+=y;
|
161 |
} |
162 |
} |
163 |
/**
|
164 |
* DOCUMENT ME!
|
165 |
*
|
166 |
* @author Vicente Caballero Navarro
|
167 |
*/
|
168 |
class EndHandler extends AbstractHandler { |
169 |
/**
|
170 |
* Crea un nuevo PointHandler.
|
171 |
*
|
172 |
* @param i DOCUMENT ME!
|
173 |
* @param x DOCUMENT ME!
|
174 |
* @param y DOCUMENT ME!
|
175 |
*/
|
176 |
public EndHandler(int i, double x, double y) { |
177 |
point = new Point2D.Double(x, y); |
178 |
index = i; |
179 |
} |
180 |
|
181 |
/**
|
182 |
* DOCUMENT ME!
|
183 |
*
|
184 |
* @param x DOCUMENT ME!
|
185 |
* @param y DOCUMENT ME!
|
186 |
*
|
187 |
* @return DOCUMENT ME!
|
188 |
*/
|
189 |
public void move(double x, double y) { |
190 |
gp.pointCoords[gp.numCoords-2]+=x;
|
191 |
gp.pointCoords[gp.numCoords-1]+=y;
|
192 |
} |
193 |
} |
194 |
} |