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