Revision 247

View differences:

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
42 42

  
43 43
import java.awt.Graphics2D;
44 44
import java.awt.geom.AffineTransform;
45
import java.awt.geom.Arc2D;
46
import java.awt.geom.FlatteningPathIterator;
47
import java.awt.geom.NoninvertibleTransformException;
45 48
import java.awt.geom.Point2D;
46 49
import java.awt.geom.Rectangle2D;
47 50
import java.util.ArrayList;
......
52 55
import org.gvsig.fmap.geom.Geometry;
53 56
import org.gvsig.fmap.geom.GeometryLocator;
54 57
import org.gvsig.fmap.geom.GeometryManager;
58
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
59
import org.gvsig.fmap.geom.Geometry.TYPES;
55 60
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;
56 66
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
57 67
import org.gvsig.tools.ToolsLocator;
58 68
import org.gvsig.tools.dynobject.DynStruct;
......
61 71
import org.gvsig.tools.persistence.Persistent;
62 72
import org.gvsig.tools.persistence.PersistentState;
63 73
import org.gvsig.tools.persistence.exception.PersistenceException;
74
import org.gvsig.app.project.documents.layout.geometryadapters.PrintingCircle2D;
64 75

  
65 76
/**
66 77
 * Abstract adaptor to relate the geometries with the fframes and to be able to
......
164 175
     */
165 176
    public void print(Graphics2D g, AffineTransform at,
166 177
        ISymbol symbol, PrintAttributes properties){
167
        symbol.print(g, at, getGeometry(), 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
    	}
187
        symbol.print(g, at, geom, properties);
168 188
    }
169 189

  
170 190
    /**

Also available in: Unified diff