svn-gvsig-desktop / tags / v1_0_2_Build_906 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLyrDefault.java @ 10972
History | View | Annotate | Download (19.1 KB)
1 | 1100 | fjp | /* 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 | 214 | fernando | package com.iver.cit.gvsig.fmap.layers; |
42 | |||
43 | 10401 | fjp | import java.awt.Image; |
44 | 5923 | fjp | import java.awt.image.BufferedImage; |
45 | 2531 | caballero | import java.util.ArrayList; |
46 | 5200 | ldiaz | import java.util.Hashtable; |
47 | 2531 | caballero | import java.util.Iterator; |
48 | 8765 | jjdelcerro | import java.util.List; |
49 | 9360 | fdiaz | import java.util.Map; |
50 | 8765 | jjdelcerro | import java.util.Set; |
51 | 214 | fernando | |
52 | 5760 | jmvivo | import javax.swing.ImageIcon; |
53 | |||
54 | 2659 | fjp | import org.apache.log4j.Logger; |
55 | 354 | fernando | import org.cresques.cts.ICoordTrans; |
56 | 214 | fernando | import org.cresques.cts.IProjection; |
57 | |||
58 | 8765 | jjdelcerro | import com.hardcode.driverManager.Driver; |
59 | 2531 | caballero | import com.iver.cit.gvsig.fmap.DriverException; |
60 | 6878 | cesar | import com.iver.cit.gvsig.fmap.MapContext; |
61 | 6164 | luisw2 | import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
62 | 2531 | caballero | import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
63 | 4147 | fjp | import com.iver.cit.gvsig.fmap.edition.EditionException; |
64 | 3329 | fjp | import com.iver.cit.gvsig.fmap.operations.strategies.Strategy; |
65 | 10401 | fjp | import com.iver.utiles.IPersistance; |
66 | 2531 | caballero | import com.iver.utiles.XMLEntity; |
67 | 214 | fernando | |
68 | /**
|
||
69 | 435 | vcaballero | * Implementaci?n de las caracter?sticas de alto nivel de las capas:
|
70 | * visibilidad, activaci?n, nombre, ...
|
||
71 | 214 | fernando | */
|
72 | 10401 | fjp | public abstract class FLyrDefault implements FLayer, Driver { |
73 | 5923 | fjp | // private PropertyChangeSupport lnkPropertyChangeSupport;
|
74 | private static Logger logger = Logger.getLogger(FLyrDefault.class); |
||
75 | |||
76 | 525 | vcaballero | /** Path de la capa en el arbol de capas */
|
77 | private FLayers parentLayer = null; |
||
78 | 5923 | fjp | |
79 | 745 | fjp | private FLayers virtualLayers = null; |
80 | 5923 | fjp | |
81 | 757 | fjp | private FLyrText layerText = null; |
82 | 5923 | fjp | |
83 | 274 | fjp | private String name; |
84 | 5923 | fjp | |
85 | 354 | fernando | private IProjection projection;
|
86 | 5923 | fjp | |
87 | 8765 | jjdelcerro | // private boolean visible = true;
|
88 | //
|
||
89 | // private boolean active;
|
||
90 | 5923 | fjp | |
91 | 434 | fjp | private int transparency = 0; |
92 | 5923 | fjp | |
93 | 885 | fjp | private ICoordTrans ct;
|
94 | 5923 | fjp | |
95 | 1176 | fjp | private double minScale = -1; // -1 indica que no se usa |
96 | 5923 | fjp | |
97 | 1176 | fjp | private double maxScale = -1; |
98 | 5923 | fjp | |
99 | 8765 | jjdelcerro | // private boolean isInTOC = true;
|
100 | 5923 | fjp | |
101 | 3256 | nacho | protected ArrayList layerListeners = new ArrayList(); |
102 | 884 | fernando | |
103 | 5923 | fjp | private Strategy privateStrategy = null; |
104 | |||
105 | 8765 | jjdelcerro | // private boolean isediting;
|
106 | 5908 | caballero | |
107 | 5200 | ldiaz | private Hashtable properties = new Hashtable(); |
108 | 5908 | caballero | |
109 | 8765 | jjdelcerro | // private boolean bCacheDrawnLayers;
|
110 | |||
111 | 5923 | fjp | private BufferedImage cacheImageDrawnLayers = null; |
112 | |||
113 | 8765 | jjdelcerro | // 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 | 10401 | fjp | private Image tocStatusImage; |
121 | |||
122 | 5923 | fjp | public Object getProperty(Object key) { |
123 | 5200 | ldiaz | return properties.get(key);
|
124 | } |
||
125 | 5923 | fjp | |
126 | public void setProperty(Object key, Object val) { |
||
127 | 5200 | ldiaz | properties.put(key, val); |
128 | } |
||
129 | 5908 | caballero | |
130 | 9360 | fdiaz | public Map getExtendedProperties() { |
131 | return properties;
|
||
132 | } |
||
133 | 525 | vcaballero | /**
|
134 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setActive(boolean)
|
||
135 | */
|
||
136 | public void setActive(boolean selected) { |
||
137 | 8765 | jjdelcerro | //active = selected;
|
138 | status.active = selected; |
||
139 | 5923 | fjp | callActivationChanged(LayerEvent.createActivationChangedEvent(this,
|
140 | "active"));
|
||
141 | 525 | vcaballero | } |
142 | 214 | fernando | |
143 | 525 | vcaballero | /**
|
144 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#isActive()
|
||
145 | */
|
||
146 | public boolean isActive() { |
||
147 | 8765 | jjdelcerro | // return active;
|
148 | return status.active;
|
||
149 | 525 | vcaballero | } |
150 | 214 | fernando | |
151 | 525 | vcaballero | /**
|
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 | 1082 | fernando | callNameChanged(LayerEvent.createNameChangedEvent(this, "name")); |
157 | 525 | vcaballero | } |
158 | 214 | fernando | |
159 | 525 | vcaballero | /**
|
160 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getName()
|
||
161 | */
|
||
162 | public String getName() { |
||
163 | return name;
|
||
164 | } |
||
165 | 214 | fernando | |
166 | 567 | luisw | /*
|
167 | 525 | vcaballero | * @see com.iver.cit.gvsig.fmap.layers.FLayer#load()
|
168 | */
|
||
169 | 1034 | vcaballero | public void load() throws DriverIOException { |
170 | 525 | vcaballero | } |
171 | 214 | fernando | |
172 | 525 | vcaballero | /**
|
173 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setVisible(boolean)
|
||
174 | */
|
||
175 | public void setVisible(boolean visibility) { |
||
176 | 8765 | jjdelcerro | // visible = visibility;
|
177 | boolean changed = status.visible != visibility;
|
||
178 | status.visible = visibility; |
||
179 | 6002 | fjp | setDirty(true);
|
180 | 7367 | jmvivo | if (changed){
|
181 | if (this.getMapContext() != null){ |
||
182 | this.getMapContext().clearAllCachingImageDrawnLayers();
|
||
183 | } |
||
184 | } |
||
185 | 5923 | fjp | callVisibilityChanged(LayerEvent.createVisibilityChangedEvent(this,
|
186 | "visible"));
|
||
187 | 525 | vcaballero | } |
188 | 435 | vcaballero | |
189 | 525 | vcaballero | /**
|
190 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#isVisible()
|
||
191 | */
|
||
192 | public boolean isVisible() { |
||
193 | 8765 | jjdelcerro | // return visible && this.available;
|
194 | return status.visible && status.available;
|
||
195 | 525 | vcaballero | } |
196 | 435 | vcaballero | |
197 | 525 | vcaballero | /**
|
198 | 1034 | vcaballero | * Devuelve la capa padre de la actual.
|
199 | 8765 | jjdelcerro | *
|
200 | 1034 | vcaballero | * @return FLayers padre.
|
201 | 525 | vcaballero | */
|
202 | public FLayers getParentLayer() {
|
||
203 | return parentLayer;
|
||
204 | } |
||
205 | 435 | vcaballero | |
206 | 525 | vcaballero | /**
|
207 | 1034 | vcaballero | * Inserta la capa padre.
|
208 | 8765 | jjdelcerro | *
|
209 | 5923 | fjp | * @param root
|
210 | * capa padre.
|
||
211 | 525 | vcaballero | */
|
212 | public void setParentLayer(FLayers root) { |
||
213 | this.parentLayer = root;
|
||
214 | } |
||
215 | 435 | vcaballero | |
216 | 525 | vcaballero | /**
|
217 | 1034 | vcaballero | * Inserta una proyecci?n.
|
218 | 8765 | jjdelcerro | *
|
219 | 5923 | fjp | * @param proj
|
220 | * Proyecci?n.
|
||
221 | 525 | vcaballero | */
|
222 | public void setProjection(IProjection proj) { |
||
223 | 5908 | caballero | projection = proj; |
224 | 5923 | fjp | // 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 | 6881 | cesar | if ((proj != null) && (getMapContext() != null)) |
227 | if (proj != getMapContext().getProjection()) {
|
||
228 | ICoordTrans ct = proj.getCT(getMapContext().getProjection()); |
||
229 | 5923 | fjp | setCoordTrans(ct); |
230 | logger.debug("Cambio proyecci?n: FMap con "
|
||
231 | 6881 | cesar | + getMapContext().getProjection().getAbrev() + " y capa "
|
232 | 5923 | fjp | + getName() + " con " + proj.getAbrev());
|
233 | } |
||
234 | 525 | vcaballero | } |
235 | 435 | vcaballero | |
236 | 525 | vcaballero | /**
|
237 | * @see org.cresques.geo.Projected#getProjection()
|
||
238 | */
|
||
239 | public IProjection getProjection() {
|
||
240 | return projection;
|
||
241 | } |
||
242 | 435 | vcaballero | |
243 | 525 | vcaballero | /**
|
244 | * @see org.cresques.geo.Projected#reProject(org.cresques.cts.ICoordTrans)
|
||
245 | */
|
||
246 | public void reProject(ICoordTrans arg0) { |
||
247 | } |
||
248 | 435 | vcaballero | |
249 | 525 | vcaballero | /**
|
250 | 1034 | vcaballero | * Devuelve el nivel de transparencia de la capa.
|
251 | 8765 | jjdelcerro | *
|
252 | 1034 | vcaballero | * @return Entero que representa el nivel de transparencia.
|
253 | 525 | vcaballero | */
|
254 | public int getTransparency() { |
||
255 | 434 | fjp | return transparency;
|
256 | } |
||
257 | 525 | vcaballero | |
258 | /**
|
||
259 | 1034 | vcaballero | * Inserta el nivel de transparencia de la capa.
|
260 | 8765 | jjdelcerro | *
|
261 | 5923 | fjp | * @param trans
|
262 | * Nivel de transparencia.
|
||
263 | 525 | vcaballero | */
|
264 | 434 | fjp | public void setTransparency(int trans) { |
265 | transparency = trans; |
||
266 | 6002 | fjp | setDirty(true);
|
267 | 434 | fjp | } |
268 | 435 | vcaballero | |
269 | 525 | vcaballero | /**
|
270 | 1034 | vcaballero | * Devuelve el XMLEntity a partir del objeto.
|
271 | 8765 | jjdelcerro | *
|
272 | 1034 | vcaballero | * @return XMLEntity.
|
273 | 1828 | fernando | * @throws XMLException
|
274 | 525 | vcaballero | */
|
275 | 1828 | fernando | public XMLEntity getXMLEntity() throws XMLException { |
276 | 525 | vcaballero | XMLEntity xml = new XMLEntity();
|
277 | 5923 | fjp | xml.putProperty("className", this.getClass().getName()); |
278 | 435 | vcaballero | |
279 | 525 | vcaballero | if (this instanceof FLayers) { |
280 | } |
||
281 | |||
282 | 8765 | jjdelcerro | // xml.putProperty("active", active);
|
283 | xml.putProperty("active", status.active);
|
||
284 | 525 | vcaballero | xml.putProperty("name", name);
|
285 | 5923 | fjp | xml.putProperty("minScale", minScale);
|
286 | xml.putProperty("maxScale", maxScale);
|
||
287 | 5908 | caballero | |
288 | 5923 | fjp | // TODO xml.addChild(parentLayer.getXMLEntity());
|
289 | 8765 | jjdelcerro | // xml.putProperty("visible", visible);
|
290 | xml.putProperty("visible", status.visible);
|
||
291 | 1417 | fjp | if (projection != null) { |
292 | xml.putProperty("proj", projection.getAbrev());
|
||
293 | } |
||
294 | 1455 | luisw | xml.putProperty("transparency", transparency);
|
295 | 8765 | jjdelcerro | // xml.putProperty("isInTOC", isInTOC);
|
296 | xml.putProperty("isInTOC", status.inTOC);
|
||
297 | |||
298 | // persist Properties hashTable
|
||
299 | |||
300 | Set keyset = properties.keySet();
|
||
301 | 9360 | fdiaz | |
302 | 8765 | jjdelcerro | |
303 | 9360 | fdiaz | int numProperties = 0; |
304 | 8765 | jjdelcerro | 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 | 9360 | fdiaz | 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 | 8765 | jjdelcerro | } |
333 | } |
||
334 | 9360 | fdiaz | xml.putProperty("numProperties", numProperties);
|
335 | 8765 | jjdelcerro | |
336 | 525 | vcaballero | return xml;
|
337 | } |
||
338 | |||
339 | 2183 | fernando | /*
|
340 | * Inserta los valores de los atributos del XMLEntity al objeto.
|
||
341 | 8765 | jjdelcerro | *
|
342 | 2183 | fernando | * @param xml XMLEntity.
|
343 | 8765 | jjdelcerro | *
|
344 | 5923 | fjp | * @throws XMLException @throws DriverException @throws DriverIOException
|
345 | 8765 | jjdelcerro | *
|
346 | 5923 | fjp | * 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 | 2183 | fernando | |
356 | 525 | vcaballero | /**
|
357 | 1034 | vcaballero | * Inserta los valores de los atributos del XMLEntity al objeto.
|
358 | 8765 | jjdelcerro | *
|
359 | 5923 | fjp | * @param xml
|
360 | * XMLEntity.
|
||
361 | 8765 | jjdelcerro | *
|
362 | 1034 | vcaballero | * @throws XMLException
|
363 | * @throws DriverException
|
||
364 | * @throws DriverIOException
|
||
365 | 525 | vcaballero | */
|
366 | 5923 | fjp | public void setXMLEntity(XMLEntity xml) throws XMLException { |
367 | 8765 | jjdelcerro | // active = xml.getBooleanProperty("active");
|
368 | status.active = xml.getBooleanProperty("active");
|
||
369 | 525 | vcaballero | name = xml.getStringProperty("name");
|
370 | 5923 | fjp | minScale = xml.getDoubleProperty("minScale");
|
371 | maxScale = xml.getDoubleProperty("maxScale");
|
||
372 | 8765 | jjdelcerro | // visible = xml.getBooleanProperty("visible");
|
373 | status.visible = xml.getBooleanProperty("visible");
|
||
374 | 1417 | fjp | if (xml.contains("proj")) { |
375 | 6164 | luisw2 | setProjection(CRSFactory.getCRS(xml.getStringProperty("proj")));
|
376 | 1417 | fjp | } |
377 | 1455 | luisw | if (xml.contains("transparency")) |
378 | transparency = xml.getIntProperty("transparency");
|
||
379 | 5802 | jaume | if (xml.contains("isInTOC")) |
380 | 8765 | jjdelcerro | // 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 | 9360 | fdiaz | Object obj= null; |
388 | IPersistance objPersist; |
||
389 | 8765 | jjdelcerro | for (int iProp=0; iProp<numProps; iProp++) { |
390 | 9360 | fdiaz | XMLEntity xmlProp = xml.getChild(0);
|
391 | 8765 | jjdelcerro | try {
|
392 | String className = xmlProp.getStringProperty("className"); |
||
393 | 9360 | fdiaz | 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 | 8765 | jjdelcerro | String propName = xmlProp.getStringProperty("layerPropertyName"); |
402 | properties.put(propName, obj); |
||
403 | } catch (Exception e) { |
||
404 | continue;
|
||
405 | } |
||
406 | 9360 | fdiaz | // remove Properties children to avoid breaking layers' XML reading logic
|
407 | xml.removeChild(0);
|
||
408 | 8765 | jjdelcerro | } |
409 | } |
||
410 | 525 | vcaballero | } |
411 | 694 | fernando | |
412 | /**
|
||
413 | 2183 | fernando | * Inserta los valores de los atributos del XMLEntity al objeto.
|
414 | 8765 | jjdelcerro | *
|
415 | 5923 | fjp | * @param xml
|
416 | * XMLEntity.
|
||
417 | 8765 | jjdelcerro | *
|
418 | 2183 | fernando | * @throws XMLException
|
419 | * @throws DriverException
|
||
420 | * @throws DriverIOException
|
||
421 | */
|
||
422 | 5923 | fjp | public void setXMLEntity03(XMLEntity xml) throws XMLException { |
423 | 8765 | jjdelcerro | // active = xml.getBooleanProperty("active");
|
424 | status.active = xml.getBooleanProperty("active");
|
||
425 | 2183 | fernando | name = xml.getStringProperty("name");
|
426 | 5923 | fjp | minScale = xml.getDoubleProperty("minScale");
|
427 | maxScale = xml.getDoubleProperty("maxScale");
|
||
428 | 8765 | jjdelcerro | // visible = xml.getBooleanProperty("visible");
|
429 | status.visible = xml.getBooleanProperty("visible");
|
||
430 | 2183 | fernando | if (xml.contains("proj")) { |
431 | 6164 | luisw2 | setProjection(CRSFactory.getCRS(xml.getStringProperty("proj")));
|
432 | 2183 | fernando | } |
433 | if (xml.contains("transparency")) |
||
434 | transparency = xml.getIntProperty("transparency");
|
||
435 | } |
||
436 | |||
437 | /**
|
||
438 | 6881 | cesar | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getMapContext()
|
439 | 694 | fernando | */
|
440 | 6881 | cesar | public MapContext getMapContext() {
|
441 | 884 | fernando | if (getParentLayer() != null) { |
442 | 6881 | cesar | return getParentLayer().getMapContext();
|
443 | 884 | fernando | } else {
|
444 | return null; |
||
445 | } |
||
446 | 694 | fernando | } |
447 | |||
448 | 884 | fernando | /**
|
449 | 1034 | vcaballero | * A?ade a la lista de listener un nuevo LayerListener.
|
450 | 8765 | jjdelcerro | *
|
451 | 5923 | fjp | * @param o
|
452 | * LayerListener.
|
||
453 | 8765 | jjdelcerro | *
|
454 | 1034 | vcaballero | * @return boolean.
|
455 | 884 | fernando | */
|
456 | 727 | fernando | public boolean addLayerListener(LayerListener o) { |
457 | 4370 | caballero | if (layerListeners.contains(o))
|
458 | return false; |
||
459 | 727 | fernando | return layerListeners.add(o);
|
460 | } |
||
461 | 5908 | caballero | public LayerListener[] getLayerListeners() { |
462 | return (LayerListener[])layerListeners.toArray(new LayerListener[0]); |
||
463 | } |
||
464 | 884 | fernando | /**
|
465 | 1034 | vcaballero | * Borra de la lista de listeners el que se pasa como par?metro.
|
466 | 8765 | jjdelcerro | *
|
467 | 5923 | fjp | * @param o
|
468 | * LayerListener a borrar.
|
||
469 | 8765 | jjdelcerro | *
|
470 | 1034 | vcaballero | * @return True si ha sido correcto el borrado del Listener.
|
471 | 884 | fernando | */
|
472 | 727 | fernando | public boolean removeLayerListener(LayerListener o) { |
473 | return layerListeners.remove(o);
|
||
474 | } |
||
475 | 884 | fernando | |
476 | /**
|
||
477 | 1034 | vcaballero | * Llamada al metodo nameChanged de los Listeners dados de alta.
|
478 | 8765 | jjdelcerro | *
|
479 | 5923 | fjp | * @param e
|
480 | * LayerEvent.
|
||
481 | 884 | fernando | */
|
482 | private void callNameChanged(LayerEvent e) { |
||
483 | 727 | fernando | for (Iterator iter = layerListeners.iterator(); iter.hasNext();) { |
484 | LayerListener listener = (LayerListener) iter.next(); |
||
485 | 884 | fernando | |
486 | 727 | fernando | listener.nameChanged(e); |
487 | } |
||
488 | } |
||
489 | 884 | fernando | |
490 | /**
|
||
491 | 1034 | vcaballero | * Llamada al m?todo visibilityChanged de los Listeners.
|
492 | 8765 | jjdelcerro | *
|
493 | 5923 | fjp | * @param e
|
494 | * LayerEvent.
|
||
495 | 884 | fernando | */
|
496 | private void callVisibilityChanged(LayerEvent e) { |
||
497 | 727 | fernando | for (Iterator iter = layerListeners.iterator(); iter.hasNext();) { |
498 | LayerListener listener = (LayerListener) iter.next(); |
||
499 | 884 | fernando | |
500 | 727 | fernando | listener.visibilityChanged(e); |
501 | } |
||
502 | } |
||
503 | 884 | fernando | |
504 | /**
|
||
505 | 1034 | vcaballero | * Llamada al m?todo activationChanged de los Listener.
|
506 | 8765 | jjdelcerro | *
|
507 | 5923 | fjp | * @param e
|
508 | * LayerEvent.
|
||
509 | 884 | fernando | */
|
510 | private void callActivationChanged(LayerEvent e) { |
||
511 | 727 | fernando | for (Iterator iter = layerListeners.iterator(); iter.hasNext();) { |
512 | LayerListener listener = (LayerListener) iter.next(); |
||
513 | 884 | fernando | |
514 | 727 | fernando | listener.activationChanged(e); |
515 | } |
||
516 | } |
||
517 | 745 | fjp | |
518 | 884 | fernando | /**
|
519 | 1034 | vcaballero | * Devuelve las capas virtuales.
|
520 | 8765 | jjdelcerro | *
|
521 | 1034 | vcaballero | * @return FLayers.
|
522 | 884 | fernando | */
|
523 | 745 | fjp | public FLayers getVirtualLayers() {
|
524 | return virtualLayers;
|
||
525 | } |
||
526 | 884 | fernando | |
527 | /**
|
||
528 | 1034 | vcaballero | * Inserta las capas virtuales.
|
529 | 8765 | jjdelcerro | *
|
530 | 5923 | fjp | * @param virtualLayers
|
531 | * FLayers.
|
||
532 | 884 | fernando | */
|
533 | 745 | fjp | public void setVirtualLayers(FLayers virtualLayers) { |
534 | this.virtualLayers = virtualLayers;
|
||
535 | } |
||
536 | 884 | fernando | |
537 | /**
|
||
538 | 1034 | vcaballero | * Devuelve la capa de texto.
|
539 | 8765 | jjdelcerro | *
|
540 | 1034 | vcaballero | * @return capa de texto.
|
541 | 884 | fernando | */
|
542 | 757 | fjp | public FLyrText getLayerText() {
|
543 | return layerText;
|
||
544 | } |
||
545 | 884 | fernando | |
546 | /**
|
||
547 | 1034 | vcaballero | * Inserta la capa de texto.
|
548 | 8765 | jjdelcerro | *
|
549 | 5923 | fjp | * @param layerText
|
550 | * Capa de texto.
|
||
551 | 884 | fernando | */
|
552 | 757 | fjp | public void setLayerText(FLyrText layerText) { |
553 | this.layerText = layerText;
|
||
554 | } |
||
555 | 885 | fjp | |
556 | /**
|
||
557 | 4479 | fjp | * Inserta la Transformaci?n de coordenadas.
|
558 | 8765 | jjdelcerro | *
|
559 | 5923 | fjp | * @param ct
|
560 | * Transformaci?n de coordenadas.
|
||
561 | 885 | fjp | */
|
562 | public void setCoordTrans(ICoordTrans ct) { |
||
563 | this.ct = ct;
|
||
564 | } |
||
565 | |||
566 | /**
|
||
567 | 4479 | fjp | * Devuelve las transformaci?n de coordenadas.
|
568 | 8765 | jjdelcerro | *
|
569 | 4479 | fjp | * @return ct.
|
570 | 885 | fjp | */
|
571 | public ICoordTrans getCoordTrans() {
|
||
572 | return ct;
|
||
573 | } |
||
574 | 5908 | caballero | |
575 | 4376 | nacho | /**
|
576 | 5923 | fjp | * 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 | 4376 | nacho | */
|
582 | 5923 | fjp | public void wakeUp() { |
583 | } |
||
584 | 5908 | caballero | |
585 | 5923 | fjp | public double getMinScale() { |
586 | return minScale;
|
||
587 | } |
||
588 | 1176 | fjp | |
589 | 5923 | fjp | /*
|
590 | * (non-Javadoc)
|
||
591 | 8765 | jjdelcerro | *
|
592 | 5923 | fjp | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getMaxScale()
|
593 | */
|
||
594 | public double getMaxScale() { |
||
595 | return maxScale;
|
||
596 | } |
||
597 | 5908 | caballero | |
598 | 5923 | fjp | public void setMinScale(double minScale) { |
599 | this.minScale = minScale;
|
||
600 | } |
||
601 | 5908 | caballero | |
602 | 5923 | fjp | public void setMaxScale(double maxScale) { |
603 | this.maxScale = maxScale;
|
||
604 | } |
||
605 | 5908 | caballero | |
606 | 5923 | fjp | public boolean isWithinScale(double scale) { |
607 | 5908 | caballero | |
608 | 5923 | fjp | 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 | 5908 | caballero | |
618 | 5923 | fjp | return bVisible;
|
619 | } |
||
620 | 3690 | caballero | |
621 | 5923 | fjp | public Strategy getStrategy() {
|
622 | return privateStrategy;
|
||
623 | } |
||
624 | |||
625 | public void setStrategy(Strategy s) { |
||
626 | privateStrategy = s; |
||
627 | } |
||
628 | |||
629 | 5152 | fjp | public void setEditing(boolean b) throws EditionException { |
630 | 8765 | jjdelcerro | // isediting = b;
|
631 | status.editing = b; |
||
632 | 6002 | fjp | setDirty(true);
|
633 | setCachingDrawnLayers(b); |
||
634 | 3690 | caballero | } |
635 | 5923 | fjp | |
636 | 4147 | fjp | protected void callEditionChanged(LayerEvent e) { |
637 | 4144 | fjp | for (Iterator iter = layerListeners.iterator(); iter.hasNext();) { |
638 | LayerListener listener = (LayerListener) iter.next(); |
||
639 | |||
640 | listener.editionChanged(e); |
||
641 | } |
||
642 | } |
||
643 | |||
644 | 5923 | fjp | public boolean isEditing() { |
645 | 8765 | jjdelcerro | // return isediting;
|
646 | return status.editing;
|
||
647 | 3690 | caballero | } |
648 | 5908 | caballero | |
649 | 5923 | fjp | public ImageIcon getTocImageIcon() { |
650 | return null; |
||
651 | } |
||
652 | 5908 | caballero | |
653 | 5923 | fjp | public boolean isInTOC() { |
654 | 8765 | jjdelcerro | // return isInTOC;
|
655 | return status.inTOC;
|
||
656 | 5923 | fjp | } |
657 | |||
658 | /* (non-Javadoc)
|
||
659 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#isCachingDrawnLayers()
|
||
660 | */
|
||
661 | public boolean isCachingDrawnLayers() { |
||
662 | 8765 | jjdelcerro | // return bCacheDrawnLayers;
|
663 | return status.cacheDrawnLayers;
|
||
664 | 5923 | fjp | } |
665 | |||
666 | /* (non-Javadoc)
|
||
667 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setCachingDrawnLayers(boolean)
|
||
668 | */
|
||
669 | public void setCachingDrawnLayers(boolean bCacheDrawnLayers) { |
||
670 | 8765 | jjdelcerro | // this.bCacheDrawnLayers = bCacheDrawnLayers;
|
671 | status.cacheDrawnLayers = bCacheDrawnLayers; |
||
672 | if (status.cacheDrawnLayers == false) |
||
673 | 5997 | fjp | this.cacheImageDrawnLayers = null; |
674 | 5923 | fjp | } |
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 | 8765 | jjdelcerro | return status.dirty;
|
686 | 5923 | fjp | } |
687 | |||
688 | public void setDirty(boolean dirty) { |
||
689 | 8765 | jjdelcerro | status.dirty = dirty; |
690 | 5923 | fjp | } |
691 | 8765 | jjdelcerro | |
692 | 6543 | jmvivo | public boolean isAvailable() { |
693 | 8765 | jjdelcerro | return status.available;
|
694 | 6400 | jmvivo | } |
695 | 8765 | jjdelcerro | |
696 | 6532 | jmvivo | public void setAvailable(boolean available) { |
697 | 8765 | jjdelcerro | status.available = available; |
698 | 6400 | jmvivo | } |
699 | 8765 | jjdelcerro | |
700 | 6532 | jmvivo | public void reload() throws DriverIOException { |
701 | this.setAvailable(true); |
||
702 | } |
||
703 | 8765 | jjdelcerro | |
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 | 6532 | jmvivo | public boolean visibleRequired() { |
744 | 8765 | jjdelcerro | return status.visible;
|
745 | 6532 | jmvivo | } |
746 | 8765 | jjdelcerro | |
747 | 6532 | jmvivo | public String getInfoString() { |
748 | return null; |
||
749 | } |
||
750 | 5923 | fjp | |
751 | 6856 | fjp | public boolean isWritable() { |
752 | 8765 | jjdelcerro | return status.writable;
|
753 | 6856 | fjp | } |
754 | 9225 | fjp | |
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 | 5923 | fjp | |
762 | 10048 | fjp | /**
|
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 | 6856 | fjp | |
769 | 10048 | fjp | } |
770 | 9225 | fjp | |
771 | 10401 | fjp | public Image getTocStatusImage() { |
772 | return tocStatusImage;
|
||
773 | } |
||
774 | 10048 | fjp | |
775 | 10401 | fjp | public void setTocStatusImage(Image tocStatusImage) { |
776 | this.tocStatusImage = tocStatusImage;
|
||
777 | 10633 | fjp | logger.debug("setTocStatusImage " + tocStatusImage + " sobre capa " + this.getName()); |
778 | 10401 | fjp | } |
779 | 10048 | fjp | |
780 | 10401 | fjp | |
781 | 214 | fernando | } |