Revision 1514 branches/pilotoDWG/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FArc2D.java
FArc2D.java | ||
---|---|---|
44 | 44 |
*/ |
45 | 45 |
package com.iver.cit.gvsig.fmap.core; |
46 | 46 |
|
47 |
import java.awt.geom.AffineTransform; |
|
48 |
import java.awt.geom.Arc2D; |
|
49 | 47 |
import java.awt.geom.Point2D; |
50 | 48 |
import java.awt.geom.Rectangle2D; |
51 | 49 |
import java.util.ArrayList; |
52 | 50 |
|
53 |
import com.iver.cit.gvsig.fmap.edition.cad.TrigonometricalFunctions; |
|
54 |
|
|
55 | 51 |
/** |
56 | 52 |
* DOCUMENT ME! |
57 | 53 |
* |
58 | 54 |
* @author Vicente Caballero Navarro |
59 | 55 |
*/ |
60 | 56 |
public class FArc2D extends FPolyline2D { |
61 |
private Point2D init; |
|
62 | 57 |
private Point2D center; |
63 |
private Point2D end; |
|
64 | 58 |
|
65 | 59 |
/** |
66 | 60 |
* DOCUMENT ME! |
67 | 61 |
* |
68 | 62 |
* @param gpx |
69 | 63 |
*/ |
70 |
public FArc2D(GeneralPathX gpx,Point2D i,Point2D c,Point2D e) {
|
|
64 |
public FArc2D(GeneralPathX gpx,Point2D c) {
|
|
71 | 65 |
super(gpx); |
72 |
init=i; |
|
73 | 66 |
center=c; |
74 |
end=e; |
|
75 | 67 |
} |
76 | 68 |
/* (non-Javadoc) |
77 | 69 |
* @see com.iver.cit.gvsig.fmap.core.FShape#cloneFShape() |
78 | 70 |
*/ |
79 | 71 |
public FShape cloneFShape() { |
80 |
FArc2D arc=new FArc2D((GeneralPathX) gp.clone(),init,center,end);
|
|
72 |
FArc2D arc=new FArc2D((GeneralPathX) gp.clone(),center);
|
|
81 | 73 |
return arc; |
82 | 74 |
} |
83 | 75 |
/** |
84 | 76 |
* DOCUMENT ME! |
85 | 77 |
* |
86 |
* @param at DOCUMENT ME! |
|
87 |
*/ |
|
88 |
public void transform(AffineTransform at) { |
|
89 |
Handler[] handlers=getHandlers(); |
|
90 |
Point2D p0=new Point2D.Double(); |
|
91 |
Point2D p1=new Point2D.Double(); |
|
92 |
Point2D p2=new Point2D.Double(); |
|
93 |
at.transform(handlers[0].getPoint(),p0); |
|
94 |
at.transform(handlers[1].getPoint(),p1); |
|
95 |
at.transform(handlers[2].getPoint(),p2); |
|
96 |
Arc2D arco = TrigonometricalFunctions.createArc(p0,p1,p2); |
|
97 |
//FArc2D arc=new FArc2D(new GeneralPathX(arco),handlers[1].getPoint()); |
|
98 |
gp=new GeneralPathX(arco); |
|
99 |
//gp.transform(at); |
|
100 |
//CenterHandler centerhandler=(CenterHandler)getHandlers()[0]; |
|
101 |
//Point2D aux=new Point2D.Double(); |
|
102 |
//at.transform(centerhandler.getPoint(),aux); |
|
103 |
//centerhandler.setPoint(aux); |
|
104 |
} |
|
105 |
/** |
|
106 |
* DOCUMENT ME! |
|
107 |
* |
|
108 | 78 |
* @return DOCUMENT ME! |
109 | 79 |
*/ |
110 | 80 |
public Handler[] getHandlers() { |
... | ... | |
114 | 84 |
//Point2D end=new Point2D.Double(gp.pointCoords[gp.numCoords-2],gp.pointCoords[gp.numCoords-1]); |
115 | 85 |
//Point2D center=new Point2D.Double((gp.pointCoords[gp.numCoords/2]),(end.getY()+gp.pointCoords[gp.numCoords/2+1])/2); |
116 | 86 |
|
117 |
handlers.add(new InitHandler(0, init.getX(), init.getY())); |
|
87 |
//handlers.add(new InitHandler(0, init.getX(), init.getY()));
|
|
118 | 88 |
handlers.add(new CenterHandler(1, center.getX(), center.getY())); |
119 |
handlers.add(new EndHandler(2, end.getX(), end.getY())); |
|
89 |
//handlers.add(new EndHandler(2, end.getX(), end.getY()));
|
|
120 | 90 |
//handlers.add(new RadioHandler(3, rect.getCenterX(), rect.getY())); |
121 | 91 |
//handlers.add(new RadioHandler(3, rect.getCenterX(), rect.getMaxY())); |
122 | 92 |
|
... | ... | |
149 | 119 |
* @return DOCUMENT ME! |
150 | 120 |
*/ |
151 | 121 |
public void move(double x, double y) { |
122 |
//p1.setLocation(p1.getX()+x,p1.getY()+y); |
|
152 | 123 |
center=new Point2D.Double(center.getX()+x,center.getY()+y); |
153 |
/*for (int i=0;i<gp.numCoords/2;i++){ |
|
124 |
//p3.setLocation(p3.getX()+x,p3.getY()+y); |
|
125 |
for (int i=0;i<gp.numCoords/2;i++){ |
|
154 | 126 |
gp.pointCoords[i*2]+=x; |
155 | 127 |
gp.pointCoords[i*2+1]+=y; |
156 | 128 |
} |
157 |
*/ |
|
158 | 129 |
} |
159 |
public void setPoint(Point2D p){ |
|
160 |
center=p; |
|
161 |
} |
|
162 | 130 |
} |
163 | 131 |
|
164 | 132 |
/** |
... | ... | |
178 | 146 |
point = new Point2D.Double(x, y); |
179 | 147 |
index = i; |
180 | 148 |
} |
181 |
public void setPoint(Point2D p){ |
|
182 |
init=p; |
|
183 |
} |
|
149 |
|
|
184 | 150 |
/** |
185 | 151 |
* DOCUMENT ME! |
186 | 152 |
* |
... | ... | |
190 | 156 |
* @return DOCUMENT ME! |
191 | 157 |
*/ |
192 | 158 |
public void move(double x, double y) { |
193 |
init=new Point2D.Double(init.getX()+x,init.getY()+y); |
|
194 |
//gp.pointCoords[0]+=x; |
|
195 |
//gp.pointCoords[1]+=y; |
|
159 |
gp.pointCoords[0]+=x; |
|
160 |
gp.pointCoords[1]+=y; |
|
196 | 161 |
} |
197 | 162 |
} |
198 | 163 |
/** |
... | ... | |
212 | 177 |
point = new Point2D.Double(x, y); |
213 | 178 |
index = i; |
214 | 179 |
} |
215 |
public void setPoint(Point2D p){ |
|
216 |
end=p; |
|
217 |
} |
|
180 |
|
|
218 | 181 |
/** |
219 | 182 |
* DOCUMENT ME! |
220 | 183 |
* |
... | ... | |
224 | 187 |
* @return DOCUMENT ME! |
225 | 188 |
*/ |
226 | 189 |
public void move(double x, double y) { |
227 |
end=new Point2D.Double(end.getX()+x,end.getY()+y); |
|
228 |
//gp.pointCoords[gp.numCoords-2]+=x; |
|
229 |
//gp.pointCoords[gp.numCoords-1]+=y; |
|
190 |
gp.pointCoords[gp.numCoords-2]+=x; |
|
191 |
gp.pointCoords[gp.numCoords-1]+=y; |
|
230 | 192 |
} |
231 | 193 |
} |
232 | 194 |
} |
Also available in: Unified diff