Revision 46491 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/swing/pickercontroller/impl/EnvelopePickerControllerImpl.java
EnvelopePickerControllerImpl.java | ||
---|---|---|
313 | 313 |
if( !this.isValid() ) { |
314 | 314 |
throw new IllegalValueException(); |
315 | 315 |
} |
316 |
|
|
316 |
Envelope envelope = null; |
|
317 | 317 |
if( this.txtEnvelope==null ) { |
318 | 318 |
try { |
319 | 319 |
double upperLeftX = DoubleDocumentFilter.getValue(this.txtUpperLeftX); |
... | ... | |
321 | 321 |
double lowerRightX = DoubleDocumentFilter.getValue(this.txtLowerRightX); |
322 | 322 |
double lowerRightY = DoubleDocumentFilter.getValue(this.txtLowerRightY); |
323 | 323 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
324 |
Envelope envelope = geomManager.createEnvelope(Geometry.SUBTYPES.GEOM2D);
|
|
324 |
envelope = geomManager.createEnvelope(Geometry.SUBTYPES.GEOM2D); |
|
325 | 325 |
Point upperLeft = geomManager.createPoint(upperLeftX, upperLeftY, Geometry.SUBTYPES.GEOM2D); |
326 | 326 |
Point lowerRight = geomManager.createPoint(lowerRightX, lowerRightY, Geometry.SUBTYPES.GEOM2D); |
327 | 327 |
envelope.setUpperCorner(upperLeft); |
328 | 328 |
envelope.setLowerCorner(lowerRight); |
329 |
return envelope; |
|
330 | 329 |
} catch (Exception ex) { |
331 |
throw new GeometryRuntimeException("Can't create envelope", ex);
|
|
330 |
return null;
|
|
332 | 331 |
} |
333 | 332 |
} else { |
334 | 333 |
try { |
335 | 334 |
Geometry geom = GeometryUtils.createFrom(this.txtEnvelope.getText()); |
336 |
return geom.getEnvelope();
|
|
335 |
envelope = geom.getEnvelope();
|
|
337 | 336 |
} catch(Exception ex) { |
338 | 337 |
return null; |
339 | 338 |
} |
340 | 339 |
} |
340 |
if( this.mapControl!=null ) { |
|
341 |
envelope.setProjection(this.mapControl.getProjection()); |
|
342 |
} |
|
343 |
return envelope; |
|
341 | 344 |
} |
342 | 345 |
|
343 | 346 |
@Override |
... | ... | |
346 | 349 |
this.clear(); |
347 | 350 |
return; |
348 | 351 |
} |
352 |
if( envelope.isCollapsed() ) { |
|
353 |
this.clear(); |
|
354 |
return; |
|
355 |
} |
|
349 | 356 |
if( this.txtEnvelope==null ) { |
350 | 357 |
this.txtUpperLeftX.setText(String.format("%+f", envelope.getMinimum(DIMENSIONS.X))); |
351 | 358 |
this.txtUpperLeftY.setText(String.format("%+f", envelope.getMaximum(DIMENSIONS.Y))); |
352 | 359 |
this.txtLowerRightX.setText(String.format("%+f", envelope.getMaximum(DIMENSIONS.X))); |
353 | 360 |
this.txtLowerRightY.setText(String.format("%+f", envelope.getMinimum(DIMENSIONS.Y))); |
354 | 361 |
} else { |
355 |
this.txtEnvelope.setText(envelope.getGeometry().convertToWKTQuietly());
|
|
362 |
this.txtEnvelope.setText(envelope.getBox2D().convertToWKTQuietly());
|
|
356 | 363 |
} |
357 | 364 |
} |
358 | 365 |
|
Also available in: Unified diff