Revision 20098 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/ViewPort.java
ViewPort.java | ||
---|---|---|
59 | 59 |
|
60 | 60 |
|
61 | 61 |
/** |
62 |
* <p>The <code>ViewPort</code> class represents the information needed to transform an area of a map that user
|
|
63 |
* will use to work to the available area of a gvSIG's view in screen.</p>
|
|
64 |
* |
|
62 |
* <p><code>ViewPort</code> class represents the logic needed to transform a rectangular area of a map
|
|
63 |
* to the available area in screen to display it.</p>
|
|
64 |
*
|
|
65 | 65 |
* <p>Includes an affine transformation, between the rectangular area selected of the external map, in its own |
66 |
* <i>map coordinates</i>, to the rectangular area of a view in <i>screen coordinates</i>.</p> |
|
67 |
* |
|
68 |
* <p>Then we have:
|
|
66 |
* <i>map coordinates</i>, to the rectangular area available of a view in <i>screen coordinates</i>.</p>
|
|
67 |
*
|
|
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 |
* <li><i>distanceUnits</i>: distance measurement unit, for data in screen.
|
|
82 |
* <li><i>mapUnits</i>: measurement unit, for data in map.
|
|
81 |
* <li><i>distanceUnits</i>: distance measurement units, of data in screen.
|
|
82 |
* <li><i>mapUnits</i>: measurement units, of data in map.
|
|
83 | 83 |
* <li><i>extents</i>: an {@link ExtentHistory ExtentHistory} with the last previous extents. |
84 |
* <li><i>offset</i>: position in pixels of the view, where start drawing the map.
|
|
84 |
* <li><i>offset</i>: position in pixels of the available rectangular area, where start drawing the map.
|
|
85 | 85 |
* <li><i>dist1pixel</i>: the distance in <i>world coordinates</i> equivalent to 1 pixel in the view with the |
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 { |
... | ... | |
97 | 97 |
* <p>Metric unit or length equal to 1000 meters.</p> |
98 | 98 |
*/ |
99 | 99 |
public static int KILOMETROS = 0; |
100 |
|
|
100 | 101 |
/** |
101 | 102 |
* <p>The base unit of length in the International System of Units that is equal to the distance |
102 | 103 |
* traveled by light in a vacuum in {frac;1;299,792,458} second or to about 39.37 inches.</p> |
103 | 104 |
*/ |
104 | 105 |
public static int METROS = 1; |
106 |
|
|
105 | 107 |
/** |
106 | 108 |
* <p>Metric unit or length equal to 0'01 meters.</p> |
107 | 109 |
*/ |
108 | 110 |
public static int CENTIMETRO = 2; |
111 |
|
|
109 | 112 |
/** |
110 | 113 |
* <p>Metric unit or length equal to 0'001 meters.</p> |
111 | 114 |
*/ |
112 | 115 |
public static int MILIMETRO = 3; |
116 |
|
|
113 | 117 |
/** |
114 |
* <p>The international statute mile is by international agreement. It is defined to be precisely
|
|
118 |
* <p>The international statute mile by international agreement. It is defined to be precisely |
|
115 | 119 |
* 1,760 international yards (by definition, 0.9144 m each) and is therefore exactly 1,609.344 |
116 | 120 |
* metres (1.609344 km).</p> |
117 | 121 |
*/ |
118 | 122 |
public static int MILLAS = 4; |
123 |
|
|
119 | 124 |
/** |
120 |
* <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>
|
|
121 | 126 |
*/ |
122 | 127 |
public static int YARDAS = 5; |
128 |
|
|
123 | 129 |
/** |
124 | 130 |
* <p>Any of various units of length based on the length of the human foot; especially : |
125 | 131 |
* a unit equal to 1/3 yard and comprising 12 inches.</p> |
126 | 132 |
*/ |
127 | 133 |
public static int PIES = 6; |
134 |
|
|
128 | 135 |
/** |
129 | 136 |
* <p>Unit of length equal to 1/36 yard.</p> |
130 | 137 |
*/ |
131 | 138 |
public static int PULGADAS = 7; |
139 |
|
|
132 | 140 |
/** |
133 | 141 |
* <p>Grades according the current projection.</p> |
134 | 142 |
*/ |
... | ... | |
136 | 144 |
|
137 | 145 |
/** |
138 | 146 |
* <p>Screen resolution in <i>dots-per-inch</i>. Useful to calculate the geographic scale of the view.</p> |
139 |
* |
|
147 |
*
|
|
140 | 148 |
* @see Toolkit#getScreenResolution() |
141 | 149 |
* @see #getScale() |
142 | 150 |
*/ |
143 | 151 |
private static int dpi = java.awt.Toolkit.getDefaultToolkit() |
144 | 152 |
.getScreenResolution(); |
153 |
|
|
145 | 154 |
/** |
146 | 155 |
* <p>Area selected by user using some tool.</p> |
147 |
* |
|
156 |
*
|
|
148 | 157 |
* <p>When the zoom changes (for instance when using the zoom in or zoom out tools, |
149 | 158 |
* but also zooming to a selected feature or shape) the extent that covers that |
150 | 159 |
* area is the value returned by this method. It is not the actual area shown |
... | ... | |
158 | 167 |
* which returns the extent that contains this one but regarding the current |
159 | 168 |
* view's aspect ratio. |
160 | 169 |
* </p> |
161 |
* |
|
170 |
*
|
|
162 | 171 |
* @see #getExtent() |
163 | 172 |
* @see #setExtent(Rectangle2D) |
164 | 173 |
*/ |
165 | 174 |
protected Rectangle2D extent; |
175 |
|
|
166 | 176 |
/** |
167 | 177 |
* <p>Location and dimensions of the extent adjusted to the image size.</p> |
168 |
* |
|
178 |
*
|
|
169 | 179 |
* @see #getAdjustedExtent() |
170 | 180 |
*/ |
171 | 181 |
protected Rectangle2D adjustedExtent; |
182 |
|
|
172 | 183 |
/** |
173 | 184 |
* <p>History with the last extents of the view.</p> |
174 |
* |
|
185 |
*
|
|
175 | 186 |
* @see #setPreviousExtent() |
176 | 187 |
* @see #getExtents() |
177 | 188 |
*/ |
... | ... | |
180 | 191 |
/** |
181 | 192 |
* <p>Size in <i>screen coordinates</i> of the rectangle where the image is displayed.</p> |
182 | 193 |
* <p>Used by {@linkplain #calculateAffineTransform()} to calculate:<br> |
183 |
* |
|
194 |
*
|
|
184 | 195 |
* <ul> |
185 | 196 |
* <li>The new {@link #scale scale} . |
186 | 197 |
* <li>The new {@link #adjustedExtent adjustableExtent} . |
... | ... | |
189 | 200 |
* <li>The new real world coordinates equivalent to 3 pixels ({@link #dist3pixel dist3pixel}) . |
190 | 201 |
* </ul> |
191 | 202 |
* </p> |
192 |
* |
|
203 |
*
|
|
193 | 204 |
* @see #getImageSize() |
194 | 205 |
* @see #getImageHeight() |
195 | 206 |
* @see #getImageWidth() |
196 | 207 |
* @see #setImageSize(Dimension) |
197 | 208 |
*/ |
198 | 209 |
private Dimension imageSize; |
210 |
|
|
199 | 211 |
/** |
200 | 212 |
* <p>the affine transformation between the {@link #extent extent} in <i>map 2D coordinates</i> to |
201 | 213 |
* the image area in the screen, in <i>screen 2D coordinates</i> (pixels).</p> |
202 |
* |
|
214 |
*
|
|
203 | 215 |
* @see AffineTransform |
204 |
* |
|
216 |
*
|
|
205 | 217 |
* @see #getAffineTransform() |
206 | 218 |
* @see #setAffineTransform(AffineTransform) |
207 | 219 |
* @see #calculateAffineTransform() |
208 | 220 |
*/ |
209 | 221 |
private AffineTransform trans = new AffineTransform(); |
222 |
|
|
210 | 223 |
/** |
211 | 224 |
* <p>Measurement unit used for measuring distances and displaying information.</p> |
212 |
* |
|
225 |
*
|
|
213 | 226 |
* @see #getDistanceUnits() |
214 | 227 |
* @see #setDistanceUnits(int) |
215 | 228 |
*/ |
216 | 229 |
private int distanceUnits = METROS; |
230 |
|
|
217 | 231 |
/** |
218 | 232 |
* <p>Measurement unit used by this view port for the map.</p> |
219 |
* |
|
233 |
*
|
|
220 | 234 |
* @see #getMapUnits() |
221 | 235 |
* @see #setMapUnits(int) |
222 | 236 |
*/ |
223 | 237 |
private int mapUnits = METROS; |
238 |
|
|
224 | 239 |
/** |
225 | 240 |
* <p>Array with the {@link ViewPortListener ViewPortListener}s registered to this view port.</p> |
226 |
* |
|
241 |
*
|
|
227 | 242 |
* @see #addViewPortListener(ViewPortListener) |
228 | 243 |
* @see #removeViewPortListener(ViewPortListener) |
229 | 244 |
*/ |
230 | 245 |
private ArrayList listeners = new ArrayList(); |
246 |
|
|
231 | 247 |
/** |
232 | 248 |
* <p>The offset is the position where start drawing the map.</p> |
233 | 249 |
* <p>The offset of a <a href="http://www.gvsig.gva.es/">gvSIG</a>'s <i>View</i> is |
234 | 250 |
* always (0, 0) because the drawing area fits with the full window area. But in |
235 | 251 |
* a <a href="http://www.gvsig.gva.es/">gvSIG</a>'s <i>Layout</i> it's up to the place where |
236 | 252 |
* the <code>FFrameView</code> is located.</p> |
237 |
* |
|
253 |
*
|
|
238 | 254 |
* @see #getOffset() |
239 | 255 |
* @see #setOffset(Point2D) |
240 | 256 |
*/ |
... | ... | |
247 | 263 |
|
248 | 264 |
/** |
249 | 265 |
* <p>Background color of this view.</p> |
250 |
* |
|
266 |
*
|
|
251 | 267 |
* @see #getBackColor() |
252 | 268 |
* @see #setBackColor(Color) |
253 | 269 |
*/ |
... | ... | |
255 | 271 |
|
256 | 272 |
/** |
257 | 273 |
* <p>Information about the map projection used in this view.</p> |
258 |
* |
|
274 |
*
|
|
259 | 275 |
* @see #getProjection() |
260 | 276 |
* @see #setProjection(IProjection) |
261 | 277 |
*/ |
... | ... | |
263 | 279 |
|
264 | 280 |
/** |
265 | 281 |
* <p>Represents the distance in <i>world coordinates</i> equivalent to 1 pixel in the view with the current extent.</p> |
266 |
* |
|
282 |
*
|
|
267 | 283 |
* @see #getDist1pixel() |
268 | 284 |
* @see #setDist1pixel(double) |
269 | 285 |
*/ |
... | ... | |
271 | 287 |
|
272 | 288 |
/** |
273 | 289 |
* <p>Represents the distance in <i>world coordinates</i> equivalent to 3 pixels in the view with the current extent.</p> |
274 |
* |
|
290 |
*
|
|
275 | 291 |
* @see #getDist3pixel() |
276 | 292 |
* @see #setDist3pixel(double) |
277 | 293 |
*/ |
... | ... | |
284 | 300 |
|
285 | 301 |
/** |
286 | 302 |
* <p>Clipping area.</p> |
287 |
* |
|
303 |
*
|
|
288 | 304 |
* @see #setClipRect(Rectangle2D) |
289 | 305 |
*/ |
290 | 306 |
private Rectangle2D cliprect; |
291 | 307 |
|
292 | 308 |
/** |
293 | 309 |
* <p>Enables or disables the <i>"adjustable extent"</i> mode.</p> |
294 |
* |
|
310 |
*
|
|
295 | 311 |
* <p> |
296 | 312 |
* When calculates the affine transform, if |
297 | 313 |
* <ul> |
... | ... | |
301 | 317 |
* <li><i>disabled</i>: the new <code>adjustedExtent</code> will be like <code>extent</code>. |
302 | 318 |
* </ul> |
303 | 319 |
* </p> |
304 |
* |
|
320 |
*
|
|
305 | 321 |
* @see #setAdjustable(boolean) |
306 | 322 |
*/ |
307 | 323 |
private boolean adjustableExtent=true; |
... | ... | |
327 | 343 |
|
328 | 344 |
/** |
329 | 345 |
* <p>Changes the status of the <i>"adjustable extent"</i> option to enabled or disabled.</p> |
330 |
* |
|
346 |
* |
|
347 |
* <p>If view port isn't adjustable, won't bear in mind the aspect ratio of the available rectangular area to |
|
348 |
* calculate the affine transform from the original map in real coordinates. (Won't scale the image to adapt |
|
349 |
* it to the available rectangular area).</p> |
|
350 |
* |
|
331 | 351 |
* @param boolean the boolean to be set |
332 | 352 |
*/ |
333 | 353 |
public void setAdjustable(boolean adjustable) { |
... | ... | |
336 | 356 |
|
337 | 357 |
/** |
338 | 358 |
* <p>Appends the specified {@link ViewPortListener ViewPortListener} listener if weren't.</p> |
339 |
* |
|
359 |
*
|
|
340 | 360 |
* @param arg0 the listener to add |
341 | 361 |
* |
342 | 362 |
* @return <code>true</code> if has been added successfully |
343 |
* |
|
363 |
*
|
|
344 | 364 |
* @see #removeViewPortListener(ViewPortListener) |
345 | 365 |
*/ |
346 | 366 |
public boolean addViewPortListener(ViewPortListener arg0) { |
... | ... | |
350 | 370 |
} |
351 | 371 |
|
352 | 372 |
/** |
353 |
* @see ArrayList#remove(Object) |
|
354 |
* |
|
373 |
* <p>Removes the specified {@link ViewPortListener ViewPortListener} listener, if existed.</p> |
|
374 |
* |
|
375 |
* @param arg0 the listener to remove |
|
376 |
* |
|
377 |
* @return <code>true</code> if the contained the specified listener. |
|
378 |
* |
|
355 | 379 |
* @see #addViewPortListener(ViewPortListener) |
356 | 380 |
*/ |
357 | 381 |
public boolean removeViewPortListener(ViewPortListener arg0) { |
... | ... | |
359 | 383 |
} |
360 | 384 |
|
361 | 385 |
/** |
362 |
* <p>Converts and returns the distance <code>d</code> argument, that is in <i>map
|
|
386 |
* <p>Converts and returns the distance <code>d</code>, that is in <i>map |
|
363 | 387 |
* coordinates</i> to <i>screen coordinates</i> using a <i>delta transform</i> with |
364 | 388 |
* the transformation affine information in the {@link #trans #trans} attribute.</p> |
365 | 389 |
* |
366 | 390 |
* @param d distance in <i>map coordinates</i> |
367 | 391 |
* |
368 | 392 |
* @return distance equivalent in <i>screen coordinates</i> |
369 |
* |
|
393 |
*
|
|
370 | 394 |
* @see #toMapDistance(int) |
371 | 395 |
* @see AffineTransform#deltaTransform(Point2D, Point2D)S |
372 | 396 |
*/ |
... | ... | |
382 | 406 |
|
383 | 407 |
return (int) (d * pScreen.x); |
384 | 408 |
} |
385 |
|
|
386 |
|
|
409 |
|
|
387 | 410 |
/** |
388 |
* Devuelve un punto en pixels a partir de una coordenada X e Y real. |
|
411 |
* <p>Converts and returns the 2D point <code>(x,y)</code>, that is in <i>map |
|
412 |
* coordinates</i> to <i>screen coordinates</i> (pixels) using |
|
413 |
* the affine transformation in the {@link #trans #trans} attribute.</p> |
|
389 | 414 |
* |
390 |
* @param x Coordenada X real.
|
|
391 |
* @param y Coordenada Y real.
|
|
415 |
* @param x the <code>x</code> <i>map coordinate</i> of a 2D point
|
|
416 |
* @param y the <code>y</code> <i>map coordinate</i> of a 2D point
|
|
392 | 417 |
* |
393 |
* @return Punto en pixels. |
|
418 |
* @return 2D point equivalent in <i>screen coordinates</i> (pixels) |
|
419 |
* |
|
420 |
* @see #fromMapPoint(Point2D) |
|
421 |
* @see AffineTransform#transform(Point2D, Point2D) |
|
394 | 422 |
*/ |
395 | 423 |
public Point2D fromMapPoint(double x, double y) { |
396 | 424 |
Point2D.Double pWorld = new Point2D.Double(x, y); |
... | ... | |
413 | 441 |
* @param point the 2D point in <i>map coordinates</i> |
414 | 442 |
* |
415 | 443 |
* @return 2D point equivalent in <i>screen coordinates</i> (pixels) |
416 |
* |
|
444 |
*
|
|
417 | 445 |
* @see #toMapPoint(Point2D) |
418 | 446 |
* @see #fromMapPoint(double, double) |
419 | 447 |
*/ |
... | ... | |
430 | 458 |
* @param y the <code>y</code> <i>screen coordinate</i> of a 2D point |
431 | 459 |
* |
432 | 460 |
* @return 2D point equivalent in <i>map coordinates</i> |
433 |
* |
|
461 |
*
|
|
434 | 462 |
* @see #toMapPoint(Point2D) |
435 | 463 |
* @see #fromMapPoint(double, double) |
436 | 464 |
*/ |
... | ... | |
439 | 467 |
|
440 | 468 |
return toMapPoint(pScreen); |
441 | 469 |
} |
470 |
|
|
442 | 471 |
/** |
443 | 472 |
* <p>Converts and returns the {@link Rectangle2D Rectangle2D}, that is in <i>screen |
444 | 473 |
* coordinates</i> (pixels) to <i>map coordinates</i> using {@linkplain #toMapDistance(int)}, |
445 | 474 |
* and {@linkplain #toMapPoint(int, int)}.</p> |
446 |
* |
|
475 |
*
|
|
447 | 476 |
* @param r the 2D rectangle in <i>screen coordinates</i> (pixels) |
448 | 477 |
* @return 2D rectangle equivalent in <i>map coordinates</i> |
449 |
* |
|
478 |
*
|
|
450 | 479 |
* @see #fromMapRectangle(Rectangle2D) |
451 | 480 |
* @see #toMapDistance(int) |
452 | 481 |
* @see #toMapPoint(int, int) |
... | ... | |
458 | 487 |
rect.setFrameFromDiagonal(p1,p2); |
459 | 488 |
return rect; |
460 | 489 |
} |
490 |
|
|
461 | 491 |
/** |
462 |
* <p>Converts and returns the distance <code>d</code> argument, that is in <i>screen
|
|
492 |
* <p>Converts and returns the distance <code>d</code>, that is in <i>screen |
|
463 | 493 |
* coordinates</i> to <i>map coordinates</i> using the transformation affine information |
464 | 494 |
* in the {@link #trans #trans} attribute.</p> |
465 | 495 |
* |
466 | 496 |
* @param d distance in pixels |
467 | 497 |
* |
468 | 498 |
* @return distance equivalent in <i>map coordinates</i> |
469 |
* |
|
499 |
*
|
|
470 | 500 |
* @see #fromMapDistance(double) |
471 | 501 |
* @see AffineTransform |
472 | 502 |
*/ |
... | ... | |
480 | 510 |
* <p>Converts and returns the 2D point argument, that is in <i>screen coordinates</i> |
481 | 511 |
* (pixels) to <i>map coordinates</i> using the |
482 | 512 |
* inverse affine transformation of the {@link #trans #trans} attribute.</p> |
483 |
* |
|
513 |
*
|
|
484 | 514 |
* @param pScreen the 2D point in <i>screen coordinates</i> (pixels) |
485 | 515 |
* |
486 | 516 |
* @return 2D point equivalent in <i>map coordinates</i> |
487 |
* |
|
517 |
*
|
|
488 | 518 |
* @see #toMapPoint(int, int) |
489 | 519 |
* @see AffineTransform#createInverse() |
490 | 520 |
* @see AffineTransform#transform(Point2D, Point2D) |
... | ... | |
512 | 542 |
* @param pt2 another 2D point in <i>map coordinates</i> |
513 | 543 |
* |
514 | 544 |
* @return the distance in meters between the two points 2D |
515 |
* |
|
545 |
*
|
|
516 | 546 |
* @see GeoCalc#distanceVincenty(Point2D, Point2D) |
517 | 547 |
*/ |
518 | 548 |
public double distanceWorld(Point2D pt1, Point2D pt2) { |
... | ... | |
526 | 556 |
} |
527 | 557 |
return (dist*MapContext.CHANGEM[getMapUnits()]); |
528 | 558 |
} |
559 |
|
|
529 | 560 |
/** |
530 | 561 |
* <p>Sets as extent and adjusted extent of this view port, the previous. Recalculating |
531 | 562 |
* its parameters.</p> |
532 |
* |
|
563 |
*
|
|
533 | 564 |
* @see #getExtents() |
534 | 565 |
* @see #calculateAffineTransform() |
535 | 566 |
*/ |
... | ... | |
545 | 576 |
|
546 | 577 |
/** |
547 | 578 |
* <p>Gets the area selected by user using some tool.</p> |
548 |
* |
|
549 |
* <p>When the zoom changes (for instance when using the <i>zoom in</i> or <i>zoom out</i> tools,
|
|
579 |
*
|
|
580 |
* <p>When the zoom changes (for instance using the <i>zoom in</i> or <i>zoom out</i> tools, |
|
550 | 581 |
* but also zooming to a selected feature or shape) the extent that covers that |
551 | 582 |
* area is the value returned by this method. It is not the actual area shown |
552 | 583 |
* because it doesn't care about the aspect ratio of the image size of the view. However, any |
553 | 584 |
* part of the real world contained in this extent is shown in the view.</p> |
585 |
* |
|
554 | 586 |
* <p>If you are looking for the complete extent currently shown, you must use the |
555 | 587 |
* {@linkplain #getAdjustedExtent()} method.</p> |
556 |
* |
|
588 |
*
|
|
557 | 589 |
* @return the current extent |
558 |
* |
|
590 |
*
|
|
559 | 591 |
* @see #setExtent(Rectangle2D) |
560 | 592 |
* @see #getAdjustedExtent() |
561 | 593 |
* @see #setPreviousExtent() |
... | ... | |
566 | 598 |
} |
567 | 599 |
|
568 | 600 |
/** |
569 |
* <p>Changes the extent and adjusted extent of this view port:<br>
|
|
601 |
* <p>Changes the <i>extent</i> and <i>adjusted extent</i> of this view port:<br>
|
|
570 | 602 |
* <ul> |
571 | 603 |
* <li>Stores the previous extent. |
572 | 604 |
* <li>Calculates the new extent using <code>r</code>: |
573 | 605 |
* <pre>extent = new Rectangle2D.Double(r.getMinX() - 0.1, r.getMinY() - 0.1, r.getWidth() + 0.2, r.getHeight() + 0.2);</pre> |
574 | 606 |
* <li>Executes {@linkplain #calculateAffineTransform()}: getting the new scale, adjusted extent, affine transformation between |
575 | 607 |
* map and screen coordinates, the real world coordinates equivalent to 1 pixel, and the real world coordinates equivalent to 3 pixels. |
576 |
* <li>Notifies to all {@link ViewPortListener ViewPortListener}s registered that the extent has changed.
|
|
608 |
* <li>Notifies all {@link ViewPortListener ViewPortListener} registered that the extent has changed.
|
|
577 | 609 |
* </ul> |
578 | 610 |
* </p> |
579 | 611 |
* |
580 | 612 |
* @param r the new extent |
581 |
* |
|
613 |
*
|
|
582 | 614 |
* @see #getExtent() |
583 | 615 |
* @see #getExtents() |
584 | 616 |
* @see #calculateAffineTransform() |
... | ... | |
606 | 638 |
} |
607 | 639 |
|
608 | 640 |
/** |
609 |
* <p>Changes the extent and adjusted extent of this view port:<br>
|
|
641 |
* <p>Changes the <i>extent</i> and <i>adjusted extent</i> of this view port:<br>
|
|
610 | 642 |
* <ul> |
611 | 643 |
* <li>Executes {@linkplain #calculateAffineTransform()}: getting the new scale, adjusted extent, affine transformation between |
612 | 644 |
* map and screen coordinates, the real world coordinates equivalent to 1 pixel, and the real world coordinates equivalent to 3 pixels. |
613 |
* <li>Notifies to all {@link ViewPortListener ViewPortListener}s registered that the extent has changed.
|
|
645 |
* <li>Notifies to all {@link ViewPortListener ViewPortListener} registered that the extent has changed. |
|
614 | 646 |
* </ul> |
615 | 647 |
* </p> |
616 |
* |
|
648 |
*
|
|
617 | 649 |
* @see #setExtent(Rectangle2D) |
618 | 650 |
* @see #calculateAffineTransform() |
619 | 651 |
*/ |
... | ... | |
632 | 664 |
* is the extent in <i>screen coordinates</i> from the image in <i>map coordinates</i>.</p> |
633 | 665 |
* |
634 | 666 |
* @return the scale <i>extent / image size</i> projected by this view port |
635 |
* |
|
667 |
*
|
|
636 | 668 |
* @deprecated since 07/09/07, use {@linkplain MapContext#getScaleView()} |
637 | 669 |
*/ |
638 | 670 |
public double getScale() { |
... | ... | |
642 | 674 |
|
643 | 675 |
/** |
644 | 676 |
* <p>Affine transformation between <i>map 2D coordinates</i> to <i>screen 2D coordinates</i> (pixels), |
645 |
* preserving the "straightness" and "parallelism" of lines.</p> |
|
677 |
* preserving the "straightness" and "parallelism" of the lines.</p>
|
|
646 | 678 |
* |
647 | 679 |
* @return the affine transformation |
648 |
* |
|
680 |
*
|
|
649 | 681 |
* @see #setAffineTransform(AffineTransform) |
650 | 682 |
* @see #calculateAffineTransform() |
651 | 683 |
*/ |
... | ... | |
657 | 689 |
* <p>Returns the size of the image projected.</p> |
658 | 690 |
* |
659 | 691 |
* @return the image size |
660 |
* |
|
692 |
*
|
|
661 | 693 |
* @see #setImageSize(Dimension) |
662 | 694 |
* @see #getImageHeight() |
663 | 695 |
* @see #getImageWidth() |
... | ... | |
665 | 697 |
public Dimension getImageSize() { |
666 | 698 |
return imageSize; |
667 | 699 |
} |
700 |
|
|
668 | 701 |
/** |
669 | 702 |
* <p>Sets the size of the image projected, recalculating the parameters of this view port.</p> |
670 | 703 |
* |
671 | 704 |
* @param imageSize the image size |
672 |
* |
|
705 |
*
|
|
673 | 706 |
* @see #getImageSize() |
674 | 707 |
* @see #calculateAffineTransform() |
675 | 708 |
*/ |
... | ... | |
683 | 716 |
* has changed.</p> |
684 | 717 |
* |
685 | 718 |
* @param newRect the new adjusted extend |
686 |
* |
|
719 |
*
|
|
687 | 720 |
* @see #refreshExtent() |
688 | 721 |
* @see #setExtent(Rectangle2D) |
689 | 722 |
* @see #setPreviousExtent() |
... | ... | |
699 | 732 |
} |
700 | 733 |
} |
701 | 734 |
|
702 |
|
|
703 | 735 |
/** |
704 | 736 |
* <p>Notifies to all view port listeners registered, that the background color of this view port |
705 | 737 |
* has changed.</p> |
706 | 738 |
* |
707 | 739 |
* @param c the new background color |
708 |
* |
|
740 |
*
|
|
709 | 741 |
* @see #setBackColor(Color) |
710 | 742 |
* @see ColorEvent |
711 | 743 |
* @see ViewPortListener |
... | ... | |
718 | 750 |
listener.backColorChanged(ce); |
719 | 751 |
} |
720 | 752 |
} |
753 |
|
|
721 | 754 |
/** |
722 | 755 |
* <p>Notifies to all view port listeners registered, that the projection of this view port |
723 | 756 |
* has changed.</p> |
724 | 757 |
* |
725 | 758 |
* @param projection the new projection |
726 |
* |
|
759 |
*
|
|
727 | 760 |
* @see #setProjection(IProjection) |
728 | 761 |
* @see ProjectionEvent |
729 | 762 |
* @see ViewPortListener |
... | ... | |
737 | 770 |
} |
738 | 771 |
} |
739 | 772 |
|
740 |
|
|
741 | 773 |
/** |
742 | 774 |
* <p>Calculates the affine transformation between the {@link #extent extent} in <i>map 2D coordinates</i> to |
743 | 775 |
* the image area in the screen, in <i>screen 2D coordinates</i> (pixels).</p> |
744 |
* |
|
776 |
*
|
|
745 | 777 |
* <p>This process recalculates some parameters of this view port:<br> |
746 |
* |
|
778 |
*
|
|
747 | 779 |
* <ul> |
748 | 780 |
* <li>The new {@link #scale scale} . |
749 | 781 |
* <li>The new {@link #adjustedExtent adjustedExtent} . |
... | ... | |
752 | 784 |
* <li>The new real world coordinates equivalent to 3 pixels ({@link #dist3pixel dist3pixel}) . |
753 | 785 |
* </ul> |
754 | 786 |
* </p> |
755 |
* |
|
787 |
*
|
|
756 | 788 |
* @see #getAffineTransform() |
757 | 789 |
* @see #setAffineTransform(AffineTransform) |
758 | 790 |
* @see #refreshExtent() |
... | ... | |
841 | 873 |
/** |
842 | 874 |
* <p>Sets the offset.</p> |
843 | 875 |
* <p>The offset is the position where start drawing the map.</p> |
844 |
* <p>The offset of a <a href="http://www.gvsig.gva.es/">gvSIG</a>'s <i>View</i> is |
|
845 |
* always (0, 0) because the drawing area fits with the full window area. But in |
|
846 |
* a <a href="http://www.gvsig.gva.es/">gvSIG</a>'s <i>Layout</i> it's up to the place where |
|
847 |
* the <code>FFrameView</code> is located.</p> |
|
848 | 876 |
* |
849 | 877 |
* @param p 2D point that represents the offset in pixels |
850 |
* |
|
878 |
*
|
|
851 | 879 |
* @see #getOffset() |
852 | 880 |
*/ |
853 | 881 |
public void setOffset(Point2D p) { |
854 | 882 |
offset = p; |
855 | 883 |
} |
884 |
|
|
856 | 885 |
/** |
857 | 886 |
* <p>Gets the offset.</p> |
858 | 887 |
* <p>The offset is the position where start drawing the map.</p> |
859 |
* <p>The offset of a <a href="http://www.gvsig.gva.es/">gvSIG</a>'s <i>View</i> is |
|
860 |
* always (0, 0) because the drawing area fits with the full window area. But in |
|
861 |
* a <a href="http://www.gvsig.gva.es/">gvSIG</a>'s <i>Layout</i> it's up to the place where |
|
862 |
* the <code>FFrameView</code> is located.</p> |
|
863 | 888 |
* |
864 | 889 |
* @return 2D point that represents the offset in pixels |
865 |
* |
|
890 |
*
|
|
866 | 891 |
* @see #setOffset(Point2D) |
867 | 892 |
*/ |
868 | 893 |
public Point2D getOffset() { |
869 | 894 |
return offset; |
870 | 895 |
} |
896 |
|
|
871 | 897 |
/** |
872 |
* <p>Sets the background color for the view.</p>
|
|
898 |
* <p>Sets the background color.</p> |
|
873 | 899 |
* |
874 | 900 |
* @param c the new background color |
875 |
* |
|
901 |
*
|
|
876 | 902 |
* @see #getBackColor() |
877 | 903 |
*/ |
878 | 904 |
public void setBackColor(Color c) { |
... | ... | |
881 | 907 |
} |
882 | 908 |
|
883 | 909 |
/** |
884 |
* <p>Gets the background color of this view.</p>
|
|
910 |
* <p>Gets the background color.</p> |
|
885 | 911 |
* |
886 | 912 |
* @return the background color of the view |
887 |
* |
|
913 |
*
|
|
888 | 914 |
* @see #setBackColor(Color) |
889 | 915 |
*/ |
890 | 916 |
public Color getBackColor() { |
891 | 917 |
return backColor; |
892 | 918 |
} |
893 | 919 |
|
894 |
|
|
895 | 920 |
/** |
896 | 921 |
* <p>Returns the extent currently covered by the view adjusted (scaled) to the image size aspect.</p> |
897 |
* |
|
922 |
*
|
|
898 | 923 |
* @return extent of the view adjusted to the image size aspect |
899 |
* |
|
924 |
*
|
|
900 | 925 |
* @see #setAdjustable(boolean) |
901 | 926 |
*/ |
902 | 927 |
public Rectangle2D getAdjustedExtent() { |
... | ... | |
910 | 935 |
* <p>Returns the measurement unit of this view port used for measuring distances and displaying information.</p> |
911 | 936 |
* |
912 | 937 |
* @return the measurement unit of this view used for measuring distances and displaying information |
913 |
* |
|
938 |
*
|
|
914 | 939 |
* @see #setDistanceUnits(int) |
915 | 940 |
*/ |
916 | 941 |
public int getDistanceUnits() { |
... | ... | |
921 | 946 |
* <p>Sets the measurement unit of this view port used for measuring distances and displaying information.</p> |
922 | 947 |
* |
923 | 948 |
* @param distanceUnits the measurement unit of this view used for measuring distances and displaying information |
924 |
* |
|
949 |
*
|
|
925 | 950 |
* @see #getDistanceUnits() |
926 | 951 |
*/ |
927 | 952 |
public void setDistanceUnits(int distanceUnits) { |
928 | 953 |
this.distanceUnits = distanceUnits; |
929 | 954 |
} |
930 | 955 |
|
931 |
|
|
932 | 956 |
/** |
933 | 957 |
* <p>Gets the measurement unit used by this view port for the map.</p> |
934 | 958 |
* |
935 | 959 |
* @return Returns the current map measure unit |
936 |
* |
|
960 |
*
|
|
937 | 961 |
* @see #setMapUnits(int) |
938 | 962 |
*/ |
939 | 963 |
public int getMapUnits() { |
... | ... | |
944 | 968 |
* <p>Sets the measurement unit used by this view port for the map.</p> |
945 | 969 |
* |
946 | 970 |
* @param mapUnits the new map measure unit |
947 |
* |
|
971 |
*
|
|
948 | 972 |
* @see #getMapUnits() |
949 | 973 |
*/ |
950 | 974 |
public void setMapUnits(int mapUnits) { |
... | ... | |
952 | 976 |
} |
953 | 977 |
|
954 | 978 |
/** |
955 |
* <p>Gets the size in <i>screen coordinates</i> of the rectangle where the image is displayed.</p>
|
|
979 |
* <p>Gets the width in <i>screen coordinates</i> of the rectangle where the image is displayed.</p>
|
|
956 | 980 |
* <p>Used by {@linkplain #calculateAffineTransform()} to calculate:<br> |
957 |
* |
|
981 |
*
|
|
958 | 982 |
* <ul> |
959 | 983 |
* <li>The new {@link #scale scale} . |
960 | 984 |
* <li>The new {@link #adjustedExtent adjustableExtent} . |
... | ... | |
963 | 987 |
* <li>The new real world coordinates equivalent to 3 pixels ({@link #dist3pixel dist3pixel}) . |
964 | 988 |
* </ul> |
965 | 989 |
* </p> |
966 |
* |
|
990 |
*
|
|
967 | 991 |
* @see #getImageHeight() |
968 | 992 |
* @see #getImageSize() |
969 | 993 |
* @see #setImageSize(Dimension) |
... | ... | |
971 | 995 |
public int getImageWidth() { |
972 | 996 |
return imageSize.width; |
973 | 997 |
} |
998 |
|
|
974 | 999 |
/** |
975 |
* <p>Sets the size in <i>screen coordinates</i> of the rectangle where the image is displayed.</p>
|
|
1000 |
* <p>Gets the height in <i>screen coordinates</i> of the rectangle where the image is displayed.</p>
|
|
976 | 1001 |
* <p>Used by {@linkplain #calculateAffineTransform()} to calculate:<br> |
977 |
* |
|
1002 |
*
|
|
978 | 1003 |
* <ul> |
979 | 1004 |
* <li>The new {@link #scale scale} . |
980 | 1005 |
* <li>The new {@link #adjustedExtent adjustableExtent} . |
... | ... | |
983 | 1008 |
* <li>The new real world coordinates equivalent to 3 pixels ({@link #dist3pixel dist3pixel}) . |
984 | 1009 |
* </ul> |
985 | 1010 |
* </p> |
986 |
* |
|
1011 |
*
|
|
987 | 1012 |
* @see #getImageWidth() |
988 | 1013 |
* @see #getImageSize() |
989 | 1014 |
* @see #setImageSize(Dimension) |
... | ... | |
993 | 1018 |
} |
994 | 1019 |
|
995 | 1020 |
/** |
996 |
* <p>Gets the distance in <i>world coordinates</i> equivalent to 1 pixel in the view with the current extent.</p> |
|
1021 |
* <p>Gets the distance in <i>world coordinates</i> equivalent to 1 pixel in the view with the current extent.</p>
|
|
997 | 1022 |
* |
998 | 1023 |
* @return the distance |
999 |
* |
|
1024 |
*
|
|
1000 | 1025 |
* @see #setDist1pixel(double) |
1001 | 1026 |
*/ |
1002 | 1027 |
public double getDist1pixel() { |
... | ... | |
1004 | 1029 |
} |
1005 | 1030 |
|
1006 | 1031 |
/** |
1007 |
* <p>Sets the distance in <i>world coordinates</i> equivalent to 1 pixel in the view with the current extent.</p> |
|
1032 |
* <p>Sets the distance in <i>world coordinates</i> equivalent to 1 pixel in the view with the current extent.</p>
|
|
1008 | 1033 |
* |
1009 | 1034 |
* @param dist1pixel the distance |
1010 |
* |
|
1035 |
*
|
|
1011 | 1036 |
* @see #getDist1pixel() |
1012 | 1037 |
*/ |
1013 | 1038 |
public void setDist1pixel(double dist1pixel) { |
... | ... | |
1015 | 1040 |
} |
1016 | 1041 |
|
1017 | 1042 |
/** |
1018 |
* <p>Gets the distance in <i>world coordinates</i> equivalent to 3 pixels in the view with the current extent.</p> |
|
1043 |
* <p>Gets the distance in <i>world coordinates</i> equivalent to 3 pixels in the view with the current extent.</p>
|
|
1019 | 1044 |
* |
1020 | 1045 |
* @return the distance |
1021 |
* |
|
1046 |
*
|
|
1022 | 1047 |
* @see #setDist3pixel(double) |
1023 | 1048 |
*/ |
1024 | 1049 |
public double getDist3pixel() { |
... | ... | |
1026 | 1051 |
} |
1027 | 1052 |
|
1028 | 1053 |
/** |
1029 |
* <p>Sets the distance in <i>world coordinates</i> equivalent to 3 pixels in the view with the current extent.</p> |
|
1054 |
* <p>Sets the distance in <i>world coordinates</i> equivalent to 3 pixels in the view with the current extent.</p>
|
|
1030 | 1055 |
* |
1031 | 1056 |
* @param dist3pixel the distance |
1032 |
* |
|
1057 |
*
|
|
1033 | 1058 |
* @see #getDist3pixel() |
1034 | 1059 |
*/ |
1035 | 1060 |
public void setDist3pixel(double dist3pixel) { |
1036 | 1061 |
this.dist3pixel = dist3pixel; |
1037 | 1062 |
} |
1063 |
|
|
1038 | 1064 |
/** |
1039 | 1065 |
* <p>Returns the last previous extents of this view port.</p> |
1040 | 1066 |
* |
1041 | 1067 |
* @return the last previous extents of this view port |
1042 |
* |
|
1068 |
*
|
|
1043 | 1069 |
* @see #setPreviousExtent() |
1044 | 1070 |
*/ |
1045 | 1071 |
public ExtentHistory getExtents() { |
... | ... | |
1050 | 1076 |
* <p>Gets the projection used in this view port.</p> |
1051 | 1077 |
* |
1052 | 1078 |
* @return projection used in this view port |
1053 |
* |
|
1079 |
*
|
|
1054 | 1080 |
* @see #setProjection(IProjection) |
1055 | 1081 |
*/ |
1056 | 1082 |
public IProjection getProjection() { |
... | ... | |
1061 | 1087 |
* <p>Sets the projection to this view port.</p> |
1062 | 1088 |
* |
1063 | 1089 |
* @param proj the new projection |
1064 |
* |
|
1090 |
*
|
|
1065 | 1091 |
* @see #getProjection() |
1066 | 1092 |
*/ |
1067 | 1093 |
public void setProjection(IProjection proj) { |
... | ... | |
1080 | 1106 |
|
1081 | 1107 |
/** |
1082 | 1108 |
* <p>Sets only the affine transform to this view port, without updating dependent attributes.</p> |
1083 |
* <p><b><i>This method can be problematic!</i></b></p>
|
|
1109 |
* <p><b><i>This method could be problematic!</i></b></p>
|
|
1084 | 1110 |
* |
1085 | 1111 |
* @param at the affine transform to set |
1086 |
* |
|
1112 |
*
|
|
1087 | 1113 |
* @see #getAffineTransform() |
1088 | 1114 |
* @see #calculateAffineTransform() |
1089 | 1115 |
*/ |
... | ... | |
1100 | 1126 |
* <li><i>className</i>: name of this class. |
1101 | 1127 |
* <li>If defined, the adjusted extent: |
1102 | 1128 |
* <ul> |
1103 |
* <li><i>adjustedExtentX</i>: X coordinate of the adjusted extent. |
|
1129 |
* <li><i>adjustedExtentX</i>: X coordinate of the adjusted extent.
|
|
1104 | 1130 |
* <li><i>adjustedExtentY</i>: Y coordinate of the adjusted extent. |
1105 | 1131 |
* <li><i>adjustedExtentW</i>: width of the adjusted extent. |
1106 | 1132 |
* <li><i>adjustedExtentH</i>: height of the adjusted extent. |
1107 |
* </ul> |
|
1133 |
* </ul>
|
|
1108 | 1134 |
* <li>If defined, the background color: |
1109 | 1135 |
* <ul> |
1110 | 1136 |
* <li><i>backColor</i>: background color. |
1111 |
* </ul> |
|
1137 |
* </ul>
|
|
1112 | 1138 |
* <li>If defined, the clip: |
1113 | 1139 |
* <ul> |
1114 |
* <li><i>clipX</i>: X coordinate of the clip. |
|
1140 |
* <li><i>clipX</i>: X coordinate of the clip.
|
|
1115 | 1141 |
* <li><i>clipY</i>: Y coordinate of clip. |
1116 | 1142 |
* <li><i>clipW</i>: width of the clip. |
1117 | 1143 |
* <li><i>clipH</i>: height of the clip. |
1118 |
* </ul> |
|
1144 |
* </ul>
|
|
1119 | 1145 |
* <li><i>dist1pixel</i>: the distance in world coordinates equivalent to 1 pixel in the view. |
1120 | 1146 |
* <li><i>dist3pixel</i>: the distance in world coordinates equivalent to 3 pixels in the view. |
1121 | 1147 |
* <li><i>distanceUnits</i>: the distance measurement unit. |
1122 | 1148 |
* <li>If defined, the extent: |
1123 | 1149 |
* <ul> |
1124 |
* <li><i>extentX</i>: X coordinate of the extent. |
|
1150 |
* <li><i>extentX</i>: X coordinate of the extent.
|
|
1125 | 1151 |
* <li><i>extentY</i>: Y coordinate of the extent. |
1126 | 1152 |
* <li><i>extentW</i>: width of the extent. |
1127 | 1153 |
* <li><i>extentH</i>: height of the extent. |
1128 |
* </ul> |
|
1129 |
* <li><i>mapUnits</i>: the map measurement unit. |
|
1154 |
* </ul>
|
|
1155 |
* <li><i>mapUnits</i>: the map measurement unit.
|
|
1130 | 1156 |
* <li><i>offsetX</i>: X coordinate of the offset. |
1131 |
* <li><i>offsetY</i>: Y coordinate of the offset. |
|
1157 |
* <li><i>offsetY</i>: Y coordinate of the offset.
|
|
1132 | 1158 |
* <li>If defined, the projection: |
1133 | 1159 |
* <ul> |
1134 |
* <li><i>proj</i>: the projection. |
|
1135 |
* </ul> |
|
1160 |
* <li>If its defined, the projection: |
|
1161 |
* <ul> |
|
1162 |
* <li><i>proj</i>: the projection.</li> |
|
1163 |
* </ul> |
|
1164 |
* </ul> |
|
1136 | 1165 |
* <li><i>scale</i>: ratio between the size of <code>imageSize</code> and <code>extent</code>. |
1137 | 1166 |
* </ul> |
1138 | 1167 |
* <li>Child branches: |
... | ... | |
1140 | 1169 |
* <li>XML entity of the internal {@link ExtentHistory ExtentHistory} . |
1141 | 1170 |
* </ul> |
1142 | 1171 |
* </ul> |
1143 |
* |
|
1172 |
*
|
|
1144 | 1173 |
* @return the XML entity |
1145 |
* |
|
1174 |
*
|
|
1146 | 1175 |
* @see #createFromXML(XMLEntity) |
1147 | 1176 |
*/ |
1148 | 1177 |
public XMLEntity getXMLEntity() { |
... | ... | |
1197 | 1226 |
* @param xml an XML entity |
1198 | 1227 |
* |
1199 | 1228 |
* @return the new <code>ViewPort</code> |
1200 |
* |
|
1229 |
*
|
|
1201 | 1230 |
* @see #getXMLEntity() |
1202 | 1231 |
* @see #createFromXML(XMLEntity) |
1203 | 1232 |
*/ |
... | ... | |
1254 | 1283 |
vp.refreshExtent(); |
1255 | 1284 |
return vp; |
1256 | 1285 |
} |
1286 |
|
|
1257 | 1287 |
/** |
1258 | 1288 |
* <p>Creates a new <code>ViewPort</code> from an XML entity.</p> |
1259 | 1289 |
* |
1260 | 1290 |
* @param xml an XML entity |
1261 | 1291 |
* |
1262 | 1292 |
* @return the new <code>ViewPort</code> |
1263 |
* |
|
1293 |
*
|
|
1264 | 1294 |
* @see #getXMLEntity() |
1265 | 1295 |
* @see #createFromXML03(XMLEntity) |
1266 | 1296 |
*/ |
... | ... | |
1322 | 1352 |
|
1323 | 1353 |
/** |
1324 | 1354 |
* <p>Fast clone implementation: creates and returns a clone of this view port using XML entities.</p> |
1325 |
* <p>Doesn't <i>deepclone</i> to avoid unnecessary memory consumption.</p>
|
|
1355 |
* <p>Isn't a <i>deepclone</i> to avoid unnecessary memory consumption.</p>
|
|
1326 | 1356 |
* |
1327 | 1357 |
* @return the new view port |
1328 |
* |
|
1358 |
*
|
|
1329 | 1359 |
* @see #createFromXML(XMLEntity) |
1330 | 1360 |
*/ |
1331 | 1361 |
public ViewPort cloneViewPort() { |
1332 | 1362 |
return createFromXML(getXMLEntity()); |
1333 | 1363 |
} |
1334 | 1364 |
|
1335 |
|
|
1336 | 1365 |
/** |
1337 |
* <p>Returns a <code>string</code> representation of the main values of this view port: <code>{@linkplain #extent}</code>,
|
|
1366 |
* <p>Returns a <code>String</code> representation of the main values of this view port: <code>{@linkplain #extent}</code>,
|
|
1338 | 1367 |
* <code>{@linkplain #adjustedExtent}</code>, <code>{@linkplain #imageSize}</code>, <code>{@linkplain #scale}</code>, and <code>{@linkplain #trans}</code>.</p> |
1339 |
* |
|
1368 |
*
|
|
1340 | 1369 |
* @return a <code>string</code> representation of the main values of this view port |
1341 | 1370 |
*/ |
1342 | 1371 |
public String toString() { |
... | ... | |
1351 | 1380 |
|
1352 | 1381 |
/** |
1353 | 1382 |
* <p>Sets the position and size of the clipping rectangle.</p> |
1354 |
* |
|
1383 |
*
|
|
1355 | 1384 |
* @param rectView the clipping rectangle to set |
1356 | 1385 |
*/ |
1357 | 1386 |
public void setClipRect(Rectangle2D rectView) { |
1358 | 1387 |
cliprect=rectView; |
1359 | 1388 |
} |
1360 | 1389 |
|
1390 |
/** |
|
1391 |
* <p>Converts and returns the {@link Rectangle2D Rectangle2D}, that is in <i>map |
|
1392 |
* coordinates</i> to <i>screen coordinates</i> (pixels) using an <i>inverse transform</i> with |
|
1393 |
* the transformation affine information in the {@link #trans #trans} attribute.</p> |
|
1394 |
* |
|
1395 |
* @param r the 2D rectangle in <i>map coordinates</i> |
|
1396 |
* @return 2D rectangle equivalent in <i>screen coordinates</i> (pixels) |
|
1397 |
* |
|
1398 |
* @see #toMapRectangle(Rectangle2D) |
|
1399 |
* @see #fromMapDistance(double) |
|
1400 |
* @see #fromMapPoint(Point2D) |
|
1401 |
*/ |
|
1361 | 1402 |
public Rectangle2D fromMapRectangle(Rectangle2D r) { |
1362 | 1403 |
Rectangle2D rect=new Rectangle2D.Double(); |
1363 | 1404 |
Point2D p1=fromMapPoint((int)r.getX(),(int)r.getY()); |
... | ... | |
1365 | 1406 |
rect.setFrameFromDiagonal(p1,p2); |
1366 | 1407 |
return rect; |
1367 | 1408 |
} |
1409 |
|
|
1410 |
/** |
|
1411 |
* <p>Recalculates the current <code>{@linkplain #extent}</code> using an scale. It's necessary execute {@linkplain #refreshExtent()} after.</p> |
|
1412 |
* |
|
1413 |
* @param s the scale to set |
|
1414 |
* |
|
1415 |
* @deprecated since 07/09/07, use {@linkplain MapContext#setScaleView(long)} |
|
1416 |
*/ |
|
1368 | 1417 |
public void setScale(long s){ |
1369 | 1418 |
double x=extent.getX(); |
1370 | 1419 |
double y=extent.getY(); |
... | ... | |
1383 | 1432 |
double h1=extent.getHeight()*difw; |
1384 | 1433 |
extent.setRect(-x1,-y1,w1,h1); |
1385 | 1434 |
} |
1386 |
|
|
1387 | 1435 |
} |
Also available in: Unified diff