Revision 20332 branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/ViewPort.java

View differences:

ViewPort.java
61 61
/**
62 62
 * <p><code>ViewPort</code> class represents the logic needed to transform a rectangular area of a map
63 63
 *  to the available area in screen to display it.</p>
64
 *  
64
 *
65 65
 * <p>Includes an affine transformation, between the rectangular area selected of the external map, in its own
66 66
 *  <i>map coordinates</i>, to the rectangular area available of a view in <i>screen coordinates</i>.</p>
67
 * 
67
 *
68 68
 * <p>Elements:
69 69
 * <ul>
70 70
 * <li><i>extent</i>: the area selected of the map, in <i>map coordinates</i>.
71 71
 * <li><i>imageSize</i>: width and height in pixels (<i>screen coordinates</i>) of the area available
72
 *  in screen to display the area selected of the map. 
72
 *  in screen to display the area selected of the map.
73 73
 * <li><i>adjustedExtent</i>: the area selected must be an scale of <i>imageSize</i>.<br>This implies adapt the
74 74
 *  extent, preserving and centering it, and adding around the needed area to fill all the image size. That
75 75
 *  added area will be extracted from the original map, wherever exists, and filled with the background color
76
 *  wherever not. 
76
 *  wherever not.
77 77
 * <li><i>scale</i>: the scale between the adjusted extent and the image size.
78
 * <li><i>backColor</i>: the default background color in the view, if there is no map. 
78
 * <li><i>backColor</i>: the default background color in the view, if there is no map.
79 79
 * <li><i>trans</i>: the affine transformation.
80 80
 * <li><i>proj</i>: map projection used in this view.
81 81
 * <li><i>distanceUnits</i>: distance measurement units, of data in screen.
......
86 86
 *  current extent.
87 87
 * <li><i>dist3pixel</i>: the distance in <i>world coordinates</i> equivalent to 3 pixels in the view with the
88 88
 *  current extent.
89
 * <li><i>listeners</i>: list with the {@link ViewPortListener ViewPortListener} registered. 
89
 * <li><i>listeners</i>: list with the {@link ViewPortListener ViewPortListener} registered.
90 90
 * </ul>
91 91
 * </p>
92
 *  
92
 *
93 93
 * @author Vicente Caballero Navarro
94 94
 */
95 95
public class ViewPort {
......
122 122
	public static int MILLAS = 4;
123 123

  
124 124
	/**
125
	 * <p>Unit of length equal in the United States to 0.9144 meter.</p> 
125
	 * <p>Unit of length equal in the United States to 0.9144 meter.</p>
126 126
	 */
127 127
	public static int YARDAS = 5;
128 128

  
......
144 144

  
145 145
	/**
146 146
	 * <p>Screen resolution in <i>dots-per-inch</i>. Useful to calculate the geographic scale of the view.</p>
147
	 * 
147
	 *
148 148
	 * @see Toolkit#getScreenResolution()
149 149
	 * @see #getScale()
150 150
	 */
......
152 152

  
153 153
	/**
154 154
	 * <p>Area selected by user using some tool.</p>
155
	 * 
155
	 *
156 156
	 * <p>When the zoom changes (for instance when using the zoom in or zoom out tools,
157 157
	 *  but also zooming to a selected feature or shape) the extent that covers that
158 158
	 *  area is the value returned by this method. It is not the actual area shown
......
166 166
	 * which returns the extent that contains this one but regarding the current
167 167
	 * view's aspect ratio.
168 168
	 * </p>
169
	 * 
169
	 *
170 170
	 * @see #getExtent()
171 171
	 * @see #setExtent(Rectangle2D)
172 172
	 */
......
174 174

  
175 175
	/**
176 176
	 * <p>Location and dimensions of the extent adjusted to the image size.</p>
177
	 * 
177
	 *
178 178
	 * @see #getAdjustedExtent()
179 179
	 */
180 180
	private Rectangle2D adjustedExtent;
181 181

  
182 182
	/**
183 183
	 * <p>History with the last extents of the view.</p>
184
	 * 
184
	 *
185 185
	 * @see #setPreviousExtent()
186 186
	 * @see #getExtents()
187 187
	 */
......
190 190
	/**
191 191
	 * <p>Size in <i>screen coordinates</i> of the rectangle where the image is displayed.</p>
192 192
	 * <p>Used by {@linkplain #calculateAffineTransform()} to calculate:<br>
193
  	 * 
193
  	 *
194 194
	 * <ul>
195 195
	 * <li>The new {@link #scale scale} .
196 196
	 * <li>The new {@link #adjustedExtent adjustableExtent} .
......
199 199
	 * <li>The new real world coordinates equivalent to 3 pixels ({@link #dist3pixel dist3pixel}) .
200 200
	 * </ul>
201 201
	 * </p>
202
	 * 
202
	 *
203 203
	 * @see #getImageSize()
204 204
	 * @see #getImageHeight()
205 205
	 * @see #getImageWidth()
......
210 210
	/**
211 211
	 * <p>the affine transformation between the {@link #extent extent} in <i>map 2D coordinates</i> to
212 212
	 *  the image area in the screen, in <i>screen 2D coordinates</i> (pixels).</p>
213
	 *  
213
	 *
214 214
	 * @see AffineTransform
215
	 * 
215
	 *
216 216
	 * @see #getAffineTransform()
217 217
	 * @see #setAffineTransform(AffineTransform)
218 218
	 * @see #calculateAffineTransform()
......
221 221

  
222 222
	/**
223 223
	 * <p>Measurement unit used for measuring distances and displaying information.</p>
224
	 * 
224
	 *
225 225
	 * @see #getDistanceUnits()
226 226
	 * @see #setDistanceUnits(int)
227 227
	 */
......
229 229

  
230 230
	/**
231 231
	 * <p>Measurement unit used by this view port for the map.</p>
232
	 * 
232
	 *
233 233
	 * @see #getMapUnits()
234 234
	 * @see #setMapUnits(int)
235 235
	 */
......
237 237

  
238 238
	/**
239 239
	 * <p>Array with the {@link ViewPortListener ViewPortListener}s registered to this view port.</p>
240
	 * 
240
	 *
241 241
	 * @see #addViewPortListener(ViewPortListener)
242 242
	 * @see #removeViewPortListener(ViewPortListener)
243 243
	 */
......
249 249
	 * always (0, 0) because the drawing area fits with the full window area. But in
250 250
	 * a <a href="http://www.gvsig.gva.es/">gvSIG</a>'s <i>Layout</i> it's up to the place where
251 251
	 * the <code>FFrameView</code> is located.</p>
252
	 * 
252
	 *
253 253
	 * @see #getOffset()
254 254
	 * @see #setOffset(Point2D)
255 255
	 */
......
262 262

  
263 263
	/**
264 264
	 * <p>Background color of this view.</p>
265
	 * 
265
	 *
266 266
	 * @see #getBackColor()
267 267
	 * @see #setBackColor(Color)
268 268
	 */
......
270 270

  
271 271
	/**
272 272
	 * <p>Information about the map projection used in this view.</p>
273
	 * 
273
	 *
274 274
	 * @see #getProjection()
275 275
	 * @see #setProjection(IProjection)
276 276
	 */
......
278 278

  
279 279
	/**
280 280
	 * <p>Represents the distance in <i>world coordinates</i> equivalent to 1 pixel in the view with the current extent.</p>
281
	 * 
281
	 *
282 282
	 * @see #getDist1pixel()
283 283
	 * @see #setDist1pixel(double)
284 284
	 */
......
286 286

  
287 287
	/**
288 288
	 * <p>Represents the distance in <i>world coordinates</i> equivalent to 3 pixels in the view with the current extent.</p>
289
	 * 
289
	 *
290 290
	 * @see #getDist3pixel()
291 291
	 * @see #setDist3pixel(double)
292 292
	 */
......
299 299

  
300 300
	/**
301 301
	 * <p>Clipping area.</p>
302
	 * 
302
	 *
303 303
	 * @see #setClipRect(Rectangle2D)
304 304
	 */
305 305
	private Rectangle2D cliprect;
306 306

  
307 307
	/**
308 308
	 * <p>Enables or disables the <i>"adjustable extent"</i> mode.</p>
309
	 * 
309
	 *
310 310
	 * <p>
311 311
	 * When calculates the affine transform, if
312 312
	 * <ul>
......
316 316
	 * <li><i>disabled</i>: the new <code>adjustedExtent</code> will be like <code>extent</code>.
317 317
	 * </ul>
318 318
	 * </p>
319
	 * 
319
	 *
320 320
	 * @see #setAdjustable(boolean)
321 321
	 */
322 322
	private boolean adjustableExtent=true;
323
	/**
324
	 * <p>Measurement unit used for measuring areas and displaying information.</p>
325
	 *
326
	 * @see #getDistanceArea()
327
	 * @see #setDistanceArea(int)
328
	 */
329
	private int distanceArea = 0;
323 330

  
324 331
	/**
325 332
	 * <p>Creates a new view port with the information of the projection in <code>proj</code> argument, and
......
342 349

  
343 350
	/**
344 351
	 * <p>Changes the status of the <i>"adjustable extent"</i> option to enabled or disabled.</p>
345
	 * 
352
	 *
346 353
	 * <p>If view port isn't adjustable, won't bear in mind the aspect ratio of the available rectangular area to
347 354
	 *  calculate the affine transform from the original map in real coordinates. (Won't scale the image to adapt
348 355
	 *  it to the available rectangular area).</p>
349
	 *  
356
	 *
350 357
	 * @param boolean the boolean to be set
351 358
	 */
352 359
	public void setAdjustable(boolean adjustable) {
......
355 362

  
356 363
	/**
357 364
	 * <p>Appends the specified {@link ViewPortListener ViewPortListener} listener if weren't.</p>
358
	 * 
365
	 *
359 366
	 * @param arg0 the listener to add
360 367
	 *
361 368
	 * @return <code>true</code> if has been added successfully
362
	 * 
369
	 *
363 370
	 * @see #removeViewPortListener(ViewPortListener)
364 371
	 */
365 372
	public boolean addViewPortListener(ViewPortListener arg0) {
......
370 377

  
371 378
	/**
372 379
 	 * <p>Removes the specified {@link ViewPortListener ViewPortListener} listener, if existed.</p>
373
	 * 
380
	 *
374 381
	 * @param arg0 the listener to remove
375
	 * 
382
	 *
376 383
	 * @return <code>true</code> if the contained the specified listener.
377
	 * 
384
	 *
378 385
	 * @see #addViewPortListener(ViewPortListener)
379 386
	 */
380 387
	public boolean removeViewPortListener(ViewPortListener arg0) {
......
389 396
	 * @param d distance in <i>map coordinates</i>
390 397
	 *
391 398
	 * @return distance equivalent in <i>screen coordinates</i>
392
	 * 
399
	 *
393 400
	 * @see #toMapDistance(int)
394 401
	 * @see AffineTransform#deltaTransform(Point2D, Point2D)S
395 402
	 */
......
414 421
	 * @param d distance in pixels
415 422
	 *
416 423
	 * @return distance equivalent in <i>map coordinates</i>
417
	 * 
424
	 *
418 425
	 * @see #fromMapDistance(double)
419 426
	 * @see AffineTransform
420 427
	 */
......
428 435
	 * <p>Converts and returns the {@link Rectangle2D Rectangle2D}, that is in <i>map
429 436
	 *  coordinates</i> to <i>screen coordinates</i> (pixels) using an <i>inverse transform</i> with
430 437
	 *  the transformation affine information in the {@link #trans #trans} attribute.</p>
431
	 * 
438
	 *
432 439
	 * @param r the 2D rectangle in <i>map coordinates</i>
433 440
	 * @return 2D rectangle equivalent in <i>screen coordinates</i> (pixels)
434
	 * 
441
	 *
435 442
	 * @see #toMapRectangle(Rectangle2D)
436 443
	 * @see #fromMapDistance(double)
437 444
	 * @see #fromMapPoint(Point2D)
......
442 449
		Point2D p1=fromMapPoint((int)r.getX(),(int)r.getY());
443 450
		return new Rectangle2D.Double(p1.getX(),p1.getY(),w,h);
444 451
	}
445
	
452

  
446 453
	/**
447 454
	 * <p>Converts and returns the {@link Rectangle2D Rectangle2D}, that is in <i>screen
448 455
	 *  coordinates</i> (pixels) to <i>map coordinates</i> using {@linkplain #toMapDistance(int)},
449 456
	 *  and {@linkplain #toMapPoint(int, int)}.</p>
450
	 * 
457
	 *
451 458
	 * @param r the 2D rectangle in <i>screen coordinates</i> (pixels)
452 459
	 * @return 2D rectangle equivalent in <i>map coordinates</i>
453
	 * 
460
	 *
454 461
	 * @see #fromMapRectangle(Rectangle2D)
455 462
	 * @see #toMapDistance(int)
456 463
	 * @see #toMapPoint(int, int)
......
461 468
		Point2D p1=toMapPoint((int)r.getX(),(int)r.getY());
462 469
		return new Rectangle2D.Double(p1.getX(),p1.getY(),w,h);
463 470
	}
464
	
471

  
465 472
	/**
466 473
	 * <p>Converts and returns the 2D point <code>(x,y)</code>, that is in <i>map
467
	 *  coordinates</i> to <i>screen coordinates</i> (pixels) using 
474
	 *  coordinates</i> to <i>screen coordinates</i> (pixels) using
468 475
	 *  the affine transformation in the {@link #trans #trans} attribute.</p>
469 476
	 *
470 477
	 * @param x the <code>x</code> <i>map coordinate</i> of a 2D point
471 478
	 * @param y the <code>y</code> <i>map coordinate</i> of a 2D point
472 479
	 *
473 480
	 * @return 2D point equivalent in <i>screen coordinates</i> (pixels)
474
	 * 
481
	 *
475 482
	 * @see #fromMapPoint(Point2D)
476 483
	 * @see AffineTransform#transform(Point2D, Point2D)
477 484
	 */
......
496 503
	 * @param point the 2D point in <i>map coordinates</i>
497 504
	 *
498 505
	 * @return 2D point equivalent in <i>screen coordinates</i> (pixels)
499
	 * 
506
	 *
500 507
	 * @see #toMapPoint(Point2D)
501 508
	 * @see #fromMapPoint(double, double)
502 509
	 */
......
513 520
	 * @param y the <code>y</code> <i>screen coordinate</i> of a 2D point
514 521
	 *
515 522
	 * @return 2D point equivalent in <i>map coordinates</i>
516
	 * 
523
	 *
517 524
	 * @see #toMapPoint(Point2D)
518 525
	 * @see #fromMapPoint(double, double)
519 526
	 */
......
527 534
	 * <p>Converts and returns the 2D point argument, that is in <i>screen coordinates</i>
528 535
	 *  (pixels) to <i>map coordinates</i> using the
529 536
	 *  inverse affine transformation of the {@link #trans #trans} attribute.</p>
530
	 * 
537
	 *
531 538
	 * @param pScreen the 2D point in <i>screen coordinates</i> (pixels)
532 539
	 *
533 540
	 * @return 2D point equivalent in <i>map coordinates</i>
534
	 * 
541
	 *
535 542
	 * @see #toMapPoint(int, int)
536 543
	 * @see AffineTransform#createInverse()
537 544
	 * @see AffineTransform#transform(Point2D, Point2D)
......
539 546
	public Point2D toMapPoint(Point2D pScreen) {
540 547
		Point2D.Double pWorld = new Point2D.Double();
541 548
		AffineTransform at;
542
	
549

  
543 550
		try {
544 551
			at = trans.createInverse();
545 552
			at.transform(pScreen, pWorld);
546 553
		} catch (NoninvertibleTransformException e) {
547 554
			throw new RuntimeException(e);
548 555
		}
549
	
556

  
550 557
		return pWorld;
551 558
	}
552 559

  
......
559 566
	 * @param pt2 another 2D point in <i>map coordinates</i>
560 567
	 *
561 568
	 * @return the distance in meters between the two points 2D
562
	 * 
569
	 *
563 570
	 * @see GeoCalc#distanceVincenty(Point2D, Point2D)
564 571
	 */
565 572
	public double distanceWorld(Point2D pt1, Point2D pt2) {
......
577 584
	/**
578 585
	 * <p>Sets as extent and adjusted extent of this view port, the previous. Recalculating
579 586
	 *  its parameters.</p>
580
	 * 
587
	 *
581 588
	 * @see #getExtents()
582 589
	 * @see #calculateAffineTransform()
583 590
	 */
......
593 600

  
594 601
	/**
595 602
	 * <p>Gets the area selected by user using some tool.</p>
596
	 * 
603
	 *
597 604
	 * <p>When the zoom changes (for instance using the <i>zoom in</i> or <i>zoom out</i> tools,
598 605
	 *  but also zooming to a selected feature or shape) the extent that covers that
599 606
	 *  area is the value returned by this method. It is not the actual area shown
600 607
	 *  because it doesn't care about the aspect ratio of the image size of the view. However, any
601 608
	 *  part of the real world contained in this extent is shown in the view.</p>
602
	 * 
609
	 *
603 610
	 * <p>If you are looking for the complete extent currently shown, you must use the
604 611
	 *  {@linkplain #getAdjustedExtent()} method.</p>
605
	 * 
612
	 *
606 613
	 * @return the current extent
607
	 * 
614
	 *
608 615
	 * @see #setExtent(Rectangle2D)
609 616
	 * @see #getAdjustedExtent()
610 617
	 * @see #setPreviousExtent()
......
627 634
	 * </p>
628 635
	 *
629 636
	 * @param r the new extent
630
	 * 
637
	 *
631 638
	 * @see #getExtent()
632 639
	 * @see #getExtents()
633 640
	 * @see #calculateAffineTransform()
......
662 669
	 * <li>Notifies to all {@link ViewPortListener ViewPortListener} registered that the extent has changed.
663 670
	 * </ul>
664 671
	 * </p>
665
	 * 
672
	 *
666 673
	 * @see #setExtent(Rectangle2D)
667 674
	 * @see #calculateAffineTransform()
668 675
	 */
......
681 688
	 *  is the extent in <i>screen coordinates</i> from the image in <i>map coordinates</i>.</p>
682 689
	 *
683 690
	 * @return the scale <i>extent / image size</i> projected by this view port
684
	 * 
691
	 *
685 692
	 * @deprecated since 07/09/07, use {@linkplain MapContext#getScaleView()}
686 693
	 */
687 694
	public double getScale() {
......
691 698

  
692 699
	/**
693 700
	 * <p>Recalculates the current <code>{@linkplain #extent}</code> using an scale. It's necessary execute {@linkplain #refreshExtent()} after.</p>
694
	 * 
701
	 *
695 702
	 * @param s the scale to set
696
	 * 
697
	 * @deprecated since 07/09/07, use {@linkplain MapContext#setScaleView(long)} 
703
	 *
704
	 * @deprecated since 07/09/07, use {@linkplain MapContext#setScaleView(long)}
698 705
	 */
699 706
	public void setScale(long s){
700 707
		double x=extent.getX();
......
713 720
        double w1=extent.getWidth()*difw;
714 721
        double h1=extent.getHeight()*difw;
715 722
		extent.setRect(-x1,-y1,w1,h1);
716
	}	
723
	}
717 724

  
718 725
	/**
719 726
	 * <p>Affine transformation between <i>map 2D coordinates</i> to <i>screen 2D coordinates</i> (pixels),
720 727
	 * preserving the "straightness" and "parallelism" of the lines.</p>
721 728
	 *
722 729
	 * @return the affine transformation
723
	 * 
730
	 *
724 731
	 * @see #setAffineTransform(AffineTransform)
725 732
	 * @see #calculateAffineTransform()
726 733
	 */
......
732 739
	 * <p>Returns the size of the image projected.</p>
733 740
	 *
734 741
	 * @return the image size
735
	 * 
742
	 *
736 743
	 * @see #setImageSize(Dimension)
737 744
	 * @see #getImageHeight()
738 745
	 * @see #getImageWidth()
......
745 752
	 * <p>Sets the size of the image projected, recalculating the parameters of this view port.</p>
746 753
	 *
747 754
	 * @param imageSize the image size
748
	 * 
755
	 *
749 756
	 * @see #getImageSize()
750 757
	 * @see #calculateAffineTransform()
751 758
	 */
......
759 766
	 *  has changed.</p>
760 767
	 *
761 768
	 * @param newRect the new adjusted extend
762
	 * 
769
	 *
763 770
	 * @see #refreshExtent()
764 771
	 * @see #setExtent(Rectangle2D)
765 772
	 * @see #setPreviousExtent()
......
780 787
	 *  has changed.</p>
781 788
	 *
782 789
	 * @param c the new background color
783
	 * 
790
	 *
784 791
	 * @see #setBackColor(Color)
785 792
	 * @see ColorEvent
786 793
	 * @see ViewPortListener
......
799 806
	 *  has changed.</p>
800 807
	 *
801 808
	 * @param projection the new projection
802
	 * 
809
	 *
803 810
	 * @see #setProjection(IProjection)
804 811
	 * @see ProjectionEvent
805 812
	 * @see ViewPortListener
......
816 823
	/**
817 824
	 * <p>Calculates the affine transformation between the {@link #extent extent} in <i>map 2D coordinates</i> to
818 825
	 *  the image area in the screen, in <i>screen 2D coordinates</i> (pixels).</p>
819
	 * 
826
	 *
820 827
	 * <p>This process recalculates some parameters of this view port:<br>
821
	 * 
828
	 *
822 829
	 * <ul>
823 830
	 * <li>The new {@link #scale scale} .
824 831
	 * <li>The new {@link #adjustedExtent adjustedExtent} .
......
827 834
	 * <li>The new real world coordinates equivalent to 3 pixels ({@link #dist3pixel dist3pixel}) .
828 835
	 * </ul>
829 836
	 * </p>
830
	 * 
837
	 *
831 838
	 * @see #getAffineTransform()
832 839
	 * @see #setAffineTransform(AffineTransform)
833 840
	 * @see #refreshExtent()
......
924 931
	 * <p>The offset is the position where start drawing the map.</p>
925 932
	 *
926 933
	 * @param p 2D point that represents the offset in pixels
927
	 * 
934
	 *
928 935
	 * @see #getOffset()
929 936
	 */
930 937
	public void setOffset(Point2D p) {
......
936 943
	 * <p>The offset is the position where start drawing the map.</p>
937 944
	 *
938 945
	 * @return 2D point that represents the offset in pixels
939
	 * 
946
	 *
940 947
	 * @see #setOffset(Point2D)
941 948
	 */
942 949
	public Point2D getOffset() {
......
947 954
	 * <p>Sets the background color.</p>
948 955
	 *
949 956
	 * @param c the new background color
950
	 * 
957
	 *
951 958
	 * @see #getBackColor()
952 959
	 */
953 960
	public void setBackColor(Color c) {
......
959 966
	 * <p>Gets the background color.</p>
960 967
	 *
961 968
	 * @return the background color of the view
962
	 * 
969
	 *
963 970
	 * @see #setBackColor(Color)
964 971
	 */
965 972
	public Color getBackColor() {
......
968 975

  
969 976
	/**
970 977
	 * <p>Returns the extent currently covered by the view adjusted (scaled) to the image size aspect.</p>
971
	 * 
978
	 *
972 979
	 * @return extent of the view adjusted to the image size aspect
973
	 * 
980
	 *
974 981
	 * @see #setAdjustable(boolean)
975 982
	 */
976 983
	public Rectangle2D getAdjustedExtent() {
......
984 991
	 * <p>Returns the measurement unit of this view port used for measuring distances and displaying information.</p>
985 992
	 *
986 993
	 * @return the measurement unit of this view used for measuring distances and displaying information
987
	 * 
994
	 *
988 995
	 * @see #setDistanceUnits(int)
989 996
	 */
990 997
	public int getDistanceUnits() {
991 998
		return distanceUnits;
992 999
	}
1000
	/**
1001
	 * <p>Returns the measurement unit of this view port used for measuring areas and displaying information.</p>
1002
	 *
1003
	 * @return the measurement unit of this view used for measuring areas and displaying information
1004
	 *
1005
	 * @see #setDistanceUnits(int)
1006
	 */
1007
	public int getDistanceArea() {
1008
		return distanceArea;
1009
	}
993 1010

  
1011

  
994 1012
	/**
995 1013
	 * <p>Sets the measurement unit of this view port used for measuring distances and displaying information.</p>
996 1014
	 *
997 1015
	 * @param distanceUnits the measurement unit of this view used for measuring distances and displaying information
998
	 * 
1016
	 *
999 1017
	 * @see #getDistanceUnits()
1000 1018
	 */
1001 1019
	public void setDistanceUnits(int distanceUnits) {
1002 1020
		this.distanceUnits = distanceUnits;
1003 1021
	}
1022
	/**
1023
	 * <p>Sets the measurement unit of this view port used for measuring areas and displaying information.</p>
1024
	 *
1025
	 * @param distanceUnits the measurement unit of this view used for measuring areas and displaying information
1026
	 *
1027
	 * @see #getDistanceUnits()
1028
	 */
1029
	public void setDistanceArea(int distanceArea) {
1030
		this.distanceArea = distanceArea;
1031
	}
1004 1032

  
1005 1033
	/**
1006 1034
	 * <p>Gets the measurement unit used by this view port for the map.</p>
1007 1035
	 *
1008 1036
	 * @return Returns the current map measure unit
1009
	 * 
1037
	 *
1010 1038
	 * @see #setMapUnits(int)
1011 1039
	 */
1012 1040
	public int getMapUnits() {
......
1017 1045
	 * <p>Sets the measurement unit used by this view port for the map.</p>
1018 1046
	 *
1019 1047
	 * @param mapUnits the new map measure unit
1020
	 * 
1048
	 *
1021 1049
	 * @see #getMapUnits()
1022 1050
	 */
1023 1051
	public void setMapUnits(int mapUnits) {
......
1027 1055
	/**
1028 1056
	 * <p>Gets the width in <i>screen coordinates</i> of the rectangle where the image is displayed.</p>
1029 1057
	 * <p>Used by {@linkplain #calculateAffineTransform()} to calculate:<br>
1030
  	 * 
1058
  	 *
1031 1059
	 * <ul>
1032 1060
	 * <li>The new {@link #scale scale} .
1033 1061
	 * <li>The new {@link #adjustedExtent adjustableExtent} .
......
1036 1064
	 * <li>The new real world coordinates equivalent to 3 pixels ({@link #dist3pixel dist3pixel}) .
1037 1065
	 * </ul>
1038 1066
	 * </p>
1039
	 * 
1067
	 *
1040 1068
	 * @see #getImageHeight()
1041 1069
	 * @see #getImageSize()
1042 1070
	 * @see #setImageSize(Dimension)
......
1048 1076
	/**
1049 1077
	 * <p>Gets the height in <i>screen coordinates</i> of the rectangle where the image is displayed.</p>
1050 1078
	 * <p>Used by {@linkplain #calculateAffineTransform()} to calculate:<br>
1051
  	 * 
1079
  	 *
1052 1080
	 * <ul>
1053 1081
	 * <li>The new {@link #scale scale} .
1054 1082
	 * <li>The new {@link #adjustedExtent adjustableExtent} .
......
1057 1085
	 * <li>The new real world coordinates equivalent to 3 pixels ({@link #dist3pixel dist3pixel}) .
1058 1086
	 * </ul>
1059 1087
	 * </p>
1060
	 * 
1088
	 *
1061 1089
	 * @see #getImageWidth()
1062 1090
	 * @see #getImageSize()
1063 1091
	 * @see #setImageSize(Dimension)
......
1067 1095
	}
1068 1096

  
1069 1097
	/**
1070
	 * <p>Gets the distance in <i>world coordinates</i> equivalent to 1 pixel in the view with the current extent.</p> 
1098
	 * <p>Gets the distance in <i>world coordinates</i> equivalent to 1 pixel in the view with the current extent.</p>
1071 1099
	 *
1072 1100
	 * @return the distance
1073
	 * 
1101
	 *
1074 1102
	 * @see #setDist1pixel(double)
1075 1103
	 */
1076 1104
	public double getDist1pixel() {
......
1078 1106
	}
1079 1107

  
1080 1108
	/**
1081
	 * <p>Sets the distance in <i>world coordinates</i> equivalent to 1 pixel in the view with the current extent.</p> 
1109
	 * <p>Sets the distance in <i>world coordinates</i> equivalent to 1 pixel in the view with the current extent.</p>
1082 1110
	 *
1083 1111
	 * @param dist1pixel the distance
1084
	 * 
1112
	 *
1085 1113
	 * @see #getDist1pixel()
1086 1114
	 */
1087 1115
	public void setDist1pixel(double dist1pixel) {
......
1089 1117
	}
1090 1118

  
1091 1119
	/**
1092
	 * <p>Gets the distance in <i>world coordinates</i> equivalent to 3 pixels in the view with the current extent.</p> 
1120
	 * <p>Gets the distance in <i>world coordinates</i> equivalent to 3 pixels in the view with the current extent.</p>
1093 1121
	 *
1094 1122
	 * @return the distance
1095
	 * 
1123
	 *
1096 1124
	 * @see #setDist3pixel(double)
1097 1125
	 */
1098 1126
	public double getDist3pixel() {
......
1100 1128
	}
1101 1129

  
1102 1130
	/**
1103
	 * <p>Sets the distance in <i>world coordinates</i> equivalent to 3 pixels in the view with the current extent.</p> 
1131
	 * <p>Sets the distance in <i>world coordinates</i> equivalent to 3 pixels in the view with the current extent.</p>
1104 1132
	 *
1105 1133
	 * @param dist3pixel the distance
1106
	 * 
1134
	 *
1107 1135
	 * @see #getDist3pixel()
1108 1136
	 */
1109 1137
	public void setDist3pixel(double dist3pixel) {
......
1114 1142
	 * <p>Returns the last previous extents of this view port.</p>
1115 1143
	 *
1116 1144
	 * @return the last previous extents of this view port
1117
	 * 
1145
	 *
1118 1146
	 * @see #setPreviousExtent()
1119 1147
	 */
1120 1148
	public ExtentHistory getExtents() {
......
1125 1153
	 * <p>Gets the projection used in this view port.</p>
1126 1154
	 *
1127 1155
	 * @return projection used in this view port
1128
	 * 
1156
	 *
1129 1157
	 * @see #setProjection(IProjection)
1130 1158
	 */
1131 1159
	public IProjection getProjection() {
......
1136 1164
	 * <p>Sets the projection to this view port.</p>
1137 1165
	 *
1138 1166
	 * @param proj the new projection
1139
	 * 
1167
	 *
1140 1168
	 * @see #getProjection()
1141 1169
	 */
1142 1170
	public void setProjection(IProjection proj) {
......
1158 1186
	 * <p><b><i>This method could be problematic!</i></b></p>
1159 1187
	 *
1160 1188
	 * @param at the affine transform to set
1161
	 * 
1189
	 *
1162 1190
	 * @see #getAffineTransform()
1163 1191
	 * @see #calculateAffineTransform()
1164 1192
	 */
......
1175 1203
	 *  <li><i>className</i>: name of this class.
1176 1204
	 *  <li>If defined, the adjusted extent:
1177 1205
	 *   <ul>
1178
	 *   <li><i>adjustedExtentX</i>: X coordinate of the adjusted extent. 
1206
	 *   <li><i>adjustedExtentX</i>: X coordinate of the adjusted extent.
1179 1207
	 *   <li><i>adjustedExtentY</i>: Y coordinate of the adjusted extent.
1180 1208
	 *   <li><i>adjustedExtentW</i>: width of the adjusted extent.
1181 1209
	 *   <li><i>adjustedExtentH</i>: height of the adjusted extent.
1182
	 *   </ul> 
1210
	 *   </ul>
1183 1211
	 *  <li>If defined, the background color:
1184 1212
	 *   <ul>
1185 1213
	 *   <li><i>backColor</i>: background color.
1186
	 *   </ul> 
1214
	 *   </ul>
1187 1215
	 *  <li>If defined, the clip:
1188 1216
	 *   <ul>
1189
	 *   <li><i>clipX</i>: X coordinate of the clip. 
1217
	 *   <li><i>clipX</i>: X coordinate of the clip.
1190 1218
	 *   <li><i>clipY</i>: Y coordinate of clip.
1191 1219
	 *   <li><i>clipW</i>: width of the clip.
1192 1220
	 *   <li><i>clipH</i>: height of the clip.
1193
	 *   </ul> 
1221
	 *   </ul>
1194 1222
	 *  <li><i>dist1pixel</i>: the distance in world coordinates equivalent to 1 pixel in the view.
1195 1223
	 *  <li><i>dist3pixel</i>: the distance in world coordinates equivalent to 3 pixels in the view.
1196 1224
	 *  <li><i>distanceUnits</i>: the distance measurement unit.
1197 1225
	 *  <li>If defined, the extent:
1198 1226
	 *   <ul>
1199
	 *   <li><i>extentX</i>: X coordinate of the extent. 
1227
	 *   <li><i>extentX</i>: X coordinate of the extent.
1200 1228
	 *   <li><i>extentY</i>: Y coordinate of the extent.
1201 1229
	 *   <li><i>extentW</i>: width of the extent.
1202 1230
	 *   <li><i>extentH</i>: height of the extent.
1203
	 *   </ul> 
1204
	 *  <li><i>mapUnits</i>: the map measurement unit. 
1231
	 *   </ul>
1232
	 *  <li><i>mapUnits</i>: the map measurement unit.
1205 1233
	 *  <li><i>offsetX</i>: X coordinate of the offset.
1206
	 *  <li><i>offsetY</i>: Y coordinate of the offset. 
1234
	 *  <li><i>offsetY</i>: Y coordinate of the offset.
1207 1235
	 *  <li>If defined, the projection:
1208 1236
	 *   <ul>
1209 1237
	 *   <li><i>proj</i>: the projection.
1210
	 *   </ul> 
1238
	 *   </ul>
1211 1239
	 *  <li><i>scale</i>: ratio between the size of <code>imageSize</code> and <code>extent</code>.
1212 1240
	 *  </ul>
1213 1241
	 * <li>Child branches:
......
1215 1243
	 *  <li>XML entity of the internal {@link ExtentHistory ExtentHistory} .
1216 1244
	 *  </ul>
1217 1245
	 * </ul>
1218
	 * 
1246
	 *
1219 1247
	 * @return the XML entity
1220
	 * 
1248
	 *
1221 1249
	 * @see #createFromXML(XMLEntity)
1222 1250
	 */
1223 1251
	public XMLEntity getXMLEntity() {
......
1272 1300
	 * @param xml an XML entity
1273 1301
	 *
1274 1302
	 * @return the new <code>ViewPort</code>
1275
	 * 
1303
	 *
1276 1304
	 * @see #getXMLEntity()
1277 1305
	 * @see #createFromXML(XMLEntity)
1278 1306
	 */
......
1336 1364
	 * @param xml an XML entity
1337 1365
	 *
1338 1366
	 * @return the new <code>ViewPort</code>
1339
	 * 
1367
	 *
1340 1368
	 * @see #getXMLEntity()
1341 1369
	 * @see #createFromXML03(XMLEntity)
1342 1370
	 */
......
1368 1396
		vp.setDist1pixel(xml.getDoubleProperty("dist1pixel"));
1369 1397
		vp.setDist3pixel(xml.getDoubleProperty("dist3pixel"));
1370 1398
		vp.setDistanceUnits(xml.getIntProperty("distanceUnits"));
1399
		if (xml.contains("distanceArea")){
1400
			vp.setDistanceArea(xml.getIntProperty("distanceArea"));
1401
		}else{
1402
			vp.setDistanceArea(xml.getIntProperty("distanceUnits"));
1403
		}
1371 1404
		vp.extents = ExtentHistory.createFromXML(xml.getChild(0));
1372 1405

  
1373 1406
		if (xml.contains("extentX")) {
......
1401 1434
	 * <p>Isn't a <i>deepclone</i> to avoid unnecessary memory consumption.</p>
1402 1435
	 *
1403 1436
	 * @return the new view port
1404
	 * 
1437
	 *
1405 1438
	 * @see #createFromXML(XMLEntity)
1406 1439
	 */
1407 1440
	public ViewPort cloneViewPort() {
......
1411 1444
	/**
1412 1445
	 * <p>Returns a <code>String</code> representation of the main values of this view port: <code>{@linkplain #extent}</code>,
1413 1446
	 *  <code>{@linkplain #adjustedExtent}</code>, <code>{@linkplain #imageSize}</code>, <code>{@linkplain #scale}</code>, and <code>{@linkplain #trans}</code>.</p>
1414
	 * 
1447
	 *
1415 1448
	 * @return a <code>string</code> representation of the main values of this view port
1416 1449
	 */
1417 1450
	public String toString() {
1418
		
1451

  
1419 1452
		String str;
1420 1453
		str = "Datos del viewPort:\nExtent=" + extent + "\nadjustedExtent=" +
1421 1454
			adjustedExtent + "\nimageSize=" + imageSize + "\nescale=" + scale +
......
1426 1459

  
1427 1460
	/**
1428 1461
	 * <p>Sets the position and size of the clipping rectangle.</p>
1429
	 * 
1462
	 *
1430 1463
	 * @param rectView the clipping rectangle to set
1431 1464
	 */
1432 1465
	public void setClipRect(Rectangle2D rectView) {

Also available in: Unified diff