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