Revision 27398 branches/v2_0_0_prep/extensions/extEditing/src/com/iver/cit/gvsig/gui/cad/DefaultCADTool.java
DefaultCADTool.java | ||
---|---|---|
65 | 65 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
66 | 66 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
67 | 67 |
import org.gvsig.fmap.geom.aggregate.MultiPrimitive; |
68 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
68 | 69 |
import org.gvsig.fmap.geom.handler.Handler; |
69 | 70 |
import org.gvsig.fmap.geom.operation.Draw; |
70 | 71 |
import org.gvsig.fmap.geom.operation.DrawOperationContext; |
... | ... | |
130 | 131 |
|
131 | 132 |
public void addTemporalCache(Geometry geom) { |
132 | 133 |
temporalCache.add(geom); |
133 |
insertSpatialCache(geom); |
|
134 |
try { |
|
135 |
insertSpatialCache(geom); |
|
136 |
} catch (CreateEnvelopeException e) { |
|
137 |
logger.error("Error adding the spatial cache", e); |
|
138 |
} |
|
134 | 139 |
} |
135 | 140 |
|
136 | 141 |
public void clearTemporalCache() { |
137 | 142 |
Geometry[] geoms = (Geometry[]) temporalCache.toArray(new Geometry[0]); |
138 | 143 |
for (int i = 0; i < geoms.length; i++) { |
139 |
removeSpatialCache(geoms[i]); |
|
144 |
try { |
|
145 |
removeSpatialCache(geoms[i]); |
|
146 |
} catch (CreateEnvelopeException e) { |
|
147 |
logger.error("Error removing the temporal cache", e); |
|
148 |
} |
|
140 | 149 |
} |
141 | 150 |
temporalCache.clear(); |
142 | 151 |
} |
143 | 152 |
|
144 |
private void insertSpatialCache(Geometry geom) { |
|
153 |
private void insertSpatialCache(Geometry geom) throws CreateEnvelopeException {
|
|
145 | 154 |
VectorialLayerEdited vle = getVLE(); |
146 | 155 |
SpatialCache spatialCache = ((FLyrVect) vle.getLayer()) |
147 | 156 |
.getSpatialCache(); |
148 | 157 |
Envelope r = geom.getEnvelope(); |
149 | 158 |
if (geom.getType() == Geometry.TYPES.POINT) { |
150 |
r = UtilFunctions.createEnvelope(r.getMinimum(0), r.getMinimum(1), r
|
|
151 |
.getMinimum(0) + 1, r.getMinimum(1) + 1);// Rectangle2D.Double(r.getX(),r.getY(),1,1); |
|
159 |
r = geomManager.createEnvelope(r.getMinimum(0), r.getMinimum(1), r
|
|
160 |
.getMinimum(0) + 1, r.getMinimum(1) + 1, SUBTYPES.GEOM2D);// Rectangle2D.Double(r.getX(),r.getY(),1,1);
|
|
152 | 161 |
} |
153 | 162 |
spatialCache.insert(r, geom); |
154 | 163 |
|
155 | 164 |
} |
156 | 165 |
|
157 |
private void removeSpatialCache(Geometry geom) { |
|
166 |
private void removeSpatialCache(Geometry geom) throws CreateEnvelopeException {
|
|
158 | 167 |
VectorialLayerEdited vle = getVLE(); |
159 | 168 |
SpatialCache spatialCache = ((FLyrVect) vle.getLayer()) |
160 | 169 |
.getSpatialCache(); |
161 | 170 |
Envelope r = geom.getEnvelope(); |
162 | 171 |
if (geom.getType() == Geometry.TYPES.POINT) { |
163 |
r = UtilFunctions.createEnvelope(r.getMinimum(0), r.getMinimum(1), r
|
|
164 |
.getMinimum(0) + 1, r.getMinimum(1) + 1);// Rectangle2D.Double(r.getX(),r.getY(),1,1); |
|
172 |
r = geomManager.createEnvelope(r.getMinimum(0), r.getMinimum(1), r
|
|
173 |
.getMinimum(0) + 1, r.getMinimum(1) + 1, SUBTYPES.GEOM2D);// Rectangle2D.Double(r.getX(),r.getY(),1,1);
|
|
165 | 174 |
} |
166 | 175 |
spatialCache.remove(r, geom); |
167 | 176 |
|
... | ... | |
241 | 250 |
e.printStackTrace(); |
242 | 251 |
} catch (GeometryOperationException e) { |
243 | 252 |
e.printStackTrace(); |
244 |
} catch (InstantiationException e) {
|
|
253 |
} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
|
|
245 | 254 |
e.printStackTrace(); |
246 |
} catch (IllegalAccessException e) { |
|
247 |
e.printStackTrace(); |
|
248 |
} |
|
255 |
} |
|
249 | 256 |
// draw(g, |
250 | 257 |
// getCadToolAdapter().getMapControl().getViewPort(), |
251 | 258 |
// symbol); |
... | ... | |
279 | 286 |
} catch (DataException e) { |
280 | 287 |
NotificationManager.addError(e.getMessage(), e); |
281 | 288 |
return null; |
289 |
} catch (CreateEnvelopeException e) { |
|
290 |
NotificationManager.addError(e.getMessage(), e); |
|
291 |
return null; |
|
282 | 292 |
} |
283 | 293 |
} |
284 | 294 |
public Feature insertAndSelectGeometry(Geometry geometry){ |
... | ... | |
321 | 331 |
} catch (DataException e) { |
322 | 332 |
NotificationManager.addError(e.getMessage(), e); |
323 | 333 |
return null; |
334 |
} catch (CreateEnvelopeException e) { |
|
335 |
NotificationManager.addError(e.getMessage(), e); |
|
336 |
return null; |
|
324 | 337 |
} |
325 | 338 |
|
326 | 339 |
} |
... | ... | |
354 | 367 |
// vle.drawHandlers(geometry.cloneGeometry(), gh, vp); |
355 | 368 |
// vle.setHandlersImage(handlersImage); |
356 | 369 |
// vle.setSelectionImage(selectionImage); |
357 |
insertSpatialCache(geometry); |
|
370 |
try { |
|
371 |
insertSpatialCache(geometry); |
|
372 |
} catch (CreateEnvelopeException e) { |
|
373 |
logger.error("Error creating the envelope", e); |
|
374 |
} |
|
358 | 375 |
|
359 | 376 |
} |
360 | 377 |
|
... | ... | |
631 | 648 |
try { |
632 | 649 |
curve = (Curve)geomManager.create(TYPES.CURVE, SUBTYPES.GEOM2D); |
633 | 650 |
curve.setGeneralPath(gpx); |
634 |
} catch (InstantiationException e) {
|
|
651 |
} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
|
|
635 | 652 |
logger.error(new CreateGeometryException(TYPES.CURVE, SUBTYPES.GEOM2D, e)); |
636 |
} catch (IllegalAccessException e) { |
|
637 |
logger.error(new CreateGeometryException(TYPES.CURVE, SUBTYPES.GEOM2D, e)); |
|
638 | 653 |
} |
639 | 654 |
return curve; |
640 | 655 |
} |
... | ... | |
653 | 668 |
try { |
654 | 669 |
surface = (Surface)geomManager.create(TYPES.SURFACE, SUBTYPES.GEOM2D); |
655 | 670 |
surface.setGeneralPath(gpx); |
656 |
} catch (InstantiationException e) {
|
|
671 |
} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
|
|
657 | 672 |
logger.error(new CreateGeometryException(TYPES.SURFACE, SUBTYPES.GEOM2D, e)); |
658 |
} catch (IllegalAccessException e) { |
|
659 |
logger.error(new CreateGeometryException(TYPES.SURFACE, SUBTYPES.GEOM2D, e)); |
|
660 | 673 |
} |
661 | 674 |
return surface; |
662 | 675 |
} |
... | ... | |
691 | 704 |
point = (Point)geomManager.create(TYPES.POINT, SUBTYPES.GEOM2D); |
692 | 705 |
point.setX(x); |
693 | 706 |
point.setY(y); |
694 |
} catch (InstantiationException e) {
|
|
707 |
} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
|
|
695 | 708 |
logger.error(new CreateGeometryException(TYPES.POINT, SUBTYPES.GEOM2D, e)); |
696 |
} catch (IllegalAccessException e) { |
|
697 |
logger.error(new CreateGeometryException(TYPES.POINT, SUBTYPES.GEOM2D, e)); |
|
698 |
} |
|
709 |
} |
|
699 | 710 |
return point; |
700 | 711 |
} |
701 | 712 |
|
... | ... | |
728 | 739 |
try { |
729 | 740 |
arc = (Arc)geomManager.create(TYPES.ARC, SUBTYPES.GEOM2D); |
730 | 741 |
arc.setPoints(p1, p2, p3); |
731 |
} catch (InstantiationException e) {
|
|
742 |
} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
|
|
732 | 743 |
logger.error(new CreateGeometryException(TYPES.ARC, SUBTYPES.GEOM2D, e)); |
733 |
} catch (IllegalAccessException e) { |
|
734 |
logger.error(new CreateGeometryException(TYPES.ARC, SUBTYPES.GEOM2D, e)); |
|
735 |
} |
|
736 |
return arc; |
|
744 |
} |
|
745 |
return arc; |
|
737 | 746 |
} |
738 | 747 |
|
739 | 748 |
/** |
... | ... | |
751 | 760 |
try { |
752 | 761 |
circle = (Circle)geomManager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D); |
753 | 762 |
circle.setPoints(p1, p2, p3); |
754 |
} catch (InstantiationException e) {
|
|
763 |
} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
|
|
755 | 764 |
logger.error(new CreateGeometryException(TYPES.CIRCLE, SUBTYPES.GEOM2D, e)); |
756 |
} catch (IllegalAccessException e) { |
|
757 |
logger.error(new CreateGeometryException(TYPES.CIRCLE, SUBTYPES.GEOM2D, e)); |
|
758 |
} |
|
765 |
} |
|
759 | 766 |
return circle; |
760 | 767 |
} |
761 | 768 |
|
... | ... | |
786 | 793 |
try { |
787 | 794 |
circle = (Circle)geomManager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D); |
788 | 795 |
circle.setPoints(p1, p2); |
789 |
} catch (InstantiationException e) {
|
|
796 |
} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
|
|
790 | 797 |
logger.error(new CreateGeometryException(TYPES.CIRCLE, SUBTYPES.GEOM2D, e)); |
791 |
} catch (IllegalAccessException e) { |
|
792 |
logger.error(new CreateGeometryException(TYPES.CIRCLE, SUBTYPES.GEOM2D, e)); |
|
793 |
} |
|
798 |
} |
|
794 | 799 |
return circle; |
795 | 800 |
} |
796 | 801 |
|
... | ... | |
821 | 826 |
try { |
822 | 827 |
circle = (Circle)geomManager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D); |
823 | 828 |
circle.setPoints(p1, radious); |
824 |
} catch (InstantiationException e) {
|
|
829 |
} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
|
|
825 | 830 |
logger.error(new CreateGeometryException(TYPES.CIRCLE, SUBTYPES.GEOM2D, e)); |
826 |
} catch (IllegalAccessException e) { |
|
827 |
logger.error(new CreateGeometryException(TYPES.CIRCLE, SUBTYPES.GEOM2D, e)); |
|
828 | 831 |
} |
829 | 832 |
return circle; |
830 | 833 |
} |
... | ... | |
858 | 861 |
try { |
859 | 862 |
ellipse = (Ellipse)geomManager.create(TYPES.ELLIPSE, SUBTYPES.GEOM2D); |
860 | 863 |
ellipse.setPoints(p1, p2, d); |
861 |
} catch (InstantiationException e) {
|
|
864 |
} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
|
|
862 | 865 |
logger.error(new CreateGeometryException(TYPES.ELLIPSE, SUBTYPES.GEOM2D, e)); |
863 |
} catch (IllegalAccessException e) { |
|
864 |
logger.error(new CreateGeometryException(TYPES.ELLIPSE, SUBTYPES.GEOM2D, e)); |
|
865 |
} |
|
866 |
} |
|
866 | 867 |
return ellipse; |
867 | 868 |
} |
868 | 869 |
|
... | ... | |
881 | 882 |
for (int i=0 ; i<points.length ; i++){ |
882 | 883 |
spline.addVertex(createPoint(points[i])); |
883 | 884 |
} |
884 |
} catch (InstantiationException e) {
|
|
885 |
} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
|
|
885 | 886 |
logger.error(new CreateGeometryException(TYPES.SPLINE, SUBTYPES.GEOM2D, e)); |
886 |
} catch (IllegalAccessException e) { |
|
887 |
logger.error(new CreateGeometryException(TYPES.SPLINE, SUBTYPES.GEOM2D, e)); |
|
888 | 887 |
} |
889 | 888 |
return spline; |
890 | 889 |
} |
... | ... | |
903 | 902 |
for (int i=0 ; i<geometries.length ; i++){ |
904 | 903 |
multiPrimitive.addPrimitive((Primitive)geometries[i]); |
905 | 904 |
} |
906 |
} catch (InstantiationException e) {
|
|
905 |
} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
|
|
907 | 906 |
logger.error(new CreateGeometryException(TYPES.SPLINE, SUBTYPES.GEOM2D, e)); |
908 |
} catch (IllegalAccessException e) { |
|
909 |
logger.error(new CreateGeometryException(TYPES.SPLINE, SUBTYPES.GEOM2D, e)); |
|
910 | 907 |
} |
911 | 908 |
return multiPrimitive; |
912 | 909 |
} |
Also available in: Unified diff