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