root / tags / v1_0_2_Build_903+3D / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLyrDefault.java @ 10722
History | View | Annotate | Download (19.1 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.fmap.layers; |
42 |
|
43 |
import java.awt.Image; |
44 |
import java.awt.image.BufferedImage; |
45 |
import java.util.ArrayList; |
46 |
import java.util.Hashtable; |
47 |
import java.util.Iterator; |
48 |
import java.util.List; |
49 |
import java.util.Map; |
50 |
import java.util.Set; |
51 |
|
52 |
import javax.swing.ImageIcon; |
53 |
|
54 |
import org.apache.log4j.Logger; |
55 |
import org.cresques.cts.ICoordTrans; |
56 |
import org.cresques.cts.IProjection; |
57 |
|
58 |
import com.hardcode.driverManager.Driver; |
59 |
import com.iver.cit.gvsig.fmap.DriverException; |
60 |
import com.iver.cit.gvsig.fmap.MapContext; |
61 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
62 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
63 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
64 |
import com.iver.cit.gvsig.fmap.operations.strategies.Strategy; |
65 |
import com.iver.utiles.IPersistance; |
66 |
import com.iver.utiles.XMLEntity; |
67 |
|
68 |
/**
|
69 |
* Implementaci?n de las caracter?sticas de alto nivel de las capas:
|
70 |
* visibilidad, activaci?n, nombre, ...
|
71 |
*/
|
72 |
public abstract class FLyrDefault implements FLayer, Driver { |
73 |
// private PropertyChangeSupport lnkPropertyChangeSupport;
|
74 |
private static Logger logger = Logger.getLogger(FLyrDefault.class); |
75 |
|
76 |
/** Path de la capa en el arbol de capas */
|
77 |
private FLayers parentLayer = null; |
78 |
|
79 |
private FLayers virtualLayers = null; |
80 |
|
81 |
private FLyrText layerText = null; |
82 |
|
83 |
private String name; |
84 |
|
85 |
private IProjection projection;
|
86 |
|
87 |
// private boolean visible = true;
|
88 |
//
|
89 |
// private boolean active;
|
90 |
|
91 |
private int transparency = 0; |
92 |
|
93 |
private ICoordTrans ct;
|
94 |
|
95 |
private double minScale = -1; // -1 indica que no se usa |
96 |
|
97 |
private double maxScale = -1; |
98 |
|
99 |
// private boolean isInTOC = true;
|
100 |
|
101 |
protected ArrayList layerListeners = new ArrayList(); |
102 |
|
103 |
private Strategy privateStrategy = null; |
104 |
|
105 |
// private boolean isediting;
|
106 |
|
107 |
private Hashtable properties = new Hashtable(); |
108 |
|
109 |
// private boolean bCacheDrawnLayers;
|
110 |
|
111 |
private BufferedImage cacheImageDrawnLayers = null; |
112 |
|
113 |
// private boolean bDirty;
|
114 |
|
115 |
// private boolean available = true;
|
116 |
|
117 |
//by default, all is active, visible and avalaible
|
118 |
private FLayerStatus status = new FLayerStatus(); |
119 |
|
120 |
private Image tocStatusImage; |
121 |
|
122 |
public Object getProperty(Object key) { |
123 |
return properties.get(key);
|
124 |
} |
125 |
|
126 |
public void setProperty(Object key, Object val) { |
127 |
properties.put(key, val); |
128 |
} |
129 |
|
130 |
public Map getExtendedProperties() { |
131 |
return properties;
|
132 |
} |
133 |
/**
|
134 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#setActive(boolean)
|
135 |
*/
|
136 |
public void setActive(boolean selected) { |
137 |
//active = selected;
|
138 |
status.active = selected; |
139 |
callActivationChanged(LayerEvent.createActivationChangedEvent(this,
|
140 |
"active"));
|
141 |
} |
142 |
|
143 |
/**
|
144 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#isActive()
|
145 |
*/
|
146 |
public boolean isActive() { |
147 |
// return active;
|
148 |
return status.active;
|
149 |
} |
150 |
|
151 |
/**
|
152 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#setName(java.lang.String)
|
153 |
*/
|
154 |
public void setName(String name) { |
155 |
this.name = name;
|
156 |
callNameChanged(LayerEvent.createNameChangedEvent(this, "name")); |
157 |
} |
158 |
|
159 |
/**
|
160 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#getName()
|
161 |
*/
|
162 |
public String getName() { |
163 |
return name;
|
164 |
} |
165 |
|
166 |
/*
|
167 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#load()
|
168 |
*/
|
169 |
public void load() throws DriverIOException { |
170 |
} |
171 |
|
172 |
/**
|
173 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#setVisible(boolean)
|
174 |
*/
|
175 |
public void setVisible(boolean visibility) { |
176 |
// visible = visibility;
|
177 |
boolean changed = status.visible != visibility;
|
178 |
status.visible = visibility; |
179 |
setDirty(true);
|
180 |
if (changed){
|
181 |
if (this.getMapContext() != null){ |
182 |
this.getMapContext().clearAllCachingImageDrawnLayers();
|
183 |
} |
184 |
} |
185 |
callVisibilityChanged(LayerEvent.createVisibilityChangedEvent(this,
|
186 |
"visible"));
|
187 |
} |
188 |
|
189 |
/**
|
190 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#isVisible()
|
191 |
*/
|
192 |
public boolean isVisible() { |
193 |
// return visible && this.available;
|
194 |
return status.visible && status.available;
|
195 |
} |
196 |
|
197 |
/**
|
198 |
* Devuelve la capa padre de la actual.
|
199 |
*
|
200 |
* @return FLayers padre.
|
201 |
*/
|
202 |
public FLayers getParentLayer() {
|
203 |
return parentLayer;
|
204 |
} |
205 |
|
206 |
/**
|
207 |
* Inserta la capa padre.
|
208 |
*
|
209 |
* @param root
|
210 |
* capa padre.
|
211 |
*/
|
212 |
public void setParentLayer(FLayers root) { |
213 |
this.parentLayer = root;
|
214 |
} |
215 |
|
216 |
/**
|
217 |
* Inserta una proyecci?n.
|
218 |
*
|
219 |
* @param proj
|
220 |
* Proyecci?n.
|
221 |
*/
|
222 |
public void setProjection(IProjection proj) { |
223 |
projection = proj; |
224 |
// Comprobar que la proyecci?n es la misma que la de FMap
|
225 |
// Si no lo es, es una capa que est? reproyectada al vuelo
|
226 |
if ((proj != null) && (getMapContext() != null)) |
227 |
if (proj != getMapContext().getProjection()) {
|
228 |
ICoordTrans ct = proj.getCT(getMapContext().getProjection()); |
229 |
setCoordTrans(ct); |
230 |
logger.debug("Cambio proyecci?n: FMap con "
|
231 |
+ getMapContext().getProjection().getAbrev() + " y capa "
|
232 |
+ getName() + " con " + proj.getAbrev());
|
233 |
} |
234 |
} |
235 |
|
236 |
/**
|
237 |
* @see org.cresques.geo.Projected#getProjection()
|
238 |
*/
|
239 |
public IProjection getProjection() {
|
240 |
return projection;
|
241 |
} |
242 |
|
243 |
/**
|
244 |
* @see org.cresques.geo.Projected#reProject(org.cresques.cts.ICoordTrans)
|
245 |
*/
|
246 |
public void reProject(ICoordTrans arg0) { |
247 |
} |
248 |
|
249 |
/**
|
250 |
* Devuelve el nivel de transparencia de la capa.
|
251 |
*
|
252 |
* @return Entero que representa el nivel de transparencia.
|
253 |
*/
|
254 |
public int getTransparency() { |
255 |
return transparency;
|
256 |
} |
257 |
|
258 |
/**
|
259 |
* Inserta el nivel de transparencia de la capa.
|
260 |
*
|
261 |
* @param trans
|
262 |
* Nivel de transparencia.
|
263 |
*/
|
264 |
public void setTransparency(int trans) { |
265 |
transparency = trans; |
266 |
setDirty(true);
|
267 |
} |
268 |
|
269 |
/**
|
270 |
* Devuelve el XMLEntity a partir del objeto.
|
271 |
*
|
272 |
* @return XMLEntity.
|
273 |
* @throws XMLException
|
274 |
*/
|
275 |
public XMLEntity getXMLEntity() throws XMLException { |
276 |
XMLEntity xml = new XMLEntity();
|
277 |
xml.putProperty("className", this.getClass().getName()); |
278 |
|
279 |
if (this instanceof FLayers) { |
280 |
} |
281 |
|
282 |
// xml.putProperty("active", active);
|
283 |
xml.putProperty("active", status.active);
|
284 |
xml.putProperty("name", name);
|
285 |
xml.putProperty("minScale", minScale);
|
286 |
xml.putProperty("maxScale", maxScale);
|
287 |
|
288 |
// TODO xml.addChild(parentLayer.getXMLEntity());
|
289 |
// xml.putProperty("visible", visible);
|
290 |
xml.putProperty("visible", status.visible);
|
291 |
if (projection != null) { |
292 |
xml.putProperty("proj", projection.getAbrev());
|
293 |
} |
294 |
xml.putProperty("transparency", transparency);
|
295 |
// xml.putProperty("isInTOC", isInTOC);
|
296 |
xml.putProperty("isInTOC", status.inTOC);
|
297 |
|
298 |
// persist Properties hashTable
|
299 |
|
300 |
Set keyset = properties.keySet();
|
301 |
|
302 |
|
303 |
int numProperties = 0; |
304 |
Iterator keyitr = keyset.iterator();
|
305 |
while (keyitr.hasNext()) {
|
306 |
String propName = (String)keyitr.next(); |
307 |
Object obj = properties.get(propName);
|
308 |
if (obj instanceof IPersistance) |
309 |
{ |
310 |
IPersistance persistObj = (IPersistance)obj; |
311 |
XMLEntity xmlPropObj = persistObj.getXMLEntity(); |
312 |
// make sure the node contains the class name
|
313 |
if (!xmlPropObj.contains("className")) { |
314 |
try {
|
315 |
String propClassName = persistObj.getClassName();
|
316 |
System.out.println("PROP CLASS NAME "+propClassName); |
317 |
xmlPropObj.putProperty("className", propClassName);
|
318 |
} catch (Exception e) { |
319 |
e.printStackTrace(); |
320 |
} |
321 |
} |
322 |
xmlPropObj.putProperty("layerPropertyName", propName);
|
323 |
xml.addChild(xmlPropObj); |
324 |
numProperties++; |
325 |
} else if (obj instanceof String) { |
326 |
XMLEntity xmlPropObj = new XMLEntity();
|
327 |
xmlPropObj.putProperty("className", String.class.getName()); |
328 |
xmlPropObj.putProperty("value",(String)obj); |
329 |
xmlPropObj.putProperty("layerPropertyName", propName);
|
330 |
xml.addChild(xmlPropObj); |
331 |
numProperties++; |
332 |
} |
333 |
} |
334 |
xml.putProperty("numProperties", numProperties);
|
335 |
|
336 |
return xml;
|
337 |
} |
338 |
|
339 |
/*
|
340 |
* Inserta los valores de los atributos del XMLEntity al objeto.
|
341 |
*
|
342 |
* @param xml XMLEntity.
|
343 |
*
|
344 |
* @throws XMLException @throws DriverException @throws DriverIOException
|
345 |
*
|
346 |
* public void setXMLEntity03(XMLEntity xml) throws XMLException { active =
|
347 |
* xml.getBooleanProperty("active"); name = xml.getStringProperty("name");
|
348 |
* minScale=xml.getDoubleProperty("minScale");
|
349 |
* maxScale=xml.getDoubleProperty("maxScale"); visible =
|
350 |
* xml.getBooleanProperty("visible"); if (xml.contains("proj")) {
|
351 |
* setProjection(ProjectionPool.get(xml.getStringProperty("proj"))); } if
|
352 |
* (xml.contains("transparency")) transparency =
|
353 |
* xml.getIntProperty("transparency"); }
|
354 |
*/
|
355 |
|
356 |
/**
|
357 |
* Inserta los valores de los atributos del XMLEntity al objeto.
|
358 |
*
|
359 |
* @param xml
|
360 |
* XMLEntity.
|
361 |
*
|
362 |
* @throws XMLException
|
363 |
* @throws DriverException
|
364 |
* @throws DriverIOException
|
365 |
*/
|
366 |
public void setXMLEntity(XMLEntity xml) throws XMLException { |
367 |
// active = xml.getBooleanProperty("active");
|
368 |
status.active = xml.getBooleanProperty("active");
|
369 |
name = xml.getStringProperty("name");
|
370 |
minScale = xml.getDoubleProperty("minScale");
|
371 |
maxScale = xml.getDoubleProperty("maxScale");
|
372 |
// visible = xml.getBooleanProperty("visible");
|
373 |
status.visible = xml.getBooleanProperty("visible");
|
374 |
if (xml.contains("proj")) { |
375 |
setProjection(CRSFactory.getCRS(xml.getStringProperty("proj")));
|
376 |
} |
377 |
if (xml.contains("transparency")) |
378 |
transparency = xml.getIntProperty("transparency");
|
379 |
if (xml.contains("isInTOC")) |
380 |
// isInTOC = xml.getBooleanProperty("isInTOC");
|
381 |
status.inTOC = xml.getBooleanProperty("isInTOC");
|
382 |
|
383 |
// recreate Properties hashTable
|
384 |
|
385 |
if (xml.contains("numProperties")) { |
386 |
int numProps = xml.getIntProperty("numProperties"); |
387 |
Object obj= null; |
388 |
IPersistance objPersist; |
389 |
for (int iProp=0; iProp<numProps; iProp++) { |
390 |
XMLEntity xmlProp = xml.getChild(0);
|
391 |
try {
|
392 |
String className = xmlProp.getStringProperty("className"); |
393 |
if (className.equals(String.class.getName())) { |
394 |
obj = xmlProp.getStringProperty("value");
|
395 |
} else {
|
396 |
Class classProp = Class.forName(className); |
397 |
obj = classProp.newInstance(); |
398 |
objPersist = (IPersistance)obj; |
399 |
objPersist.setXMLEntity(xmlProp); |
400 |
} |
401 |
String propName = xmlProp.getStringProperty("layerPropertyName"); |
402 |
properties.put(propName, obj); |
403 |
} catch (Exception e) { |
404 |
continue;
|
405 |
} |
406 |
// remove Properties children to avoid breaking layers' XML reading logic
|
407 |
xml.removeChild(0);
|
408 |
} |
409 |
} |
410 |
} |
411 |
|
412 |
/**
|
413 |
* Inserta los valores de los atributos del XMLEntity al objeto.
|
414 |
*
|
415 |
* @param xml
|
416 |
* XMLEntity.
|
417 |
*
|
418 |
* @throws XMLException
|
419 |
* @throws DriverException
|
420 |
* @throws DriverIOException
|
421 |
*/
|
422 |
public void setXMLEntity03(XMLEntity xml) throws XMLException { |
423 |
// active = xml.getBooleanProperty("active");
|
424 |
status.active = xml.getBooleanProperty("active");
|
425 |
name = xml.getStringProperty("name");
|
426 |
minScale = xml.getDoubleProperty("minScale");
|
427 |
maxScale = xml.getDoubleProperty("maxScale");
|
428 |
// visible = xml.getBooleanProperty("visible");
|
429 |
status.visible = xml.getBooleanProperty("visible");
|
430 |
if (xml.contains("proj")) { |
431 |
setProjection(CRSFactory.getCRS(xml.getStringProperty("proj")));
|
432 |
} |
433 |
if (xml.contains("transparency")) |
434 |
transparency = xml.getIntProperty("transparency");
|
435 |
} |
436 |
|
437 |
/**
|
438 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#getMapContext()
|
439 |
*/
|
440 |
public MapContext getMapContext() {
|
441 |
if (getParentLayer() != null) { |
442 |
return getParentLayer().getMapContext();
|
443 |
} else {
|
444 |
return null; |
445 |
} |
446 |
} |
447 |
|
448 |
/**
|
449 |
* A?ade a la lista de listener un nuevo LayerListener.
|
450 |
*
|
451 |
* @param o
|
452 |
* LayerListener.
|
453 |
*
|
454 |
* @return boolean.
|
455 |
*/
|
456 |
public boolean addLayerListener(LayerListener o) { |
457 |
if (layerListeners.contains(o))
|
458 |
return false; |
459 |
return layerListeners.add(o);
|
460 |
} |
461 |
public LayerListener[] getLayerListeners() { |
462 |
return (LayerListener[])layerListeners.toArray(new LayerListener[0]); |
463 |
} |
464 |
/**
|
465 |
* Borra de la lista de listeners el que se pasa como par?metro.
|
466 |
*
|
467 |
* @param o
|
468 |
* LayerListener a borrar.
|
469 |
*
|
470 |
* @return True si ha sido correcto el borrado del Listener.
|
471 |
*/
|
472 |
public boolean removeLayerListener(LayerListener o) { |
473 |
return layerListeners.remove(o);
|
474 |
} |
475 |
|
476 |
/**
|
477 |
* Llamada al metodo nameChanged de los Listeners dados de alta.
|
478 |
*
|
479 |
* @param e
|
480 |
* LayerEvent.
|
481 |
*/
|
482 |
private void callNameChanged(LayerEvent e) { |
483 |
for (Iterator iter = layerListeners.iterator(); iter.hasNext();) { |
484 |
LayerListener listener = (LayerListener) iter.next(); |
485 |
|
486 |
listener.nameChanged(e); |
487 |
} |
488 |
} |
489 |
|
490 |
/**
|
491 |
* Llamada al m?todo visibilityChanged de los Listeners.
|
492 |
*
|
493 |
* @param e
|
494 |
* LayerEvent.
|
495 |
*/
|
496 |
private void callVisibilityChanged(LayerEvent e) { |
497 |
for (Iterator iter = layerListeners.iterator(); iter.hasNext();) { |
498 |
LayerListener listener = (LayerListener) iter.next(); |
499 |
|
500 |
listener.visibilityChanged(e); |
501 |
} |
502 |
} |
503 |
|
504 |
/**
|
505 |
* Llamada al m?todo activationChanged de los Listener.
|
506 |
*
|
507 |
* @param e
|
508 |
* LayerEvent.
|
509 |
*/
|
510 |
private void callActivationChanged(LayerEvent e) { |
511 |
for (Iterator iter = layerListeners.iterator(); iter.hasNext();) { |
512 |
LayerListener listener = (LayerListener) iter.next(); |
513 |
|
514 |
listener.activationChanged(e); |
515 |
} |
516 |
} |
517 |
|
518 |
/**
|
519 |
* Devuelve las capas virtuales.
|
520 |
*
|
521 |
* @return FLayers.
|
522 |
*/
|
523 |
public FLayers getVirtualLayers() {
|
524 |
return virtualLayers;
|
525 |
} |
526 |
|
527 |
/**
|
528 |
* Inserta las capas virtuales.
|
529 |
*
|
530 |
* @param virtualLayers
|
531 |
* FLayers.
|
532 |
*/
|
533 |
public void setVirtualLayers(FLayers virtualLayers) { |
534 |
this.virtualLayers = virtualLayers;
|
535 |
} |
536 |
|
537 |
/**
|
538 |
* Devuelve la capa de texto.
|
539 |
*
|
540 |
* @return capa de texto.
|
541 |
*/
|
542 |
public FLyrText getLayerText() {
|
543 |
return layerText;
|
544 |
} |
545 |
|
546 |
/**
|
547 |
* Inserta la capa de texto.
|
548 |
*
|
549 |
* @param layerText
|
550 |
* Capa de texto.
|
551 |
*/
|
552 |
public void setLayerText(FLyrText layerText) { |
553 |
this.layerText = layerText;
|
554 |
} |
555 |
|
556 |
/**
|
557 |
* Inserta la Transformaci?n de coordenadas.
|
558 |
*
|
559 |
* @param ct
|
560 |
* Transformaci?n de coordenadas.
|
561 |
*/
|
562 |
public void setCoordTrans(ICoordTrans ct) { |
563 |
this.ct = ct;
|
564 |
} |
565 |
|
566 |
/**
|
567 |
* Devuelve las transformaci?n de coordenadas.
|
568 |
*
|
569 |
* @return ct.
|
570 |
*/
|
571 |
public ICoordTrans getCoordTrans() {
|
572 |
return ct;
|
573 |
} |
574 |
|
575 |
/**
|
576 |
* M?todo que es llamado por Flayers para notificar a la capa que va a ser
|
577 |
* a?adida. Esta previa notificaci?n es util para las capas que necesitan
|
578 |
* hacer algo antes de ser a?adida. Por ejemplo, el raster necesita volver a
|
579 |
* abrir el fichero que ha podido ser cerrado con anterioridad. Si no se
|
580 |
* redefine este m?todo no se har? nada ya que este es vacio.
|
581 |
*/
|
582 |
public void wakeUp() { |
583 |
} |
584 |
|
585 |
public double getMinScale() { |
586 |
return minScale;
|
587 |
} |
588 |
|
589 |
/*
|
590 |
* (non-Javadoc)
|
591 |
*
|
592 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#getMaxScale()
|
593 |
*/
|
594 |
public double getMaxScale() { |
595 |
return maxScale;
|
596 |
} |
597 |
|
598 |
public void setMinScale(double minScale) { |
599 |
this.minScale = minScale;
|
600 |
} |
601 |
|
602 |
public void setMaxScale(double maxScale) { |
603 |
this.maxScale = maxScale;
|
604 |
} |
605 |
|
606 |
public boolean isWithinScale(double scale) { |
607 |
|
608 |
boolean bVisible = true; |
609 |
if (getMinScale() != -1) { |
610 |
if (scale < getMinScale())
|
611 |
bVisible = false;
|
612 |
} |
613 |
if (getMaxScale() != -1) { |
614 |
if (scale > getMaxScale())
|
615 |
bVisible = false;
|
616 |
} |
617 |
|
618 |
return bVisible;
|
619 |
} |
620 |
|
621 |
public Strategy getStrategy() {
|
622 |
return privateStrategy;
|
623 |
} |
624 |
|
625 |
public void setStrategy(Strategy s) { |
626 |
privateStrategy = s; |
627 |
} |
628 |
|
629 |
public void setEditing(boolean b) throws EditionException { |
630 |
// isediting = b;
|
631 |
status.editing = b; |
632 |
setDirty(true);
|
633 |
setCachingDrawnLayers(b); |
634 |
} |
635 |
|
636 |
protected void callEditionChanged(LayerEvent e) { |
637 |
for (Iterator iter = layerListeners.iterator(); iter.hasNext();) { |
638 |
LayerListener listener = (LayerListener) iter.next(); |
639 |
|
640 |
listener.editionChanged(e); |
641 |
} |
642 |
} |
643 |
|
644 |
public boolean isEditing() { |
645 |
// return isediting;
|
646 |
return status.editing;
|
647 |
} |
648 |
|
649 |
public ImageIcon getTocImageIcon() { |
650 |
return null; |
651 |
} |
652 |
|
653 |
public boolean isInTOC() { |
654 |
// return isInTOC;
|
655 |
return status.inTOC;
|
656 |
} |
657 |
|
658 |
/* (non-Javadoc)
|
659 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#isCachingDrawnLayers()
|
660 |
*/
|
661 |
public boolean isCachingDrawnLayers() { |
662 |
// return bCacheDrawnLayers;
|
663 |
return status.cacheDrawnLayers;
|
664 |
} |
665 |
|
666 |
/* (non-Javadoc)
|
667 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#setCachingDrawnLayers(boolean)
|
668 |
*/
|
669 |
public void setCachingDrawnLayers(boolean bCacheDrawnLayers) { |
670 |
// this.bCacheDrawnLayers = bCacheDrawnLayers;
|
671 |
status.cacheDrawnLayers = bCacheDrawnLayers; |
672 |
if (status.cacheDrawnLayers == false) |
673 |
this.cacheImageDrawnLayers = null; |
674 |
} |
675 |
|
676 |
public BufferedImage getCacheImageDrawnLayers() { |
677 |
return cacheImageDrawnLayers;
|
678 |
} |
679 |
|
680 |
public void setCacheImageDrawnLayers(BufferedImage cacheImageDrawnLayers) { |
681 |
this.cacheImageDrawnLayers = cacheImageDrawnLayers;
|
682 |
} |
683 |
|
684 |
public boolean isDirty() { |
685 |
return status.dirty;
|
686 |
} |
687 |
|
688 |
public void setDirty(boolean dirty) { |
689 |
status.dirty = dirty; |
690 |
} |
691 |
|
692 |
public boolean isAvailable() { |
693 |
return status.available;
|
694 |
} |
695 |
|
696 |
public void setAvailable(boolean available) { |
697 |
status.available = available; |
698 |
} |
699 |
|
700 |
public void reload() throws DriverIOException { |
701 |
this.setAvailable(true); |
702 |
} |
703 |
|
704 |
/**
|
705 |
* Returns the status of the layer
|
706 |
*/
|
707 |
public FLayerStatus getFLayerStatus(){
|
708 |
return status;
|
709 |
} |
710 |
/**
|
711 |
* Sets the status of the layer
|
712 |
* @param status
|
713 |
*/
|
714 |
public void setFLayerStatus(FLayerStatus status){ |
715 |
this.status = status;
|
716 |
} |
717 |
|
718 |
/*
|
719 |
* This stuff is to save error's info that causes
|
720 |
* unavailable status.
|
721 |
* */
|
722 |
|
723 |
public boolean isOk(){ |
724 |
return status.isOk();
|
725 |
} |
726 |
|
727 |
public int getNumErrors(){ |
728 |
return status.getNumErrors();
|
729 |
} |
730 |
|
731 |
public DriverException getError(int i){ |
732 |
return status.getError(i);
|
733 |
} |
734 |
|
735 |
public List getErrors(){ |
736 |
return status.getErrors();
|
737 |
} |
738 |
|
739 |
public void addError(DriverException error){ |
740 |
status.addLayerError(error); |
741 |
} |
742 |
|
743 |
public boolean visibleRequired() { |
744 |
return status.visible;
|
745 |
} |
746 |
|
747 |
public String getInfoString() { |
748 |
return null; |
749 |
} |
750 |
|
751 |
public boolean isWritable() { |
752 |
return status.writable;
|
753 |
} |
754 |
|
755 |
/* (non-Javadoc)
|
756 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#cloneLayer()
|
757 |
*/
|
758 |
public FLayer cloneLayer() throws Exception { |
759 |
return this; |
760 |
} |
761 |
|
762 |
/**
|
763 |
* This method is called when the layer is going to be removed from the view.
|
764 |
* Layers that find it useful can overwrite it.
|
765 |
*
|
766 |
*/
|
767 |
public void removingThisLayer() { |
768 |
|
769 |
} |
770 |
|
771 |
public Image getTocStatusImage() { |
772 |
return tocStatusImage;
|
773 |
} |
774 |
|
775 |
public void setTocStatusImage(Image tocStatusImage) { |
776 |
this.tocStatusImage = tocStatusImage;
|
777 |
logger.debug("setTocStatusImage " + tocStatusImage + " sobre capa " + this.getName()); |
778 |
} |
779 |
|
780 |
|
781 |
} |