Revision 20098 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/MapContext.java

View differences:

MapContext.java
86 86
/**
87 87
 * <p>The <code>MapContext</code> class represents the model and a part of the control and view around graphical layers
88 88
 * used by {@link MapControl MapControl}.</p>
89
 *
89
 * 
90 90
 * <p>An instance of <code>MapContext</code> is made up with:
91 91
 * <ul>
92 92
 * <li>a hierarchy of {@link FLayers FLayers} nodes
93 93
 * <li>a {@link GraphicLayer GraphicLayer} layer
94 94
 * <li>a {@link ViewPort ViewPort}
95 95
 * <li>an {@link EventBuffer EventButter}
96
 * <li>some {@link com.iver.cit.gvsig.fmap.rendering.LegendListener LegendListener}s
96
 * <li>some {@link com.iver.cit.gvsig.fmap.layers.LegendListener LegendListener}s
97 97
 * <li>some {@link LayerDrawingListener LayerDrawingListener}s
98 98
 * <li>some {@link LayerEventListener LayerEventListener}s
99 99
 * <li>some {@link ErrorListener ErrorListener}s
......
105 105
public class MapContext implements Projected {
106 106
	/**
107 107
	 * <p>Defines the value which a unit of a distance measurement must be divided to obtain its equivalent <b>in meters</b>.</p>
108
	 *
108
	 * 
109 109
	 * <p><b><i>Conversion values of distance measurements:</i></b>
110 110
	 * <ul>
111 111
	 *  <li><code>MapContext.CHANGEM[0]</code>: kilometer
......
118 118
	 *  <li><code>MapContext.CHANGEM[7]</code>: inch
119 119
	 *  <li><code>MapContext.CHANGEM[8]</code>: grade
120 120
	 * </ul>
121
	 *
121
	 * 
122 122
	 * <p><h3>Examples:</h3>
123 123
	 * <pre>1 international statute mile / MapContext.CHANGEM[4] = X meters</pre>
124 124
	 * <pre>1 kilometer / MapContext.CHANGEM[0] = X meters</pre>
125 125
	 * <pre>1 grade / MapContext.CHANGEM[8] = X meters</pre>
126 126
	 * </p>
127
	 *
128
	 * <p><h3>Grade conversion value: <code>MapContext.CHANGEM[8]</code></h3>
127
	 * 
128
	 * <p><h3>Grade conversion value: <code>MapContext.CHANGEM[8]</code></h3> 
129 129
	 * The value of <code>MapContext.CHANGEM[8]</code> represents the meters of a straight line between two
130
	 *  points on the Earth surface that are 1 grade far each other of the center of the Earth. This value has been calculated using
130
	 *  points on the Earth surface that are 1 grade far each other of the center of the Earth. This value has been calculated using 
131 131
	 *  a radius approximated of R<sub>Earth</sub>=6.37846082678100774672e6 meters, according these equations:
132 132
	 * <pre>D = 2 * (sin (1)) * R<sub>Earth</sub></pre>
133 133
	 * <pre>MapContext.CHANGEM[8] = 1 / D</pre>
......
142 142

  
143 143
	/**
144 144
	 * <p>Defines the value which a unit of a distance measurement must be divided to obtain its equivalent <b>in centimeters</b>.</p>
145
	 *
145
	 * 
146 146
	 * <p><b><i>Conversion values of distance measurements:</i></b>
147 147
	 * <ul>
148 148
	 *  <li><code>MapContext.CHANGE[0]</code>: kilometer
......
155 155
	 *  <li><code>MapContext.CHANGE[7]</code>: inch
156 156
	 *  <li><code>MapContext.CHANGE[8]</code>: grade
157 157
	 * </ul>
158
	 *
158
	 * 
159 159
	 * <p><h3>Examples:</h3>
160 160
	 * <pre>1 international statute mile / MapContext.CHANGE[4] = X centimeters</pre>
161 161
	 * <pre>1 kilometer / MapContext.CHANGE[0] = X centimeters</pre>
162 162
	 * <pre>1 grade / MapContext.CHANGE[8] = X centimeters</pre>
163 163
	 * </p>
164
	 *
165
	 * <p><h3>Grade conversion value: <code>MapContext.CHANGE[8]</code></h3>
164
	 * 
165
	 * <p><h3>Grade conversion value: <code>MapContext.CHANGE[8]</code></h3> 
166 166
	 * The value of <code>MapContext.CHANGE[8]</code> represents the centimeters of a straight line between two
167
	 *  points on the Earth surface that are 1 grade far each other of the center of the Earth. This value has been calculated using
167
	 *  points on the Earth surface that are 1 grade far each other of the center of the Earth. This value has been calculated using 
168 168
	 *  a radius approximated of R<sub>Earth</sub>=6.37846082678100774672e6 meters, according these equations:
169 169
	 * <pre>D = 2 * (sin (1)) * R<sub>Earth</sub></pre>
170 170
	 * <pre>MapContext.CHANGE[8] = 1 / D</pre>
......
178 178
			91.44, 30.48, 2.54, 1/8.983152841195214E-4 };
179 179

  
180 180
	/* Do not alter the order and the values of this array, if you need append values.*/
181
	/**
182
	 * <p>Gets the name of all distance measurements supported by <code>MapContext</code>.</p>
183
	 */
181 184
	public static final String[] NAMES= {
182 185
		Messages.getString("Kilometros"),
183 186
		Messages.getString("Metros"),
......
205 208
	public static final int CONTAINS = 6;
206 209

  
207 210
	public static final int OVERLAPS = 7;
211

  
208 212
	/**
209 213
	 * A hierarchy of {@link FLayers FLayers} nodes.
210
	 *
214
	 * 
211 215
	 * @see #getLayers()
212 216
	 * @see #print(Graphics2D, double, PrintRequestAttributeSet)
213 217
	 */
214 218
	protected FLayers layers;
219

  
215 220
	/**
216 221
	 * A layer with graphical items: geometries and symbols.
217
	 *
222
	 * 
218 223
	 * @see #getGraphicsLayer()
219 224
	 * @see #setGraphicsLayer(GraphicLayer)
220 225
	 * @see #drawGraphics(BufferedImage, Graphics2D, Cancellable, double)
221 226
	 * @see #print(Graphics2D, double, PrintRequestAttributeSet)
222 227
	 */
223 228
	private GraphicLayer tracLayer = new GraphicLayer();
229

  
224 230
	/**
225 231
	 * Information for draw layers in a view.
226
	 *
232
	 * 
227 233
	 * @see #getViewPort()
228 234
	 * @see #setViewPort(ViewPort)
229 235
	 */
......
233 239

  
234 240
	/**
235 241
	 * Array list with all {@link LegendListener LegendListener} registered to this map.
236
	 *
242
	 * 
237 243
	 * @see #addLayerListener(LegendListener)
238 244
	 * @see #removeLayerListener(LegendListener)
239 245
	 * @see #callLegendChanged()
......
242 248

  
243 249
	/**
244 250
	 * Array list with all {@link LayerDrawingListener LayerDrawingListener} registered to this map.
245
	 *
251
	 * 
246 252
	 * @see #addLayerDrawingListener(LayerDrawingListener)
247 253
	 * @see #removeLayerDrawListener(LayerDrawingListener)
248 254
	 * @see #fireLayerDrawingEvent(LayerDrawEvent)
249 255
	 */
250 256
	private ArrayList layerDrawingListeners = new ArrayList();
257

  
251 258
	/**
252 259
	 * <p>Buffer that is used to store and eject events produced on this map:
253 260
	 * <ul>
......
259 266
	 *  <li>Selection events on an {@link AlphanumericData AlphanumericData} data layer.
260 267
	 * </ul>
261 268
	 * </p>
262
	 *
269
	 * 
263 270
	 * @see #addAtomicEventListener(AtomicEventListener)
264 271
	 * @see #removeAtomicEventListener(AtomicEventListener)
265 272
	 * @see #beginAtomicEvent()
266 273
	 * @see #endAtomicEvent()
267 274
	 */
268 275
	private EventBuffer eventBuffer = new EventBuffer();
276

  
269 277
	/**
270 278
	 * Event listener for the collection of layers of this map.
271 279
	 */
272 280
	private LayerEventListener layerEventListener = null;
281

  
273 282
	/**
274 283
	 * List with information of all errors produced on all layers.
275
	 *
284
	 * 
276 285
	 * @see #addLayerError(String)
277 286
	 * @see #getLayersError()
278 287
	 * @see #clearErrors()
279 288
	 */
280 289
	private ArrayList layersError = new ArrayList();
290

  
281 291
	/**
282 292
	 * Array list with all {@link ErrorListener ErrorListener} registered to this map.
283
	 *
293
	 * 
284 294
	 * @see #addErrorListener(ErrorListener)
285 295
	 * @see #removeErrorListener(LegendListener)
286 296
	 * @see #callNewErrorEvent(ErrorEvent)
......
294 304
	// ResourceBundle.getBundle("FMap");
295 305

  
296 306
	/**
297
	 * <p>Default zoom in factor.</p>
307
	 * <p>Default <i>zoom in</i> factor.</p>
298 308
	 * <p>Doing a <i>zoom in</i> operation, decreases the focal distance and increases the eyesight angle to the surface. This allows view an smaller
299 309
	 * area but with the items bigger.</p>
300 310
	 */
301 311
	public static double ZOOMINFACTOR=2;
312

  
302 313
	/**
303
	 * <p>Default zoom out factor.</p>
314
	 * <p>Default <i>zoom out</i> factor.</p>
304 315
	 * <p>Doing a <i>zoom out</i> operation, increases the focal distance and decreases the eyesight angle to the surface. This allows view a bigger
305 316
	 * area but with the items smaller.</p>
306 317
	 */
307 318
	public static double ZOOMOUTFACTOR=0.5;
308 319

  
320
	/**
321
	 * <p>Color used to represent the selections.</p>
322
	 */
309 323
	private static Color selectionColor = Color.YELLOW;
310 324

  
311 325

  
312 326
	/**
313
	 * Devuelve el color que se aplica a los shapes seleccionados.
327
	 * <p>Gets the color used to represent the selections.</p>
314 328
	 *
315
	 * @return DOCUMENT ME!
329
	 * @return color used to represent the selections
316 330
	 */
317 331
	public static Color getSelectionColor() {
318 332
		return selectionColor;
319 333
	}
320 334

  
321 335
	/**
322
	 * Introduce el color que se aplica a los shapes seleccionados.
336
	 * <p>Sets the color used to represent the selections.</p>
323 337
	 *
324
	 * @param selectionColor DOCUMENT ME!
338
	 * @param selectionColor color used to represent the selections
325 339
	 */
326 340
	public static void setSelectionColor(Color selectionColor) {
327 341
		MapContext.selectionColor = selectionColor;
328 342
	}
343

  
329 344
	/**
330 345
	 * <p>Creates a new map context with the drawing information defined in the view port argument, and
331 346
	 *  without layers.</p>
332 347
	 *
333
	 * @param vp information for drawing the layers of this map as a view
348
	 * @param vp information for drawing the layers of this map in the available rectangular area according a projection
334 349
	 */
335 350
	public MapContext(ViewPort vp) {
336 351
		this.layers = new FLayers();//(this,null);
......
343 358
		setViewPort(vp);
344 359

  
345 360
	}
361

  
346 362
	/**
347 363
	 * <p>Creates a new map context with the layers and the drawing information defined in the view port arguments.</p>
348
	 *
364
	 * 
349 365
	 * @param fLayers the initial hierarchy of nodes of layers that this map will have
350
	 * @param vp information for drawing the layers of this map as a view
366
	 * @param vp information for drawing the layers of this map in the available rectangular area according a projection
351 367
	 */
352 368
	public MapContext(FLayers fLayers, ViewPort vp) {
353 369
		this.layers = fLayers;
......
360 376
	}
361 377

  
362 378
	/**
363
	 * <p>Reports to all driver error listeners registered of a bundle of driver exceptions caused in the same map atomic transaction.</p>
364
	 *
379
	 * <p>Reports to all driver error listeners registered of a bundle of driver exceptions caused in the same map atomic transaction.</p> 
380
	 * 
365 381
	 * @param introductoryText introductory text specified by developer. If <code>null</code>, use ""
366 382
	 * @param driverExceptions list with a bundle of driver exceptions caught during an atomic event
367
	 *
383
	 * 
368 384
	 * @see #addErrorListener(ErrorListener)
369 385
	 * @see #removeErrorListener(LegendListener)
370 386
	 * @see #callNewErrorEvent(ErrorEvent)
......
377 393
		}
378 394
	}
379 395

  
380

  
381 396
	/**
382 397
	 * <p>Adds the specified legend listener (if didn't exist) to receive legend events from this map.</p>
383 398
	 *
384 399
	 * @param listener the legend listener
385
	 *
400
	 * 
386 401
	 * @see #removeLayerListener(LegendListener)
387 402
	 * @see #callLegendChanged()
388 403
	 */
......
398 413

  
399 414
	/**
400 415
	 * <p>Adds the specified layer drawing listener to catch and handle drawing events from layers of this map.</p>
401
	 *
416
	 * 
402 417
	 * @param listener the listener to add
403
	 *
418
	 * 
404 419
	 * @see #removeLayerDrawListener(LayerDrawingListener)
405 420
	 * @see #fireLayerDrawingEvent(LayerDrawEvent)
406 421
	 */
407 422
	public void addLayerDrawingListener(LayerDrawingListener listener) {
408 423
		layerDrawingListeners.add(listener);
409 424
	}
425

  
410 426
	/**
411 427
	 * <p>Removes the specified layer drawing listener from this map.</p>
412
	 *
428
	 * 
413 429
	 * @param listener the listener to remove
414
	 *
430
	 * 
415 431
	 * @see #addLayerDrawingListener(LayerDrawingListener)
416 432
	 * @see #fireLayerDrawingEvent(LayerDrawEvent)
417 433
	 */
418 434
	public void removeLayerDrawListener(LayerDrawingListener listener) {
419 435
		layerDrawingListeners.remove(listener);
420 436
	}
437

  
421 438
	/**
422 439
	 * <p>Adds the specified error listener to receive error events from this map.</p>
423
	 *
440
	 * 
424 441
	 * @param listener the listener to add
425
	 *
442
	 * 
426 443
	 * @see #removeErrorListener(LegendListener)
427 444
	 * @see #callNewErrorEvent(ErrorEvent)
428 445
	 * @see #reportDriverExceptions(String, List)
......
430 447
	public void addErrorListener(ErrorListener listener) {
431 448
		errorListeners.add(listener);
432 449
	}
450

  
433 451
	/**
434 452
	 * <p>Removes the specified error listener from this map.</p>
435
	 *
453
	 * 
436 454
	 * @param listener the listener to remove
437
	 *
455
	 * 
438 456
	 * @see #addErrorListener(ErrorListener)
439 457
	 * @see #callNewErrorEvent(ErrorEvent)
440 458
	 * @see #reportDriverExceptions(String, List)
......
450 468

  
451 469
	/**
452 470
	 * <p>Notifies to all legend listeners registered, that one legend has changed.</p>
453
	 * <p>This method must be call only if it's wanted to reflect a legend change.</p>
454
	 *
471
	 * <p>This method must be called only if it's wanted to reflect a legend change.</p>
472
	 * 
455 473
	 * @see #addLayerListener(LegendListener)
456 474
	 * @see #removeLayerListener(LegendListener)
457 475
	 */
......
461 479
		}
462 480
		// getLayers().moveTo(0,0);
463 481
	}
482

  
464 483
	/**
465 484
	 * <p>Fires a layer drawing event to all {@link LayerDrawingListener LayerDrawingListener} listeners registered,
466 485
	 *  distinguishing the kind of event.</p>
467
	 *
486
	 * 
468 487
	 * @param e the event
469 488
	 *
470 489
	 * @see #addLayerDrawingListener(LayerDrawingListener)
......
492 511
		}
493 512
		// getLayers().moveTo(0,0);
494 513
	}
514

  
495 515
	/**
496 516
	 * <p>Notifies to all error listeners registered, that one error has been produced.</p>
497
	 *
517
	 * 
498 518
	 * @param e the event with information of the error
499
	 *
519
	 * 
500 520
	 * @see #addErrorListener(ErrorListener)
501 521
	 * @see #removeErrorListener(LegendListener)
502 522
	 * @see #reportDriverExceptions(String, List)
......
511 531

  
512 532
	/**
513 533
	 * <p>Removes the specified layer listener from this map.</p>
514
	 *
534
	 * 
515 535
	 * @param listener the listener to remove
516
	 *
536
	 * 
517 537
	 * @see #addLayerListener(LegendListener)
518 538
	 * @see #callLegendChanged()
519 539
	 */
......
535 555
		return layers;
536 556
	}
537 557

  
538

  
539 558
	/**
540 559
	 * <p>Draws the visible layers of this map according its view port, on the image parameter.</p>
541 560
	 *
......
560 579
	 * @param scale the scale of the view. Must be between {@linkplain FLayer#getMinScale()} and {@linkplain FLayer#getMaxScale()}.
561 580
	 * @param properties a set with the settings to be applied to a whole print job and to all the documents in the print job
562 581
	 *
563
	 * @throws DriverException if fails using some driver.
564
	 *
582
	 * @throws ReadDriverException if fails reading with driver.
583
	 * 
565 584
	 * @see FLayers#print(Graphics2D, ViewPort, Cancellable, double, PrintRequestAttributeSet)
566 585
	 * @see GraphicLayer#draw(BufferedImage, Graphics2D, ViewPort, Cancellable, double)
567 586
	 */
......
586 605
		layers.print(g, viewPort, cancel, scale, properties);
587 606
		tracLayer.draw(null, g, viewPort, cancel, scale);
588 607
	}
608

  
589 609
	/**
590
	 * <p>Returns a new map with the information of the <code>vp</code> argument, and the layers of this map.</p>
610
	 * <p>Returns a new <code>MapContext</code> instance with the information of the <code>vp</code> argument, and the layers of this map.</p>
591 611
	 *
592
	 * @param vp information for drawing the layers
612
	 * @param vp information for drawing the layers of this map in the available rectangular area according a projection
593 613
	 *
594
	 * @return a new map
614
	 * @return a new <code>MapContext</code> instance projected by <code>vp</code>
595 615
	 */
596 616
	public MapContext createNewFMap(ViewPort vp) {
597 617
		MapContext ret = new MapContext(vp);
......
601 621
	}
602 622

  
603 623
	/**
604
	 * <p>Creates a new independent map, that has a clone of the layers and the view port of this one.</p>
624
	 * <p>Creates a new independent <code>MapContext</code> instance, that has a clone of the layers and the view port of this one.</p>
605 625
	 * <p>The new map will have the same data source drivers to avoid waste memory, and work faster.</p>
606 626
	 *
607
	 * @return the new map
627
	 * @return the new <code>MapContext</code> instance
608 628
	 *
609 629
	 * @throws XMLException if fails cloning the view port or a layer
610
	 *
630
	 * 
611 631
	 * @see FLayer#cloneLayer()
612 632
	 * @see ViewPort#cloneViewPort()
613 633
	 */
......
635 655
//		return createFromXML(getXMLEntity());
636 656

  
637 657
	}
658

  
638 659
	/**
639 660
	 * Like {@linkplain #cloneFMap()}, but now doesn't clone the layers, rather copies them.
640
	 *
661
	 * 
641 662
	 * @return the new map
642 663
	 */
643 664
	public MapContext cloneToDraw() {
......
680 701
	 * <li><code>-1</code> if there is no image
681 702
	 * <li><code>0</code> if there is no extent defined for the image
682 703
	 * </ul>
683
	 *
704
	 * 
684 705
	 * @see #setScaleView(long)
685 706
	 * @see ViewPort#getAdjustedExtent()
686 707
	 * @see IProjection#getScale(double, double, double, double)
......
708 729

  
709 730
	}
710 731

  
711

  
712 732
	/**
713 733
	 * <p>Sets the new extent of the view, calculated using the scale argument.</p>
714 734
	 * <p>Doesn't updates the scale if there isn't information about the dimension of the image or the
715 735
	 *  adjusted extent.</p>
716 736
	 *
717 737
	 * @param scale the new scale for the view
718
	 *
738
	 * 
719 739
	 * @see ViewPort#setProjection(IProjection)
720 740
	 * @see #getScaleView()
721 741
	 */
......
733 753
	}
734 754

  
735 755
	/**
736
	 * Returns the screen resolution (Dots Per Inch) as it was defined by the user's preference, or
737
	 * by default as it is defined in the default Toolkit.
756
	 * <p>Returns the screen resolution (Dots Per Inch) as it was defined by the user's preference, or
757
	 * by default as it is defined in the default Toolkit.</p>
758
	 * 
738 759
	 * @return double with the screen's dpi
739 760
	 */
740 761
	public static double getScreenDPI() {
......
743 764
		double dpi = prefsResolution.getInt("dpi",kit.getScreenResolution());
744 765
		return dpi;
745 766
	}
767

  
746 768
	/**
747 769
	 * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#setVectorial(com.iver.cit.gvsig.fmap.VectorialAdapter)
748 770
	 */
......
806 828
		}
807 829
	}
808 830

  
809
	/*
831
	/**
810 832
	 * @see org.cresques.geo.Projected#reProject(org.cresques.cts.ICoordTrans)
811 833
	 */
812 834
	public void reProject(ICoordTrans arg0) {
......
899 921
	 * <p>Draws this map if its {@link ViewPort ViewPort} has an extent defined:<br>
900 922
	 * <ol>
901 923
	 * <li>Selects only the layers that have to be drawn: {@linkplain #prepareDrawing(BufferedImage, Graphics2D, double)}.
902
	 * <li>Sets quality: antialiasing by text and images, and quality rendering.
924
	 * <li>Sets quality: antialiasing by text and images, and quality rendering. 
903 925
	 * <li>Draws the layers.
904 926
	 * <li>Fires a <code>LayerDrawEvent.GRAPHICLAYER_BEFORE_DRAW</code>.
905 927
	 * <li>Draws the graphic layer.
906 928
	 * <li>Fires a <code>LayerDrawEvent.GRAPHICLAYER_AFTER_DRAW</code>.
907 929
	 * <li>Invokes the garbage collector and memory clean.
908 930
	 * </ol></p>
909
	 *
931
	 * 
910 932
	 * @param image buffer used sometimes instead <code>g</code> to accelerate the draw. For example, if two points are as closed that can't be distinguished, draws only one.
911 933
	 * @param g for rendering 2-dimensional shapes, text and images on the Java(tm) platform
912
	 * @param cancel an object thread that implements the {@link Cancellable Cancellable} interface, and will allow to cancel the draw
934
	 * @param cancel shared object that determines if this layer can continue being drawn
913 935
	 * @param scale the scale of the view. Must be between {@linkplain FLayer#getMinScale()} and {@linkplain FLayer#getMaxScale()}.
914
	 * @throws DriverException if fails using some driver.
936
	 * @throws ReadDriverException if fails reading with the driver.
915 937
	 */
916 938
	public void draw(BufferedImage image, Graphics2D g, Cancellable cancel,
917 939
			double scale) throws ReadDriverException {
......
959 981
		 */
960 982
		System.gc();
961 983
	}
984
	
962 985
	/**
963 986
	 * <p>Checks out layers that need to be repainted.</p>
964 987
	 * <p>If one layer node uses a cache with previous image drawn, but hasn't any, or if it's dirty, then,
965 988
	 *  that layer must be repainted. </p>
966 989
	 * <p>If one layer node needn't to be repainted, checks out it recursively.</p>
967 990
	 * <p><i>The cache of "previous image drawn" allows accelerate the repaint process.</i></p>
968
	 *
991
	 * 
969 992
	 * @see #draw(BufferedImage, Graphics2D, Cancellable, double)
970 993
	 * @see #recursivePrepareDrawing(FLayers, int)
971 994
	 */
......
996 1019
		else
997 1020
			recursivePrepareDrawing(layers);
998 1021
	}
1022

  
999 1023
	/**
1000 1024
	 * <p>Invoked by {@linkplain MapContext#recursivePrepareDrawing(FLayers, int)}. Sets all previous layer nodes
1001 1025
	 *  in the argument as not dirty, what means that don't need to be repainted.</p>
1002 1026
	 * <p>Each layer node can decide validate or not it's sub-layers according its implementation.</p>
1003 1027
	 * <p>This is useful when it's editing, for accelerate the draw, because the layers of a {@link FLayers FLayers} node
1004 1028
	 * are painted according its index in the collection, and each one upper the previous.</p>
1005
	 *
1006
	 * @param layers a node with layers
1029
	 * 
1030
	 * @param layers a node with layers 
1007 1031
	 * @param index index of the current layer in the internal list of layers
1008
	 *
1032
	 * 
1009 1033
	 * @see #recursivePrepareDrawing(FLayers, int)
1010 1034
	 * @see #prepareDrawing(BufferedImage, Graphics2D, double)
1011 1035
	 */
......
1025 1049
//			lyr.setDirty(true);
1026 1050
//		}
1027 1051
	}
1052

  
1028 1053
	/**
1029 1054
	 * <p>Checks out recursively, layers that have a cache with an image of previous layers drawn, and if are dirty
1030 1055
	 * notify the previous layers that are valid.</p>
1031
	 *
1056
	 * 
1032 1057
	 * @param parent node that contains the layers
1033 1058
	 * @param indexInParent the least layer index in the <code>parent</code> argument. This allows reduce the time processing
1034 1059
	 *  if is known that the first layers aren't a collection and will (or won't) be validated
1035
	 *
1060
	 * 
1036 1061
	 * @see #prepareDrawing(BufferedImage, Graphics2D, double)
1037 1062
	 */
1038 1063
	private void recursivePrepareDrawing(FLayers parent)
......
1058 1083

  
1059 1084
	/**
1060 1085
	 * <p>Draws only the internal graphic layer using the information of the {@link ViewPort ViewPort} of this map.</p>
1061
	 *
1086
	 * 
1062 1087
	 * @param image image used to accelerate the screen draw
1063 1088
	 * @param g for rendering 2-dimensional shapes, text and images on the Java(tm) platform
1064
	 * @param cancel an object thread that implements the {@link Cancellable Cancellable} interface, and will allow to cancel the draw
1089
	 * @param cancel shared object that determines if this layer can continue being drawn
1065 1090
	 * @param scale value that represents the scale
1066
	 * @throws DriverException if fails using some driver.
1067
	 *
1091
	 * @throws ReadDriverException if fails reading with the driver.
1092
	 * 
1068 1093
	 * @see GraphicLayer#draw(BufferedImage, Graphics2D, ViewPort, Cancellable, double)
1069 1094
	 */
1070 1095
	public void drawGraphics(BufferedImage image, Graphics2D g,
......
1077 1102
	/**
1078 1103
	 * <p>Like {@linkplain MapContext#draw(BufferedImage, Graphics2D, Cancellable, double)}, but creating
1079 1104
	 *  the task as cancellable.</p>
1080
	 *
1105
	 * 
1081 1106
	 * @param image buffer used sometimes instead <code>g</code> to accelerate the draw. For example, if two points are as closed that can't be distinguished, draws only one.
1082 1107
	 * @param g for rendering 2-dimensional shapes, text and images on the Java(tm) platform
1083 1108
	 * @param scale the scale of the view. Must be between {@linkplain FLayer#getMinScale()} and {@linkplain FLayer#getMaxScale()}.
1084
	 *
1085
	 * @throws DriverException if fails using some driver.
1086
	 *
1109
	 * 
1110
	 * @throws ReadDriverException if the driver fails reading.
1111
	 * 
1087 1112
	 * @see #draw(BufferedImage, Graphics2D, Cancellable, double)
1088 1113
	 */
1089 1114
	public void draw(BufferedImage image, Graphics2D g, double scale)
......
1108 1133
	 * <p>Gets the {@link ViewPort ViewPort} associated to this map.</p>
1109 1134
	 *
1110 1135
	 * @return the view port
1111
	 *
1136
	 * 
1112 1137
	 * @see #setViewPort(ViewPort)
1113 1138
	 */
1114 1139
	public ViewPort getViewPort() {
......
1122 1147
	 *  adds the new one.</p>
1123 1148
	 *
1124 1149
	 * @param viewPort the viewPort
1125
	 *
1150
	 * 
1126 1151
	 * @see #getViewPort()
1127 1152
	 */
1128 1153
	public void setViewPort(ViewPort viewPort) {
......
1149 1174
	 * <p>Returns the union of all extents of all layers of this map.</p>
1150 1175
	 *
1151 1176
	 * @return full extent of layers of this map
1152
	 * @throws DriverException if fails using a driver.
1153
	 *
1177
	 * @throws ReadDriverException if the driver fails reading.
1178
	 * 
1154 1179
	 * @see FLayers#getFullExtent()
1155 1180
	 */
1156 1181
	public Rectangle2D getFullExtent() throws ReadDriverException {
......
1163 1188
	 * <li>XML entity of the internal {@link ViewPort ViewPort}.
1164 1189
	 * <li>XML entity of the internal {@link FLayers FLayers}.
1165 1190
	 * </ul>
1166
	 *
1191
	 * 
1167 1192
	 * @return XMLEntity the XML entity
1168 1193
	 * @throws XMLException if there is any error creating the XML from the map.
1169
	 *
1194
	 * 
1170 1195
	 * @see #createFromXML(XMLEntity)
1171 1196
	 * @see #createFromXML03(XMLEntity)
1172 1197
	 * @see ViewPort#getXMLEntity()
......
1180 1205

  
1181 1206
		return xml;
1182 1207
	}
1208

  
1183 1209
	/**
1184
	 * <p>Creates a new <code>MapContext</code> from an XML entity, with
1210
	 * <p>Creates a new <code>MapContext</code> instance from an XML entity, with
1185 1211
	 *  the data of the {@link ViewPort ViewPort} and
1186 1212
	 *  {@link FLayers FLayers}.</p>
1187 1213
	 *
1188 1214
	 * @param xml an XML entity
1189 1215
	 *
1190
	 * @return the new <code>MapContext</code>
1216
	 * @return the new <code>MapContext</code> instance
1191 1217
	 *
1192 1218
	 * @throws XMLException if there is any error creating the map from the XML.
1193
	 *
1219
	 * 
1194 1220
	 * @see #getXMLEntity()
1195 1221
	 * @see #createFromXML(XMLEntity)
1196 1222
	 * @see ViewPort#createFromXML03(XMLEntity)
......
1205 1231
	}
1206 1232

  
1207 1233
	/**
1208
	 * <p>Creates a new <code>MapContext</code> from an XML entity, with
1234
	 * <p>Creates a new <code>MapContext</code> instance from an XML entity, with
1209 1235
	 *  with the data of the {@link ViewPort ViewPort} and
1210 1236
	 *  {@link FLayers FLayers}.</p>
1211 1237
	 *
1212 1238
	 * @param xml an XML entity
1213 1239
	 *
1214
	 * @return the new <code>MapContext</code>
1240
	 * @return the new <code>MapContext</code> instance
1215 1241
	 *
1216 1242
	 * @throws XMLException if there is any error creating the map from the XML.
1217
	 *
1243
	 * 
1218 1244
	 * @see #getXMLEntity()
1219 1245
	 * @see #createFromXML03(XMLEntity)
1220 1246
	 * @see ViewPort#createFromXML(XMLEntity)
......
1234 1260
	 * @param listener the new listener
1235 1261
	 *
1236 1262
	 * @return <code>true</code> if has added the listener successfully
1237
	 *
1238
	 * @see #removeAtomicEventListener(AtomicEventListener)
1263
	 * 
1264
	 * @see #removeAtomicEventListener(AtomicEventListener) 
1239 1265
	 * @see EventBuffer#addAtomicEventListener(AtomicEventListener)
1240 1266
	 */
1241 1267
	public boolean addAtomicEventListener(AtomicEventListener listener) {
......
1246 1272
	 * <p>Removes a listener of atomic events from the internal {@link EventBuffer EventBuffer}.</p>
1247 1273
	 *
1248 1274
	 * @param listener the listener to remove
1249
	 *
1275
	 * 
1250 1276
     * @return <tt>true</tt> if the list contained the specified element
1251
	 *
1277
	 * 
1252 1278
	 * @see #addAtomicEventListener(AtomicEventListener)
1253 1279
	 * @see EventBuffer#removeAtomicEventListener(AtomicEventListener)
1254 1280
	 */
......
1258 1284

  
1259 1285
	/**
1260 1286
	 * @see EventBuffer#beginAtomicEvent()
1261
	 *
1287
	 * 
1262 1288
	 * @see #endAtomicEvent()
1263 1289
	 */
1264 1290
	public void beginAtomicEvent() {
......
1267 1293

  
1268 1294
	/**
1269 1295
	 * @see EventBuffer#endAtomicEvent()
1270
	 *
1296
	 * 
1271 1297
	 * @see #beginAtomicEvent()
1272 1298
	 */
1273 1299
	public void endAtomicEvent() {
......
1282 1308
	 * @author Fernando Gonz?lez Cort?s
1283 1309
	 */
1284 1310
	public class LayerEventListener implements LayerCollectionListener {
1285
		/**
1311
		/*
1286 1312
		 * @see com.iver.cit.gvsig.fmap.layers.LayerCollectionListener#layerAdded(com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent)
1287 1313
		 */
1288 1314
		public void layerAdded(LayerCollectionEvent e) {
......
1303 1329
			FLayer lyr = e.getAffectedLayer();
1304 1330
			selectionListener(lyr);
1305 1331
		}
1332

  
1306 1333
		/**
1307 1334
		 * <p>Registers an event buffer as a listener for all layers as argument.</p>
1308 1335
		 *
1309 1336
		 * <p>Each {@link FLayer FLayer} of this map must have an event buffer for all kind
1310 1337
		 * of specific listeners of that layer. This method distinguish between {@link Classifiable Classifiable},
1311
		 * {@link AlphanumericData AlphanumericData}, and {@link FLayers FLayers} layers, and for each one,
1312
		 * registers, for their specific listeners, the <code>eventBuffer</code> as a listener.</p>
1313
		 *
1338
		 * {@link AlphanumericData AlphanumericData}, and {@link FLayers FLayers} layers, and for each one, 
1339
		 * registers, for their specific listeners, the <code>eventBuffer</code> as a listener.</p> 
1340
		 * 
1314 1341
		 * @param the layer or layers
1315 1342
		 */
1316 1343
		private void selectionListener(FLayer lyr){
......
1395 1422
				throws CancelationException {
1396 1423
		}
1397 1424
	}
1425

  
1398 1426
	/**
1399
	 * <p>Adds the {@link LayerEventListener LayerEventListener} of this map to the
1400
	 *  collection of layers argument.</p>
1401
	 *
1427
	 * <p>Adds the {@link LayerEventListener LayerEventListener} of this map to the 
1428
	 *  collection of layers argument.</p> 
1429
	 * 
1402 1430
	 * @param a collection of layers
1403 1431
	 */
1404 1432
	public void addAsCollectionListener(FLayers layers2) {
1405 1433
		layers2.addLayerCollectionListener(layerEventListener);
1406 1434
	}
1435

  
1407 1436
	/**
1408 1437
	 * <p>Returns the internal {@link GraphicLayer GraphicLayer}.</p>
1409
	 *
1438
	 * 
1410 1439
	 * @return the graphic layer of this map
1411
	 *
1440
	 * 
1412 1441
	 * @see #setGraphicsLayer(GraphicLayer)
1413 1442
	 */
1414 1443
	public GraphicLayer getGraphicsLayer() {
......
1417 1446

  
1418 1447
	/**
1419 1448
	 * <p>Sets a new {@link GraphicLayer GraphicLayer} to this map.</p>
1420
	 *
1449
	 * 
1421 1450
	 * @param graphicLayer the new graphic layer
1422
	 *
1451
	 * 
1423 1452
	 * @see #getGraphicsLayer()
1424 1453
	 */
1425 1454
	public void setGraphicsLayer(GraphicLayer graphicLayer) {
1426 1455
		tracLayer = graphicLayer;
1427 1456
	}
1457

  
1428 1458
	/**
1429 1459
	 * <p>Indicates whether some other object is "equal to" this map.</p>
1430 1460
	 * <p>Returns <code>true</code> if success one of this options:
1431
	 * <ol>
1461
	 * <ul>
1432 1462
	 * <li>Both objects are equal according to {@linkplain Object#equals(Object)}.
1433 1463
	 * <li>Both maps have the same layers.
1434 1464
	 * <li>Both maps have the same number of layers and with the same name.
1435
	 * </ol>
1465
	 * </ul>
1436 1466
	 * </p>
1437
	 *
1467
	 * 
1438 1468
	 * @param obj the reference object with which to compare.
1439
     * @return <code>true</code> if this object is the same as the <code>arg0</code> argument; <code>false</code> otherwise.
1440
	 *
1469
     * @return <code>true</code> if this object is the same as the <code>arg0</code> argument;  otherwise <code>false</code>.
1470
	 *  
1441 1471
	 * @see Object#equals(Object)
1442 1472
	 */
1443 1473
	public boolean equals(Object arg0) {
......
1461 1491
		}
1462 1492
		return isEqual;
1463 1493
	}
1494

  
1464 1495
	/**
1465 1496
	 * <p>Registers the message of an error associated to this map.</p>
1466
	 *
1497
	 * 
1467 1498
	 * @param stringProperty the error message
1468
	 *
1499
	 * 
1469 1500
	 * @see #getLayersError()
1470 1501
	 * @see #clearErrors()
1471 1502
	 */
1472 1503
	public void addLayerError(String stringProperty) {
1473 1504
		layersError.add(stringProperty);
1474 1505
	}
1506

  
1475 1507
	/**
1476
	 * <p>Gets the list with all errors messages registered to this map.</p>
1477
	 *
1508
	 * <p>Gets the list with all error messages registered to this map.</p>
1509
	 * 
1478 1510
	 * @return the list of errors registered to this map
1479
	 *
1511
	 * 
1480 1512
	 * @see #addLayerError(String)
1481 1513
	 * @see #clearErrors()
1482 1514
	 */
1483 1515
	public ArrayList getLayersError() {
1484 1516
		return layersError;
1485 1517
	}
1518

  
1486 1519
	/**
1487 1520
	 * <p>Removes all error messages associated to this map.</p>
1488
	 *
1521
	 * 
1489 1522
	 * @see #addLayerError(String)
1490 1523
	 * @see #getLayersError()
1491 1524
	 */
1492 1525
	public void clearErrors() {
1493 1526
		layersError.clear();
1494 1527
	}
1528

  
1495 1529
	/**
1496 1530
	 * <p>Removes from this map, all caching images of drawn layers, registered.</p>
1497
	 *
1531
	 * 
1498 1532
	 * @see #clearCachingImageDrawnLayers(FLayers)
1499 1533
	 */
1500 1534
	public void clearAllCachingImageDrawnLayers() {
1501 1535
		clearCachingImageDrawnLayers(this.layers);
1502 1536
	}
1537
	
1503 1538
	/**
1504 1539
	 * <p>Removes from the layer collection argument, all caching images of drawn layers, registered.</p>
1505
	 *
1540
	 * 
1506 1541
	 * @param layers a layer collection
1507
	 *
1542
	 * 
1508 1543
	 * @see #clearAllCachingImageDrawnLayers()
1509 1544
	 */
1510 1545
	private void clearCachingImageDrawnLayers(FLayers layers){
......
1520 1555
		}
1521 1556
	}
1522 1557

  
1523

  
1524

  
1558
	/**
1559
	 * <p>Creates and returns a new group of layers that belongs to this <code>MapContext</code>.</p>
1560
	 * 
1561
	 * @param parent layer node in this <code>MapContexte</code> that will be the parent of the new node
1562
	 * @return the new layer node
1563
	 */
1525 1564
	public FLayers getNewGroupLayer(FLayers parent) {
1526 1565
		FLayers group1 = new FLayers();//(this,parent);
1527 1566
		group1.setMapContext(this);

Also available in: Unified diff