Revision 436
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/geometryadapters/PrintingCircle2D.java | ||
---|---|---|
1 |
package org.gvsig.app.project.documents.layout.geometryadapters; |
|
2 |
|
|
3 |
//public class PrintingCircle2D {} |
|
4 |
|
|
5 |
|
|
6 |
import java.awt.Rectangle; |
|
7 |
import java.awt.Shape; |
|
8 |
import java.awt.geom.AffineTransform; |
|
9 |
import java.awt.geom.PathIterator; |
|
10 |
import java.awt.geom.Point2D; |
|
11 |
import java.awt.geom.Rectangle2D; |
|
12 |
|
|
13 |
import org.cresques.cts.ICoordTrans; |
|
14 |
import org.gvsig.fmap.geom.Geometry; |
|
15 |
import org.gvsig.fmap.geom.handler.Handler; |
|
16 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
|
17 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
18 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
19 |
import org.gvsig.fmap.geom.primitive.Circle; |
|
20 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
21 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
22 |
import org.gvsig.fmap.geom.primitive.Point; |
|
23 |
import org.gvsig.fmap.geom.primitive.Ring; |
|
24 |
import org.gvsig.fmap.geom.primitive.SurfaceAppearance; |
|
25 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
26 |
|
|
27 |
public class PrintingCircle2D implements Circle { |
|
28 |
Circle delegate; |
|
29 |
|
|
30 |
public PrintingCircle2D(Circle delegate) { |
|
31 |
this.delegate = delegate; |
|
32 |
} |
|
33 |
|
|
34 |
public Shape getInternalShape() { |
|
35 |
return delegate.getInternalShape(); |
|
36 |
} |
|
37 |
|
|
38 |
public Shape getShape() { |
|
39 |
return delegate.getShape(); |
|
40 |
} |
|
41 |
|
|
42 |
public Shape getShape(AffineTransform affineTransform) { |
|
43 |
double radious = getRadious(); |
|
44 |
Point2D origin = new Point2D.Double(getCenter().getCoordinateAt(0)-radious, getCenter().getCoordinateAt(1)-radious); |
|
45 |
Point2D radiusTrans = new Point2D.Double(radious, radious); |
|
46 |
affineTransform.transform(origin, origin); |
|
47 |
affineTransform.transform(radiusTrans, radiusTrans); |
|
48 |
java.awt.geom.Ellipse2D.Double ellipse = |
|
49 |
new java.awt.geom.Ellipse2D.Double(origin.getX(), |
|
50 |
origin.getY(), radiusTrans.getX(), radiusTrans.getY()); |
|
51 |
return ellipse; |
|
52 |
} |
|
53 |
|
|
54 |
public void setPoints(Point center, Point radious) { |
|
55 |
delegate.setPoints(center, radious); |
|
56 |
} |
|
57 |
|
|
58 |
public void setPoints(Point center, double radious) { |
|
59 |
delegate.setPoints(center, radious); |
|
60 |
} |
|
61 |
|
|
62 |
public void setPoints(Point p1, Point p2, Point p3) { |
|
63 |
delegate.setPoints(p1, p2, p3); |
|
64 |
} |
|
65 |
|
|
66 |
public Point getCenter() { |
|
67 |
return delegate.getCenter(); |
|
68 |
} |
|
69 |
|
|
70 |
public Rectangle getBounds() { |
|
71 |
return delegate.getBounds(); |
|
72 |
} |
|
73 |
|
|
74 |
public double getRadious() { |
|
75 |
return delegate.getRadious(); |
|
76 |
} |
|
77 |
|
|
78 |
public void setSurfaceAppearance(SurfaceAppearance app) { |
|
79 |
delegate.setSurfaceAppearance(app); |
|
80 |
} |
|
81 |
|
|
82 |
public SurfaceAppearance getSurfaceAppearance() { |
|
83 |
return delegate.getSurfaceAppearance(); |
|
84 |
} |
|
85 |
|
|
86 |
public double getCoordinateAt(int index, int dimension) { |
|
87 |
return delegate.getCoordinateAt(index, dimension); |
|
88 |
} |
|
89 |
|
|
90 |
public int getNumInteriorRings() { |
|
91 |
return delegate.getNumInteriorRings(); |
|
92 |
} |
|
93 |
|
|
94 |
public Ring getInteriorRing(int index) { |
|
95 |
return delegate.getInteriorRing(index); |
|
96 |
} |
|
97 |
|
|
98 |
public void addInteriorRing(Ring ring) { |
|
99 |
delegate.addInteriorRing(ring); |
|
100 |
} |
|
101 |
|
|
102 |
public void removeInteriorRing(int index) { |
|
103 |
delegate.removeInteriorRing(index); |
|
104 |
} |
|
105 |
|
|
106 |
public void setCoordinateAt(int index, int dimension, double value) { |
|
107 |
delegate.setCoordinateAt(index, dimension, value); |
|
108 |
} |
|
109 |
|
|
110 |
public void addVertex(Point point) { |
|
111 |
delegate.addVertex(point); |
|
112 |
} |
|
113 |
|
|
114 |
public void addVertex(double x, double y) { |
|
115 |
delegate.addVertex(x, y); |
|
116 |
} |
|
117 |
|
|
118 |
public int compareTo(Object o) { |
|
119 |
return delegate.compareTo(o); |
|
120 |
} |
|
121 |
|
|
122 |
public void addVertex(double x, double y, double z) { |
|
123 |
delegate.addVertex(x, y, z); |
|
124 |
} |
|
125 |
|
|
126 |
public void removeVertex(int index) { |
|
127 |
delegate.removeVertex(index); |
|
128 |
} |
|
129 |
|
|
130 |
public Point getVertex(int index) { |
|
131 |
return delegate.getVertex(index); |
|
132 |
} |
|
133 |
|
|
134 |
public boolean contains(double x, double y) { |
|
135 |
return delegate.contains(x, y); |
|
136 |
} |
|
137 |
|
|
138 |
public int getNumVertices() { |
|
139 |
return delegate.getNumVertices(); |
|
140 |
} |
|
141 |
|
|
142 |
public void insertVertex(int index, Point p) { |
|
143 |
delegate.insertVertex(index, p); |
|
144 |
} |
|
145 |
|
|
146 |
public boolean contains(Point2D p) { |
|
147 |
return delegate.contains(p); |
|
148 |
} |
|
149 |
|
|
150 |
public void setVertex(int index, Point p) { |
|
151 |
delegate.setVertex(index, p); |
|
152 |
} |
|
153 |
|
|
154 |
public void setGeneralPath(GeneralPathX generalPathX) { |
|
155 |
delegate.setGeneralPath(generalPathX); |
|
156 |
} |
|
157 |
|
|
158 |
public boolean intersects(double x, double y, double w, double h) { |
|
159 |
return delegate.intersects(x, y, w, h); |
|
160 |
} |
|
161 |
|
|
162 |
public void addMoveToVertex(Point point) { |
|
163 |
delegate.addMoveToVertex(point); |
|
164 |
} |
|
165 |
|
|
166 |
public void closePrimitive() { |
|
167 |
delegate.closePrimitive(); |
|
168 |
} |
|
169 |
|
|
170 |
public void ensureCapacity(int capacity) { |
|
171 |
delegate.ensureCapacity(capacity); |
|
172 |
} |
|
173 |
|
|
174 |
public boolean contains(double x, double y, double w, double h) { |
|
175 |
return delegate.contains(x, y, w, h); |
|
176 |
} |
|
177 |
|
|
178 |
public int getType() { |
|
179 |
return delegate.getType(); |
|
180 |
} |
|
181 |
|
|
182 |
public Geometry cloneGeometry() { |
|
183 |
return delegate.cloneGeometry(); |
|
184 |
} |
|
185 |
|
|
186 |
public boolean intersects(Rectangle2D r) { |
|
187 |
return delegate.intersects(r); |
|
188 |
} |
|
189 |
|
|
190 |
public boolean contains(Rectangle2D r) { |
|
191 |
return delegate.contains(r); |
|
192 |
} |
|
193 |
|
|
194 |
public boolean fastIntersects(double x, double y, double w, double h) { |
|
195 |
return delegate.fastIntersects(x, y, w, h); |
|
196 |
} |
|
197 |
|
|
198 |
public Envelope getEnvelope() { |
|
199 |
return delegate.getEnvelope(); |
|
200 |
} |
|
201 |
|
|
202 |
public void reProject(ICoordTrans ct) { |
|
203 |
delegate.reProject(ct); |
|
204 |
} |
|
205 |
|
|
206 |
public void transform(AffineTransform at) { |
|
207 |
delegate.transform(at); |
|
208 |
} |
|
209 |
|
|
210 |
public int getDimension() { |
|
211 |
return delegate.getDimension(); |
|
212 |
} |
|
213 |
|
|
214 |
public boolean isSimple() { |
|
215 |
return delegate.isSimple(); |
|
216 |
} |
|
217 |
|
|
218 |
public boolean isCCW() throws GeometryOperationNotSupportedException, |
|
219 |
GeometryOperationException { |
|
220 |
return delegate.isCCW(); |
|
221 |
} |
|
222 |
|
|
223 |
public Object invokeOperation(int index, GeometryOperationContext ctx) |
|
224 |
throws GeometryOperationNotSupportedException, |
|
225 |
GeometryOperationException { |
|
226 |
return delegate.invokeOperation(index, ctx); |
|
227 |
} |
|
228 |
|
|
229 |
public Object invokeOperation(String opName, GeometryOperationContext ctx) |
|
230 |
throws GeometryOperationNotSupportedException, |
|
231 |
GeometryOperationException { |
|
232 |
return delegate.invokeOperation(opName, ctx); |
|
233 |
} |
|
234 |
|
|
235 |
public GeometryType getGeometryType() { |
|
236 |
return delegate.getGeometryType(); |
|
237 |
} |
|
238 |
|
|
239 |
public byte[] convertToWKB() throws GeometryOperationNotSupportedException, |
|
240 |
GeometryOperationException { |
|
241 |
return delegate.convertToWKB(); |
|
242 |
} |
|
243 |
|
|
244 |
public byte[] convertToWKB(int srs) |
|
245 |
throws GeometryOperationNotSupportedException, |
|
246 |
GeometryOperationException { |
|
247 |
return delegate.convertToWKB(srs); |
|
248 |
} |
|
249 |
|
|
250 |
public byte[] convertToWKBForcingType(int srs, int type) |
|
251 |
throws GeometryOperationNotSupportedException, |
|
252 |
GeometryOperationException { |
|
253 |
return delegate.convertToWKBForcingType(srs, type); |
|
254 |
} |
|
255 |
|
|
256 |
public String convertToWKT() throws GeometryOperationNotSupportedException, |
|
257 |
GeometryOperationException { |
|
258 |
return delegate.convertToWKT(); |
|
259 |
} |
|
260 |
|
|
261 |
public Geometry buffer(double distance) |
|
262 |
throws GeometryOperationNotSupportedException, |
|
263 |
GeometryOperationException { |
|
264 |
return delegate.buffer(distance); |
|
265 |
} |
|
266 |
|
|
267 |
public boolean contains(Geometry geometry) |
|
268 |
throws GeometryOperationNotSupportedException, |
|
269 |
GeometryOperationException { |
|
270 |
return delegate.contains(geometry); |
|
271 |
} |
|
272 |
|
|
273 |
public double distance(Geometry other) |
|
274 |
throws GeometryOperationNotSupportedException, |
|
275 |
GeometryOperationException { |
|
276 |
return delegate.distance(other); |
|
277 |
} |
|
278 |
|
|
279 |
public Geometry[] closestPoints(Geometry other) |
|
280 |
throws GeometryOperationNotSupportedException, |
|
281 |
GeometryOperationException { |
|
282 |
return delegate.closestPoints(other); |
|
283 |
} |
|
284 |
|
|
285 |
public boolean isWithinDistance(Geometry other, double distance) |
|
286 |
throws GeometryOperationNotSupportedException, |
|
287 |
GeometryOperationException { |
|
288 |
return delegate.isWithinDistance(other, distance); |
|
289 |
} |
|
290 |
|
|
291 |
public boolean overlaps(Geometry geometry) |
|
292 |
throws GeometryOperationNotSupportedException, |
|
293 |
GeometryOperationException { |
|
294 |
return delegate.overlaps(geometry); |
|
295 |
} |
|
296 |
|
|
297 |
public Geometry convexHull() throws GeometryOperationNotSupportedException, |
|
298 |
GeometryOperationException { |
|
299 |
return delegate.convexHull(); |
|
300 |
} |
|
301 |
|
|
302 |
public boolean coveredBy(Geometry geometry) |
|
303 |
throws GeometryOperationNotSupportedException, |
|
304 |
GeometryOperationException { |
|
305 |
return delegate.coveredBy(geometry); |
|
306 |
} |
|
307 |
|
|
308 |
public boolean covers(Geometry geometry) |
|
309 |
throws GeometryOperationNotSupportedException, |
|
310 |
GeometryOperationException { |
|
311 |
return delegate.covers(geometry); |
|
312 |
} |
|
313 |
|
|
314 |
public boolean crosses(Geometry geometry) |
|
315 |
throws GeometryOperationNotSupportedException, |
|
316 |
GeometryOperationException { |
|
317 |
return delegate.crosses(geometry); |
|
318 |
} |
|
319 |
|
|
320 |
public Geometry difference(Geometry other) |
|
321 |
throws GeometryOperationNotSupportedException, |
|
322 |
GeometryOperationException { |
|
323 |
return delegate.difference(other); |
|
324 |
} |
|
325 |
|
|
326 |
public boolean disjoint(Geometry geometry) |
|
327 |
throws GeometryOperationNotSupportedException, |
|
328 |
GeometryOperationException { |
|
329 |
return delegate.disjoint(geometry); |
|
330 |
} |
|
331 |
|
|
332 |
public Geometry intersection(Geometry other) |
|
333 |
throws GeometryOperationNotSupportedException, |
|
334 |
GeometryOperationException { |
|
335 |
return delegate.intersection(other); |
|
336 |
} |
|
337 |
|
|
338 |
public boolean intersects(Geometry geometry) |
|
339 |
throws GeometryOperationNotSupportedException, |
|
340 |
GeometryOperationException { |
|
341 |
return delegate.intersects(geometry); |
|
342 |
} |
|
343 |
|
|
344 |
public Geometry snapTo(Geometry other, double snapTolerance) |
|
345 |
throws GeometryOperationNotSupportedException, |
|
346 |
GeometryOperationException { |
|
347 |
return delegate.snapTo(other, snapTolerance); |
|
348 |
} |
|
349 |
|
|
350 |
public boolean touches(Geometry geometry) |
|
351 |
throws GeometryOperationNotSupportedException, |
|
352 |
GeometryOperationException { |
|
353 |
return delegate.touches(geometry); |
|
354 |
} |
|
355 |
|
|
356 |
public Geometry union(Geometry other) |
|
357 |
throws GeometryOperationNotSupportedException, |
|
358 |
GeometryOperationException { |
|
359 |
return delegate.union(other); |
|
360 |
} |
|
361 |
|
|
362 |
public boolean within(Geometry geometry) |
|
363 |
throws GeometryOperationNotSupportedException, |
|
364 |
GeometryOperationException { |
|
365 |
return delegate.within(geometry); |
|
366 |
} |
|
367 |
|
|
368 |
public Point centroid() throws GeometryOperationNotSupportedException, |
|
369 |
GeometryOperationException { |
|
370 |
return delegate.centroid(); |
|
371 |
} |
|
372 |
|
|
373 |
public Point getInteriorPoint() |
|
374 |
throws GeometryOperationNotSupportedException, |
|
375 |
GeometryOperationException { |
|
376 |
return delegate.getInteriorPoint(); |
|
377 |
} |
|
378 |
|
|
379 |
public double area() throws GeometryOperationNotSupportedException, |
|
380 |
GeometryOperationException { |
|
381 |
return delegate.area(); |
|
382 |
} |
|
383 |
|
|
384 |
public double perimeter() throws GeometryOperationNotSupportedException, |
|
385 |
GeometryOperationException { |
|
386 |
return delegate.perimeter(); |
|
387 |
} |
|
388 |
|
|
389 |
public void rotate(double radAngle, double basex, double basey) { |
|
390 |
delegate.rotate(radAngle, basex, basey); |
|
391 |
} |
|
392 |
|
|
393 |
public void move(double dx, double dy) { |
|
394 |
delegate.move(dx, dy); |
|
395 |
} |
|
396 |
|
|
397 |
public void scale(Point basePoint, double sx, double sy) { |
|
398 |
delegate.scale(basePoint, sx, sy); |
|
399 |
} |
|
400 |
|
|
401 |
public boolean isValid() { |
|
402 |
return delegate.isValid(); |
|
403 |
} |
|
404 |
|
|
405 |
public ValidationStatus getValidationStatus() { |
|
406 |
return delegate.getValidationStatus(); |
|
407 |
} |
|
408 |
|
|
409 |
public Geometry makeValid() { |
|
410 |
return delegate.makeValid(); |
|
411 |
} |
|
412 |
|
|
413 |
public Rectangle2D getBounds2D() { |
|
414 |
return delegate.getBounds2D(); |
|
415 |
} |
|
416 |
|
|
417 |
public PathIterator getPathIterator(AffineTransform at) { |
|
418 |
return delegate.getPathIterator(at); |
|
419 |
} |
|
420 |
|
|
421 |
public Handler[] getHandlers(int type) { |
|
422 |
return delegate.getHandlers(type); |
|
423 |
} |
|
424 |
|
|
425 |
public PathIterator getPathIterator(AffineTransform at, double flatness) { |
|
426 |
return delegate.getPathIterator(at, flatness); |
|
427 |
} |
|
428 |
|
|
429 |
public GeneralPathX getGeneralPath() { |
|
430 |
return delegate.getGeneralPath(); |
|
431 |
} |
|
432 |
} |
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/geometryadapters/GeometryAdapter.java | ||
---|---|---|
16 | 16 |
* along with this program; if not, write to the Free Software |
17 | 17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
18 | 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 | 19 |
*/ |
41 | 20 |
package org.gvsig.app.project.documents.layout.geometryadapters; |
42 | 21 |
|
43 | 22 |
import java.awt.Graphics2D; |
44 | 23 |
import java.awt.geom.AffineTransform; |
45 |
import java.awt.geom.Arc2D; |
|
46 |
import java.awt.geom.FlatteningPathIterator; |
|
47 |
import java.awt.geom.NoninvertibleTransformException; |
|
48 | 24 |
import java.awt.geom.Point2D; |
49 | 25 |
import java.awt.geom.Rectangle2D; |
50 | 26 |
import java.util.ArrayList; |
... | ... | |
55 | 31 |
import org.gvsig.fmap.geom.Geometry; |
56 | 32 |
import org.gvsig.fmap.geom.GeometryLocator; |
57 | 33 |
import org.gvsig.fmap.geom.GeometryManager; |
58 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
59 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
60 | 34 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
61 |
import org.gvsig.fmap.geom.primitive.Circle; |
|
62 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
63 |
import org.gvsig.fmap.geom.primitive.Point; |
|
64 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
|
65 |
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException; |
|
66 | 35 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
67 | 36 |
import org.gvsig.tools.ToolsLocator; |
68 | 37 |
import org.gvsig.tools.dynobject.DynStruct; |
... | ... | |
71 | 40 |
import org.gvsig.tools.persistence.Persistent; |
72 | 41 |
import org.gvsig.tools.persistence.PersistentState; |
73 | 42 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
74 |
import org.gvsig.app.project.documents.layout.geometryadapters.PrintingCircle2D; |
|
75 | 43 |
|
76 | 44 |
/** |
77 | 45 |
* Abstract adaptor to relate the geometries with the fframes and to be able to |
78 | 46 |
* integrate them in the Layout. |
79 |
*
|
|
47 |
* |
|
80 | 48 |
* @author Vicente Caballero Navarro |
81 | 49 |
*/ |
82 | 50 |
public abstract class GeometryAdapter implements Persistent, Cloneable { |
... | ... | |
84 | 52 |
public static final String PERSISTENCE_DEFINITION_NAME = "GeometryAdapter"; |
85 | 53 |
|
86 | 54 |
private static final String POINTS_FIELD = "points"; |
87 |
|
|
55 |
|
|
88 | 56 |
protected static final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
89 | 57 |
|
90 | 58 |
private List<Point2D> points = new ArrayList<Point2D>(); |
... | ... | |
96 | 64 |
|
97 | 65 |
/** |
98 | 66 |
* Add a point to de geometry. |
99 |
* |
|
100 |
* @param point |
|
101 |
* Point that is added. |
|
102 |
* |
|
67 |
* |
|
68 |
* @param point Point that is added. |
|
69 |
* |
|
103 | 70 |
* @return Number of points that contains the geometry. |
104 | 71 |
*/ |
105 | 72 |
public int addPoint(Point2D point) { |
... | ... | |
117 | 84 |
|
118 | 85 |
/** |
119 | 86 |
* Adds the GeneralPathX with all the points of the geometry. |
120 |
* |
|
121 |
* @param gpx |
|
122 |
* GeneralPathX |
|
87 |
* |
|
88 |
* @param gpx GeneralPathX |
|
123 | 89 |
*/ |
124 | 90 |
protected void setGeometry(Geometry geometry) { |
125 | 91 |
this.geometry = geometry; |
... | ... | |
127 | 93 |
|
128 | 94 |
/** |
129 | 95 |
* Obtains the geometry passing him as parameter the last point. |
130 |
* |
|
131 |
* @param p |
|
132 |
* Last Point. |
|
133 |
* @throws CreateGeometryException |
|
96 |
* |
|
97 |
* @param p Last Point. |
|
98 |
* @throws CreateGeometryException |
|
134 | 99 |
*/ |
135 | 100 |
public abstract void obtainShape(Point2D p); |
136 | 101 |
|
137 | 102 |
/** |
138 | 103 |
* Applies the transformation to all the points of the geometry. |
139 |
* |
|
140 |
* @param at |
|
141 |
* AffineTransform |
|
104 |
* |
|
105 |
* @param at AffineTransform |
|
142 | 106 |
*/ |
143 | 107 |
public void applyTransform(AffineTransform at) { |
144 | 108 |
for (int i = 0; i < points.size(); i++) { |
... | ... | |
150 | 114 |
|
151 | 115 |
/** |
152 | 116 |
* It draws the geometry on the Graphics that is passed like parameter. |
153 |
* |
|
154 |
* @param g |
|
155 |
* Graphics |
|
156 |
* @param at |
|
157 |
* AffineTransform |
|
158 |
* @param symbol |
|
159 |
* FSymbol |
|
117 |
* |
|
118 |
* @param g Graphics |
|
119 |
* @param at AffineTransform |
|
120 |
* @param symbol FSymbol |
|
160 | 121 |
*/ |
161 |
public void draw(Graphics2D g, AffineTransform at, ISymbol symbol){ |
|
122 |
public void draw(Graphics2D g, AffineTransform at, ISymbol symbol) {
|
|
162 | 123 |
symbol.draw(g, at, geometry, null, null); |
163 | 124 |
} |
164 | 125 |
|
165 | 126 |
/** |
166 | 127 |
* It print the geometry on the Graphics that is passed like parameter. |
167 |
* |
|
168 |
* @param g |
|
169 |
* Graphics |
|
170 |
* @param at |
|
171 |
* AffineTransform |
|
172 |
* @param symbol |
|
173 |
* ISymbol |
|
128 |
* |
|
129 |
* @param g Graphics |
|
130 |
* @param at AffineTransform |
|
131 |
* @param symbol ISymbol |
|
174 | 132 |
* @param properties |
175 | 133 |
*/ |
176 | 134 |
public void print(Graphics2D g, AffineTransform at, |
177 |
ISymbol symbol, PrintAttributes properties){ |
|
178 |
Geometry geom = getGeometry(); |
|
179 |
if (geom instanceof Circle) { |
|
180 |
// circles must be handled differently in order to print really round geometries |
|
181 |
// as the flatness used for screen may not be good for printing |
|
182 |
Circle circle = ((Circle) geom); |
|
183 |
PrintingCircle2D printCircle = new PrintingCircle2D(circle); |
|
184 |
geom = printCircle; |
|
185 |
|
|
186 |
} |
|
135 |
ISymbol symbol, PrintAttributes properties) { |
|
136 |
Geometry geom = getGeometry(); |
|
187 | 137 |
symbol.print(g, at, geom, properties); |
188 | 138 |
} |
189 | 139 |
|
190 | 140 |
/** |
191 | 141 |
* Paints the geometry on the Graphics adding him the last point if the |
192 | 142 |
* parameter andLastPoint is true. |
193 |
* |
|
194 |
* @param g |
|
195 |
* Graphics |
|
196 |
* @param at |
|
197 |
* AffineTransform |
|
198 |
* @param andLastPoint |
|
199 |
* If true add last point. |
|
143 |
* |
|
144 |
* @param g Graphics |
|
145 |
* @param at AffineTransform |
|
146 |
* @param andLastPoint If true add last point. |
|
200 | 147 |
*/ |
201 | 148 |
public abstract void paint(Graphics2D g, AffineTransform at, |
202 |
boolean andLastPoint); |
|
149 |
boolean andLastPoint);
|
|
203 | 150 |
|
204 | 151 |
/** |
205 | 152 |
* Set the point of cursor. |
206 |
* |
|
207 |
* @param p |
|
208 |
* Point of cursor. |
|
153 |
* |
|
154 |
* @param p Point of cursor. |
|
209 | 155 |
*/ |
210 | 156 |
public abstract void pointPosition(Point2D p); |
211 | 157 |
|
212 | 158 |
/** |
213 | 159 |
* Obtains the shape of the Geometry. |
214 |
*
|
|
160 |
* |
|
215 | 161 |
* @return Geometry. |
216 | 162 |
* @deprecated |
217 | 163 |
*/ |
218 |
public Geometry getGeometry(AffineTransform at){ |
|
164 |
public Geometry getGeometry(AffineTransform at) {
|
|
219 | 165 |
Geometry clonedGeom = geometry.cloneGeometry(); |
220 | 166 |
clonedGeom.transform(at); |
221 | 167 |
return clonedGeom; |
222 | 168 |
} |
223 |
|
|
169 |
|
|
224 | 170 |
/** |
225 | 171 |
* Returns the geometry to draw |
226 |
* @return
|
|
227 |
* the geometry
|
|
172 |
* |
|
173 |
* @return the geometry
|
|
228 | 174 |
*/ |
229 |
public Geometry getGeometry(){ |
|
175 |
public Geometry getGeometry() {
|
|
230 | 176 |
return geometry; |
231 | 177 |
} |
232 | 178 |
|
233 | 179 |
/** |
234 | 180 |
* Returns all the points of Geometry. |
235 |
*
|
|
181 |
* |
|
236 | 182 |
* @return Array of points. |
237 | 183 |
*/ |
238 | 184 |
public Point2D[] getPoints() { |
... | ... | |
241 | 187 |
|
242 | 188 |
/** |
243 | 189 |
* Draws a handler in each vertex of the Geometry. |
244 |
* |
|
245 |
* @param g |
|
246 |
* Graphics |
|
247 |
* @param at |
|
248 |
* AffineTransform. |
|
190 |
* |
|
191 |
* @param g Graphics |
|
192 |
* @param at AffineTransform. |
|
249 | 193 |
*/ |
250 | 194 |
public void drawVertex(Graphics2D g, AffineTransform at) { |
251 | 195 |
Point2D[] ps = getPoints(); |
... | ... | |
256 | 200 |
|
257 | 201 |
for (int i = 0; i < pointRes.length; i++) { |
258 | 202 |
g.fillRect((int) pointRes[i].getX() - d, (int) pointRes[i].getY() |
259 |
- d, d * 2, d * 2); |
|
203 |
- d, d * 2, d * 2);
|
|
260 | 204 |
} |
261 | 205 |
} |
262 | 206 |
|
263 | 207 |
/** |
264 | 208 |
* Modifies a point of the Geometry from an index by the one that is passed |
265 | 209 |
* like parameter. |
266 |
* |
|
267 |
* @param pos |
|
268 |
* Index |
|
269 |
* @param point |
|
270 |
* Point |
|
210 |
* |
|
211 |
* @param pos Index |
|
212 |
* @param point Point |
|
271 | 213 |
*/ |
272 | 214 |
public void changePoint(int pos, Point2D point) { |
273 | 215 |
this.points.set(pos, point); |
... | ... | |
275 | 217 |
|
276 | 218 |
/** |
277 | 219 |
* Add all the points of Geometry. |
278 |
* |
|
279 |
* @param points |
|
280 |
* All points. |
|
220 |
* |
|
221 |
* @param points All points. |
|
281 | 222 |
*/ |
282 | 223 |
public void setPoints(Point2D[] points) { |
283 | 224 |
this.points.clear(); |
... | ... | |
329 | 270 |
public static void registerPersistent() { |
330 | 271 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
331 | 272 |
if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) { |
332 |
DynStruct definition =
|
|
333 |
manager.addDefinition(GeometryAdapter.class, |
|
334 |
PERSISTENCE_DEFINITION_NAME, |
|
335 |
"GeometryAdapter persistence definition", null, null); |
|
273 |
DynStruct definition |
|
274 |
= manager.addDefinition(GeometryAdapter.class,
|
|
275 |
PERSISTENCE_DEFINITION_NAME,
|
|
276 |
"GeometryAdapter persistence definition", null, null);
|
|
336 | 277 |
|
337 | 278 |
definition.addDynFieldList(POINTS_FIELD) |
338 |
.setClassOfItems(Point2D.class).setMandatory(true); |
|
279 |
.setClassOfItems(Point2D.class).setMandatory(true);
|
|
339 | 280 |
} |
340 | 281 |
|
341 | 282 |
CircleAdapter.registerPersistent(); |
... | ... | |
346 | 287 |
} |
347 | 288 |
|
348 | 289 |
public void loadFromState(PersistentState state) |
349 |
throws PersistenceException { |
|
290 |
throws PersistenceException {
|
|
350 | 291 |
points = state.getList(POINTS_FIELD); |
351 | 292 |
obtainShape((Point2D) points.get(points.size() - 1)); |
352 | 293 |
} |
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/geometryadapters/CircleAdapter.java | ||
---|---|---|
41 | 41 |
import org.gvsig.tools.dynobject.DynStruct; |
42 | 42 |
import org.gvsig.tools.persistence.PersistenceManager; |
43 | 43 |
|
44 |
/** |
|
45 |
* DOCUMENT ME! |
|
46 |
* |
|
47 |
* @author Vicente Caballero Navarro |
|
48 |
*/ |
|
49 | 44 |
public class CircleAdapter extends GeometryAdapter { |
50 | 45 |
public static final String PERSISTENCE_DEFINITION_NAME = "CircleAdapter"; |
51 | 46 |
private static final Logger logger = LoggerFactory |
52 | 47 |
Also available in: Unified diff