Revision 14294

View differences:

trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrDefault.java
71 71
import com.iver.utiles.XMLEntity;
72 72

  
73 73
/**
74
 * Implementaci?n de las caracter?sticas de alto nivel de las capas:
75
 * visibilidad, activaci?n, nombre, ...
74
 * <p>Implementation of the high level characteristics of the layers: visibility, activation, name, ...</p>
75
 * 
76
 * <p>Represents a definition of a basic <a href="http://www.gvsig.gva.es/">gvSIG</a> layer, with the implementation of 
77
 *  the <code>FLayer</code> methods, and new functionality: 
78
 * <ul>
79
 *  <li>Supports transparency.
80
 *  <li>Notification of evens produced using this layer.
81
 *  <li>Can have internal virtual layers.
82
 *  <li>Can have a text layer.
83
 *  <li>Supports an strategy for visit its geometries.
84
 *  <li>Can have an image in the <i>TOC (table of contents)</i> associated to the state of this layer.
85
 * </ul>
86
 * </p>
87
 *
88
 * <p>Each graphical layer will inherit from this class and adapt to its particular logic and model.</p>
89
 *
90
 * @see FLayer
76 91
 */
77 92
public abstract class FLyrDefault implements FLayer {
78 93
	// private PropertyChangeSupport lnkPropertyChangeSupport;
94
	/**
95
	 * Useful for debug the problems during the implementation.
96
	 */
79 97
	private static Logger logger = Logger.getLogger(FLyrDefault.class);
80 98
	private LayerChangeSupport layerChangeSupport = new LayerChangeSupport();
81
    
82
	/** Path de la capa en el arbol de capas */
99
	/**
100
	 * Path to the upper layer which this layer belongs.
101
	 * 
102
	 * @see #getParentLayer()
103
	 * @see #setParentLayer(FLayers)
104
	 */
83 105
	private FLayers parentLayer = null;
106
	/**
107
	 * A node in the tree of layers. Isn't used.
108
	 * 
109
	 * @see #getVirtualLayers()
110
	 * @see #setVirtualLayers(FLayers)
111
	 */
84 112
	private FLayers virtualLayers = null;
113
	/**
114
	 * Name for this layer, this also will be a property in the XML entity that represents this layer.
115
	 *
116
	 * @see #getName()
117
	 * @see #setName(String)
118
	 */
85 119
	private String name;
120
	/**
121
	 * Projection for this layer.
122
	 *
123
	 * @see #getProjection()
124
	 * @see #setProjection(IProjection)
125
	 */
86 126
	private IProjection projection;
127
	/**
128
	 * Transparency level of this layer in the range 0-255. By default 0.
129
	 *
130
	 * @see #getTransparency()
131
	 * @see #setTransparency(int)
132
	 */
87 133
	private int transparency = 0;
134
	/**
135
	 * Coordinate transformation.
136
	 *
137
	 * @see #getCoordTrans()
138
	 * @see #setCoordTrans(ICoordTrans)
139
	 */
88 140
	private ICoordTrans ct;
141
	/**
142
	 * Minimum scale, >= 0 or -1 if not defined. By default -1.
143
	 *
144
	 * @see #getMinScale()
145
	 * @see #setMinScale(double)
146
	 */
89 147
	private double minScale = -1; // -1 indica que no se usa
148
	/**
149
	 * Maximum scale, >= 0 or -1 if not defined. By default -1.
150
	 *
151
	 * @see #getMaxScale()
152
	 * @see #setMaxScale(double)
153
	 */
90 154
	private double maxScale = -1;
91 155
//	private boolean isInTOC = true;
156
	/**
157
	 * Array list with all listeners registered to this layer.
158
	 *
159
	 * @see #getLayerListeners()
160
	 * @see #setLayerText(FLyrText)
161
	 * @see #removeLayerListener(LayerListener)
162
	 * @see #callEditionChanged(LayerEvent)
163
	 */
92 164
	protected ArrayList layerListeners = new ArrayList();
165
	/**
166
	 * Strategy of drawing and processing for this layer.
167
	 *
168
	 * @see #getStrategy()
169
	 * @see #setStrategy(Strategy)
170
	 */
93 171
	private Strategy privateStrategy = null;
172
	/**
173
	 * Hash table with the extended properties of this layer.
174
	 *
175
	 * @see #getProperty(Object)
176
	 * @see #setProperty(Object, Object)
177
	 * @see #getExtendedProperties()
178
	 */
94 179
	private Hashtable properties = new Hashtable();
180
	/**
181
	 * Image with bands that stores the information of the drawn layers.
182
	 *
183
	 * @see #getCacheImageDrawnLayers()
184
	 * @see #setCacheImageDrawnLayers(BufferedImage)
185
	 */
95 186
	private BufferedImage cacheImageDrawnLayers = null;
96 187

  
97 188
	//by default, all is active, visible and avalaible
189
	/**
190
	 * Status of this layer.
191
	 *
192
	 * @see #getFLayerStatus()
193
	 * @see #setFLayerStatus(FLayerStatus)
194
	 * @see #isActive()
195
	 * @see #setActive(boolean)
196
	 * @see #isVisible()
197
	 * @see #setVisible(boolean)
198
	 * @see #visibleRequired()
199
	 * @see #isEditing()
200
	 * @see #setEditing(boolean)
201
	 * @see #isInTOC()
202
	 * @see #isCachingDrawnLayers()
203
	 * @see #setCachingDrawnLayers(boolean)
204
	 * @see #isDirty()
205
	 * @see #setDirty(boolean)
206
	 * @see #isAvailable()
207
	 * @see #setAvailable(boolean)
208
	 * @see #isOk()
209
	 * @see #isWritable()
210
	 * @see #getNumErrors()
211
	 * @see #getError(int)
212
	 * @see #getErrors()
213
	 * @see #addError(DriverException)
214
	 */
98 215
	private FLayerStatus status = new FLayerStatus();
99

  
216
	/*
217
	 * (non-Javadoc)
218
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getProperty(java.lang.Object)
219
	 */
100 220
	public Object getProperty(Object key) {
101 221
		return properties.get(key);
102 222
	}
103

  
223
	/*
224
	 * (non-Javadoc)
225
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#setProperty(java.lang.Object, java.lang.Object)
226
	 */
104 227
	public void setProperty(Object key, Object val) {
105 228
		properties.put(key, val);
106 229
	}
107

  
230
	/*
231
	 * (non-Javadoc)
232
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getExtendedProperties()
233
	 */
108 234
	public Map getExtendedProperties() {
109 235
		return properties;
110 236
	}
111
	/**
237
	/*
238
	 * (non-Javadoc)
112 239
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#setActive(boolean)
113 240
	 */
114 241
	public void setActive(boolean selected) {
115 242
		//active = selected;
116 243
		status.active = selected;
117 244
		callActivationChanged(LayerEvent.createActivationChangedEvent(this,
118
				"active"));
245
		"active"));
119 246
	}
120 247

  
121
	/**
248
	/*
249
	 * (non-Javadoc)
122 250
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#isActive()
123 251
	 */
124 252
	public boolean isActive() {
......
126 254
		return status.active;
127 255
	}
128 256

  
129
	/**
257
	/*
258
	 * (non-Javadoc)
130 259
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#setName(java.lang.String)
131 260
	 */
132 261
	public void setName(String name) {
......
134 263
		callNameChanged(LayerEvent.createNameChangedEvent(this, "name"));
135 264
	}
136 265

  
137
	/**
266
	/*
267
	 * (non-Javadoc)
138 268
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getName()
139 269
	 */
140 270
	public String getName() {
......
142 272
	}
143 273

  
144 274
	/*
275
	 * (non-Javadoc)
145 276
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#load()
146 277
	 */
147 278
	public void load() throws LoadLayerException {
148 279
	}
149 280

  
150
	/**
281
	/*
282
	 * (non-Javadoc)
151 283
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#setVisible(boolean)
152
	 */
284
	 */	
153 285
	public void setVisible(boolean visibility) {
154 286
//		visible = visibility;
155 287
		boolean changed = status.visible != visibility;
......
161 293
			}
162 294
		}
163 295
		callVisibilityChanged(LayerEvent.createVisibilityChangedEvent(this,
164
				"visible"));
296
		"visible"));
165 297
	}
166 298

  
167
	/**
299

  
300
	/*
301
	 * (non-Javadoc)
168 302
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#isVisible()
169 303
	 */
170 304
	public boolean isVisible() {
......
172 306
		return status.visible && status.available;
173 307
	}
174 308

  
175
	/**
176
	 * Devuelve la capa padre de la actual.
177
	 *
178
	 * @return FLayers padre.
309
	/*
310
	 * (non-Javadoc)
311
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getParentLayer()
179 312
	 */
180 313
	public FLayers getParentLayer() {
181 314
		return parentLayer;
182 315
	}
183 316

  
184
	/**
185
	 * Inserta la capa padre.
186
	 *
187
	 * @param root
188
	 *            capa padre.
317

  
318
	/*
319
	 * (non-Javadoc)
320
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#setParentLayer(com.iver.cit.gvsig.fmap.layers.FLayers)
189 321
	 */
190 322
	public void setParentLayer(FLayers root) {
191 323
		this.parentLayer = root;
192 324
	}
193 325

  
194
	/**
195
	 * Inserta una proyecci?n.
196
	 *
197
	 * @param proj
198
	 *            Proyecci?n.
326
	/*
327
	 * (non-Javadoc)
328
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#setProjection(org.cresques.cts.IProjection)
199 329
	 */
200 330
	public void setProjection(IProjection proj) {
201 331
		projection = proj;
......
211 341
			}
212 342
	}
213 343

  
214
	/**
344
	/*
345
	 * (non-Javadoc)
215 346
	 * @see org.cresques.geo.Projected#getProjection()
216 347
	 */
217 348
	public IProjection getProjection() {
218 349
		return projection;
219 350
	}
220 351

  
221
	/**
352
	/*
353
	 * (non-Javadoc)
222 354
	 * @see org.cresques.geo.Projected#reProject(org.cresques.cts.ICoordTrans)
223 355
	 */
224 356
	public void reProject(ICoordTrans arg0) {
225 357
	}
226 358

  
227 359
	/**
228
	 * Devuelve el nivel de transparencia de la capa.
360
	 * Returns the transparency level of this layer, in the range 0-255 .
229 361
	 *
230
	 * @return Entero que representa el nivel de transparencia.
362
	 * @return the transparency level
363
	 * 
364
	 * @see #setTransparency(int)
231 365
	 */
232 366
	public int getTransparency() {
233 367
		return transparency;
234 368
	}
235 369

  
236 370
	/**
237
	 * Inserta el nivel de transparencia de la capa.
371
	 * Inserts the transparency level for this layer, the range allowed is 0-255 .
238 372
	 *
239
	 * @param trans
240
	 *            Nivel de transparencia.
373
	 * @param trans the transparency level
374
	 * 
375
	 * @see #getTransparency()
241 376
	 */
242 377
	public void setTransparency(int trans) {
243 378
		transparency = trans;
244 379
		setDirty(true);
245 380
	}
246

  
247 381
	/**
248
	 * Devuelve el XMLEntity a partir del objeto.
382
	 * <p>Returns an entity that represents this layer.</p>
249 383
	 *
250
	 * @return XMLEntity.
251
	 * @throws XMLException
384
	 * <p>This XML entity has elements (properties) that represent and store information about this layer.</p>
385
	 *
386
	 * <p>There are two kinds of information: default properties of this layer, and extended properties (they added that weren't by default)</p>
387
	 *
388
	 * <p> <b>Default properties:</b>
389
	 *  <ul>
390
	 *   <li> className : name of this class
391
	 *   <li> active : if this layer is active or not
392
	 *   <li> name : name of this layer
393
	 *   <li> minScale : minimum scale of this layer
394
	 *   <li> maxScale : maximum scale of this layer
395
	 *   <li> visible : if this layer is visible or not
396
	 *   <li> proj : the projection of this layer (only if it's defined)
397
	 *   <li> transparency : transparency level of this layer
398
	 *   <li> isInTOC : if this layer is in the TOC or not
399
	 *   <li> numProperties : number of extended properties
400
	 *  </ul>
401
	 * </p>
402
	 *
403
	 * <p> <b>Extended properties:</b> are stored as children of the tree-node returned. There are two kinds of information for a child,
404
	 *  according if it's an instance of an <code>String</code> or of an object that implements the interface <code>IPersistance</code>.
405
	 *
406
	 *  <ul>
407
	 *   <li> <i>Instance of <code>String</code>:</i>
408
	 *   <ul>
409
	 *    <li> className : name of the class of the object that it's the property
410
	 *    <li> value : value of the property
411
	 *    <li> layerPropertyName : name of the extended property of the layer
412
	 *   </ul>
413
	 *   <li> <i>Implements <code>IPersistance</code>:</i>
414
	 *   <ul>
415
	 *    <li> Information returned by the implementation of the method <code>getXMLEntity</code> of that object
416
	 *    <li> className : name of the class of the object (this information could be with the information returned by
417
	 *     the method <code>getXMLEntity</code> of that object
418
	 *    <li> layerPropertyName : name of the extended property of the layer
419
	 *   </ul>
420
	 *  <ul>
421
	 * </p>
422
	 *
423
	 * @return an XML entity with information to the current layer
424
	 * @throws com.iver.cit.gvsig.fmap.layers.XMLException if there is an error obtaining the object.
425
	 * 
426
	 * @see #setXMLEntity(XMLEntity)
427
	 * @see #setXMLEntity03(XMLEntity)
252 428
	 */
253 429
	public XMLEntity getXMLEntity() throws XMLException {
254 430
		XMLEntity xml = new XMLEntity();
......
284 460
		Iterator keyitr = keyset.iterator();
285 461
		XMLEntity xmlProperties = new XMLEntity();
286 462
		xmlProperties.putProperty("childName","properties");
287
	    while (keyitr.hasNext()) {
288
	      String propName = (String)keyitr.next();
289
	      Object obj = properties.get(propName);
290
	      if (obj instanceof IPersistence)
291
	      {
292
	    	  IPersistence persistObj = (IPersistence)obj;
293
	          XMLEntity xmlPropObj = persistObj.getXMLEntity();
294
              // make sure the node contains the class name
295
	          if (!xmlPropObj.contains("className")) {
296
	        	  try {
297
	        		  String propClassName = persistObj.getClassName();
298
		        	  System.out.println("PROP CLASS NAME "+propClassName);
299
		        	  xmlPropObj.putProperty("className", propClassName);
300
	        	  } catch (Exception e) {
301
	        		  e.printStackTrace();
302
	        	  }
303
	          }
304
	          xmlPropObj.putProperty("layerPropertyName", propName);
305
	          xmlProperties.addChild(xmlPropObj);
306
	      } else if (obj instanceof String) {
307
	          XMLEntity xmlPropObj = new XMLEntity();
308
        	  xmlPropObj.putProperty("className", String.class.getName());
309
        	  xmlPropObj.putProperty("value",(String)obj);
310
	          xmlPropObj.putProperty("layerPropertyName", propName);
311
	          xmlProperties.addChild(xmlPropObj);
463
		while (keyitr.hasNext()) {
464
			String propName = (String)keyitr.next();
465
			Object obj = properties.get(propName);
466
			if (obj instanceof IPersistence)
467
			{
468
				IPersistence persistObj = (IPersistence)obj;
469
				XMLEntity xmlPropObj = persistObj.getXMLEntity();
470
				// make sure the node contains the class name
471
				if (!xmlPropObj.contains("className")) {
472
					try {
473
						String propClassName = persistObj.getClassName();
474
						System.out.println("PROP CLASS NAME "+propClassName);
475
						xmlPropObj.putProperty("className", propClassName);
476
					} catch (Exception e) {
477
						e.printStackTrace();
478
					}
479
				}
480
				xmlPropObj.putProperty("layerPropertyName", propName);
481
				xmlProperties.addChild(xmlPropObj);
482
			} else if (obj instanceof String) {
483
				XMLEntity xmlPropObj = new XMLEntity();
484
				xmlPropObj.putProperty("className", String.class.getName());
485
				xmlPropObj.putProperty("value",(String)obj);
486
				xmlPropObj.putProperty("layerPropertyName", propName);
487
				xmlProperties.addChild(xmlPropObj);
312 488

  
313
	      }
314
	    }
315
	    if (xmlProperties.getChildrenCount() > 0) {
316
	    	xml.addChild(xmlProperties);
317
	    }
318
	    return xml;
489
			}
490
		}
491
		if (xmlProperties.getChildrenCount() > 0) {
492
			xml.addChild(xmlProperties);
493
		}
494
		return xml;
319 495
	}
320 496

  
321
	/*
322
	 * Inserta los valores de los atributos del XMLEntity al objeto.
497
	/**
498
	 * <p>Inserts information to this layer.</p>
323 499
	 *
324
	 * @param xml XMLEntity.
500
	 * <p>This XML entity has elements that represent and store information about this layer.</p>
325 501
	 *
326
	 * @throws XMLException @throws DriverException @throws DriverIOException
502
	 * <p>The properties are the same as the described in <code>getXMLEntity()</code>. And the properties
503
	 *  <i>proj</i>,  <i>transparency</i>, <i>isInTOC</i>, <i>numProperties</i> are optional.</p>
327 504
	 *
328
	 * public void setXMLEntity03(XMLEntity xml) throws XMLException { active =
329
	 * xml.getBooleanProperty("active"); name = xml.getStringProperty("name");
330
	 * minScale=xml.getDoubleProperty("minScale");
331
	 * maxScale=xml.getDoubleProperty("maxScale"); visible =
332
	 * xml.getBooleanProperty("visible"); if (xml.contains("proj")) {
333
	 * setProjection(ProjectionPool.get(xml.getStringProperty("proj"))); } if
334
	 * (xml.contains("transparency")) transparency =
335
	 * xml.getIntProperty("transparency"); }
336
	 */
337

  
338
	/**
339
	 * Inserta los valores de los atributos del XMLEntity al objeto.
505
	 * @see FLyrDefault#getXMLEntity()
340 506
	 *
341
	 * @param xml
342
	 *            XMLEntity.
507
	 * @param xml an <code>XMLEntity</code> with the information
343 508
	 *
344
	 * @throws XMLException
345
	 * @throws DriverException
346
	 * @throws DriverIOException
509
	 * @throws com.iver.cit.gvsig.fmap.layers.XMLException if there is an error setting the object.
510
	 * 
511
	 * @see #getXMLEntity()
347 512
	 */
348 513
	public void setXMLEntity(XMLEntity xml) throws XMLException {
349 514
//		active = xml.getBooleanProperty("active");
......
364 529

  
365 530

  
366 531

  
367
        // recreate Properties hashTable
532
		// recreate Properties hashTable
368 533

  
369 534
		if (xml.contains("numProperties")) { // for older projects
370 535
			int numProps = xml.getIntProperty("numProperties");
371 536
			Object obj= null;
372 537
			IPersistence objPersist;
373
            for (int iProp=0; iProp<numProps; iProp++) {
374
        	    XMLEntity xmlProp = xml.getChild(0);
375
        	    try {
376
        	    	String className = xmlProp.getStringProperty("className");
377
        	    	if (className.equals(String.class.getName())) {
378
        	    		obj = xmlProp.getStringProperty("value");
379
        	    	} else {
380
	        	        Class classProp = Class.forName(className);
381
		                obj = classProp.newInstance();
382
	    	            objPersist = (IPersistence)obj;
383
	        	        objPersist.setXMLEntity(xmlProp);
384
	                }
385
	                String propName = xmlProp.getStringProperty("layerPropertyName");
386
	                properties.put(propName, obj);
387
        		} catch (Exception e) {
388
        			continue;
389
        		}
390
        		// remove Properties children to avoid breaking layers' XML reading logic
391
        		xml.removeChild(0);
392
            }
538
			for (int iProp=0; iProp<numProps; iProp++) {
539
				XMLEntity xmlProp = xml.getChild(0);
540
				try {
541
					String className = xmlProp.getStringProperty("className");
542
					if (className.equals(String.class.getName())) {
543
						obj = xmlProp.getStringProperty("value");
544
					} else {
545
						Class classProp = Class.forName(className);
546
						obj = classProp.newInstance();
547
						objPersist = (IPersistence)obj;
548
						objPersist.setXMLEntity(xmlProp);
549
					}
550
					String propName = xmlProp.getStringProperty("layerPropertyName");
551
					properties.put(propName, obj);
552
				} catch (Exception e) {
553
					continue;
554
				}
555
				// remove Properties children to avoid breaking layers' XML reading logic
556
				xml.removeChild(0);
557
			}
393 558
		}          // newer projects store properties under a node
394 559
		else {
395 560
			int xmlPropertiesPos = xml.firstIndexOfChild("childName","properties");
......
404 569
				String className;
405 570
				Class classProp;
406 571
				IPersistence objPersist;
407
	            for (int iProp=0; iProp<numProps; iProp++) {
408
	        	    XMLEntity xmlProp = xmlProperties.getChild(iProp);
409
	        	    try {
410
	        	    	className = xmlProp.getStringProperty("className");
411
	        	    	if (className.equals(String.class.getName())) {
412
	        	    		obj = xmlProp.getStringProperty("value");
413
	        	    	} else {
414
	        	    		classProp = Class.forName(className);
415
	        	    		obj = classProp.newInstance();
416
	        	    		objPersist = (IPersistence)obj;
417
	        	    		objPersist.setXMLEntity(xmlProp);
572
				for (int iProp=0; iProp<numProps; iProp++) {
573
					XMLEntity xmlProp = xmlProperties.getChild(iProp);
574
					try {
575
						className = xmlProp.getStringProperty("className");
576
						if (className.equals(String.class.getName())) {
577
							obj = xmlProp.getStringProperty("value");
578
						} else {
579
							classProp = Class.forName(className);
580
							obj = classProp.newInstance();
581
							objPersist = (IPersistence)obj;
582
							objPersist.setXMLEntity(xmlProp);
418 583

  
419
	        	    	}
420
	        	    	String propName = xmlProp.getStringProperty("layerPropertyName");
421
	        	    	properties.put(propName, obj);
422
	        		} catch (Exception e) {
423
	        			//FIXME: OJO !!!!!
424
	        			continue;
425
	        		}
426
	            }
427
	       		// remove Properties children to avoid breaking layers' XML reading logic
428
	        	xml.removeChild(xmlPropertiesPos);
584
						}
585
						String propName = xmlProp.getStringProperty("layerPropertyName");
586
						properties.put(propName, obj);
587
					} catch (Exception e) {
588
						//FIXME: OJO !!!!!
589
						continue;
590
					}
591
				}
592
				// remove Properties children to avoid breaking layers' XML reading logic
593
				xml.removeChild(xmlPropertiesPos);
429 594
			}
430 595
		}
431 596
	}
432 597

  
433 598
	/**
434
	 * Inserta los valores de los atributos del XMLEntity al objeto.
599
	 * <p>Inserts some default properties to the this layer.</p>
435 600
	 *
436
	 * @param xml
437
	 *            XMLEntity.
601
	 * <p> <b>Properties:</b>
602
	 *  <ul>
603
	 *   <li> active : if this layer is active or not
604
	 *   <li> name : name of this layer
605
	 *   <li> minScale : minimum scale of this layer
606
	 *   <li> maxScale : maximum scale of this layer
607
	 *   <li> visible : if this layer is visible or not
608
	 *   <li> proj : the projection of this layer (only if it's defined)
609
	 *   <li> transparency : transparency level of this layer (only if it's defined)
610
	 *  </ul>
611
	 * </p>
438 612
	 *
439
	 * @throws XMLException
440
	 * @throws DriverException
441
	 * @throws DriverIOException
613
	 * @see FLyrDefault#getXMLEntity()
614
	 *
615
	 * @param xml an <code>XMLEntity</code> with the information
616
	 *
617
	 * @throws com.iver.cit.gvsig.fmap.layers.XMLException if there is an error obtaining the object.
618
	 * 
619
	 * @see #getXMLEntity()
620
	 * @see #setXMLEntity(XMLEntity)
442 621
	 */
443 622
	public void setXMLEntity03(XMLEntity xml) throws XMLException {
444 623
//		active = xml.getBooleanProperty("active");
......
455 634
			transparency = xml.getIntProperty("transparency");
456 635
	}
457 636

  
458
	/**
637
	/*
638
	 * (non-Javadoc)
459 639
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getMapContext()
460 640
	 */
461 641
	public MapContext getMapContext() {
......
466 646
		}
467 647
	}
468 648

  
469
	/**
470
	 * A?ade a la lista de listener un nuevo LayerListener.
471
	 *
472
	 * @param o
473
	 *            LayerListener.
474
	 *
475
	 * @return boolean.
649
	/*
650
	 * (non-Javadoc)
651
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#addLayerListener(com.iver.cit.gvsig.fmap.layers.LayerListener)
476 652
	 */
477 653
	public boolean addLayerListener(LayerListener o) {
478 654
		if (layerListeners.contains(o))
479 655
			return false;
480 656
		return layerListeners.add(o);
481 657
	}
658
	/*
659
	 * (non-Javadoc)
660
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getLayerListeners()
661
	 */
482 662
	public LayerListener[] getLayerListeners() {
483 663
		return (LayerListener[])layerListeners.toArray(new LayerListener[0]);
484 664
	}
485
	/**
486
	 * Borra de la lista de listeners el que se pasa como par?metro.
487
	 *
488
	 * @param o
489
	 *            LayerListener a borrar.
490
	 *
491
	 * @return True si ha sido correcto el borrado del Listener.
665
	/*
666
	 * (non-Javadoc)
667
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#removeLayerListener(com.iver.cit.gvsig.fmap.layers.LayerListener)
492 668
	 */
493 669
	public boolean removeLayerListener(LayerListener o) {
494 670
		return layerListeners.remove(o);
495 671
	}
496

  
497 672
	/**
498
	 * Llamada al metodo nameChanged de los Listeners dados de alta.
673
	 * Called by the method {@linkplain #setName(String)}. Notifies all listeners associated to this layer,
674
	 *  that its name has changed.
499 675
	 *
500
	 * @param e
501
	 *            LayerEvent.
676
	 * @param e a layer event with the name of the property that has changed
677
	 * 
678
	 * @see #setName(String)
502 679
	 */
503 680
	private void callNameChanged(LayerEvent e) {
504 681
		for (Iterator iter = layerListeners.iterator(); iter.hasNext();) {
......
509 686
	}
510 687

  
511 688
	/**
512
	 * Llamada al m?todo visibilityChanged de los Listeners.
689
	 * Called by the method {@linkplain #setVisible(boolean)}. Notifies all listeners associated to this layer,
690
	 *  that its visibility has changed.
513 691
	 *
514
	 * @param e
515
	 *            LayerEvent.
692
	 * @param e a layer event with the name of the property that has changed
693
	 * 
694
	 * @see #setVisible(boolean)
516 695
	 */
517 696
	private void callVisibilityChanged(LayerEvent e) {
518 697
		for (Iterator iter = layerListeners.iterator(); iter.hasNext();) {
......
523 702
	}
524 703

  
525 704
	/**
526
	 * Llamada al m?todo activationChanged de los Listener.
705
	 * Called by the method {@linkplain #setActive(boolean)}. Notifies all listeners associated to this layer,
706
	 *  that its active state has changed.
527 707
	 *
528
	 * @param e
529
	 *            LayerEvent.
708
	 * @param e a layer event with the name of the property that has changed
709
	 * 
710
	 * @see #setActive(boolean)
530 711
	 */
531 712
	private void callActivationChanged(LayerEvent e) {
532 713
		for (Iterator iter = layerListeners.iterator(); iter.hasNext();) {
......
537 718
	}
538 719

  
539 720
	/**
540
	 * Devuelve las capas virtuales.
721
	 * Returns the virtual layers associated to this layer.
541 722
	 *
542
	 * @return FLayers.
723
	 * @return a node with the layers
724
	 * 
725
	 * @see #setVirtualLayers(FLayers)
543 726
	 */
544 727
	public FLayers getVirtualLayers() {
545 728
		return virtualLayers;
546 729
	}
547 730

  
548 731
	/**
549
	 * Inserta las capas virtuales.
732
	 * Inserts virtual layers to this layer.
550 733
	 *
551
	 * @param virtualLayers
552
	 *            FLayers.
734
	 * @param virtualLayers a node with the layers
735
	 * 
736
	 * @see #getVirtualLayers()
553 737
	 */
554 738
	public void setVirtualLayers(FLayers virtualLayers) {
555 739
		this.virtualLayers = virtualLayers;
556 740
	}
557 741

  
558 742
	/**
559
	 * Inserta la Transformaci?n de coordenadas.
743
	 * Sets transformation coordinates for this layer.
560 744
	 *
561
	 * @param ct
562
	 *            Transformaci?n de coordenadas.
745
	 * @param ct an object that implements the <code>ICoordTrans</code> interface, and with the transformation coordinates
746
	 * 
747
	 * @see #getCoordTrans()
563 748
	 */
564 749
	public void setCoordTrans(ICoordTrans ct) {
565 750
		this.ct = ct;
566 751
	}
567 752

  
568 753
	/**
569
	 * Devuelve las transformaci?n de coordenadas.
754
	 * Returns the transformation coordinates of this layer.
570 755
	 *
571
	 * @return ct.
756
	 * @return ct an object that implements the <code>ICoordTrans</code> interface, and with the transformation coordinates
757
	 * 
758
	 * @see #setCoordTrans(ICoordTrans)
572 759
	 */
573 760
	public ICoordTrans getCoordTrans() {
574 761
		return ct;
575 762
	}
576 763

  
577 764
	/**
578
	 * M?todo que es llamado por Flayers para notificar a la capa que va a ser
579
	 * a?adida. Esta previa notificaci?n es util para las capas que necesitan
580
	 * hacer algo antes de ser a?adida. Por ejemplo, el raster necesita volver a
581
	 * abrir el fichero que ha podido ser cerrado con anterioridad. Si no se
582
	 * redefine este m?todo no se har? nada ya que este es vacio.
583
	 * @throws LoadLayerException
765
	 * <p>Method called by {@link FLayers FLayers} to notify this layer that is going to be added.
766
	 *  This previous notification is useful for the layers that need do something before being added. For
767
	 *  example, the raster needs reopen a file that could have been closed recently.</p>
584 768
	 */
585 769
	public void wakeUp() throws LoadLayerException {
586 770
	}
587

  
771
	/*
772
	 * (non-Javadoc)
773
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getMinScale()
774
	 */
588 775
	public double getMinScale() {
589 776
		return minScale;
590 777
	}
591 778

  
592 779
	/*
593 780
	 * (non-Javadoc)
594
	 *
595 781
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getMaxScale()
596 782
	 */
597 783
	public double getMaxScale() {
598 784
		return maxScale;
599 785
	}
600

  
786
	/*
787
	 * (non-Javadoc)
788
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#setMinScale(double)
789
	 */
601 790
	public void setMinScale(double minScale) {
602 791
		this.minScale = minScale;
603 792
	}
604

  
793
	/*
794
	 * (non-Javadoc)
795
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#setMaxScale(double)
796
	 */
605 797
	public void setMaxScale(double maxScale) {
606 798
		this.maxScale = maxScale;
607 799
	}
608

  
800
	/*
801
	 * (non-Javadoc)
802
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#isWithinScale(double)
803
	 */
609 804
	public boolean isWithinScale(double scale) {
610 805

  
611 806
		boolean bVisible = true;
......
620 815

  
621 816
		return bVisible;
622 817
	}
623

  
818
	/**
819
	 * Returns the strategy of drawing and processing for this layer.
820
	 *
821
	 * @return an object that implements the <code>Strategy</code> interface.
822
	 * 
823
	 * @see #setStrategy(Strategy)
824
	 */
624 825
	public Strategy getStrategy() {
625 826
		return privateStrategy;
626 827
	}
627

  
828
	/**
829
	 * Inserts the strategy of drawing and processing this layer.
830
	 *
831
	 * @param s an object that implements the <code>Strategy</code> interface.
832
	 * 
833
	 * @see #getStrategy()
834
	 */
628 835
	public void setStrategy(Strategy s) {
629 836
		privateStrategy = s;
630 837
	}
631

  
838
	/*
839
	 * (non-Javadoc)
840
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#setEditing(boolean)
841
	 */
632 842
	public void setEditing(boolean b) throws StartEditionLayerException {
633 843
//		isediting = b;
634 844
		status.editing = b;
635 845
		setDirty(true);
636 846
		setCachingDrawnLayers(b);
637 847
	}
638

  
848
	/**
849
	 * Called by some version of the method {@linkplain #setEditing(boolean)} overwritten. Notifies 
850
	 *  all listeners associated to this layer, that its edition state has changed.
851
	 *
852
	 * @param e a layer event with the name of the property that has changed
853
	 * 
854
	 * @see #setEditing(boolean)
855
	 */
639 856
	protected void callEditionChanged(LayerEvent e) {
640 857
		for (Iterator iter = layerListeners.iterator(); iter.hasNext();) {
641 858
			LayerListener listener = (LayerListener) iter.next();
......
643 860
			listener.editionChanged(e);
644 861
		}
645 862
	}
646

  
863
	/*
864
	 * (non-Javadoc)
865
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#isEditing()
866
	 */
647 867
	public boolean isEditing() {
648 868
//		return isediting;
649 869
		return status.editing;
650 870
	}
651

  
871
	/*
872
	 * (non-Javadoc)
873
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getTocImageIcon()
874
	 */
652 875
	public ImageIcon getTocImageIcon() {
653 876
		return null;
654 877
	}
655

  
878
	/*
879
	 * (non-Javadoc)
880
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#isInTOC()
881
	 */
656 882
	public boolean isInTOC() {
657 883
//		return isInTOC;
658 884
		return status.inTOC;
659 885
	}
886
	/*
887
	 * (non-Javadoc)
888
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#setInTOC(boolean)
889
	 */
660 890
	public void setInTOC(boolean b) {
661 891
		status.inTOC=b;
662 892
	}
663
	/* (non-Javadoc)
893
	/*
894
	 * (non-Javadoc)
664 895
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#isCachingDrawnLayers()
665 896
	 */
666 897
	public boolean isCachingDrawnLayers() {
......
668 899
		return status.cacheDrawnLayers;
669 900
	}
670 901

  
671
	/* (non-Javadoc)
902

  
903
	/*
904
	 * (non-Javadoc)
672 905
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#setCachingDrawnLayers(boolean)
673 906
	 */
674 907
	public void setCachingDrawnLayers(boolean bCacheDrawnLayers) {
......
677 910
		if (status.cacheDrawnLayers == false)
678 911
			this.cacheImageDrawnLayers = null;
679 912
	}
680

  
913
	/*
914
	 * (non-Javadoc)
915
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getCacheImageDrawnLayers()
916
	 */
681 917
	public BufferedImage getCacheImageDrawnLayers() {
682 918
		return cacheImageDrawnLayers;
683 919
	}
684

  
920
	/*
921
	 * (non-Javadoc)
922
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#setCacheImageDrawnLayers(java.awt.image.BufferedImage)
923
	 */
685 924
	public void setCacheImageDrawnLayers(BufferedImage cacheImageDrawnLayers) {
686 925
		this.cacheImageDrawnLayers = cacheImageDrawnLayers;
687 926
	}
688

  
927
	/*
928
	 * (non-Javadoc)
929
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#isDirty()
930
	 */
689 931
	public boolean isDirty() {
690 932
		return status.dirty;
691 933
	}
692

  
934
	/*
935
	 * (non-Javadoc)
936
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#setDirty(boolean)
937
	 */
693 938
	public void setDirty(boolean dirty) {
694 939
		status.dirty = dirty;
695 940
	}
696

  
941
	/*
942
	 * (non-Javadoc)
943
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#isAvailable()
944
	 */
697 945
	public boolean isAvailable() {
698 946
		return status.available;
699 947
	}
700

  
948
	/*
949
	 * (non-Javadoc)
950
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#setAvailable(boolean)
951
	 */
701 952
	public void setAvailable(boolean available) {
702 953
		status.available = available;
703 954
	}
704

  
955
	/*
956
	 * (non-Javadoc)
957
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#reload()
958
	 */
705 959
	public void reload() throws ReloadLayerException {
706 960
		this.setAvailable(true);
707 961
	}
708 962

  
709
	/**
710
	 * Returns the status of the layer
963
	/*
964
	 * (non-Javadoc)
965
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getFLayerStatus()
711 966
	 */
712 967
	public FLayerStatus getFLayerStatus(){
713 968
		return status;
714 969
	}
715
	/**
716
	 * Sets the status of the layer
717
	 * @param status
970
	/*
971
	 * (non-Javadoc)
972
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#setFLayerStatus(com.iver.cit.gvsig.fmap.layers.FLayerStatus)
718 973
	 */
719 974
	public void setFLayerStatus(FLayerStatus status){
720 975
		this.status = status;
......
725 980
	 * unavailable status.
726 981
	 * */
727 982

  
983
	/*
984
	 * (non-Javadoc)
985
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#isOk()
986
	 */
987

  
728 988
	public boolean isOk(){
729 989
		return status.isOk();
730 990
	}
731

  
991
	/*
992
	 * (non-Javadoc)
993
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getNumErrors()
994
	 */
732 995
	public int getNumErrors(){
733 996
		return status.getNumErrors();
734 997
	}
......
736 999
	public BaseException getError(int i){
737 1000
		return status.getError(i);
738 1001
	}
739

  
1002
	/*
1003
	 * (non-Javadoc)
1004
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getErrors()
1005
	 */
740 1006
	public List getErrors(){
741 1007
		return status.getErrors();
742 1008
	}
743 1009

  
1010
	/*
1011
	 * (non-Javadoc)
1012
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#addError(com.iver.cit.gvsig.fmap.DriverException)
1013
	 */
744 1014
	public void addError(BaseException exception){
745 1015
		status.addLayerError(exception);
746 1016
	}
747

  
1017
	/*
1018
	 * (non-Javadoc)
1019
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#visibleRequired()
1020
	 */
748 1021
	public boolean visibleRequired() {
749 1022
		return status.visible;
750 1023
	}
751

  
1024
	/*
1025
	 * (non-Javadoc)
1026
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getInfoString()
1027
	 */
752 1028
	public String getInfoString() {
753 1029
		return null;
754 1030
	}
755

  
1031
	/*
1032
	 * (non-Javadoc)
1033
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#isWritable()
1034
	 */
756 1035
	public boolean isWritable() {
757 1036
		return status.writable;
758 1037
	}
759 1038

  
760
	/* (non-Javadoc)
1039
	/*
1040
	 * (non-Javadoc)
761 1041
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#cloneLayer()
762 1042
	 */
763 1043
	public FLayer cloneLayer() throws Exception {
764 1044
		return this;
765 1045
	}
766 1046

  
767
	/* By default this operation is not suported
768
	 *
1047
	/*
1048
	 * (non-Javadoc)
769 1049
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#newComposedLayer()
770 1050
	 */
771 1051
	public ComposedLayer newComposedLayer() {
......
776 1056
	 * FLyrDefault does not allow HyperLinks.
777 1057
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#allowLinks()
778 1058
	 */
779
    public boolean allowLinks()
780
    {
781
    	return false;
782
    }
1059
	public boolean allowLinks()
1060
	{
1061
		return false;
1062
	}
783 1063

  
784
    /**
785
     * Return null because does not allow HyperLinks
786
     * @see com.iver.cit.gvsig.fmap.layers.FLayer#getLinkProperties()
787
     */
788
    public AbstractLinkProperties getLinkProperties()
789
    {
790
    	return null;
791
    }
792
    /**
793
     * Return null because does not allow HyperLinks
794
     * @see com.iver.cit.gvsig.fmap.layers.FLayer#getLink()
795
     */
796
    public URI[] getLink(Point2D point, double tolerance)
797
    {
798
    	//return linkProperties.getLink(this)
799
    	return null;
800
    }
801
    
802
    /**
803
     * A?ade un LegendListener a la lista de Listeners.
804
     *
805
     * @param listener
806
     *            LegendListener.
807
     */
808
    public void addLegendListener(LegendListener listener) {
809
        layerChangeSupport.addLayerListener(listener);
810
    }
1064
	/**
1065
	 * Return null because does not allow HyperLinks
1066
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getLinkProperties()
1067
	 */
1068
	public AbstractLinkProperties getLinkProperties()
1069
	{
1070
		return null;
1071
	}
1072
	/**
1073
	 * Return null because does not allow HyperLinks
1074
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getLink()
1075
	 */
1076
	public URI[] getLink(Point2D point, double tolerance)
1077
	{
1078
		//return linkProperties.getLink(this)
1079
		return null;
1080
	}
811 1081

  
812
    /**
813
     * Llamada al m?todo callLegendChanged de los listener.
814
     *
815
     * @param e
816
     *            Evento.
817
     */
818
    protected void callLegendChanged(LegendChangedEvent e) {
819
        layerChangeSupport.callLegendChanged(e);
820
        if(parentLayer != null)
821
        	parentLayer.callLegendChanged(e);
822
    }
1082
	/**
1083
	 * A?ade un LegendListener a la lista de Listeners.
1084
	 *
1085
	 * @param listener
1086
	 *            LegendListener.
1087
	 */
1088
	public void addLegendListener(LegendListener listener) {
1089
		layerChangeSupport.addLayerListener(listener);
1090
	}
823 1091

  
824
    /**
825
     * Borra un LegendListener de la lista de Listeners
826
     *
827
     * @param listener
828
     *            LegendListener.
829
     */
830
    public void removeLegendListener(LegendListener listener) {
831
        layerChangeSupport.removeLayerListener(listener);
832
    }
1092
	/**
1093
	 * Llamada al m?todo callLegendChanged de los listener.
1094
	 *
1095
	 * @param e
1096
	 *            Evento.
1097
	 */
1098
	protected void callLegendChanged(LegendChangedEvent e) {
1099
		layerChangeSupport.callLegendChanged(e);
1100
		if(parentLayer != null)
1101
			parentLayer.callLegendChanged(e);
1102
	}
833 1103

  
1104
	/**
1105
	 * Borra un LegendListener de la lista de Listeners
1106
	 *
1107
	 * @param listener
1108
	 *            LegendListener.
1109
	 */
1110
	public void removeLegendListener(LegendListener listener) {
1111
		layerChangeSupport.removeLayerListener(listener);
1112
	}
1113

  
834 1114
}

Also available in: Unified diff