Revision 20100 branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/MapControl.java

View differences:

MapControl.java
79 79

  
80 80

  
81 81
/**
82
 * MapControl.
82
 * <p>A component that includes a {@link MapContext MapContext} with support for use it as a particular {@link Behavior Behavior}.</p>
83 83
 *
84
 * <p>A developer can register a set of <code>Behavior</code>, but only one (that can be a composition of several) of them can be active. The active one
85
 *  defines the way to work and access with its <code>MapContext</code>'s layers. The active behavior, in combination with the appropriate
86
 *  {@link ToolListener ToolListener} will allow user work with a particular <i>tool</i>.</p>
87
 *
88
 * <p>All mouse events produced on this component will be delegated to the current active behavior, the <i>currentMapTool</i>.</p>
89
 * 
90
 * <p><b>Drawing process:</b></p>
91
 * 
92
 * <p>Uses a double buffer for the drawing process of <code>MapContext</code>'s information.</p>
93
 * 
94
 * <p>If the double buffer wasn't created, creates a new one.</p>
95
 * 
96
 * <p>Paints the component according the following algorithm:
97
 * <br>
98
 *  &nbsp If <i>status</i> is <i>UPDATED</i>:<br>
99
 *  &nbsp &nbsp If there is a <i>double buffer</i>:<br>
100
 *  &nbsp &nbsp &nbsp If there is a <i>behavior</i> for managing the <code>MapControl</code> instance, delegates
101
 *   the drawing process to that behavior, calling: <code><i>behavior_instance</i>.paintComponent(g)</code>.<br>
102
 *  &nbsp &nbsp &nbsp Else, repaints the current graphical information quickly calling: <code>g.drawImage(image,0,0,null)</code>.<br>
103
 *  &nbsp Else, (<i>status</i> is <i>OUTDATED</i>, or <i>ONLY_GRAPHICS</i>): executes a quickly repaint of the previous information calling <code>g.drawImage(image,0,0,null)</code>, and creates
104
 *   a <i>painting request</i> to delegate the heavy drawing process to the {@link Drawer2 Drawer2}'s worker thread, according the <i>SingleWorketThread</i> pattern, starting a timer to update
105
 *   (invoking <code>repaint()</code>) the view every delay of 360 ms. during that heavy drawing process. The <i>painting request</i> once is being attended, invokes <code>MapContext</code> to
106
 *   draw the layers: <code>mapContext.draw(image, g, cancel,mapContext.getScaleView());</code> 
107
 * <br>
108
 * <p>Some notes:
109
 *  <ul>
110
 *   <li>The painting process can be cancelled calling {@link #cancelDrawing() #cancelDrawing()}.</li>
111
 *   <li>At last resort, the particular implementation of each layer in a <code>MapControl</code>'s <code>MapContrext</code>
112
 *    will be that one which will draw the graphical information, and, if supports, which could cancel its drawing subprocess.</li>
113
 *   <li>It's possible to force repaint all layers, calling {@link #drawMap(boolean doClear) #drawMap(boolean)}.</li>
114
 *   <li>It's possible repaint only the dirty layers, calling {@link #rePaintDirtyLayers() #rePaintDirtyLayers()}.</li>
115
 *   <li>It's possible repaint only the {@link GraphicLayer GraphicLayer}, calling {@link #drawGraphics() #drawGraphics()}.</li>
116
 *  </ul> 
117
 * </p>
118
 * 
119
 * <p><b>Tools:</b></p>
120
 * 
121
 * <p>A developer can:
122
 *   <ul>
123
 *    <li>Register each tool as:
124
 *     <ul>
125
 *      <li>A single behavior: {@link #addMapTool(String, Behavior) #addMapTool(String, Behavior)}.</li>
126
 *      <li>Or, a compound behavior: {@link #addMapTool(String, Behavior) #addMapTool(String, Behavior)}.</li>
127
 *     </ul>
128
 *    </li>
129
 *    <li>Get the current active tool: {@link #getCurrentMapTool() #getCurrentMapTool()}.</li>
130
 *    <li>Get the current active tool name: {@link #getCurrentTool() #getCurrentTool()}.</li>
131
 *    <li>Get a registered tool: {@link #getMapTool(String) #getMapTool(String)}.</li>
132
 *    <li>Get the name of all tools registered: {@link #getMapToolsKeySet() #getMapToolsKeySet()}.</li>
133
 *    <li>Get all tools registered, including the name they were registered: {@link #getNamesMapTools() #getNamesMapTools()}.</li>
134
 *    <li>Determine if has a tool registered: {@link #hasTool(String) #hasTool(String)}.</li>
135
 *    <li>Set as an active tool, one of the registered: {@link #setTool(String) #setTool(String)}.</li>
136
 *    <li>Set as active tool, the previous used: {@link #setPrevTool() #setPrevTool()}.</li>
137
 *   </ul>
138
 * </p>
139
 *
140
 * <p><b>Exception listener:</b></p>
141
 * 
142
 * <p> Adding an <code>ExceptionListener</code>, can get notification about any exception produced: 
143
 *  <ul>
144
 *   <li>Attending a <i>painting request</i>.</li>
145
 *   <li>Working with the active tool.</li>
146
 *   <li>Applying a <i>zoom in</i> or <i>zoom out</i> operation.</li>
147
 *  </ul>
148
 * </p>
149
 * 
150
 * <p><b>Other:</b></p>
151
 * 
152
 * <p>Other useful capabilities of <code>MapControl</code>:
153
 *   <ul>
154
 *    <li>Cancel the current drawing process (notifying it also to the inner
155
 *     <code>MapContext</code> instance and its layers): {@link #cancelDrawing() #cancelDrawing()}.</li>
156
 *    <li>Applying a <i>zoom in</i> operation centered at mouse position (without a <code>ToolListener</code>): {@link #zoomIn() #zoomIn()}.</li>
157
 *    <li>Applying a <i>zoom out</i> operation centered at mouse position (without a <code>ToolListener</code>): {@link #zoomOut() #zoomOut()}.</li>
158
 *   </ul>
159
 * </p>
160
 * 
161
 * @see CancelDraw
162
 * @see Drawer2
163
 * @see MapContextListener
164
 * @see MapToolListener
165
 * 
84 166
 * @author Fernando Gonz?lez Cort?s
85 167
 */
86
public class MapControl extends JComponent implements ComponentListener,
87
			CommandListener {
88
	/** Cuando la vista est? actualizada. */
168
public class MapControl extends JComponent implements ComponentListener, CommandListener {
169
	/**
170
	 * <p>One of the possible status of <code>MapControl</code>. Determines that all visible information has been
171
	 * drawn and its updated.</p> 
172
	 */
89 173
	public static final int ACTUALIZADO = 0;
90 174

  
91
	/** Cuando la vista est? desactualizada. */
175
	/**
176
	 * <p>One of the possible status of <code>MapControl</code>. Determines that not all visible information has been
177
	 * drawn or isn't updated.</p> 
178
	 */
92 179
	public static final int DESACTUALIZADO = 1;
93
    public static final int ONLY_GRAPHICS = 2;
180
	
181
	/**
182
	 * <p>One of the possible status of <code>MapControl</code>. Determines that only the graphical layer must
183
	 * be drawn / updated.</p> 
184
	 */
185
	public static final int ONLY_GRAPHICS = 2;
186

  
94 187
    // public static final int FAST_PAINT = 3;
95 188
	//private static Logger logger = Logger.getLogger(MapControl.class.getName());
189

  
190
    /**
191
     * <p>Inner model with the layers, event support for drawing them, and the <code>ViewPort</code>
192
     *  with information to adapt to the bounds available in <i>image coordinates</i>.</p>
193
     *  
194
     * @see #getMapContext()
195
     * @see #setMapContext(MapContext) 
196
     */
96 197
	private MapContext mapContext = null;
97
    //private boolean drawerAlive = false;
198

  
199
	//private boolean drawerAlive = false;
200

  
201
	/**
202
	 * <p>All registered <code>Behavior</code> that can define a way to work with this <code>MapControl</code>.</p>
203
	 * 
204
	 * <p>Only one of them can be active at a given moment.</p>
205
	 * 
206
	 * @see #addMapTool(String, Behavior)
207
	 * @see #addMapTool(String, Behavior[])
208
	 * @see #getMapTool(String)
209
	 * @see #getMapToolsKeySet() 
210
	 * @see #getNamesMapTools()
211
	 */
98 212
	private HashMap namesMapTools = new HashMap();
213

  
214
	/**
215
	 * <p>Active {@link Behavior Behavior} that will generate events according a criterion, and then, with a {@link ToolListener ToolListener}
216
	 *  associated, will simulate to user that works with this component as a particular tool.</p>
217
	 *  
218
	 * @see #getCurrentMapTool()
219
	 * @see #getCurrentTool()
220
	 * @see #setTool(String) 
221
	 */
99 222
	private Behavior currentMapTool = null;
223

  
224
	/**
225
	 * <p>Determines which's the current drawn status of this component:
226
	 * <ul>
227
	 *  <li><b>OUTDATED</b>: all visible information has been drawn or isn't updated.</li>
228
	 *  <li><b>UTDATED</b>: all visible information has been drawn and its updated.</li>
229
	 *  <li><b>ONLY_GRAPHICS</b>: only the graphical layer must be drawn / updated.</li>
230
	 * </ul>
231
	 * </p>
232
	 * 
233
	 * <p>The <code>MapControl</code> drawing process will consider the value of this parameter to decide which elements will
234
	 *  be updated or drawn.</p>
235
	 */
100 236
	private int status = DESACTUALIZADO;
237

  
238
	/**
239
	 * <p>Image with a buffer to accelerate the draw the changes of the graphical items in this component.</p>
240
	 * 
241
	 * <p>Firstly, information will be drawn in the buffer, and, when is outright drawn, that information will be displayed.
242
	 * Meanwhile, the previous image can be kept showed.</p>
243
	 * 
244
	 * @see BufferedImage
245
	 * 
246
	 * @see #getImage()
247
	 */
101 248
	private BufferedImage image = null;
249

  
250
	/**
251
	 * <p>Name of the tool used currently to interact with this component.</p>
252
	 * 
253
	 * @see #getCurrentTool()
254
	 * @see #setTool(String) 
255
	 */
102 256
	private String currentTool;
257

  
258
	/**
259
	 * <p>Object to store the flag that notifies a drawing thread task and <code>MapContext</code>'s layers,
260
	 * that must be canceled or can continue with the process.</p>
261
	 * 
262
	 * @see #cancelDrawing()
263
	 */
103 264
	private CancelDraw canceldraw;
265

  
104 266
	//private boolean isCancelled = true;
267

  
268
	/**
269
	 * <p>Fires an action events after a specified delay.</p>
270
	 * 
271
	 * <p><code>MapControl</code> will use the timer to update its visible graphical information during
272
	 *  a drawing process, or allowing to cancel that process.</p>
273
	 * 
274
	 * <p>This is very useful to pretend faster interactivity to user when <code>MapControl</code> has
275
	 *  lots of layers, and / or layers with heavy graphical elements, that need a long time to finish
276
	 *  drawing all its data.</p> 
277
	 */
105 278
	private Timer timer;
279

  
280
	/**
281
	 * <p>Reference to the {@link ViewPort ViewPort} of the {@link MapContext MapContext} of this component.</p>
282
	 * 
283
	 * <p>The view port once is created an instance of <code>MapControl</code>,
284
	 *  is obtained from the <i>EPSG:23030</i> projection, that's the default projection for this component.</p>
285
	 *  
286
	 * <p>After, the view port will change adapting itself according the current projection and the extent.</p>
287
	 * 
288
	 * @see #getViewPort()
289
	 * 
290
	 * @see ViewPort
291
	 */
106 292
	protected ViewPort vp;
293

  
107 294
	//private Drawer drawer;
108
    private Drawer2 drawer2;
109
    // private boolean firstDraw = true;
295

  
296
	/**
297
	 * <p>Manager of all <code>MapControl</code> painting requests.</p>
298
	 */
299
	private Drawer2 drawer2;
300

  
301
	// private boolean firstDraw = true;
302

  
303
	/**
304
	 * <p>Listener of all kind of mouse events produced in this component.</p>
305
	 * 
306
	 * <p>Delegates each mouse event to the current map tool.</p>
307
	 * 
308
	 * @see #addMapTool(String, Behavior)
309
	 * @see #addMapTool(String, Behavior[])
310
	 * @see #getMapTool(String)
311
	 * @see #getMapToolsKeySet()
312
	 * @see #getNamesMapTools()
313
	 * @see #setTool(String)
314
	 */
110 315
	protected MapToolListener mapToolListener = new MapToolListener();
316

  
317
	/**
318
	 * <p>Listener of all events produced in a this component's <code>MapContext</code>
319
	 * object during an atomic period of time.</p>
320
	 */
111 321
	private MapContextListener mapContextListener = new MapContextListener();
322

  
323
	/**
324
	 * <p>Group of <code>ExceptionListener</code> that, in whatever moment could be notified a Throwable Java error or exception.</p>
325
	 * 
326
	 * @see #addExceptionListener(ExceptionListener)
327
	 * @see #removeExceptionListener(ExceptionListener)
328
	 */
112 329
	private ExceptionHandlingSupport exceptionHandlingSupport = new ExceptionHandlingSupport();
113 330

  
331
	/**
332
	 * <p>Name of the previous tool used to interact with this component.</p>
333
	 * 
334
	 * @see #setPrevTool()
335
	 */
114 336
	private String prevTool;
115 337

  
116 338
	/**
......
119 341
    // private boolean paintEnabled = false;
120 342

  
121 343
	/**
122
	 * Crea un nuevo NewMapControl.
344
	 * <p>Creates a new <code>MapControl</code> instance with the following characteristics:
345
	 * <ul>
346
	 *  <li><i>Name</i>: MapControl .</li>
347
	 *  <li>Disables the double buffer of <code>JComponent</code> .</li>
348
	 *  <li>Sets opaque <i>(see {@link JComponent#setOpaque(boolean)} )</i>. </li>
349
	 *  <li>Sets its status to <code>OUTDATED</code> .</li>
350
	 *  <li>Creates a new {@link CancelDraw CancelDraw} object to notify <code>MapContext</code>'s layers if can continue processing the drawn or must cancel it.</li>
351
	 *  <li>Creates a new {@link MapContext MapContext} with a new {@link ViewPort ViewPort} in the projection <i>"EPSG:23030"</i> .</li>
352
	 *  <li>Creates a new {@link CommandListener CommandListener} for edition operations.</li>
353
	 *  <li>Creates a new {@link MapToolListener MapToolListener}, and associates it as a listener of whatever kind of mouse events produced in this component.</li>
354
	 *  <li>Creates a new {@link Drawer2 Drawer2} for managing the painting requests.</li>
355
	 *  <li>Creates a new timer that will refresh each 360 milliseconds the visible graphical information, when is running a drawing process.</li>
356
	 * </ul>
357
	 * </p>
123 358
	 */
124 359
	public MapControl() {
125 360
		this.setName("MapControl");
......
154 389
	}
155 390

  
156 391
	/**
157
	 * Inserta el modelo.
158
	 *
159
	 * @param model FMap.
392
	 * <p>Sets a <code>MapContext</code> to this component.</p>
393
	 * 
394
	 * <p>The <code>MapContext</code> has the <i>model</i>, and most of the <i>view</i>,
395
	 * and <i>control</i> logic of the layers of this component, including a {@link ViewPort ViewPort} to adapt the
396
	 * information to the projection, and to display it in the available area.</p>
397
	 * 
398
	 * <p>If <code>model</code> hadn't a <code>ViewPort</code>, assigns the current one to it, otherwise, use its <code>ViewPort</code>.</p>
399
	 * 
400
	 * <p>After assigning the <code>MapContext</code> and <code>ViewPort</code>, sets the same {@link MapContextListener MapContextListener}
401
	 *  that was using, and changes the <i>status</i> to <code>OUTDATED</code>.</p>
402
	 * 
403
	 * @param model this component's <code>MapContext</code>, that includes the <code>ViewPort</code>.
404
	 * 
405
	 * @see MapContext
406
	 * 
407
	 * @see #getMapContext()
160 408
	 */
161 409
	public void setMapContext(MapContext model) {
162 410
		if (mapContext != null) {
......
180 428
	}
181 429

  
182 430
	/**
183
	 * Devuelve la proyecci?n.
431
	 * <p>Gets this component's {@link MapContext MapContext} projection.</p>
184 432
	 *
185
	 * @return Proyecci?n.
433
	 * @return this component's {@link MapContext MapContext} projection
434
	 * 
435
	 * @see MapContext#getProjection()
436
	 * @see MapControl#setProjection(IProjection)
186 437
	 */
187 438
	public IProjection getProjection() {
188 439
		return getMapContext().getProjection();
189 440
	}
190 441

  
191 442
	/**
192
	 * Inserta una proyecci?n.
443
	 * <p>Sets the projection to this component's {@link MapContext MapContext}.</p>
193 444
	 *
194
	 * @param proj Proyecci?n.
445
	 * @param proj the kind of projection to this component's {@link MapContext MapContext}
446
	 * 
447
	 * @see MapContext#setProjection(IProjection)
448
	 * @see MapControl#getProjection()
195 449
	 */
196 450
	public void setProjection(IProjection proj) {
197 451
		getMapContext().setProjection(proj);
198 452
	}
199 453

  
200 454
	/**
201
	 * Devuelve el modelo.
202
	 *
203
	 * @return FMap.
455
	 * <p>Gets this component's <code>MapContext</code>, with the <i>model</i>, and most of the <i>view</i>,
456
	 * and <i>control</i> logic of the layers of this component, including a {@link ViewPort ViewPort} to adapt the
457
	 * information to the projection, and display it in the available area.</p>
458
	 * 
459
	 * @return this component's <code>MapContext</code>, that includes the <code>ViewPort</code> used to project the
460
	 * graphical information, and display it in the available area
461
	 * 
462
	 * @see MapContext
463
	 * 
464
	 * @see MapControl#setMapContext(MapContext)
204 465
	 */
205 466
	public MapContext getMapContext() {
206 467
		return mapContext;
207 468
	}
208 469

  
209 470
	/**
210
	 * Registra una herramienta (tool).
471
	 * <p>Registers a new behavior to this component.</p>
472
	 * 
473
	 * <p>According the nature of the {@link Behavior Behavior}, different events will be generated. Those
474
	 *  events can be caught by a particular {@link ToolListener ToolListener}, allowing user to interact with this
475
	 *  <code>MapControl</code> object as a <i>tool</i>.</p>
211 476
	 *
212
	 * @param name Nombre de la herramienta.
213
	 * @param tool Herramienta.
477
	 * @param name name to identify the behavior to add
478
	 * @param tool the behavior to add
479
	 * 
480
	 * @see #addMapTool(String, Behavior[])
481
	 * @see #getNamesMapTools()
482
	 * @see #getMapToolsKeySet()
483
	 * @see #hasTool(String)
214 484
	 */
215 485
	public void addMapTool(String name, Behavior tool) {
216 486
		namesMapTools.put(name, tool);
217 487
		tool.setMapControl(this);
218 488
	}
219 489

  
490
	/**
491
	 * <p>Registers a new behavior to this component as a {@link CompoundBehavior CompoundBehavior} made up of <code>tools</code>.</p>
492
	 * 
493
	 * <p>According the nature of the behaviors registered, different events will be generated. Those
494
	 *  events can be caught by a particular {@link ToolListener ToolListener}, allowing user to interact with this
495
	 *  <code>MapControl</code> object as a <i>tool</i>.</p>
496
	 *
497
	 * @param name name to identify the compound behavior to add
498
	 * @param tools the compound behavior to add
499
	 * 
500
	 * @see #addMapTool(String, Behavior)
501
	 * @see #getNamesMapTools()
502
	 * @see #getMapToolsKeySet()
503
	 * @see #hasTool(String)
504
	 */
220 505
	public void addMapTool(String name, Behavior[] tools){
221 506
		CompoundBehavior tool = new CompoundBehavior(tools);
222 507
		addMapTool(name, tool);
223 508
	}
224 509

  
225 510
	/**
226
	 * Devuelve una herramienta (tool) registrada.
511
	 * <p>Gets the <code>Behavior</code> registered in this component, identified
512
	 *  by <code>name</code>.</p>
227 513
	 *
228
	 * @param name Nombre de la herramienta.
229
	 * @return tool Herramienta.
514
	 * @param name name of a registered behavior
515
	 * 
516
	 * @return tool the registered behavior in this component as <code>name</code>, or <code>null</code> if
517
	 *  no one has that identifier
518
	 *  
519
	 * @see #addMapTool(String, Behavior)
520
	 * @see #addMapTool(String, Behavior[])
521
	 * @see #hasTool(String)
230 522
	 */
231 523
	public Behavior getMapTool(String name) {
232 524
		return (Behavior)namesMapTools.get(name);
233 525
	}
234 526

  
235 527
	/**
236
	 * Devuelve los nombres de herramientas (tool) registradas.
528
	 * <p>Returns a set view of the keys that identified the tools
529
	 *  registered.</p>
237 530
	 *
238
	 * @return Set (String) nombres de las herramientas.
531
	 * @return a set view of the keys that identified the tools registered
532
	 * 
533
	 * @see HashMap#keySet()
534
	 * 
535
	 * @see #getNamesMapTools()
536
 	 * @see #addMapTool(String, Behavior)
537
 	 * @see #addMapTool(String, Behavior[])
239 538
	 */
240 539
	public Set getMapToolsKeySet() {
241 540
		return namesMapTools.keySet();
242 541
	}
243 542

  
244

  
245 543
	/**
246
	 * Returns true if this map control contains a tool named with the value
247
	 * passed in the toolName parameter. If you have added two tools with the
248
	 * same name, the last tool will overwrite the previous ones.
249
	 * @param toolName
250
	 * @return true if the map control contains a tool with the same name than
251
	 * 		toolName. False, otherwise.
544
	 * <p>Returns <code>true</code> if this component contains a tool identified by <code>toolName</code>.</p>
545
	 * 
546
	 * @param toolName identifier of the tool
547
	 * 
548
	 * @return <code>true</code> if this component contains a tool identified by <code>toolName</code>; otherwise <code>false</code>
549
	 * 
550
	 * @see #addMapTool(String, Behavior)
551
	 * @see #addMapTool(String, Behavior[])
252 552
	 */
253 553
	public boolean hasTool(String toolName) {
254 554
		return namesMapTools.containsKey(toolName);
255 555
	}
556

  
256 557
	/**
257
	 * DOCUMENT ME!
258
	 *
259
	 * @param toolName DOCUMENT ME!
558
	 * <p>Sets as current active <code>Behavior</code> associated to this component, that one which
559
	 *  is registered and identified by <code>toolName</code>.</p>
560
	 * 
561
	 * <p>Changing the current active behavior for this <code>MapControl</code>, implies also updating the
562
	 *  previous <i>behavior</i> tool, and the current cursor.</p>
563
	 * 
564
	 * @param toolName name of a registered behavior
565
	 * 
566
	 * @see #getCurrentMapTool()
567
	 * @see #getCurrentTool()
260 568
	 */
261 569
	public void setTool(String toolName) {
262 570
		prevTool=getCurrentTool();
......
265 573
		currentTool = toolName;
266 574
		this.setCursor(mapTool.getCursor());
267 575
	}
576

  
577
	/**
578
	 * <p>Gets as current active <code>Behavior</code> associated to this component, that one which
579
	 *  is registered and identified by <code>toolName</code>.</p>
580
	 * 
581
	 * <p>Changing the current active behavior for this <code>MapControl</code>, implies also updating the
582
	 *  previous <i>behavior</i> tool, and the current cursor.</p>
583
	 * 
584
	 * @param toolName name of a registered behavior
585
	 * 
586
	 * @see #getCurrentTool()
587
	 * @see #setTool(String)
588
	 */
268 589
	public Behavior getCurrentMapTool(){
269 590
		return currentMapTool;
270 591
	}
592

  
271 593
	/**
272
	 * Returns the name of the current selected tool on this MapControl
594
	 * <p>Returns the name of the current selected tool on this MapControl</p>
273 595
	 *
274
	 * @return A tool name.
596
	 * @return the name of the current's behavior tool associated to this component
597
	 * 
598
	 * @see #getCurrentMapTool()
599
	 * @see #setTool(String)
275 600
	 */
276 601
	public String getCurrentTool() {
277 602
		return currentTool;
278 603
	}
279 604

  
280

  
281 605
	/**
282
	 * Cancela el dibujado. Se espera a que la cancelaci?n surta efecto
606
	 * <p>Determines that current drawing process of <code>MapControl</code>'s <code>MapContext</code>'s data must be canceled.</p>
607
	 * 
608
	 * <p>It has no effects if now isn't drawing that graphical information.</p>
609
	 *  
610
	 * <p>At last resort, the particular implementation of each layer in this <code>MapControl</code>'s <code>MapContrext</code>
611
     *   will be that one which will draw the graphical information, and, if supports, which could cancel its drawing subprocess.</p>
283 612
	 */
284 613
	public void cancelDrawing() {
285 614
		/* if (drawer != null) {
......
304 633
        drawerAlive = false; */
305 634
	}
306 635

  
636
	/**
637
	 * <p>Creates a {@link BufferedImage BufferedImage} image if there was no buffered image, or if
638
	 *  its viewport's image height or width is different from this component's size. Once has created
639
	 *  a double-buffer, fills it with the vieport's background color, or with <i>white</i> if it had no background color.</p>
640
	 * 
641
	 * <p>If no double-buffered existed, creates a {@link BufferedImage BufferedImage} with the size of this component,
642
	 * and as an image with 8-bit RGBA color components packed into integer pixels. That image has a <code>DirectColorModel</code> with alpha.
643
	 * The color data in that image is considered not to be premultiplied with alpha.</p> 
644
	 * 
645
	 * <p>Once has created and filled the new inner <code>MapControl</code>'s double-buffer, changes the status to
646
	 * <code>OUTDATED</code>.</p>
647
	 * 
648
	 * @return <code>true</code> if has created and filled a new double-buffer for this <code>MapControl</code> instance; otherwise <code>false</code>
649
	 */
307 650
    private boolean adaptToImageSize()
308 651
    {
309 652
        if ((image == null) || (vp.getImageWidth() != this.getWidth()) || (vp.getImageHeight() != this.getHeight()))
......
335 678
    }
336 679

  
337 680
	/**
338
	 * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
681
	 * <p>Paints the graphical information of this component using a double buffer.</p>
682
	 * 
683
	 * <p>If the double buffer wasn't created, creates a new one.</p>
684
	 * 
685
	 * <p>Paints the component according the following algorithm:
686
	 * <br>
687
	 *  &nbsp If <i>status</i> is <i>UPDATED</i>:<br>
688
	 *  &nbsp &nbsp If there is no <i>double buffer</i>:<br>
689
	 *  &nbsp &nbsp &nbsp If there is a <i>behavior</i> for managing the <code>MapControl</code> instance, delegates
690
	 *   the drawing process to that behavior, calling: <code><i>behavior_instance</i>.paintComponent(g)</code> &nbsp .<br>
691
	 *  &nbsp &nbsp &nbsp Else, repaints the current graphical information quickly calling: <code>g.drawImage(image,0,0,null)</code> &nbsp .<br>
692
	 *  &nbsp Else, (<i>status</i> is <i>OUTDATED</i>, or <i>ONLY_GRAPHICS</i>): executes a quickly repaint of the previous information calling <code>g.drawImage(image,0,0,null)</code>, and creates
693
	 *   a <i>painting request</i> to delegate the heavy drawing process to the {@link Drawer2 Drawer2}'s worker thread, according the <i>SingleWorketThread</i> pattern, starting a timer to update
694
	 *   (invoking <code>repaint()</code> that comprises invoke this method) the view every delay of 360 ms. during the the process drawing.</p>
695
	 * 
696
  	 * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
697
  	 * @see Drawer2
339 698
	 */
340 699
	protected void paintComponent(Graphics g) {
341 700
        adaptToImageSize();
......
362 721
	}
363 722

  
364 723
	/**
365
	 * Devuelve la imagen de la vista.
366
	 *
367
	 * @return imagen.
724
	 * <p>Gets the {@link BufferedImage BufferedImage} used to accelerate the draw of new ''frames'' with changes, 
725
	 * or new graphical items in this component.</p>
726
	 * 
727
	 * @return double buffered image used by this component to accelerate the draw of its graphical information, or
728
	 * <code>null</code> if isn't already created
729
	 * 
730
	 * @see BufferedImage 
368 731
	 */
369 732
	public BufferedImage getImage() {
370 733
		return image;
371 734
	}
372 735

  
373 736
	/**
374
	 * Marca el mapa para que en el pr?ximo redibujado se acceda a la
375
	 * cartograf?a para reobtener la imagen
376
	 * @param doClear Solo deber?a ser true cuando se llama desde pan
737
	 * <p>Forces repaint all visible graphical information in this component.</p>
738
	 * 
739
	 * <p>If <code>doClear == true</code>, before repainting, clears the background color, with the
740
	 *  inner viewport's background color.</p>
741
	 *
742
	 * @param doClear <code>true</code> if needs clearing the background color before drawing the map
743
	 * 
744
	 * @see #cancelDrawing()
745
	 * @see FLayers#setDirty(boolean)
377 746
	 */
378 747
	public void drawMap(boolean doClear) {
379 748
		cancelDrawing();
......
397 766
		repaint();
398 767
	}
399 768

  
769
	/**
770
	 * <p>Cancels any current drawing process, changing the status to <code>OUTDATED</code>, and forcing
771
	 * repaint only the layers dirty.</p>
772
	 * 
773
	 * @see #cancelDrawing()
774
	 */
400 775
	public void rePaintDirtyLayers()
401 776
	{
402 777
		cancelDrawing();
......
404 779
        repaint();
405 780
	}
406 781

  
782
	/**
783
	 * <p>Cancels any current drawing process, changing the status to <code>ONLY_GRAPHICS</code>, and forcing
784
	 * repaint only the graphical layer of the <code>MapContext</code>.</p>
785
	 */
407 786
    public void drawGraphics() {
408 787
        status = ONLY_GRAPHICS;
409 788
        repaint();
......
444 823
	}
445 824

  
446 825
	/**
447
	 * A?ade un listener de tipo ExceptionListener.
448
	 *
449
	 * @param o ExceptionListener.
826
	 * @see ExceptionHandlingSupport#addExceptionListener(ExceptionListener)
450 827
	 */
451 828
	public void addExceptionListener(ExceptionListener o) {
452 829
		exceptionHandlingSupport.addExceptionListener(o);
453 830
	}
454 831

  
455 832
	/**
456
	 * Borra la ExceptioListener que se pasa como par?metro.
457
	 *
458
	 * @param o ExceptionListener.
459
	 *
460
	 * @return True si se borra correctamente.
833
	 * @see ExceptionHandlingSupport#removeExceptionListener(ExceptionListener)
461 834
	 */
462 835
	public boolean removeExceptionListener(ExceptionListener o) {
463 836
		return exceptionHandlingSupport.removeExceptionListener(o);
464 837
	}
465 838

  
466 839
	/**
467
	 * Lanza una Excepci?n.
468
	 *
469
	 * @param t Excepci?n.
840
	 * @see ExceptionHandlingSupport#throwException(Throwable)
470 841
	 */
471 842
	protected void throwException(Throwable t) {
472 843
		exceptionHandlingSupport.throwException(t);
473 844
	}
474 845

  
475

  
846
	/**
847
	 * <p>Represents each <code>MapControl</code>'s data painting request.</p>
848
	 * 
849
	 * <p>The request will be attended by a <code>Drawer2</code>, which will hold it since the <code>Drawer2</code>'s worker
850
	 *  takes it, or arrives a new painting request, which will replace it.</p> 
851
	 */
476 852
    private class PaintingRequest
477 853
    {
478

  
854
    	/**
855
    	 * <p>Creates a new <code>PaintingRequest</p> instance.</p>
856
    	 */
479 857
        public PaintingRequest()
480 858
        {
481 859
        }
482 860

  
861
        /**
862
         * <p><code>MapControl</code> paint process:</p>
863
         * 
864
         * <p>
865
         *  <ul>
866
         *   <li><i>1.- </i>Cancels all previous <code>MapControl</code>'s drawing processes.</li>
867
         *   <li><i>2.- </i>If <i>status</i> was OUTDATED:
868
         *    <ul>
869
         *     <li><i>2.1.- </i>Fills the background color with viewport's background color, or <i>white</i> if it was undefined.</li>
870
         *     <li><i>2.2.- </i>Sets <i>status</i> to UPDATED.</li>
871
         *     <li><i>2.3.- </i>Notifies <i>MapContext</i> to be drawn invoking: <code>mapContext.draw(double-buffer, double-buffer's buffer, shared cancel-draw object, mapContext.getScaleView());</code>.</li>
872
         *    </ul>
873
         *   </li>
874
         *   <li><i>3.- </i>Else, if <i>status</i> was ONLY_GRAPHICS:
875
         *    <ul>
876
         *     <li><i>3.1.- </i>Sets <i>status</i> to UPDATED.</li>
877
         *     <li><i>3.2.- </i>Notifies <i>MapContext</i> to be drawn invoking: <code>mapContext.drawGraphics(double-buffer, double-buffer's buffer, shared cancel-draw object, mapContext.getScaleView());</code>.</li>
878
         *    </ul>
879
         *   </li>
880
         *   <li><i>4.- </i>Stops the <i>timer</i>.</li>
881
         *   <li><i>5.- </i>Repaints this component invoking: <code>repaint();</code></li>
882
         *  </ul>
883
         * </p>
884
         * 
885
         * @see #cancelDrawing()
886
         * @see MapContext#draw(BufferedImage, Graphics2D, Cancellable, double)
887
         * @see MapContext#drawGraphics(BufferedImage, Graphics2D, Cancellable, double)
888
         * 
889
         * @see ViewPort
890
         */
483 891
        public void paint()
484 892
        {
485 893
            try
......
552 960

  
553 961
    }
554 962

  
963

  
555 964
    /**
965
     * <p>An instance of <code>Drawer2</code> could manage all <code>MapControl</code> painting requests.</p>
966
     * 
967
     * <p>Based on the <i>WorkerThread</i> software pattern, creates a worker thread that will attend sequentially
968
     *  the current waiting painting request, after finishing the previous (that could be by a cancel action).</p>
969
     * 
970
     * <p>All new {@link PaintingRequest PaintingRequest} generated will be stored as <i>waiting requests</i> since the worker
971
     * attends it.</p>
972
     * 
973
     * <p>If a worker finished and there was no <i>painting request</i>, the worker would be set to wait until any
974
     *  <i>painting request</i> would be put.</p>
975
     * 
556 976
     * @author fjp
557
     *
558
     * Basasdo en el patr?n WorkerThread
559
     *
560 977
     */
561 978
    public class Drawer2
562 979
    {
563 980
        // Una mini cola de 2. No acumulamos peticiones de dibujado
564 981
        // dibujamos solo lo ?ltimo que nos han pedido.
565
        private PaintingRequest paintingRequest;
566
        private PaintingRequest waitingRequest;
567 982

  
983
    	/**
984
    	 * <p>Painting request that's been attended by the <code>Drawer2</code>'s worker.</p>
985
    	 * 
986
    	 * @see #put(com.iver.cit.gvsig.fmap.MapControl.PaintingRequest)
987
    	 * @see #take()
988
    	 */
989
    	private PaintingRequest paintingRequest;
990

  
991
    	/**
992
    	 * <p>Painting request waiting to be attended by the <code>Drawer2</code>'s worker.</p>
993
    	 * 
994
    	 * @see #put(com.iver.cit.gvsig.fmap.MapControl.PaintingRequest)
995
    	 * @see #take()
996
    	 */
997
    	private PaintingRequest waitingRequest;
998

  
999
    	/**
1000
    	 * <p>Determines that the <code>Drawer2</code>'s worker is busy attending a painting request.</p> 
1001
     	 * 
1002
    	 * @see #put(com.iver.cit.gvsig.fmap.MapControl.PaintingRequest)
1003
    	 * @see #take()
1004
    	 */
568 1005
        private boolean waiting;
1006

  
1007
    	/**
1008
    	 * <p>Notifies the <code>Drawer2</code>'s worker to finish or continue with its process.</p>
1009
    	 * 
1010
    	 * @see #setShutdown(boolean)
1011
    	 */
569 1012
        private boolean shutdown;
570 1013

  
1014
        /**
1015
         * <p>Sets this <code>Drawer2</code>'s worker to finish or continue with its process.</p>
1016
         * 
1017
         * @param isShutdown a boolean value
1018
         */
571 1019
        public void setShutdown(boolean isShutdown)
572 1020
        {
573 1021
            shutdown = isShutdown;
574 1022
        }
575 1023

  
1024
        /**
1025
         * <p>Creates a new drawer for managing all data painting requests in <code>MapControl</code>.</p>
1026
         * 
1027
         * <p>Includes the following steps:
1028
         *  <ul>
1029
         *   <li>By default, there is no <i>current painting request</i>.</li>
1030
         *   <li>By default, there is no <i>waiting painting request</i>.</li>
1031
         *   <li>By default, the worker thread is waiting no <i>painting request</i>.</li>
1032
         *   <li>By default, the worker thread is running.</li>
1033
         *   <li>Creates and starts a worker thread for attending the <i>painting requests</i>.</li>
1034
         *  </ul>
1035
         * </p>
1036
         */
576 1037
        public Drawer2()
577 1038
        {
578 1039
            paintingRequest = null;
......
582 1043
            new Thread(new Worker()).start();
583 1044
        }
584 1045

  
1046
        /**
1047
         * <p>Sets a <code>PaintingRequest</code> to be attended by the worker thread of this object. If 
1048
         *  this one was waiting, wakes up.</p>
1049
         * 
1050
         * <p>All waiting threads will be notified synchronized.</p>
1051
         * 
1052
         * @param newPaintRequest
1053
         * 
1054
         * @see #take()
1055
         */
585 1056
        public void put(PaintingRequest newPaintRequest)
586 1057
        {
587 1058
            waitingRequest = newPaintRequest;
......
593 1064
            }
594 1065
        }
595 1066

  
1067
        /**
1068
         * <p>Used by this object's worker, returns the current waiting drawing request, causing current thread
1069
         *  to wait until another thread invokes {@link #put(com.iver.cit.gvsig.fmap.MapControl.PaintingRequest) #put(com.iver.cit.gvsig.fmap.MapControl.PaintingRequest)},
1070
         *  if there was no waiting request.</p>
1071
         * 
1072
         * <p>All threads will access synchronized to the waiting request.</p>
1073
         * 
1074
         * @return <code>PaintingRequest</code> that was waiting to be attended
1075
         * 
1076
         * @see #put(com.iver.cit.gvsig.fmap.MapControl.PaintingRequest)
1077
         */
596 1078
        public PaintingRequest take()
597 1079
        {
598 1080
            if (waitingRequest == null)
......
613 1095
            return paintingRequest;
614 1096
        }
615 1097

  
616

  
1098
        /**
1099
         * <p>Thread for attending painting requests.</p>
1100
         * 
1101
         * <p>If there was no double buffer, sets the status to <code>OUTDATED</code> and finishes, otherwise
1102
         *  takes the painting request (it's probably that would wait some time), cancel the previous drawing
1103
         *  process, and starts processing the request.</p>
1104
         * 
1105
         * @see Thread
1106
         */
617 1107
        private class Worker implements Runnable
618 1108
        {
619
            public void run()
1109
        	/*
1110
        	 * (non-Javadoc)
1111
        	 * @see java.lang.Runnable#run()
1112
        	 */
1113
        	public void run()
620 1114
            {
621 1115
                while (!shutdown)
622 1116
                {
......
633 1127
    }
634 1128

  
635 1129
	/**
636
	 * Clase utilizada para dibujar las capas.
1130
	 * <p><code>Drawer</code> is implemented for drawing the layers of a <code>MapControl</code>'s <i>MapContext</i> instance
1131
	 *  as a <i>thread</i> of execution.</p>
1132
	 *  
1133
	 * <p>Draws <code>MapControl</code> according its <i>status</i>:
1134
	 *  <ul>
1135
	 *   <li><code><i>ONLY_GRAPHICS</i></code>: refreshes only the graphical layer, changing the status to <code><i>UPDATED</i></code>, via
1136
	 *    {@linkplain MapContext#drawGraphics(BufferedImage, Graphics2D, Cancellable, double) MapContext#drawGraphics(BufferedImage, Graphics2D, Cancellable, double)}.</li>
1137
	 *   <li><code><i>OUTDATED</i></code>: refreshes all layers, changing the status to <code><i>UPDATED</i></code>, via
1138
	 *    {@linkplain MapContext#draw(BufferedImage, Graphics2D, Cancellable, double) MapContext#draw(BufferedImage, Graphics2D, Cancellable, double)}.</li>
1139
	 *  <ul>
1140
	 * </p>
1141
	 * 
1142
	 * <p>This drawing process is accelerated by a <code>BufferedImage</code>, and can be canceled.</p>
1143
	 * 
1144
	 * <p>Once the drawing process has finished, the timer stops and this component gets repainted.</p> 
637 1145
	 *
1146
	 * @deprecated
638 1147
	 * @author Vicente Caballero Navarro
639 1148
	 */
640 1149
	public class Drawer extends Thread {
641 1150
		//private Graphics g;
1151
		
1152
		/**
1153
		 * <p>Image with a buffer to accelerate the draw the changes of the graphical items in this component.</p>
1154
		 * 
1155
		 * <p>Firstly, information will be drawn in the buffer, and, when is outright drawn, that information will be displayed.
1156
		 * Meanwhile, the previous image can be kept showed.</p>
1157
		 * 
1158
		 * @see BufferedImage
1159
		 */
642 1160
		private BufferedImage image = null;
1161

  
1162
		/**
1163
		 * <p>Object to store the flag that notifies the drawing must be canceled or can continue with the process.</p>
1164
		 * 
1165
		 * <p>At last resort, the particular implementation of each layer in a <code>MapControl</code>'s <code>MapContrext</code>
1166
         *   will be which will draw the graphical information, and, if supports, which could cancel its drawing subprocess.</p>
1167
		 */
643 1168
		private CancelDraw cancel;
644 1169
		//private boolean threadCancel = false;
645 1170

  
1171

  
646 1172
		/**
647
		 * Crea un nuevo Drawer.
648
		 *
1173
		 * <p>Creates a new <code>Drawer</code> instance.</p>
649 1174
		 */
650 1175
		public Drawer(BufferedImage image, CancelDraw cancel)
651 1176
        {
......
656 1181

  
657 1182
		/**
658 1183
		 * @see java.lang.Runnable#run()
1184
		 * @see MapContext#draw(BufferedImage, Graphics2D, Cancellable, double)
1185
		 * @see MapContext#drawGraphics(BufferedImage, Graphics2D, Cancellable, double)
659 1186
		 */
660 1187
		public void run() {
661 1188
			try {
......
699 1226
	}
700 1227

  
701 1228
	/**
702
	 * Clase para cancelar el dibujado.
1229
	 * <p>An instance of <code>CancelDraw</code> will be shared by all this <code>MapControl</code>'s <code>MapContext</code> layers,
1230
	 *  allowing receive a notification that, when they're been drawn, to be cancelled.</p>
703 1231
	 *
1232
	 * @see Cancellable
1233
	 *
704 1234
	 * @author Fernando Gonz?lez Cort?s
705 1235
	 */
706 1236
	public class CancelDraw implements Cancellable {
1237
		/**
1238
		 * <p>Determines if the drawing task must be canceled or not.</p>
1239
		 * 
1240
		 * @see #isCanceled()
1241
		 * @see #setCanceled(boolean)
1242
		 */
707 1243
		private boolean cancel = false;
708 1244

  
709 1245
		/**
710
		 * Crea un nuevo CancelDraw.
1246
		 * Creates a new <code>CancelDraw</code> object.
711 1247
		 */
712 1248
		public CancelDraw() {
713 1249
		}
714 1250

  
715
		/**
716
		 * Insertar si se debe cancelar el dibujado.
717
		 *
718
		 * @param b true si se debe cancelar el dibujado.
1251
		/*
1252
		 * (non-Javadoc)
1253
		 * @see com.iver.utiles.swing.threads.Cancellable#setCanceled(boolean)
719 1254
		 */
720 1255
		public void setCanceled(boolean b) {
721 1256
			cancel = b;
722 1257
		}
723 1258

  
724
		/**
1259
		/*
1260
		 * (non-Javadoc)
725 1261
		 * @see com.iver.utiles.swing.threads.Cancellable#isCanceled()
726 1262
		 */
727 1263
		public boolean isCanceled() {
......
729 1265
		}
730 1266
	}
731 1267

  
732

  
733 1268
	/**
734
	 * Listener del MapTool.
1269
	 * <p>Listens all kind of mouse events produced in {@link MapControl MapControl}, and invokes its current
1270
	 *  map tool <i>({@link MapControl#getCurrentMapTool() MapControl#getCurrentMapTool()}</i> to simulate a behavior.</p>
1271
	 *  
1272
	 * <p>Mouse wheel moved events produce a <i>zoom in</i> operation if wheel rotation is negative, or a <i>zoom out</i>
1273
	 *  if its positive. Both will be centered in the position of the mouse, but, meanwhile <i>zoom in</i> operation
1274
	 *  applies a factor of 0.9, <i>zoom out</i> operation applies a factor of 1.2</p>
1275
	 *  
1276
	 * <p>Mouse wheel moved events can be produced as much frequently, that between each one, the drawing process could
1277
	 *  hadn't finished. This is the reason that, in this situation, cancels always the previous drawing process before
1278
	 *  applying a <i>zoom</i> operation, and ignores all new mouse positions that are produced before 1 second.</p>
735 1279
	 *
736 1280
	 * @author Fernando Gonz?lez Cort?s
737 1281
	 */
738 1282
	public class MapToolListener implements MouseListener, MouseWheelListener,
739 1283
		MouseMotionListener {
740 1284

  
1285
		/**
1286
		 * <p>Used to avoid mouse wheel move events closed.</p>
1287
		 * 
1288
		 * <p>If a mouse wheel move event is produced 
1289
		 */
741 1290
		long t1;
1291

  
1292
		/**
1293
		 * <p>Position of the mouse, in map coordinates.</p>
1294
		 * 
1295
		 * <p>This point coordinates will be used as center of the <i>zoom</i> operation.</p>
1296
		 */
742 1297
		Point2D pReal;
1298

  
743 1299
		/**
744 1300
		 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
1301
		 * @see Behavior#mouseClicked(MouseEvent)
745 1302
		 */
746 1303
		public void mouseClicked(MouseEvent e) {
747 1304
			try {
......
753 1310

  
754 1311
		/**
755 1312
		 * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
1313
		 * @see Behavior#mouseEntered(MouseEvent)
756 1314
		 */
757 1315
		public void mouseEntered(MouseEvent e) {
758 1316
			try {
......
764 1322

  
765 1323
		/**
766 1324
		 * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
1325
		 * @see Behavior#mouseExited(MouseEvent)
767 1326
		 */
768 1327
		public void mouseExited(MouseEvent e) {
769 1328
			try {
......
775 1334

  
776 1335
		/**
777 1336
		 * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
1337
		 * @see Behavior#mousePressed(MouseEvent)
778 1338
		 */
779 1339
		public void mousePressed(MouseEvent e) {
780 1340
			try {
......
786 1346

  
787 1347
		/**
788 1348
		 * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
1349
		 * @see Behavior#mouseReleased(MouseEvent)
789 1350
		 */
790 1351
		public void mouseReleased(MouseEvent e) {
791 1352
			try {
......
797 1358

  
798 1359
		/**
799 1360
		 * @see java.awt.event.MouseWheelListener#mouseWheelMoved(java.awt.event.MouseWheelEvent)
1361
		 * @see Behavior#mouseWheelMoved(MouseWheelEvent)
800 1362
		 */
801 1363
		public void mouseWheelMoved(MouseWheelEvent e) {
802 1364
			try {
......
861 1423

  
862 1424
		/**
863 1425
		 * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
1426
		 * @see Behavior#mouseDragged(MouseEvent)
864 1427
		 */
865 1428
		public void mouseDragged(MouseEvent e) {
866 1429
			try {
......
872 1435

  
873 1436
		/**
874 1437
		 * @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
1438
		 * @see Behavior#mouseMoved(MouseEvent)
875 1439
		 */
876 1440
		public void mouseMoved(MouseEvent e) {
877 1441
			try {
......
883 1447
	}
884 1448

  
885 1449
	/**
886
	 * Listener sobre el MapContext.
1450
	 * <p<code>MapContextListener</code> listens all events produced in a <code>MapControl</code>'s <code>MapContext</code>
1451
	 * object during an atomic period of time, and sets it to dirty, <i>executing <code>drawMap(false)</code>, if any of the
1452
	 * following conditions is accomplished</i>:
1453
	 * <ul>
1454
	 *  <li>Any of the <code>LayerEvent</code> in the <code>AtomicEvent</code> parameter notifies a <i>visibility change</i>.</li>
1455
	 *  <li>There is at least one <code>ColorEvent</code> in the <code>AtomicEvent</code> parameter.</li>
1456
	 *  <li>There is at least one <code>ExtentEvent</code> in the <code>AtomicEvent</code> parameter.</li>
1457
	 *  <li>Any of the <code>LayerCollectionEvent</code> in the <code>AtomicEvent</code> parameter notifies that a driver's layer has reloaded it successfully.</li>
1458
	 *  <li>There is at least one <code>LegendEvent</code> in the <code>AtomicEvent</code> parameter.</li>
1459
	 *  <li>There is at least one <code>SelectionEvent</code> in the <code>AtomicEvent</code> parameter.</li>
1460
	 * </ul>
1461
	 * </p>
887 1462
	 *
888 1463
	 * @author Fernando Gonz?lez Cort?s
889 1464
	 */
......
941 1516
			}
942 1517
		}
943 1518
	}
1519

  
1520
	/**
1521
	 * <p>Gets the <code>ViewPort</code> of this component's {@link MapContext MapContext} .</p>
1522
	 * 
1523
	 * @see MapContext#getViewPort()
1524
	 */
944 1525
	public ViewPort getViewPort() {
945 1526
		return vp;
946 1527
	}
947 1528

  
948 1529
	/**
949
	 * Returns a HashMap with the tools that have been registered
950
	 * in the Mapcontrol.
1530
	 * <p>Returns all registered <code>Behavior</code> that can define a way to work with this <code>MapControl</code>.</p>
1531
	 * 
1532
	 * @return registered <code>Behavior</code> to this <code>MapControl</code>
1533
	 * 
1534
	 * @see #addMapTool(String, Behavior)
1535
	 * @see #addMapTool(String, Behavior[])
1536
	 * @see #getMapToolsKeySet()
1537
	 * @see #hasTool(String)
951 1538
	 */
952 1539
	public HashMap getNamesMapTools() {
953 1540
		return namesMapTools;
954 1541
	}
955 1542

  
1543
	/*
1544
	 * (non-Javadoc)
1545
	 * @see com.iver.cit.gvsig.fmap.edition.commands.CommandListener#commandRepaint()
1546
	 */
956 1547
	public void commandRepaint() {
957 1548
		drawMap(false);
958 1549
	}
959 1550

  
1551
	/*
1552
	 * (non-Javadoc)
1553
	 * @see com.iver.cit.gvsig.fmap.edition.commands.CommandListener#commandRefresh()
1554
	 */
960 1555
	public void commandRefresh() {
961 1556
		// TODO Auto-generated method stub
962 1557
	}
963 1558

  
1559
	/**
1560
	 * <p>Equivalent operation to <i>undo</i>.</p>
1561
	 * 
1562
	 * <p>Exchanges the previous tool with the current one.</p>
1563
	 * 
1564
	 * @see #addMapTool(String, Behavior)
1565
	 * @see #addMapTool(String, Behavior[])
1566
	 * @see #setTool(String)
1567
	 */
964 1568
	public void setPrevTool() {
965 1569
		setTool(prevTool);
966 1570
	}
967 1571

  
1572
	/**
1573
	 * <p>Executes a <i>zoom in</i> operation centered at the center of the extent.</p>
1574
	 * 
1575
	 * <p>This implementation is designed for being invoked outside a <code>Behavior</code>, for example
1576
	 *  by an action of pressing a button; and simulates that the event has been produced by 
1577
	 *  releasing the <i>button 1</i> of the mouse using the registered <code>Behavior</code> in this
1578
	 *  <code>MapControl</code> object that's responsible for the <i>zoom in</i> operation.</p>
1579
	 *  
1580
	 * @see #zoomOut()
1581
	 */
968 1582
	public void zoomIn() {
969 1583
		getMapContext().clearAllCachingImageDrawnLayers();
970 1584
		Behavior mapTool = (Behavior) namesMapTools.get("zoomIn");
......
979 1593
			throwException(t);
980 1594
		}
981 1595
	}
1596
	
1597
	/**
1598
	 * <p>Executes a <i>zoom out</i> operation centered at the center of the extent.</p>
1599
	 * 
1600
	 * <p>This implementation is thought for being invoked outside a <code>Behavior</code>, for example
1601
	 *  by an action of pressing a button, and simulates that the event has been produced by 
1602
	 *  releasing the <i>button 1</i> of the mouse using the registered <code>Behavior</code> in this
1603
	 *  <code>MapControl</code> object that's responsible for the <i>zoom out</i> operation.</p>
1604
	 * 
1605
	 * @see #zoomIn()
1606
	 */
982 1607
	public void zoomOut() {
983 1608
		getMapContext().clearAllCachingImageDrawnLayers();
984 1609
		Behavior mapTool = (Behavior) namesMapTools.get("zoomOut");
......
993 1618
			throwException(t);
994 1619
		}
995 1620
	}
1621

  
1622
	/**
1623
	 * <p>Returns the shared <code>CancelDraw</code> object used by this component and its layers drawing processes, that determines
1624
	 *  if the drawing process must be cancelled or can continue running.</p>
1625
	 * 
1626
	 * @return shared object that determines if the layers drawing process of this component can continue or must be cancelled
1627
	 */
996 1628
	public CancelDraw getCanceldraw() {
997 1629
		return canceldraw;
998 1630
	}
999

  
1000 1631
}

Also available in: Unified diff