Revision 5880
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/VectorialEditableAdapter.java | ||
---|---|---|
45 | 45 |
* |
46 | 46 |
* $Id$ |
47 | 47 |
* $Log$ |
48 |
* Revision 1.55 2006-06-16 10:12:36 caballero
|
|
49 |
* setGeometryType
|
|
48 |
* Revision 1.56 2006-06-16 10:44:01 fjp
|
|
49 |
* Por mandato de Vicente
|
|
50 | 50 |
* |
51 | 51 |
* Revision 1.54 2006/06/01 16:15:16 fjp |
52 | 52 |
* Escritura que permite crear drivers de manera m?s sencilla. |
... | ... | |
223 | 223 |
import com.hardcode.gdbms.engine.values.Value; |
224 | 224 |
import com.iver.cit.gvsig.fmap.DriverException; |
225 | 225 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
226 |
import com.iver.cit.gvsig.fmap.core.FGeometryCollection; |
|
227 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
|
228 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
229 | 226 |
import com.iver.cit.gvsig.fmap.core.FShape; |
230 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
231 | 227 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
232 | 228 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
233 | 229 |
import com.iver.cit.gvsig.fmap.core.IRow; |
234 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
235 | 230 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
236 | 231 |
import com.iver.cit.gvsig.fmap.drivers.BoundedShapes; |
237 | 232 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
... | ... | |
715 | 710 |
*/ |
716 | 711 |
public int doAddRow(IRow feat, int sourceType) throws DriverIOException, |
717 | 712 |
IOException { |
718 |
|
|
719 |
validate((DefaultFeature)feat); |
|
720 |
|
|
721 | 713 |
int calculatedIndex = super.doAddRow(feat, sourceType); |
722 | 714 |
// Actualiza el ?ndice espacial |
723 | 715 |
IGeometry g = ((IFeature) feat).getGeometry(); |
... | ... | |
727 | 719 |
|
728 | 720 |
return calculatedIndex; |
729 | 721 |
} |
730 |
//TODO para validar si la geometria es de un tipo que se pueda a?adir a este VectorialEditableAdapter |
|
731 |
private void validate(DefaultFeature feat) throws DriverIOException { |
|
732 |
int typeLayer=getDriver().getShapeType(); |
|
733 |
IGeometry geom=feat.getGeometry(); |
|
734 |
geom.setGeometryType(typeLayer); |
|
735 |
feat.setGeometry(geom); |
|
736 |
/* int typeLayer=getDriver().getShapeType(); |
|
737 |
IGeometry geom=feat.getGeometry(); |
|
738 |
if (geom instanceof FGeometryCollection) { |
|
739 |
((FGeometryCollection)geom).setGeometryType(typeLayer); |
|
740 |
return; |
|
741 |
} |
|
742 | 722 |
|
743 |
FShape shape=(FShape)geom.getInternalShape(); |
|
744 |
int typeShape=shape.getShapeType(); |
|
745 |
switch (typeLayer) { |
|
746 |
case FShape.POINT: |
|
747 |
|
|
748 |
break; |
|
749 |
case FShape.LINE: |
|
750 |
//FPolyline2D line=(FPolyline2D)shape; |
|
751 |
switch (typeShape) { |
|
752 |
case FShape.ARC: |
|
753 |
case FShape.CIRCLE: |
|
754 |
case FShape.ELLIPSE: |
|
755 |
case FShape.POLYGON: |
|
756 |
GeneralPathX gpx=new GeneralPathX(); |
|
757 |
gpx.append(shape.getPathIterator(null),true); |
|
758 |
shape=new FPolyline2D(gpx); |
|
759 |
//shape=line; |
|
760 |
break; |
|
761 |
} |
|
762 |
break; |
|
763 |
case FShape.POLYGON: |
|
764 |
|
|
765 |
switch (typeShape) { |
|
766 |
case FShape.CIRCLE: |
|
767 |
case FShape.ELLIPSE: |
|
768 |
case FShape.LINE: |
|
769 |
GeneralPathX gpx=new GeneralPathX(); |
|
770 |
gpx.append(shape.getPathIterator(null),true); |
|
771 |
shape=new FPolygon2D(gpx); |
|
772 |
break; |
|
773 |
} |
|
774 |
break; |
|
775 |
} |
|
776 |
feat.setGeometry(ShapeFactory.createGeometry(shape)); |
|
777 |
*/ |
|
778 |
} |
|
779 |
|
|
780 | 723 |
/** |
781 | 724 |
* Se desmarca como invalidada en el fichero de expansion o como eliminada |
782 | 725 |
* en el fichero original |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/shp/IndexedShpDriver.java | ||
---|---|---|
334 | 334 |
* @throws IOException DOCUMENT ME! |
335 | 335 |
*/ |
336 | 336 |
public synchronized IGeometry getShape(int index) throws IOException { |
337 |
IGeometry geom=null; |
|
338 | 337 |
Point2D.Double p = new Point2D.Double(); |
339 | 338 |
int numParts; |
340 | 339 |
int numPoints; |
... | ... | |
366 | 365 |
switch (type) { |
367 | 366 |
case (SHP.POINT2D): |
368 | 367 |
p = readPoint(bb); |
369 |
geom=ShapeFactory.createPoint2D(p.getX(), p.getY()); |
|
370 |
geom.setGeometryType(FShape.POINT); |
|
371 |
return geom; |
|
372 | 368 |
|
369 |
return ShapeFactory.createPoint2D(p.getX(), p.getY()); |
|
370 |
|
|
373 | 371 |
case (SHP.POLYLINE2D): |
374 | 372 |
|
373 |
//BoundingBox = readRectangle(bb); |
|
374 |
//bb.getDouble(); |
|
375 |
//bb.getDouble(); |
|
376 |
//bb.getDouble(); |
|
377 |
//bb.getDouble(); |
|
375 | 378 |
bb.position(bb.position() + 32); |
376 | 379 |
numParts = bb.getInt(); |
377 | 380 |
numPoints = bb.getInt(); |
... | ... | |
402 | 405 |
elShape.lineTo(p.x, p.y); |
403 | 406 |
} |
404 | 407 |
} |
405 |
geom = ShapeFactory.createPolyline2D(elShape); |
|
406 |
geom.setGeometryType(FShape.LINE);
|
|
407 |
return geom; |
|
408 |
|
|
409 |
return ShapeFactory.createPolyline2D(elShape);
|
|
410 |
|
|
408 | 411 |
case (SHP.POLYGON2D): |
409 | 412 |
|
410 | 413 |
// BoundingBox = readRectangle(bb); |
... | ... | |
442 | 445 |
elShape.lineTo(p.x, p.y); |
443 | 446 |
} |
444 | 447 |
} |
445 |
geom = ShapeFactory.createPolygon2D(elShape); |
|
446 |
geom.setGeometryType(FShape.POLYGON); |
|
447 |
return geom; |
|
448 | 448 |
|
449 |
return ShapeFactory.createPolygon2D(elShape); |
|
450 |
|
|
449 | 451 |
case (SHP.POINT3D): |
450 | 452 |
|
451 | 453 |
double x = bb.getDouble(); |
452 | 454 |
double y = bb.getDouble(); |
453 | 455 |
double z = bb.getDouble(); |
454 |
geom = ShapeFactory.createPoint3D(x, y, z); |
|
455 |
geom.setGeometryType(FShape.POINT); |
|
456 |
return geom; |
|
457 | 456 |
|
457 |
return ShapeFactory.createPoint3D(x, y, z); |
|
458 |
|
|
458 | 459 |
case (SHP.POLYLINE3D): |
459 | 460 |
bb.position(bb.position() + 32); |
460 | 461 |
numParts = bb.getInt(); |
... | ... | |
491 | 492 |
for (i = 0; i < numPoints; i++) { |
492 | 493 |
pZ[i] = bb.getDouble(); |
493 | 494 |
} |
494 |
geom = ShapeFactory.createPolyline3D(elShape, pZ); |
|
495 |
geom.setGeometryType(FShape.LINE); |
|
496 |
return geom; |
|
495 |
|
|
496 |
return ShapeFactory.createPolyline3D(elShape, pZ); |
|
497 | 497 |
case (SHP.POLYGON3D): |
498 | 498 |
bb.position(bb.position() + 32); |
499 | 499 |
numParts = bb.getInt(); |
... | ... | |
530 | 530 |
for (i = 0; i < numPoints; i++) { |
531 | 531 |
poZ[i] = bb.getDouble(); |
532 | 532 |
} |
533 |
geom = ShapeFactory.createPolygon3D(elShape, poZ); |
|
534 |
geom.setGeometryType(FShape.POLYGON); |
|
535 |
return geom; |
|
536 | 533 |
|
534 |
return ShapeFactory.createPolygon3D(elShape, poZ); |
|
535 |
|
|
537 | 536 |
case (SHP.MULTIPOINT2D): |
538 | 537 |
bb.position(bb.position() + 32); |
539 | 538 |
numPoints = bb.getInt(); |
... | ... | |
545 | 544 |
tempX[i] = bb.getDouble(); |
546 | 545 |
tempY[i] = bb.getDouble(); |
547 | 546 |
} |
548 |
geom = ShapeFactory.createMultipoint2D(tempX, tempY); |
|
549 |
geom.setGeometryType(FShape.POINT); |
|
550 |
return geom; |
|
551 | 547 |
|
548 |
return ShapeFactory.createMultipoint2D(tempX, tempY); |
|
549 |
|
|
552 | 550 |
case (SHP.MULTIPOINT3D): |
553 | 551 |
bb.position(bb.position() + 32); |
554 | 552 |
numPoints = bb.getInt(); |
... | ... | |
566 | 564 |
for (i = 0; i < numPoints; i++) { |
567 | 565 |
temZ[i] = bb.getDouble(); |
568 | 566 |
} |
569 |
geom = ShapeFactory.createMultipoint3D(temX, temY, temZ); |
|
570 |
geom.setGeometryType(FShape.POINT); |
|
571 |
return geom; |
|
567 |
return ShapeFactory.createMultipoint3D(temX, temY, temZ); |
|
572 | 568 |
} |
573 | 569 |
|
574 |
return geom;
|
|
570 |
return null;
|
|
575 | 571 |
} |
576 | 572 |
|
577 | 573 |
/** |
... | ... | |
631 | 627 |
extent = new Rectangle2D.Double(myHeader.myXmin, myHeader.myYmin, |
632 | 628 |
myHeader.myXmax - myHeader.myXmin, |
633 | 629 |
myHeader.myYmax - myHeader.myYmin); |
634 |
|
|
630 |
|
|
635 | 631 |
type = myHeader.myShapeType; |
636 |
|
|
632 |
|
|
637 | 633 |
double x = myHeader.myXmin; |
638 | 634 |
double y = myHeader.myYmin; |
639 | 635 |
double w = myHeader.myXmax - myHeader.myXmin; |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FMultiPoint2D.java | ||
---|---|---|
72 | 72 |
*/ |
73 | 73 |
public class FMultiPoint2D implements IGeometry { |
74 | 74 |
FPoint2D[] points = null; |
75 |
private int type=FShape.POINT; |
|
76 | 75 |
|
77 | 76 |
/** |
78 | 77 |
* Crea un nuevo MultiPoint2D. |
... | ... | |
119 | 118 |
theGeoms[i] = c; |
120 | 119 |
} |
121 | 120 |
MultiPoint geomCol = new GeometryFactory().createMultiPoint(theGeoms); |
122 |
|
|
123 |
|
|
121 |
|
|
122 |
|
|
124 | 123 |
return geomCol; |
125 | 124 |
} |
126 | 125 |
|
... | ... | |
165 | 164 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getGeometryType() |
166 | 165 |
*/ |
167 | 166 |
public int getGeometryType() { |
168 |
return type;
|
|
167 |
return FShape.MULTIPOINT;
|
|
169 | 168 |
} |
170 | 169 |
|
171 | 170 |
/* (non-Javadoc) |
... | ... | |
201 | 200 |
{ |
202 | 201 |
aux[i] = (FPoint2D) points[i].cloneFShape(); |
203 | 202 |
} |
204 |
IGeometry geom=new FMultiPoint2D(aux); |
|
205 |
//geom.setGeometryType(type); |
|
206 |
return geom; |
|
203 |
return new FMultiPoint2D(aux); |
|
207 | 204 |
} |
208 | 205 |
|
209 | 206 |
/* (non-Javadoc) |
... | ... | |
375 | 372 |
public Shape getInternalShape() { |
376 | 373 |
return this; |
377 | 374 |
} |
378 |
public int getOriginalGeometryType() { |
|
379 |
return FShape.MULTIPOINT; |
|
380 |
} |
|
381 |
public void setGeometryType(int type) { |
|
382 |
this.type=type; |
|
383 |
} |
|
384 | 375 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/AbstractHandler.java | ||
---|---|---|
61 | 61 |
public Point2D getPoint() { |
62 | 62 |
return point; |
63 | 63 |
} |
64 |
|
|
64 |
|
|
65 | 65 |
public void select(boolean b) { |
66 | 66 |
select=b; |
67 | 67 |
} |
68 | 68 |
public boolean isSelected(){ |
69 | 69 |
return select; |
70 | 70 |
} |
71 |
public boolean equalsPoint(Object obj) { |
|
72 |
Point2D p1=this.getPoint(); |
|
73 |
Point2D p2=((Handler)obj).getPoint(); |
|
74 |
if (p1.getX()==p2.getX() && p1.getY()==p2.getY()) { |
|
75 |
return true; |
|
76 |
} |
|
77 |
return false; |
|
78 |
} |
|
79 | 71 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/IGeometry.java | ||
---|---|---|
136 | 136 |
* @return una de las constantes de FShape: POINT, LINE, POLIGON |
137 | 137 |
*/ |
138 | 138 |
int getGeometryType(); |
139 |
|
|
139 | 140 |
/** |
140 |
* Obtiene el tipo de la geometr?a |
|
141 |
* |
|
142 |
* @return una de las constantes de FShape: POINT, LINE, POLIGON |
|
143 |
*/ |
|
144 |
void setGeometryType(int type); |
|
145 |
/** |
|
146 |
* Obtiene el tipo original de la geometr?a |
|
147 |
* |
|
148 |
* @return una de las constantes de FShape: POINT, LINE, POLIGON, CIRCLE, ARC, ELLIPSE... |
|
149 |
*/ |
|
150 |
int getOriginalGeometryType(); |
|
151 |
/** |
|
152 | 141 |
* Clona la Geometr?a. |
153 | 142 |
* |
154 | 143 |
* @return Geometr?a clonada. |
... | ... | |
221 | 210 |
public void transform(AffineTransform at); |
222 | 211 |
|
223 | 212 |
PathIterator getPathIterator(AffineTransform at, double flatness); |
224 |
|
|
213 |
|
|
225 | 214 |
/** |
226 | 215 |
* Useful to have the real shape behind the scenes. |
227 | 216 |
* May be uses to edit it knowing it it is a Circle, Ellipse, etc |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/gt2/FLiteShape.java | ||
---|---|---|
2 | 2 |
* Created on 12-may-2005 |
3 | 3 |
* |
4 | 4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
5 |
* |
|
5 |
*
|
|
6 | 6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
7 |
* |
|
7 |
*
|
|
8 | 8 |
* This program is free software; you can redistribute it and/or |
9 | 9 |
* modify it under the terms of the GNU General Public License |
10 | 10 |
* as published by the Free Software Foundation; either version 2 |
11 | 11 |
* of the License, or (at your option) any later version. |
12 |
* |
|
12 |
*
|
|
13 | 13 |
* This program is distributed in the hope that it will be useful, |
14 | 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | 16 |
* GNU General Public License for more details. |
17 |
* |
|
17 |
*
|
|
18 | 18 |
* You should have received a copy of the GNU General Public License |
19 | 19 |
* along with this program; if not, write to the Free Software |
20 | 20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 |
* |
|
21 |
*
|
|
22 | 22 |
* For more information, contact: |
23 | 23 |
* |
24 | 24 |
* Generalitat Valenciana |
... | ... | |
30 | 30 |
* +34 963862235 |
31 | 31 |
* gvsig@gva.es |
32 | 32 |
* www.gvsig.gva.es |
33 |
* |
|
33 |
*
|
|
34 | 34 |
* or |
35 |
* |
|
35 |
*
|
|
36 | 36 |
* IVER T.I. S.A |
37 | 37 |
* Salamanca 50 |
38 | 38 |
* 46005 Valencia |
39 | 39 |
* Spain |
40 |
* |
|
40 |
*
|
|
41 | 41 |
* +34 963163400 |
42 | 42 |
* dac@iver.es |
43 | 43 |
*/ |
... | ... | |
92 | 92 |
private AffineTransform affineTransform = null; |
93 | 93 |
private boolean generalize = false; |
94 | 94 |
private double maxDistance = 1; |
95 |
|
|
95 |
|
|
96 | 96 |
// cached iterators |
97 | 97 |
private LineIterator lineIterator = new LineIterator(); |
98 | 98 |
private GeomCollectionIterator collIterator = new GeomCollectionIterator(); |
... | ... | |
100 | 100 |
private float xScale; |
101 | 101 |
|
102 | 102 |
private float yScale; |
103 |
|
|
103 |
|
|
104 | 104 |
private GeometryFactory geomFac; |
105 | 105 |
|
106 | 106 |
private MathTransform mathTransform; |
107 | 107 |
|
108 | 108 |
private static final AffineTransform IDENTITY = new AffineTransform(); |
109 |
|
|
109 |
|
|
110 | 110 |
class PointHandler extends AbstractHandler { |
111 | 111 |
/** |
112 | 112 |
* Crea un nuevo PointHandler. |
... | ... | |
129 | 129 |
* |
130 | 130 |
* @return DOCUMENT ME! |
131 | 131 |
*/ |
132 |
public void move(double x, double y) { |
|
132 |
public void move(double x, double y) {
|
|
133 | 133 |
c.x+=x; |
134 | 134 |
c.y+=y; |
135 | 135 |
geometry.geometryChanged(); |
... | ... | |
144 | 144 |
geometry.geometryChanged(); |
145 | 145 |
} |
146 | 146 |
} |
147 |
|
|
147 | 148 |
|
148 |
|
|
149 | 149 |
/** |
150 | 150 |
* Creates a new LiteShape object. |
151 | 151 |
* |
... | ... | |
154 | 154 |
* @param generalize - set to true if the geometry need to be generalized |
155 | 155 |
* during rendering |
156 | 156 |
* @param maxDistance - distance used in the generalization process |
157 |
* @throws TransformException |
|
158 |
* @throws FactoryException |
|
157 |
* @throws TransformException
|
|
158 |
* @throws FactoryException
|
|
159 | 159 |
*/ |
160 | 160 |
public FLiteShape(Geometry geom, AffineTransform at, MathTransform mathTransform, boolean generalize, |
161 | 161 |
double maxDistance) throws TransformException, FactoryException { |
... | ... | |
171 | 171 |
* @param generalize - set to true if the geometry need to be generalized |
172 | 172 |
* during rendering |
173 | 173 |
* @param maxDistance - distance used in the generalization process |
174 |
* @throws TransformException |
|
175 |
* @throws FactoryException |
|
174 |
* @throws TransformException
|
|
175 |
* @throws FactoryException
|
|
176 | 176 |
*/ |
177 | 177 |
public FLiteShape(Geometry geom, AffineTransform at, MathTransform mathTransform, boolean generalize) throws TransformException, FactoryException { |
178 | 178 |
if( geom!=null) |
... | ... | |
200 | 200 |
* @param generalize - set to true if the geometry need to be generalized |
201 | 201 |
* during rendering |
202 | 202 |
* @param maxDistance - distance used in the generalization process |
203 |
* @throws TransformException |
|
203 |
* @throws TransformException
|
|
204 | 204 |
*/ |
205 | 205 |
public FLiteShape(Geometry geom, AffineTransform at, boolean generalize, |
206 | 206 |
double maxDistance){ |
207 | 207 |
this(geom, at, generalize); |
208 | 208 |
this.maxDistance = maxDistance; |
209 | 209 |
} |
210 |
|
|
210 |
|
|
211 | 211 |
public FLiteShape(Geometry geom) |
212 | 212 |
{ |
213 | 213 |
this(geom, null, false); |
... | ... | |
221 | 221 |
* @param generalize - set to true if the geometry need to be generalized |
222 | 222 |
* during rendering |
223 | 223 |
* @param maxDistance - distance used in the generalization process |
224 |
* @throws TransformException |
|
224 |
* @throws TransformException
|
|
225 | 225 |
*/ |
226 | 226 |
public FLiteShape(Geometry geom, AffineTransform at, boolean generalize){ |
227 | 227 |
if( geom!=null) |
... | ... | |
245 | 245 |
(affineTransform.getScaleY() * affineTransform.getScaleY()) |
246 | 246 |
+ (affineTransform.getShearY() * affineTransform.getShearY())); |
247 | 247 |
} |
248 |
|
|
248 |
|
|
249 | 249 |
private void transformGeometry(Geometry geometry) throws TransformException, FactoryException { |
250 |
|
|
250 |
|
|
251 | 251 |
if( mathTransform==null || mathTransform.isIdentity() ){ |
252 | 252 |
if( !affineTransform.isIdentity() ){ |
253 | 253 |
MathTransformFactory factory=FactoryFinder.getMathTransformFactory(null); |
... | ... | |
259 | 259 |
factory.createConcatenatedTransform(mathTransform, factory.createAffineTransform(new GeneralMatrix(affineTransform))); |
260 | 260 |
affineTransform=IDENTITY; |
261 | 261 |
} |
262 |
|
|
262 |
|
|
263 | 263 |
if( mathTransform==null || mathTransform.isIdentity() ) |
264 | 264 |
return; |
265 |
|
|
266 |
|
|
265 |
|
|
266 |
|
|
267 | 267 |
CoordinateSequenceTransformer transformer=new InPlaceCoordinateSequenceTransformer(); |
268 | 268 |
if (geometry instanceof GeometryCollection) { |
269 | 269 |
GeometryCollection collection=(GeometryCollection)geometry; |
... | ... | |
272 | 272 |
} |
273 | 273 |
}else if (geometry instanceof Point) { |
274 | 274 |
transformer.transform(((Point)geometry).getCoordinateSequence(), mathTransform); |
275 |
}else if (geometry instanceof Polygon) { |
|
275 |
}else if (geometry instanceof Polygon) {
|
|
276 | 276 |
Polygon polygon=(Polygon) geometry; |
277 | 277 |
transformGeometry(polygon.getExteriorRing()); |
278 | 278 |
for (int i = 0; i < polygon.getNumInteriorRing(); i++) { |
... | ... | |
280 | 280 |
} |
281 | 281 |
} else if (geometry instanceof LineString) { |
282 | 282 |
transformer.transform(((LineString)geometry).getCoordinateSequence(), mathTransform); |
283 |
} |
|
283 |
}
|
|
284 | 284 |
} |
285 | 285 |
|
286 | 286 |
private GeometryFactory getGeometryFactory() { |
... | ... | |
296 | 296 |
* object instead of creating it again and again during rendering |
297 | 297 |
* |
298 | 298 |
* @param g |
299 |
* @throws TransformException |
|
300 |
* @throws FactoryException |
|
299 |
* @throws TransformException
|
|
300 |
* @throws FactoryException
|
|
301 | 301 |
*/ |
302 | 302 |
public void setGeometry(Geometry g) throws TransformException, FactoryException { |
303 | 303 |
if( g!=null){ |
... | ... | |
316 | 316 |
} catch (FactoryException e) { |
317 | 317 |
// TODO Auto-generated catch block |
318 | 318 |
e.printStackTrace(); |
319 |
} |
|
319 |
}
|
|
320 | 320 |
xScale = (float) Math.sqrt( |
321 | 321 |
(affineTransform.getScaleX() * affineTransform.getScaleX()) |
322 | 322 |
+ (affineTransform.getShearX() * affineTransform.getShearX())); |
323 | 323 |
yScale = (float) Math.sqrt( |
324 | 324 |
(affineTransform.getScaleY() * affineTransform.getScaleY()) |
325 | 325 |
+ (affineTransform.getShearY() * affineTransform.getShearY())); |
326 |
|
|
326 |
|
|
327 | 327 |
} |
328 | 328 |
|
329 | 329 |
/** |
330 | 330 |
* Tests if the interior of the <code>Shape</code> entirely contains the |
331 | 331 |
* specified <code>Rectangle2D</code>. This method might conservatively |
332 | 332 |
* return <code>false</code> when: |
333 |
* |
|
333 |
*
|
|
334 | 334 |
* <ul> |
335 | 335 |
* <li> |
336 | 336 |
* the <code>intersect</code> method returns <code>true</code> and |
... | ... | |
341 | 341 |
* expensive. |
342 | 342 |
* </li> |
343 | 343 |
* </ul> |
344 |
* |
|
344 |
*
|
|
345 | 345 |
* This means that this method might return <code>false</code> even though |
346 | 346 |
* the <code>Shape</code> contains the <code>Rectangle2D</code>. The |
347 | 347 |
* <code>Area</code> class can be used to perform more accurate |
... | ... | |
405 | 405 |
* rectangular area must lie within the <code>Shape</code> for the entire |
406 | 406 |
* rectanglar area to be considered contained within the |
407 | 407 |
* <code>Shape</code>. |
408 |
* |
|
408 |
*
|
|
409 | 409 |
* <p> |
410 | 410 |
* This method might conservatively return <code>false</code> when: |
411 |
* |
|
411 |
*
|
|
412 | 412 |
* <ul> |
413 | 413 |
* <li> |
414 | 414 |
* the <code>intersect</code> method returns <code>true</code> and |
... | ... | |
418 | 418 |
* entirely contains the rectangular area are prohibitively expensive. |
419 | 419 |
* </li> |
420 | 420 |
* </ul> |
421 |
* |
|
421 |
*
|
|
422 | 422 |
* This means that this method might return <code>false</code> even though |
423 | 423 |
* the <code>Shape</code> contains the rectangular area. The |
424 | 424 |
* <code>Area</code> class can be used to perform more accurate |
... | ... | |
574 | 574 |
* boundary and provides access to the geometry of the <code>Shape</code> |
575 | 575 |
* outline. If an optional {@link AffineTransform} is specified, the |
576 | 576 |
* coordinates returned in the iteration are transformed accordingly. |
577 |
* |
|
577 |
*
|
|
578 | 578 |
* <p> |
579 | 579 |
* Each call to this method returns a fresh <code>PathIterator</code> |
580 | 580 |
* object that traverses the geometry of the <code>Shape</code> object |
581 | 581 |
* independently from any other <code>PathIterator</code> objects in use |
582 | 582 |
* at the same time. |
583 | 583 |
* </p> |
584 |
* |
|
584 |
*
|
|
585 | 585 |
* <p> |
586 | 586 |
* It is recommended, but not guaranteed, that objects implementing the |
587 | 587 |
* <code>Shape</code> interface isolate iterations that are in process |
588 | 588 |
* from any changes that might occur to the original object's geometry |
589 | 589 |
* during such iterations. |
590 | 590 |
* </p> |
591 |
* |
|
591 |
*
|
|
592 | 592 |
* <p> |
593 | 593 |
* Before using a particular implementation of the <code>Shape</code> |
594 | 594 |
* interface in more than one thread simultaneously, refer to its |
... | ... | |
619 | 619 |
pi = new PointIterator((Point) geometry, combined); |
620 | 620 |
} |
621 | 621 |
|
622 |
if (this.geometry instanceof Polygon) { |
|
622 |
if (this.geometry instanceof Polygon) {
|
|
623 | 623 |
|
624 | 624 |
pi = new PolygonIterator((Polygon) geometry, combined, generalize, |
625 | 625 |
maxDistance); |
... | ... | |
635 | 635 |
if(combined == affineTransform) |
636 | 636 |
lineIterator.init((LineString) geometry, combined, generalize, |
637 | 637 |
(float) maxDistance, xScale, yScale); |
638 |
else |
|
638 |
else
|
|
639 | 639 |
lineIterator.init((LineString) geometry, combined, generalize, |
640 | 640 |
(float) maxDistance); |
641 | 641 |
pi = lineIterator; |
... | ... | |
651 | 651 |
* Returns an iterator object that iterates along the <code>Shape</code> |
652 | 652 |
* boundary and provides access to a flattened view of the |
653 | 653 |
* <code>Shape</code> outline geometry. |
654 |
* |
|
654 |
*
|
|
655 | 655 |
* <p> |
656 | 656 |
* Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE point types are returned by |
657 | 657 |
* the iterator. |
658 | 658 |
* </p> |
659 |
* |
|
659 |
*
|
|
660 | 660 |
* <p> |
661 | 661 |
* If an optional <code>AffineTransform</code> is specified, the |
662 | 662 |
* coordinates returned in the iteration are transformed accordingly. |
663 | 663 |
* </p> |
664 |
* |
|
664 |
*
|
|
665 | 665 |
* <p> |
666 | 666 |
* The amount of subdivision of the curved segments is controlled by the |
667 | 667 |
* <code>flatness</code> parameter, which specifies the maximum distance |
... | ... | |
671 | 671 |
* flattening parameters to be treated as larger values. This limit, if |
672 | 672 |
* there is one, is defined by the particular implementation that is used. |
673 | 673 |
* </p> |
674 |
* |
|
674 |
*
|
|
675 | 675 |
* <p> |
676 | 676 |
* Each call to this method returns a fresh <code>PathIterator</code> |
677 | 677 |
* object that traverses the <code>Shape</code> object geometry |
678 | 678 |
* independently from any other <code>PathIterator</code> objects in use |
679 | 679 |
* at the same time. |
680 | 680 |
* </p> |
681 |
* |
|
681 |
*
|
|
682 | 682 |
* <p> |
683 | 683 |
* It is recommended, but not guaranteed, that objects implementing the |
684 | 684 |
* <code>Shape</code> interface isolate iterations that are in process |
685 | 685 |
* from any changes that might occur to the original object's geometry |
686 | 686 |
* during such iterations. |
687 | 687 |
* </p> |
688 |
* |
|
688 |
*
|
|
689 | 689 |
* <p> |
690 | 690 |
* Before using a particular implementation of this interface in more than |
691 | 691 |
* one thread simultaneously, refer to its documentation to verify that it |
... | ... | |
710 | 710 |
* Tests if the interior of the <code>Shape</code> intersects the interior |
711 | 711 |
* of a specified <code>Rectangle2D</code>. This method might |
712 | 712 |
* conservatively return <code>true</code> when: |
713 |
* |
|
713 |
*
|
|
714 | 714 |
* <ul> |
715 | 715 |
* <li> |
716 | 716 |
* there is a high probability that the <code>Rectangle2D</code> and the |
... | ... | |
721 | 721 |
* prohibitively expensive. |
722 | 722 |
* </li> |
723 | 723 |
* </ul> |
724 |
* |
|
724 |
*
|
|
725 | 725 |
* This means that this method might return <code>true</code> even though |
726 | 726 |
* the <code>Rectangle2D</code> does not intersect the <code>Shape</code>. |
727 | 727 |
* |
... | ... | |
746 | 746 |
* of a specified rectangular area. The rectangular area is considered to |
747 | 747 |
* intersect the <code>Shape</code> if any point is contained in both the |
748 | 748 |
* interior of the <code>Shape</code> and the specified rectangular area. |
749 |
* |
|
749 |
*
|
|
750 | 750 |
* <p> |
751 | 751 |
* This method might conservatively return <code>true</code> when: |
752 |
* |
|
752 |
*
|
|
753 | 753 |
* <ul> |
754 | 754 |
* <li> |
755 | 755 |
* there is a high probability that the rectangular area and the |
... | ... | |
760 | 760 |
* prohibitively expensive. |
761 | 761 |
* </li> |
762 | 762 |
* </ul> |
763 |
* |
|
763 |
*
|
|
764 | 764 |
* This means that this method might return <code>true</code> even though |
765 | 765 |
* the rectangular area does not intersect the <code>Shape</code>. The |
766 | 766 |
* {@link java.awt.geom.Area Area} class can be used to perform more |
... | ... | |
819 | 819 |
|
820 | 820 |
return geometry.getFactory().createPolygon(lr, null); |
821 | 821 |
} |
822 |
|
|
822 |
|
|
823 | 823 |
/** |
824 | 824 |
* Returns the affine transform for this lite shape |
825 | 825 |
* @return |
... | ... | |
849 | 849 |
if (geometry instanceof MultiLineString) |
850 | 850 |
type = FShape.LINE; |
851 | 851 |
|
852 |
|
|
852 |
|
|
853 | 853 |
return type; |
854 | 854 |
} |
855 | 855 |
|
... | ... | |
873 | 873 |
pointCoords[i] = pt.getX(); |
874 | 874 |
pointCoords[i+1] = pt.getY(); |
875 | 875 |
} */ |
876 |
|
|
876 |
|
|
877 | 877 |
} |
878 | 878 |
|
879 | 879 |
public Handler[] getStretchingHandlers() { |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FGeometryCollection.java | ||
---|---|---|
49 | 49 |
import java.awt.geom.Rectangle2D; |
50 | 50 |
import java.io.IOException; |
51 | 51 |
import java.util.ArrayList; |
52 |
import java.util.Comparator; |
|
53 |
import java.util.TreeMap; |
|
54 | 52 |
|
55 | 53 |
import org.cresques.cts.ICoordTrans; |
56 | 54 |
import org.geotools.data.postgis.attributeio.WKBEncoder; |
... | ... | |
71 | 69 |
*/ |
72 | 70 |
public class FGeometryCollection implements IGeometry { |
73 | 71 |
private ArrayList geometries = new ArrayList(); |
74 |
private int type=FShape.LINE; |
|
72 |
|
|
75 | 73 |
/** |
76 | 74 |
* Crea un nuevo FGeometryCollection. |
77 | 75 |
* |
... | ... | |
122 | 120 |
*/ |
123 | 121 |
public boolean intersects(Rectangle2D r) { |
124 | 122 |
boolean resul = false; |
125 |
if (type==FShape.LINE) { |
|
126 |
for (int i = 0; i < geometries.size(); i++){ |
|
127 |
resul = ((IGeometry)geometries.get(i)).intersects(r); |
|
128 |
if (resul) break; |
|
129 |
} |
|
130 |
}else if (type==FShape.POLYGON) { |
|
131 |
GeneralPathX gpx=new GeneralPathX(); |
|
132 |
Handler lastHandler=null; |
|
133 |
for (int i = 0; i < geometries.size(); i++) { |
|
134 |
IGeometry geom=(IGeometry)geometries.get(i); |
|
135 |
GeneralPathXIterator gpxi=(GeneralPathXIterator)geom.getPathIterator(null); |
|
136 |
Handler[] handlers=geom.getHandlers(IGeometry.SELECTHANDLER); |
|
137 |
if (lastHandler==null || handlers[0].getPoint().distance(lastHandler.getPoint())==0) { |
|
138 |
gpx.append(gpxi,true); |
|
139 |
}else { |
|
140 |
gpx.append(gpxi,false); |
|
141 |
} |
|
142 |
lastHandler=handlers[handlers.length-1]; |
|
143 |
} |
|
144 |
resul=ShapeFactory.createPolygon2D(gpx).intersects(r); |
|
123 |
for (int i = 0; i < geometries.size(); i++) |
|
124 |
{ |
|
125 |
resul = ((IGeometry)geometries.get(i)).intersects(r); |
|
126 |
if (resul) break; |
|
145 | 127 |
} |
128 |
|
|
146 | 129 |
return resul; |
147 | 130 |
} |
148 | 131 |
|
... | ... | |
173 | 156 |
|
174 | 157 |
return ret; |
175 | 158 |
*/ |
176 |
return type;
|
|
159 |
return FShape.LINE;
|
|
177 | 160 |
} |
178 |
public void setGeometryType(int type) { |
|
179 |
this.type=type; |
|
180 |
} |
|
161 |
|
|
181 | 162 |
/* (non-Javadoc) |
182 | 163 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#draw(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.core.v02.FSymbol) |
183 | 164 |
*/ |
184 | 165 |
public void draw(Graphics2D g, ViewPort vp, FSymbol symbol) { |
185 |
if (type==FShape.LINE) { |
|
186 |
for (int i = 0; i < geometries.size(); i++) |
|
187 |
((IGeometry)geometries.get(i)).draw(g, vp, symbol); |
|
188 |
}else if (type==FShape.POLYGON) { |
|
189 |
//GeneralPathXIterator gpxi=(GeneralPathXIterator)getPathIterator(null); |
|
190 |
GeneralPathX gpx=new GeneralPathX(); |
|
191 |
Handler lastHandler=null; |
|
192 |
for (int i = 0; i < geometries.size(); i++) { |
|
193 |
IGeometry geom=(IGeometry)geometries.get(i); |
|
194 |
GeneralPathXIterator gpxi=(GeneralPathXIterator)geom.getPathIterator(null); |
|
195 |
Handler[] handlers=geom.getHandlers(IGeometry.SELECTHANDLER); |
|
196 |
if (lastHandler==null || handlers[0].getPoint().distance(lastHandler.getPoint())==0) { |
|
197 |
gpx.append(gpxi,true); |
|
198 |
}else { |
|
199 |
gpx.append(gpxi,false); |
|
200 |
} |
|
201 |
lastHandler=handlers[handlers.length-1]; |
|
202 |
} |
|
203 |
ShapeFactory.createPolygon2D(gpx).draw(g,vp,symbol); |
|
204 |
} |
|
166 |
for (int i = 0; i < geometries.size(); i++) |
|
167 |
((IGeometry)geometries.get(i)).draw(g, vp, symbol); |
|
205 | 168 |
} |
206 | 169 |
|
207 | 170 |
/* (non-Javadoc) |
... | ... | |
212 | 175 |
|
213 | 176 |
for (int i = 0; i < geometries.size(); i++) |
214 | 177 |
newGeometries[i] = ((IGeometry)geometries.get(i)).cloneGeometry(); |
215 |
FGeometryCollection gc=new FGeometryCollection(newGeometries); |
|
216 |
gc.type=type; |
|
217 |
return gc; |
|
178 |
|
|
179 |
return new FGeometryCollection(newGeometries); |
|
218 | 180 |
} |
219 | 181 |
|
220 | 182 |
/* (non-Javadoc) |
... | ... | |
227 | 189 |
theGeoms[i] = ((IGeometry)geometries.get(i)).toJTSGeometry(); |
228 | 190 |
} |
229 | 191 |
GeometryCollection geomCol = new GeometryFactory().createGeometryCollection(theGeoms); |
230 |
|
|
231 |
|
|
192 |
|
|
193 |
|
|
232 | 194 |
return geomCol; |
233 | 195 |
} |
234 | 196 |
|
... | ... | |
323 | 285 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#drawInts(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.core.v02.FSymbol) |
324 | 286 |
*/ |
325 | 287 |
public void drawInts(Graphics2D g, ViewPort vp, FSymbol symbol) { |
326 |
if (type==FShape.LINE) { |
|
327 |
for (int i = 0; i < geometries.size(); i++) |
|
328 |
((IGeometry)geometries.get(i)).drawInts(g, vp, symbol); |
|
329 |
}else if (type==FShape.POLYGON) { |
|
330 |
//GeneralPathXIterator gpxi=(GeneralPathXIterator)getPathIterator(null); |
|
331 |
GeneralPathX gpx=new GeneralPathX(); |
|
332 |
Handler lastHandler=null; |
|
333 |
for (int i = 0; i < geometries.size(); i++) { |
|
334 |
IGeometry geom=(IGeometry)geometries.get(i); |
|
335 |
GeneralPathXIterator gpxi=(GeneralPathXIterator)geom.getPathIterator(null); |
|
336 |
Handler[] handlers=geom.getHandlers(IGeometry.SELECTHANDLER); |
|
337 |
if (lastHandler==null || handlers[0].getPoint().distance(lastHandler.getPoint())==0) { |
|
338 |
gpx.append(gpxi,true); |
|
339 |
}else { |
|
340 |
gpx.append(gpxi,false); |
|
341 |
} |
|
342 |
lastHandler=handlers[handlers.length-1]; |
|
343 |
} |
|
344 |
IGeometry geom=ShapeFactory.createPolygon2D(gpx); |
|
345 |
geom.setGeometryType(type); |
|
346 |
geom.drawInts(g,vp,symbol); |
|
347 |
} |
|
288 |
for (int i = 0; i < geometries.size(); i++) |
|
289 |
((IGeometry)geometries.get(i)).drawInts(g, vp, symbol); |
|
348 | 290 |
|
349 | 291 |
} |
350 | 292 |
|
... | ... | |
373 | 315 |
for (int i = 0; i < geometries.size(); i++){ |
374 | 316 |
Handler[] handAux=((IGeometry)geometries.get(i)).getHandlers(type); |
375 | 317 |
for (int j=0;j<handAux.length;j++){ |
376 |
if (!handlers.contains(handAux[j])) |
|
377 |
handlers.add(handAux[j]); |
|
318 |
handlers.add(handAux[j]); |
|
378 | 319 |
} |
379 | 320 |
} |
380 | 321 |
return (Handler[])handlers.toArray(new Handler[0]); |
... | ... | |
422 | 363 |
} |
423 | 364 |
|
424 | 365 |
public boolean intersects(double x, double y, double w, double h) { |
425 |
boolean resul = false; |
|
426 |
if (type==FShape.LINE) { |
|
427 |
for (int i=0; i < geometries.size(); i++){ |
|
428 |
IGeometry gAux = (IGeometry) geometries.get(i); |
|
429 |
resul= gAux.intersects(x,y, w, h); |
|
430 |
if (resul) break; |
|
431 |
} |
|
432 |
}else if (type==FShape.POLYGON) { |
|
433 |
GeneralPathX gpx=new GeneralPathX(); |
|
434 |
Handler lastHandler=null; |
|
435 |
for (int i = 0; i < geometries.size(); i++) { |
|
436 |
IGeometry geom=(IGeometry)geometries.get(i); |
|
437 |
GeneralPathXIterator gpxi=(GeneralPathXIterator)geom.getPathIterator(null); |
|
438 |
Handler[] handlers=geom.getHandlers(IGeometry.SELECTHANDLER); |
|
439 |
if (lastHandler==null || handlers[0].getPoint().distance(lastHandler.getPoint())==0) { |
|
440 |
gpx.append(gpxi,true); |
|
441 |
}else { |
|
442 |
gpx.append(gpxi,false); |
|
443 |
} |
|
444 |
lastHandler=handlers[handlers.length-1]; |
|
445 |
} |
|
446 |
IGeometry geom=ShapeFactory.createPolygon2D(gpx); |
|
447 |
geom.setGeometryType(FShape.POLYGON); |
|
448 |
resul=geom.intersects(x,y,w,h); |
|
366 |
boolean bRes; |
|
367 |
for (int i=0; i < geometries.size(); i++) |
|
368 |
{ |
|
369 |
IGeometry gAux = (IGeometry) geometries.get(i); |
|
370 |
bRes = gAux.intersects(x,y, w, h); |
|
371 |
if (bRes) return bRes; |
|
449 | 372 |
} |
450 |
return resul; |
|
373 |
|
|
374 |
return false; |
|
451 | 375 |
} |
452 | 376 |
|
453 | 377 |
public Rectangle getBounds() { |
... | ... | |
489 | 413 |
public Shape getInternalShape() { |
490 | 414 |
return this; |
491 | 415 |
} |
492 |
|
|
493 |
public int getOriginalGeometryType() { |
|
494 |
return type; |
|
495 |
} |
|
496 |
|
|
497 |
public boolean isClosed() { |
|
498 |
GeneralPathX gpx=new GeneralPathX(); |
|
499 |
PathIterator pi=getPathIterator(null); |
|
500 |
gpx.append(pi,true); |
|
501 |
return gpx.isClosed(); |
|
502 |
} |
|
503 | 416 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FPolygon2D.java | ||
---|---|---|
48 | 48 |
* @author Vicente Caballero Navarro |
49 | 49 |
*/ |
50 | 50 |
public class FPolygon2D extends FPolyline2D { |
51 |
private int type=FShape.POLYGON; |
|
52 | 51 |
/** |
53 | 52 |
* Crea un nuevo Polygon2D. |
54 | 53 |
* |
... | ... | |
62 | 61 |
* @see com.iver.cit.gvsig.fmap.core.FShape#getShapeType() |
63 | 62 |
*/ |
64 | 63 |
public int getShapeType() { |
65 |
return type; |
|
66 |
} |
|
67 |
public void setShapeType(int type) { |
|
68 |
this.type=type; |
|
69 |
} |
|
70 |
|
|
71 |
public int getShapeTypeOriginal() { |
|
72 | 64 |
return FShape.POLYGON; |
73 | 65 |
} |
66 |
|
|
74 | 67 |
/** |
75 | 68 |
* Clona FPolygon2D. |
76 | 69 |
* |
... | ... | |
87 | 80 |
|
88 | 81 |
/* public void draw(Graphics2D g, ViewPort vp, Style2D symbol) { |
89 | 82 |
gp.transform(vp.getAffineTransform()); |
90 |
|
|
83 |
|
|
91 | 84 |
g.setPaint(Color.red); |
92 | 85 |
g.fill(gp); |
93 | 86 |
g.setPaint(Color.black); |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FEllipse2D.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
import java.awt.geom.AffineTransform; |
44 | 44 |
import java.awt.geom.Arc2D; |
45 |
import java.awt.geom.Line2D; |
|
45 | 46 |
import java.awt.geom.Point2D; |
46 | 47 |
import java.awt.geom.Rectangle2D; |
48 |
|
|
47 | 49 |
import java.util.ArrayList; |
48 | 50 |
|
49 | 51 |
import com.iver.cit.gvsig.fmap.edition.UtilFunctions; |
... | ... | |
54 | 56 |
* |
55 | 57 |
* @author Vicente Caballero Navarro |
56 | 58 |
*/ |
57 |
public class FEllipse2D extends FPolygon2D {
|
|
59 |
public class FEllipse2D extends FPolyline2D {
|
|
58 | 60 |
private Point2D init; |
59 | 61 |
private Point2D end; |
60 | 62 |
private double ydist; |
... | ... | |
402 | 404 |
AffineTransform mT = AffineTransform.getRotateInstance(angle, init.getX(), init.getY()); |
403 | 405 |
gp = new GeneralPathX(arc); |
404 | 406 |
gp.transform(mT); |
405 |
} |
|
407 |
}
|
|
406 | 408 |
} |
407 |
|
|
409 |
|
|
408 | 410 |
/* (non-Javadoc) |
409 | 411 |
* @see com.iver.cit.gvsig.fmap.core.FPolyline2D#intersects(java.awt.geom.Rectangle2D) |
410 | 412 |
*/ |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FNullGeometry.java | ||
---|---|---|
203 | 203 |
// TODO Auto-generated method stub |
204 | 204 |
return null; |
205 | 205 |
} |
206 |
|
|
207 |
public int getOriginalGeometryType() { |
|
208 |
return FShape.NULL; |
|
209 |
} |
|
210 |
|
|
211 |
public void setGeometryType(int type) { |
|
212 |
|
|
213 |
} |
|
214 | 206 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FCircle2D.java | ||
---|---|---|
56 | 56 |
* |
57 | 57 |
* @author Vicente Caballero Navarro |
58 | 58 |
*/ |
59 |
public class FCircle2D extends FPolygon2D {
|
|
59 |
public class FCircle2D extends FPolyline2D {
|
|
60 | 60 |
private Point2D center; |
61 | 61 |
private double radio; |
62 | 62 |
|
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FGeometry.java | ||
---|---|---|
73 | 73 |
* @author FJP |
74 | 74 |
*/ |
75 | 75 |
public class FGeometry implements IGeometry3D { |
76 |
/** |
|
77 |
* |
|
78 |
*/ |
|
79 |
private static final long serialVersionUID = 5431865770186523337L; |
|
80 |
private FShape shp; |
|
81 |
private Rectangle2D bounds2D; |
|
82 |
private int type=FShape.LINE; |
|
76 |
/** |
|
77 |
* |
|
78 |
*/ |
|
79 |
private static final long serialVersionUID = 5431865770186523337L; |
|
80 |
private FShape shp; |
|
81 |
private Rectangle2D bounds2D; |
|
83 | 82 |
|
84 |
/**
|
|
85 |
* Crea un nuevo FGeometry.
|
|
86 |
*
|
|
87 |
* @param shp DOCUMENT ME!
|
|
88 |
*/
|
|
89 |
FGeometry(FShape shp) {
|
|
90 |
this.shp = shp;
|
|
91 |
}
|
|
83 |
/**
|
|
84 |
* Crea un nuevo FGeometry.
|
|
85 |
*
|
|
86 |
* @param shp DOCUMENT ME!
|
|
87 |
*/
|
|
88 |
FGeometry(FShape shp) {
|
|
89 |
this.shp = shp;
|
|
90 |
}
|
|
92 | 91 |
|
93 |
/* (non-Javadoc)
|
|
94 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#draw(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, org.geotools.renderer.style.Style2D)
|
|
95 |
*/
|
|
96 |
public void draw(Graphics2D g, ViewPort vp, FStyle2D symbol) {
|
|
97 |
// OJO CON LA PRECISION. DEBERIAMOS USAR: ((GeneralPathX) shp.m_Polyline).transform(mT);
|
|
98 |
// O HACER UNA FUNCION DE TRANSFORMACI?N QUE USE LOS DOUBLES DEL
|
|
99 |
// SHAPE
|
|
100 |
// Shape shpTrans = vp.getAffineTransform().createTransformedShape(shp);
|
|
101 |
transform(vp.getAffineTransform());
|
|
92 |
/* (non-Javadoc)
|
|
93 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#draw(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, org.geotools.renderer.style.Style2D)
|
|
94 |
*/
|
|
95 |
public void draw(Graphics2D g, ViewPort vp, FStyle2D symbol) {
|
|
96 |
// OJO CON LA PRECISION. DEBERIAMOS USAR: ((GeneralPathX) shp.m_Polyline).transform(mT);
|
|
97 |
// O HACER UNA FUNCION DE TRANSFORMACI?N QUE USE LOS DOUBLES DEL
|
|
98 |
// SHAPE
|
|
99 |
// Shape shpTrans = vp.getAffineTransform().createTransformedShape(shp);
|
|
100 |
transform(vp.getAffineTransform());
|
|
102 | 101 |
|
103 |
switch (shp.getShapeType()) {
|
|
104 |
case FShape.POINT:
|
|
105 |
shpPainter.paint(g, shp, symbol.getPointStyle2D(), 0);
|
|
102 |
switch (shp.getShapeType()) {
|
|
103 |
case FShape.POINT:
|
|
104 |
shpPainter.paint(g, shp, symbol.getPointStyle2D(), 0);
|
|
106 | 105 |
|
107 |
break;
|
|
106 |
break;
|
|
108 | 107 |
|
109 |
case FShape.LINE:
|
|
110 |
shpPainter.paint(g, shp, symbol.getLineStyle2D(), 0);
|
|
108 |
case FShape.LINE:
|
|
109 |
shpPainter.paint(g, shp, symbol.getLineStyle2D(), 0);
|
|
111 | 110 |
|
112 |
break;
|
|
111 |
break;
|
|
113 | 112 |
|
114 |
case FShape.POLYGON:
|
|
115 |
shpPainter.paint(g, shp, symbol.getPolygonStyle2D(), 0);
|
|
113 |
case FShape.POLYGON:
|
|
114 |
shpPainter.paint(g, shp, symbol.getPolygonStyle2D(), 0);
|
|
116 | 115 |
|
117 |
break;
|
|
116 |
break;
|
|
118 | 117 |
|
119 |
case FShape.TEXT:
|
|
120 |
shpPainter.paint(g, shp, symbol.getTextStyle2D(), 0);
|
|
121 |
}
|
|
122 |
}
|
|
118 |
case FShape.TEXT:
|
|
119 |
shpPainter.paint(g, shp, symbol.getTextStyle2D(), 0);
|
|
120 |
}
|
|
121 |
}
|
|
123 | 122 |
|
124 |
/**
|
|
125 |
* Dibuja la geometria actual en el graphics que se le pasa como par?metro,
|
|
126 |
* aplicandole las caracter?sticas del s?mbolo.
|
|
127 |
*
|
|
128 |
* @param g Graphics2D.
|
|
129 |
* @param vp ViewPort.
|
|
130 |
* @param symbol S?mbolo.
|
|
131 |
*/
|
|
132 |
public void draw(Graphics2D g, ViewPort vp, FSymbol symbol) {
|
|
133 |
// OJO CON LA PRECISION. DEBERIAMOS USAR: ((GeneralPathX) shp.m_Polyline).transform(mT);
|
|
134 |
// O HACER UNA FUNCION DE TRANSFORMACI?N QUE USE LOS DOUBLES DEL
|
|
135 |
// SHAPE
|
|
136 |
// Shape shpTrans = vp.getAffineTransform().createTransformedShape(shp);
|
|
137 |
transform(vp.getAffineTransform());
|
|
138 |
FGraphicUtilities.DrawShape(g, vp.getAffineTransform(), shp, symbol);
|
|
139 |
}
|
|
123 |
/**
|
|
124 |
* Dibuja la geometria actual en el graphics que se le pasa como par?metro,
|
|
125 |
* aplicandole las caracter?sticas del s?mbolo.
|
|
126 |
*
|
|
127 |
* @param g Graphics2D.
|
|
128 |
* @param vp ViewPort.
|
|
129 |
* @param symbol S?mbolo.
|
|
130 |
*/
|
|
131 |
public void draw(Graphics2D g, ViewPort vp, FSymbol symbol) {
|
|
132 |
// OJO CON LA PRECISION. DEBERIAMOS USAR: ((GeneralPathX) shp.m_Polyline).transform(mT);
|
|
133 |
// O HACER UNA FUNCION DE TRANSFORMACI?N QUE USE LOS DOUBLES DEL
|
|
134 |
// SHAPE
|
|
135 |
// Shape shpTrans = vp.getAffineTransform().createTransformedShape(shp);
|
|
136 |
transform(vp.getAffineTransform());
|
|
137 |
FGraphicUtilities.DrawShape(g, vp.getAffineTransform(), shp, symbol);
|
|
138 |
}
|
|
140 | 139 |
|
141 | 140 |
/* (non-Javadoc) |
142 | 141 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#drawInts(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.core.v02.FSymbol) |
... | ... | |
146 | 145 |
FGraphicUtilities.DrawShape(g, vp.getAffineTransform(), decimatedShape, symbol); |
147 | 146 |
} |
148 | 147 |
|
149 |
/**
|
|
150 |
* Aplica la transformaci?n a la geometr?a de la matriz de transformaci?n
|
|
151 |
* que se pasa como par?metro.
|
|
152 |
*
|
|
153 |
* @param at Matriz de transformaci?n.
|
|
154 |
*/
|
|
155 |
public void transform(AffineTransform at) {
|
|
156 |
shp.transform(at);
|
|
157 |
}
|
|
148 |
/**
|
|
149 |
* Aplica la transformaci?n a la geometr?a de la matriz de transformaci?n
|
|
150 |
* que se pasa como par?metro.
|
|
151 |
*
|
|
152 |
* @param at Matriz de transformaci?n.
|
|
153 |
*/
|
|
154 |
public void transform(AffineTransform at) {
|
|
155 |
shp.transform(at);
|
|
156 |
}
|
|
158 | 157 |
|
159 |
/* (non-Javadoc) |
|
160 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#intersects(java.awt.geom.Rectangle2D) |
|
161 |
*/ |
|
162 |
public boolean intersects(Rectangle2D r) { |
|
163 |
if (getGeometryType()==FShape.LINE && shp.getShapeType()==FShape.POLYGON) { |
|
164 |
return shp.intersects(r) && !shp.contains(r); |
|
165 |
} |
|
166 |
return shp.intersects(r); |
|
167 |
} |
|
158 |
/* (non-Javadoc) |
|
159 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#intersects(java.awt.geom.Rectangle2D) |
|
160 |
*/ |
|
161 |
public boolean intersects(Rectangle2D r) { |
|
162 |
return shp.intersects(r); |
|
163 |
} |
|
168 | 164 |
|
169 |
/* (non-Javadoc) |
|
170 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getBounds2D() |
|
171 |
*/ |
|
172 |
public Rectangle2D getBounds2D() { |
|
173 |
if (bounds2D == null) |
|
174 |
{ |
|
175 |
bounds2D = shp.getBounds2D(); |
|
176 |
} |
|
177 |
// return shp.getBounds2D(); |
|
178 |
return bounds2D; |
|
179 |
} |
|
165 |
/* (non-Javadoc) |
|
166 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getBounds2D() |
|
167 |
*/ |
|
168 |
public Rectangle2D getBounds2D() { |
|
169 |
if (bounds2D == null) |
|
170 |
{ |
|
171 |
bounds2D = shp.getBounds2D(); |
|
172 |
} |
|
173 |
// return shp.getBounds2D(); |
|
174 |
return bounds2D; |
|
175 |
} |
|
176 |
|
|
177 |
public Rectangle2D reCalculateBounds2D() |
|
178 |
{ |
|
179 |
return shp.getBounds2D(); |
|
180 |
} |
|
180 | 181 |
|
181 |
public Rectangle2D reCalculateBounds2D() |
|
182 |
{ |
|
183 |
return shp.getBounds2D(); |
|
184 |
} |
|
182 |
/* (non-Javadoc) |
|
183 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#toJTSGeometry() |
|
184 |
*/ |
|
185 |
public Geometry toJTSGeometry() { |
|
186 |
return FConverter.java2d_to_jts(shp); |
|
187 |
} |
|
185 | 188 |
|
186 |
/* (non-Javadoc)
|
|
187 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#toJTSGeometry()
|
|
188 |
*/
|
|
189 |
public Geometry toJTSGeometry() {
|
|
190 |
return FConverter.java2d_to_jts(shp);
|
|
191 |
}
|
|
189 |
/* (non-Javadoc)
|
|
190 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#createLabels(int, boolean)
|
|
191 |
*/
|
|
192 |
public FLabel[] createLabels(int position, boolean duplicates) {
|
|
193 |
FLabel[] aux = new FLabel[1];
|
|
194 |
aux[0] = FLabel.createFLabel(shp);
|
|
192 | 195 |
|
193 |
/* (non-Javadoc) |
|
194 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#createLabels(int, boolean) |
|
195 |
*/ |
|
196 |
public FLabel[] createLabels(int position, boolean duplicates) { |
|
197 |
FLabel[] aux = new FLabel[1]; |
|
198 |
aux[0] = FLabel.createFLabel(shp); |
|
196 |
return aux; |
|
197 |
} |
|
199 | 198 |
|
200 |
return aux; |
|
201 |
} |
|
199 |
/** |
|
200 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getGeometryType() |
|
201 |
*/ |
|
202 |
public int getGeometryType() { |
|
203 |
return shp.getShapeType(); |
|
204 |
} |
|
202 | 205 |
|
203 |
/**
|
|
204 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getGeometryType()
|
|
205 |
*/
|
|
206 |
public int getGeometryType() {
|
|
207 |
return type;
|
|
208 |
}
|
|
206 |
/* (non-Javadoc)
|
|
207 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#cloneGeometry()
|
|
208 |
*/
|
|
209 |
public IGeometry cloneGeometry() {
|
|
210 |
return new FGeometry(shp.cloneFShape());
|
|
211 |
}
|
|
209 | 212 |
|
210 |
/* (non-Javadoc) |
|
211 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#cloneGeometry() |
|
212 |
*/ |
|
213 |
public IGeometry cloneGeometry() { |
|
214 |
IGeometry geom=new FGeometry(shp.cloneFShape()); |
|
215 |
geom.setGeometryType(type); |
|
216 |
return geom; |
|
217 |
} |
|
213 |
/* (non-Javadoc) |
|
214 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#reProject(org.cresques.cts.ICoordTrans) |
|
215 |
*/ |
|
216 |
public void reProject(ICoordTrans ct) { |
|
217 |
shp.reProject(ct); |
|
218 |
} |
|
218 | 219 |
|
219 |
/* (non-Javadoc)
|
|
220 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#reProject(org.cresques.cts.ICoordTrans)
|
|
221 |
*/
|
|
222 |
public void reProject(ICoordTrans ct) {
|
|
223 |
shp.reProject(ct);
|
|
224 |
}
|
|
220 |
/**
|
|
221 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getPathIterator(AffineTransform)
|
|
222 |
*/
|
|
223 |
public PathIterator getPathIterator(AffineTransform at) {
|
|
224 |
return (GeneralPathXIterator)shp.getPathIterator(null);
|
|
225 |
}
|
|
225 | 226 |
|
226 |
/** |
|
227 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getPathIterator(AffineTransform) |
|
228 |
*/ |
|
229 |
public PathIterator getPathIterator(AffineTransform at) { |
|
230 |
return (GeneralPathXIterator)shp.getPathIterator(null); |
|
231 |
} |
|
232 | 227 |
|
233 |
|
|
234 |
|
|
228 |
|
|
235 | 229 |
/* (non-Javadoc) |
236 | 230 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#fastIntersects(double, double, double, double) |
237 | 231 |
*/ |
... | ... | |
243 | 237 |
return WKBEncoder.encodeGeometry(toJTSGeometry()); |
244 | 238 |
} |
245 | 239 |
/** |
246 |
* Devuelve un array con todos los valores de Z.
|
|
247 |
*
|
|
248 |
* @return Array de Zs.
|
|
249 |
*/
|
|
250 |
public double[] getZs() {
|
|
251 |
return ((FShape3D) shp).getZs();
|
|
252 |
}
|
|
253 |
/**
|
|
254 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getHandlers()
|
|
255 |
*/
|
|
256 |
public Handler[] getHandlers(int type) {
|
|
257 |
if (type==STRETCHINGHANDLER){
|
|
258 |
return shp.getStretchingHandlers();
|
|
259 |
}else if (type==SELECTHANDLER){
|
|
260 |
return shp.getSelectHandlers();
|
|
261 |
}
|
|
262 |
return null;
|
|
263 |
}
|
|
240 |
* Devuelve un array con todos los valores de Z.
|
|
241 |
*
|
|
242 |
* @return Array de Zs.
|
|
243 |
*/
|
|
244 |
public double[] getZs() {
|
|
245 |
return ((FShape3D) shp).getZs();
|
|
246 |
}
|
|
247 |
/**
|
|
248 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getHandlers()
|
|
249 |
*/
|
|
250 |
public Handler[] getHandlers(int type) {
|
|
251 |
if (type==STRETCHINGHANDLER){
|
|
252 |
return shp.getStretchingHandlers();
|
|
253 |
}else if (type==SELECTHANDLER){
|
|
254 |
return shp.getSelectHandlers();
|
|
255 |
}
|
|
256 |
return null;
|
|
257 |
}
|
|
264 | 258 |
|
265 |
/* (non-Javadoc)
|
|
266 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getGeneralPathXIterator(java.awt.geom.AffineTransform, double)
|
|
267 |
*/
|
|
268 |
public PathIterator getPathIterator(AffineTransform at, double flatness) {
|
|
269 |
return shp.getPathIterator(at, flatness);
|
|
270 |
}
|
|
259 |
/* (non-Javadoc)
|
|
260 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getGeneralPathXIterator(java.awt.geom.AffineTransform, double)
|
|
261 |
*/
|
|
262 |
public PathIterator getPathIterator(AffineTransform at, double flatness) {
|
|
263 |
return shp.getPathIterator(at, flatness);
|
|
264 |
}
|
|
271 | 265 |
|
272 |
public boolean contains(double x, double y) {
|
|
273 |
return shp.contains(x,y);
|
|
274 |
}
|
|
266 |
public boolean contains(double x, double y) {
|
|
267 |
return shp.contains(x,y);
|
|
268 |
}
|
|
275 | 269 |
|
276 |
public boolean contains(double x, double y, double w, double h) {
|
|
277 |
return shp.contains(x,y,w,h);
|
|
278 |
}
|
|
270 |
public boolean contains(double x, double y, double w, double h) {
|
|
271 |
return shp.contains(x,y,w,h);
|
|
272 |
}
|
|
279 | 273 |
|
280 |
public boolean intersects(double x, double y, double w, double h) { |
|
281 |
if (getGeometryType()==FShape.LINE && shp.getShapeType()==FShape.POLYGON) { |
|
282 |
return shp.intersects(x,y,w,h) && !shp.contains(x,y,w,h); |
|
283 |
} |
|
284 |
return shp.intersects(x,y,w,h); |
|
285 |
} |
|
274 |
public boolean intersects(double x, double y, double w, double h) { |
|
275 |
return shp.intersects(x,y,w,h); |
|
276 |
} |
|
286 | 277 |
|
287 |
public Rectangle getBounds() {
|
|
288 |
return shp.getBounds();
|
|
289 |
}
|
|
278 |
public Rectangle getBounds() {
|
|
279 |
return shp.getBounds();
|
|
280 |
}
|
|
290 | 281 |
|
291 |
public boolean contains(Point2D p) {
|
|
292 |
return shp.contains(p);
|
|
293 |
}
|
|
282 |
public boolean contains(Point2D p) {
|
|
283 |
return shp.contains(p);
|
|
284 |
}
|
|
294 | 285 |
|
295 |
public boolean contains(Rectangle2D r) {
|
|
296 |
return shp.contains(r);
|
|
297 |
}
|
|
286 |
public boolean contains(Rectangle2D r) {
|
|
287 |
return shp.contains(r);
|
|
288 |
}
|
|
298 | 289 |
|
299 |
public Shape getInternalShape() {
|
|
300 |
return shp;
|
|
301 |
}
|
|
290 |
public Shape getInternalShape() {
|
|
291 |
return shp;
|
|
292 |
}
|
|
302 | 293 |
|
303 |
public int getOriginalGeometryType() { |
|
304 |
return shp.getShapeType(); |
|
305 |
} |
|
306 |
|
|
307 |
public void setGeometryType(int type) { |
|
308 |
this.type=type; |
|
309 |
|
|
310 |
} |
|
311 |
|
|
312 |
/* public void move(double x, double y) { |
|
313 |
AffineTransform at = new AffineTransform(); |
|
314 |
at.translate(x, y); |
|
315 |
transform(at); |
|
316 |
} |
|
317 |
public void rotate(double r, double x, double y) { |
|
318 |
AffineTransform at = new AffineTransform(); |
|
319 |
at.rotate(r, x, y); |
|
320 |
transform(at); |
|
321 |
} |
|
322 |
public void scale(Point2D point,double x, double y) { |
|
323 |
AffineTransform at = new AffineTransform(); |
|
324 |
at.setToTranslation(point.getX(),point.getY()); |
|
325 |
at.scale(x,y); |
|
326 |
at.translate(-point.getX(),-point.getY()); |
|
327 |
transform(at); |
|
328 |
} */ |
|
294 |
/* public void move(double x, double y) { |
|
295 |
AffineTransform at = new AffineTransform(); |
Also available in: Unified diff