root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLyrDefault.java @ 16542
History | View | Annotate | Download (31.2 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 | 14573 | vcaballero | import java.awt.Image; |
44 | 13558 | evercher | import java.awt.geom.Point2D; |
45 | 5923 | fjp | import java.awt.image.BufferedImage; |
46 | 13558 | evercher | import java.net.URI; |
47 | 2531 | caballero | import java.util.ArrayList; |
48 | 5200 | ldiaz | import java.util.Hashtable; |
49 | 2531 | caballero | import java.util.Iterator; |
50 | 7463 | azabala | import java.util.List; |
51 | 9224 | jjdelcerro | import java.util.Map; |
52 | 7867 | sbayarri | import java.util.Set; |
53 | 214 | fernando | |
54 | 5760 | jmvivo | import javax.swing.ImageIcon; |
55 | |||
56 | 2659 | fjp | import org.apache.log4j.Logger; |
57 | 354 | fernando | import org.cresques.cts.ICoordTrans; |
58 | 214 | fernando | import org.cresques.cts.IProjection; |
59 | 10627 | caballero | import org.gvsig.exceptions.BaseException; |
60 | 214 | fernando | |
61 | 10627 | caballero | import com.hardcode.gdbms.engine.data.driver.DriverException; |
62 | import com.iver.cit.gvsig.exceptions.layers.LoadLayerException; |
||
63 | import com.iver.cit.gvsig.exceptions.layers.ReloadLayerException; |
||
64 | import com.iver.cit.gvsig.exceptions.layers.StartEditionLayerException; |
||
65 | 6878 | cesar | import com.iver.cit.gvsig.fmap.MapContext; |
66 | 6164 | luisw2 | import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
67 | 2531 | caballero | import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
68 | 10932 | jmvivo | import com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer; |
69 | 3329 | fjp | import com.iver.cit.gvsig.fmap.operations.strategies.Strategy; |
70 | 13952 | jaume | import com.iver.cit.gvsig.fmap.rendering.LegendChangedEvent; |
71 | 13913 | jaume | import com.iver.utiles.IPersistence; |
72 | 2531 | caballero | import com.iver.utiles.XMLEntity; |
73 | 214 | fernando | |
74 | /**
|
||
75 | 14294 | jvidal | * <p>Implementation of the high level characteristics of the layers: visibility, activation, name, ...</p>
|
76 | 14573 | vcaballero | *
|
77 | * <p>Represents a definition of a basic <a href="http://www.gvsig.gva.es/">gvSIG</a> layer, with the implementation of
|
||
78 | * the <code>FLayer</code> methods, and new functionality:
|
||
79 | 14294 | jvidal | * <ul>
|
80 | * <li>Supports transparency.
|
||
81 | * <li>Notification of evens produced using this layer.
|
||
82 | * <li>Can have internal virtual layers.
|
||
83 | * <li>Can have a text layer.
|
||
84 | * <li>Supports an strategy for visit its geometries.
|
||
85 | * <li>Can have an image in the <i>TOC (table of contents)</i> associated to the state of this layer.
|
||
86 | * </ul>
|
||
87 | * </p>
|
||
88 | *
|
||
89 | * <p>Each graphical layer will inherit from this class and adapt to its particular logic and model.</p>
|
||
90 | *
|
||
91 | * @see FLayer
|
||
92 | 214 | fernando | */
|
93 | 341 | fernando | public abstract class FLyrDefault implements FLayer { |
94 | 5923 | fjp | // private PropertyChangeSupport lnkPropertyChangeSupport;
|
95 | 14294 | jvidal | /**
|
96 | * Useful for debug the problems during the implementation.
|
||
97 | */
|
||
98 | 5923 | fjp | private static Logger logger = Logger.getLogger(FLyrDefault.class); |
99 | 13952 | jaume | private LayerChangeSupport layerChangeSupport = new LayerChangeSupport(); |
100 | 14294 | jvidal | /**
|
101 | * Path to the upper layer which this layer belongs.
|
||
102 | 14573 | vcaballero | *
|
103 | 14294 | jvidal | * @see #getParentLayer()
|
104 | * @see #setParentLayer(FLayers)
|
||
105 | */
|
||
106 | 525 | vcaballero | private FLayers parentLayer = null; |
107 | 14294 | jvidal | /**
|
108 | * A node in the tree of layers. Isn't used.
|
||
109 | 14573 | vcaballero | *
|
110 | 14294 | jvidal | * @see #getVirtualLayers()
|
111 | * @see #setVirtualLayers(FLayers)
|
||
112 | */
|
||
113 | 745 | fjp | private FLayers virtualLayers = null; |
114 | 14294 | jvidal | /**
|
115 | * Name for this layer, this also will be a property in the XML entity that represents this layer.
|
||
116 | *
|
||
117 | * @see #getName()
|
||
118 | * @see #setName(String)
|
||
119 | */
|
||
120 | 274 | fjp | private String name; |
121 | 14294 | jvidal | /**
|
122 | * Projection for this layer.
|
||
123 | *
|
||
124 | * @see #getProjection()
|
||
125 | * @see #setProjection(IProjection)
|
||
126 | */
|
||
127 | 354 | fernando | private IProjection projection;
|
128 | 14294 | jvidal | /**
|
129 | 15811 | vcaballero | * Transparency level of this layer in the range 0-255. By default 255.
|
130 | * 0 --> Transparent
|
||
131 | * 255 --> Opaque
|
||
132 | 14294 | jvidal | *
|
133 | * @see #getTransparency()
|
||
134 | * @see #setTransparency(int)
|
||
135 | */
|
||
136 | 15811 | vcaballero | private int transparency = 255; |
137 | 14294 | jvidal | /**
|
138 | * Coordinate transformation.
|
||
139 | *
|
||
140 | * @see #getCoordTrans()
|
||
141 | * @see #setCoordTrans(ICoordTrans)
|
||
142 | */
|
||
143 | 885 | fjp | private ICoordTrans ct;
|
144 | 14294 | jvidal | /**
|
145 | * Minimum scale, >= 0 or -1 if not defined. By default -1.
|
||
146 | *
|
||
147 | * @see #getMinScale()
|
||
148 | * @see #setMinScale(double)
|
||
149 | */
|
||
150 | 1176 | fjp | private double minScale = -1; // -1 indica que no se usa |
151 | 14294 | jvidal | /**
|
152 | * Maximum scale, >= 0 or -1 if not defined. By default -1.
|
||
153 | *
|
||
154 | * @see #getMaxScale()
|
||
155 | * @see #setMaxScale(double)
|
||
156 | */
|
||
157 | 1176 | fjp | private double maxScale = -1; |
158 | 7463 | azabala | // private boolean isInTOC = true;
|
159 | 14294 | jvidal | /**
|
160 | * Array list with all listeners registered to this layer.
|
||
161 | *
|
||
162 | * @see #getLayerListeners()
|
||
163 | * @see #setLayerText(FLyrText)
|
||
164 | * @see #removeLayerListener(LayerListener)
|
||
165 | * @see #callEditionChanged(LayerEvent)
|
||
166 | */
|
||
167 | 3256 | nacho | protected ArrayList layerListeners = new ArrayList(); |
168 | 14294 | jvidal | /**
|
169 | * Strategy of drawing and processing for this layer.
|
||
170 | *
|
||
171 | * @see #getStrategy()
|
||
172 | * @see #setStrategy(Strategy)
|
||
173 | */
|
||
174 | 5923 | fjp | private Strategy privateStrategy = null; |
175 | 14294 | jvidal | /**
|
176 | * Hash table with the extended properties of this layer.
|
||
177 | *
|
||
178 | * @see #getProperty(Object)
|
||
179 | * @see #setProperty(Object, Object)
|
||
180 | * @see #getExtendedProperties()
|
||
181 | */
|
||
182 | 5200 | ldiaz | private Hashtable properties = new Hashtable(); |
183 | 14294 | jvidal | /**
|
184 | * Image with bands that stores the information of the drawn layers.
|
||
185 | *
|
||
186 | * @see #getCacheImageDrawnLayers()
|
||
187 | * @see #setCacheImageDrawnLayers(BufferedImage)
|
||
188 | */
|
||
189 | 5923 | fjp | private BufferedImage cacheImageDrawnLayers = null; |
190 | 7867 | sbayarri | |
191 | 7463 | azabala | //by default, all is active, visible and avalaible
|
192 | 14294 | jvidal | /**
|
193 | * Status of this layer.
|
||
194 | *
|
||
195 | * @see #getFLayerStatus()
|
||
196 | * @see #setFLayerStatus(FLayerStatus)
|
||
197 | * @see #isActive()
|
||
198 | * @see #setActive(boolean)
|
||
199 | * @see #isVisible()
|
||
200 | * @see #setVisible(boolean)
|
||
201 | * @see #visibleRequired()
|
||
202 | * @see #isEditing()
|
||
203 | * @see #setEditing(boolean)
|
||
204 | * @see #isInTOC()
|
||
205 | * @see #isCachingDrawnLayers()
|
||
206 | * @see #setCachingDrawnLayers(boolean)
|
||
207 | * @see #isDirty()
|
||
208 | * @see #setDirty(boolean)
|
||
209 | * @see #isAvailable()
|
||
210 | * @see #setAvailable(boolean)
|
||
211 | * @see #isOk()
|
||
212 | * @see #isWritable()
|
||
213 | * @see #getNumErrors()
|
||
214 | * @see #getError(int)
|
||
215 | * @see #getErrors()
|
||
216 | * @see #addError(DriverException)
|
||
217 | */
|
||
218 | 7463 | azabala | private FLayerStatus status = new FLayerStatus(); |
219 | 14573 | vcaballero | /**
|
220 | * Image drawn shown in the TOC according the status of this layer.
|
||
221 | *
|
||
222 | * @see #getTocStatusImage()
|
||
223 | * @see #setTocStatusImage(Image)
|
||
224 | */
|
||
225 | private Image tocStatusImage; |
||
226 | 14294 | jvidal | /*
|
227 | * (non-Javadoc)
|
||
228 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getProperty(java.lang.Object)
|
||
229 | */
|
||
230 | 5923 | fjp | public Object getProperty(Object key) { |
231 | 5200 | ldiaz | return properties.get(key);
|
232 | } |
||
233 | 14294 | jvidal | /*
|
234 | * (non-Javadoc)
|
||
235 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setProperty(java.lang.Object, java.lang.Object)
|
||
236 | */
|
||
237 | 5923 | fjp | public void setProperty(Object key, Object val) { |
238 | 5200 | ldiaz | properties.put(key, val); |
239 | } |
||
240 | 14294 | jvidal | /*
|
241 | * (non-Javadoc)
|
||
242 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getExtendedProperties()
|
||
243 | */
|
||
244 | 9224 | jjdelcerro | public Map getExtendedProperties() { |
245 | return properties;
|
||
246 | } |
||
247 | 14294 | jvidal | /*
|
248 | * (non-Javadoc)
|
||
249 | 525 | vcaballero | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setActive(boolean)
|
250 | */
|
||
251 | public void setActive(boolean selected) { |
||
252 | 7463 | azabala | //active = selected;
|
253 | status.active = selected; |
||
254 | 5923 | fjp | callActivationChanged(LayerEvent.createActivationChangedEvent(this,
|
255 | 14294 | jvidal | "active"));
|
256 | 525 | vcaballero | } |
257 | 214 | fernando | |
258 | 14294 | jvidal | /*
|
259 | * (non-Javadoc)
|
||
260 | 525 | vcaballero | * @see com.iver.cit.gvsig.fmap.layers.FLayer#isActive()
|
261 | */
|
||
262 | public boolean isActive() { |
||
263 | 7463 | azabala | // return active;
|
264 | return status.active;
|
||
265 | 525 | vcaballero | } |
266 | 214 | fernando | |
267 | 14294 | jvidal | /*
|
268 | * (non-Javadoc)
|
||
269 | 525 | vcaballero | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setName(java.lang.String)
|
270 | */
|
||
271 | public void setName(String name) { |
||
272 | this.name = name;
|
||
273 | 1082 | fernando | callNameChanged(LayerEvent.createNameChangedEvent(this, "name")); |
274 | 525 | vcaballero | } |
275 | 214 | fernando | |
276 | 14294 | jvidal | /*
|
277 | * (non-Javadoc)
|
||
278 | 525 | vcaballero | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getName()
|
279 | */
|
||
280 | public String getName() { |
||
281 | return name;
|
||
282 | } |
||
283 | 214 | fernando | |
284 | 567 | luisw | /*
|
285 | 14294 | jvidal | * (non-Javadoc)
|
286 | 525 | vcaballero | * @see com.iver.cit.gvsig.fmap.layers.FLayer#load()
|
287 | */
|
||
288 | 10627 | caballero | public void load() throws LoadLayerException { |
289 | 525 | vcaballero | } |
290 | 214 | fernando | |
291 | 14294 | jvidal | /*
|
292 | * (non-Javadoc)
|
||
293 | 525 | vcaballero | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setVisible(boolean)
|
294 | 14573 | vcaballero | */
|
295 | 525 | vcaballero | public void setVisible(boolean visibility) { |
296 | 7463 | azabala | // visible = visibility;
|
297 | 7464 | azabala | boolean changed = status.visible != visibility;
|
298 | 7463 | azabala | status.visible = visibility; |
299 | 6002 | fjp | setDirty(true);
|
300 | 7380 | jmvivo | if (changed){
|
301 | if (this.getMapContext() != null){ |
||
302 | this.getMapContext().clearAllCachingImageDrawnLayers();
|
||
303 | } |
||
304 | } |
||
305 | 5923 | fjp | callVisibilityChanged(LayerEvent.createVisibilityChangedEvent(this,
|
306 | 14294 | jvidal | "visible"));
|
307 | 525 | vcaballero | } |
308 | 435 | vcaballero | |
309 | 14294 | jvidal | |
310 | /*
|
||
311 | * (non-Javadoc)
|
||
312 | 525 | vcaballero | * @see com.iver.cit.gvsig.fmap.layers.FLayer#isVisible()
|
313 | */
|
||
314 | public boolean isVisible() { |
||
315 | 7463 | azabala | // return visible && this.available;
|
316 | return status.visible && status.available;
|
||
317 | 525 | vcaballero | } |
318 | 435 | vcaballero | |
319 | 14294 | jvidal | /*
|
320 | * (non-Javadoc)
|
||
321 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getParentLayer()
|
||
322 | 525 | vcaballero | */
|
323 | public FLayers getParentLayer() {
|
||
324 | return parentLayer;
|
||
325 | } |
||
326 | 435 | vcaballero | |
327 | 14294 | jvidal | |
328 | /*
|
||
329 | * (non-Javadoc)
|
||
330 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setParentLayer(com.iver.cit.gvsig.fmap.layers.FLayers)
|
||
331 | 525 | vcaballero | */
|
332 | public void setParentLayer(FLayers root) { |
||
333 | this.parentLayer = root;
|
||
334 | } |
||
335 | 435 | vcaballero | |
336 | 14294 | jvidal | /*
|
337 | * (non-Javadoc)
|
||
338 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setProjection(org.cresques.cts.IProjection)
|
||
339 | 525 | vcaballero | */
|
340 | public void setProjection(IProjection proj) { |
||
341 | 5908 | caballero | projection = proj; |
342 | 5923 | fjp | // Comprobar que la proyecci?n es la misma que la de FMap
|
343 | // Si no lo es, es una capa que est? reproyectada al vuelo
|
||
344 | 6881 | cesar | if ((proj != null) && (getMapContext() != null)) |
345 | if (proj != getMapContext().getProjection()) {
|
||
346 | ICoordTrans ct = proj.getCT(getMapContext().getProjection()); |
||
347 | 5923 | fjp | setCoordTrans(ct); |
348 | logger.debug("Cambio proyecci?n: FMap con "
|
||
349 | 6881 | cesar | + getMapContext().getProjection().getAbrev() + " y capa "
|
350 | 5923 | fjp | + getName() + " con " + proj.getAbrev());
|
351 | } |
||
352 | 525 | vcaballero | } |
353 | 435 | vcaballero | |
354 | 14294 | jvidal | /*
|
355 | * (non-Javadoc)
|
||
356 | 525 | vcaballero | * @see org.cresques.geo.Projected#getProjection()
|
357 | */
|
||
358 | public IProjection getProjection() {
|
||
359 | return projection;
|
||
360 | } |
||
361 | 435 | vcaballero | |
362 | 14294 | jvidal | /*
|
363 | * (non-Javadoc)
|
||
364 | 525 | vcaballero | * @see org.cresques.geo.Projected#reProject(org.cresques.cts.ICoordTrans)
|
365 | */
|
||
366 | public void reProject(ICoordTrans arg0) { |
||
367 | } |
||
368 | 435 | vcaballero | |
369 | 525 | vcaballero | /**
|
370 | 14294 | jvidal | * Returns the transparency level of this layer, in the range 0-255 .
|
371 | 7867 | sbayarri | *
|
372 | 14294 | jvidal | * @return the transparency level
|
373 | 14573 | vcaballero | *
|
374 | 14294 | jvidal | * @see #setTransparency(int)
|
375 | 525 | vcaballero | */
|
376 | public int getTransparency() { |
||
377 | 434 | fjp | return transparency;
|
378 | } |
||
379 | 525 | vcaballero | |
380 | /**
|
||
381 | 14294 | jvidal | * Inserts the transparency level for this layer, the range allowed is 0-255 .
|
382 | 7867 | sbayarri | *
|
383 | 14294 | jvidal | * @param trans the transparency level
|
384 | 14573 | vcaballero | *
|
385 | 14294 | jvidal | * @see #getTransparency()
|
386 | 525 | vcaballero | */
|
387 | 434 | fjp | public void setTransparency(int trans) { |
388 | transparency = trans; |
||
389 | 6002 | fjp | setDirty(true);
|
390 | 434 | fjp | } |
391 | 525 | vcaballero | /**
|
392 | 14294 | jvidal | * <p>Returns an entity that represents this layer.</p>
|
393 | 7867 | sbayarri | *
|
394 | 14294 | jvidal | * <p>This XML entity has elements (properties) that represent and store information about this layer.</p>
|
395 | *
|
||
396 | * <p>There are two kinds of information: default properties of this layer, and extended properties (they added that weren't by default)</p>
|
||
397 | *
|
||
398 | * <p> <b>Default properties:</b>
|
||
399 | * <ul>
|
||
400 | * <li> className : name of this class
|
||
401 | * <li> active : if this layer is active or not
|
||
402 | * <li> name : name of this layer
|
||
403 | * <li> minScale : minimum scale of this layer
|
||
404 | * <li> maxScale : maximum scale of this layer
|
||
405 | * <li> visible : if this layer is visible or not
|
||
406 | * <li> proj : the projection of this layer (only if it's defined)
|
||
407 | * <li> transparency : transparency level of this layer
|
||
408 | * <li> isInTOC : if this layer is in the TOC or not
|
||
409 | * <li> numProperties : number of extended properties
|
||
410 | * </ul>
|
||
411 | * </p>
|
||
412 | *
|
||
413 | * <p> <b>Extended properties:</b> are stored as children of the tree-node returned. There are two kinds of information for a child,
|
||
414 | * according if it's an instance of an <code>String</code> or of an object that implements the interface <code>IPersistance</code>.
|
||
415 | *
|
||
416 | * <ul>
|
||
417 | * <li> <i>Instance of <code>String</code>:</i>
|
||
418 | * <ul>
|
||
419 | * <li> className : name of the class of the object that it's the property
|
||
420 | * <li> value : value of the property
|
||
421 | * <li> layerPropertyName : name of the extended property of the layer
|
||
422 | * </ul>
|
||
423 | * <li> <i>Implements <code>IPersistance</code>:</i>
|
||
424 | * <ul>
|
||
425 | * <li> Information returned by the implementation of the method <code>getXMLEntity</code> of that object
|
||
426 | * <li> className : name of the class of the object (this information could be with the information returned by
|
||
427 | * the method <code>getXMLEntity</code> of that object
|
||
428 | * <li> layerPropertyName : name of the extended property of the layer
|
||
429 | * </ul>
|
||
430 | * <ul>
|
||
431 | * </p>
|
||
432 | *
|
||
433 | * @return an XML entity with information to the current layer
|
||
434 | * @throws com.iver.cit.gvsig.fmap.layers.XMLException if there is an error obtaining the object.
|
||
435 | 14573 | vcaballero | *
|
436 | 14294 | jvidal | * @see #setXMLEntity(XMLEntity)
|
437 | * @see #setXMLEntity03(XMLEntity)
|
||
438 | 525 | vcaballero | */
|
439 | 1828 | fernando | public XMLEntity getXMLEntity() throws XMLException { |
440 | 525 | vcaballero | XMLEntity xml = new XMLEntity();
|
441 | 5923 | fjp | xml.putProperty("className", this.getClass().getName()); |
442 | 435 | vcaballero | |
443 | 525 | vcaballero | if (this instanceof FLayers) { |
444 | } |
||
445 | |||
446 | 7463 | azabala | // xml.putProperty("active", active);
|
447 | xml.putProperty("active", status.active);
|
||
448 | 525 | vcaballero | xml.putProperty("name", name);
|
449 | 5923 | fjp | xml.putProperty("minScale", minScale);
|
450 | xml.putProperty("maxScale", maxScale);
|
||
451 | 5908 | caballero | |
452 | 5923 | fjp | // TODO xml.addChild(parentLayer.getXMLEntity());
|
453 | 7463 | azabala | // xml.putProperty("visible", visible);
|
454 | xml.putProperty("visible", status.visible);
|
||
455 | 1417 | fjp | if (projection != null) { |
456 | 15595 | jmvivo | xml.putProperty("proj", projection.getFullCode());
|
457 | 1417 | fjp | } |
458 | 1455 | luisw | xml.putProperty("transparency", transparency);
|
459 | 7463 | azabala | // xml.putProperty("isInTOC", isInTOC);
|
460 | xml.putProperty("isInTOC", status.inTOC);
|
||
461 | 7867 | sbayarri | |
462 | 13558 | evercher | |
463 | 7867 | sbayarri | // persist Properties hashTable
|
464 | |||
465 | 10627 | caballero | |
466 | 7867 | sbayarri | Set keyset = properties.keySet();
|
467 | |||
468 | 10627 | caballero | |
469 | |||
470 | 7867 | sbayarri | Iterator keyitr = keyset.iterator();
|
471 | 9072 | jmvivo | XMLEntity xmlProperties = new XMLEntity();
|
472 | xmlProperties.putProperty("childName","properties"); |
||
473 | 14294 | jvidal | while (keyitr.hasNext()) {
|
474 | String propName = (String)keyitr.next(); |
||
475 | Object obj = properties.get(propName);
|
||
476 | if (obj instanceof IPersistence) |
||
477 | { |
||
478 | IPersistence persistObj = (IPersistence)obj; |
||
479 | XMLEntity xmlPropObj = persistObj.getXMLEntity(); |
||
480 | // make sure the node contains the class name
|
||
481 | if (!xmlPropObj.contains("className")) { |
||
482 | try {
|
||
483 | String propClassName = persistObj.getClassName();
|
||
484 | System.out.println("PROP CLASS NAME "+propClassName); |
||
485 | xmlPropObj.putProperty("className", propClassName);
|
||
486 | } catch (Exception e) { |
||
487 | e.printStackTrace(); |
||
488 | } |
||
489 | } |
||
490 | xmlPropObj.putProperty("layerPropertyName", propName);
|
||
491 | xmlProperties.addChild(xmlPropObj); |
||
492 | } else if (obj instanceof String) { |
||
493 | XMLEntity xmlPropObj = new XMLEntity();
|
||
494 | xmlPropObj.putProperty("className", String.class.getName()); |
||
495 | xmlPropObj.putProperty("value",(String)obj); |
||
496 | xmlPropObj.putProperty("layerPropertyName", propName);
|
||
497 | xmlProperties.addChild(xmlPropObj); |
||
498 | 9072 | jmvivo | |
499 | 14294 | jvidal | } |
500 | } |
||
501 | if (xmlProperties.getChildrenCount() > 0) { |
||
502 | xml.addChild(xmlProperties); |
||
503 | } |
||
504 | return xml;
|
||
505 | 525 | vcaballero | } |
506 | |||
507 | 14294 | jvidal | /**
|
508 | * <p>Inserts information to this layer.</p>
|
||
509 | 7867 | sbayarri | *
|
510 | 14294 | jvidal | * <p>This XML entity has elements that represent and store information about this layer.</p>
|
511 | 7867 | sbayarri | *
|
512 | 14294 | jvidal | * <p>The properties are the same as the described in <code>getXMLEntity()</code>. And the properties
|
513 | * <i>proj</i>, <i>transparency</i>, <i>isInTOC</i>, <i>numProperties</i> are optional.</p>
|
||
514 | 7867 | sbayarri | *
|
515 | 14294 | jvidal | * @see FLyrDefault#getXMLEntity()
|
516 | 7867 | sbayarri | *
|
517 | 14294 | jvidal | * @param xml an <code>XMLEntity</code> with the information
|
518 | 7867 | sbayarri | *
|
519 | 14294 | jvidal | * @throws com.iver.cit.gvsig.fmap.layers.XMLException if there is an error setting the object.
|
520 | 14573 | vcaballero | *
|
521 | 14294 | jvidal | * @see #getXMLEntity()
|
522 | 525 | vcaballero | */
|
523 | 5923 | fjp | public void setXMLEntity(XMLEntity xml) throws XMLException { |
524 | 7463 | azabala | // active = xml.getBooleanProperty("active");
|
525 | status.active = xml.getBooleanProperty("active");
|
||
526 | 525 | vcaballero | name = xml.getStringProperty("name");
|
527 | 5923 | fjp | minScale = xml.getDoubleProperty("minScale");
|
528 | maxScale = xml.getDoubleProperty("maxScale");
|
||
529 | 7463 | azabala | // visible = xml.getBooleanProperty("visible");
|
530 | status.visible = xml.getBooleanProperty("visible");
|
||
531 | 1417 | fjp | if (xml.contains("proj")) { |
532 | 6164 | luisw2 | setProjection(CRSFactory.getCRS(xml.getStringProperty("proj")));
|
533 | 1417 | fjp | } |
534 | 1455 | luisw | if (xml.contains("transparency")) |
535 | transparency = xml.getIntProperty("transparency");
|
||
536 | 5802 | jaume | if (xml.contains("isInTOC")) |
537 | 7463 | azabala | // isInTOC = xml.getBooleanProperty("isInTOC");
|
538 | status.inTOC = xml.getBooleanProperty("isInTOC");
|
||
539 | 7867 | sbayarri | |
540 | 13558 | evercher | |
541 | |||
542 | 14294 | jvidal | // recreate Properties hashTable
|
543 | 13558 | evercher | |
544 | 12404 | sbayarri | if (xml.contains("numProperties")) { // for older projects |
545 | int numProps = xml.getIntProperty("numProperties"); |
||
546 | Object obj= null; |
||
547 | 13913 | jaume | IPersistence objPersist; |
548 | 14294 | jvidal | for (int iProp=0; iProp<numProps; iProp++) { |
549 | XMLEntity xmlProp = xml.getChild(0);
|
||
550 | try {
|
||
551 | String className = xmlProp.getStringProperty("className"); |
||
552 | if (className.equals(String.class.getName())) { |
||
553 | obj = xmlProp.getStringProperty("value");
|
||
554 | } else {
|
||
555 | Class classProp = Class.forName(className); |
||
556 | obj = classProp.newInstance(); |
||
557 | objPersist = (IPersistence)obj; |
||
558 | objPersist.setXMLEntity(xmlProp); |
||
559 | } |
||
560 | String propName = xmlProp.getStringProperty("layerPropertyName"); |
||
561 | properties.put(propName, obj); |
||
562 | } catch (Exception e) { |
||
563 | continue;
|
||
564 | } |
||
565 | // remove Properties children to avoid breaking layers' XML reading logic
|
||
566 | xml.removeChild(0);
|
||
567 | } |
||
568 | 12404 | sbayarri | } // newer projects store properties under a node
|
569 | else {
|
||
570 | int xmlPropertiesPos = xml.firstIndexOfChild("childName","properties"); |
||
571 | XMLEntity xmlProperties =null;
|
||
572 | if (xmlPropertiesPos > -1) |
||
573 | xmlProperties = xml.getChild(xmlPropertiesPos); |
||
574 | 13558 | evercher | |
575 | 12404 | sbayarri | if (xmlProperties != null) { |
576 | 13558 | evercher | |
577 | 12404 | sbayarri | int numProps = xmlProperties.getChildrenCount();
|
578 | Object obj;
|
||
579 | String className;
|
||
580 | Class classProp;
|
||
581 | 13913 | jaume | IPersistence objPersist; |
582 | 14294 | jvidal | for (int iProp=0; iProp<numProps; iProp++) { |
583 | XMLEntity xmlProp = xmlProperties.getChild(iProp); |
||
584 | try {
|
||
585 | className = xmlProp.getStringProperty("className");
|
||
586 | if (className.equals(String.class.getName())) { |
||
587 | obj = xmlProp.getStringProperty("value");
|
||
588 | } else {
|
||
589 | classProp = Class.forName(className);
|
||
590 | obj = classProp.newInstance(); |
||
591 | objPersist = (IPersistence)obj; |
||
592 | objPersist.setXMLEntity(xmlProp); |
||
593 | 13558 | evercher | |
594 | 14294 | jvidal | } |
595 | String propName = xmlProp.getStringProperty("layerPropertyName"); |
||
596 | properties.put(propName, obj); |
||
597 | } catch (Exception e) { |
||
598 | //FIXME: OJO !!!!!
|
||
599 | continue;
|
||
600 | } |
||
601 | } |
||
602 | // remove Properties children to avoid breaking layers' XML reading logic
|
||
603 | xml.removeChild(xmlPropertiesPos); |
||
604 | 12404 | sbayarri | } |
605 | 7867 | sbayarri | } |
606 | 525 | vcaballero | } |
607 | 694 | fernando | |
608 | /**
|
||
609 | 14294 | jvidal | * <p>Inserts some default properties to the this layer.</p>
|
610 | 7867 | sbayarri | *
|
611 | 14294 | jvidal | * <p> <b>Properties:</b>
|
612 | * <ul>
|
||
613 | * <li> active : if this layer is active or not
|
||
614 | * <li> name : name of this layer
|
||
615 | * <li> minScale : minimum scale of this layer
|
||
616 | * <li> maxScale : maximum scale of this layer
|
||
617 | * <li> visible : if this layer is visible or not
|
||
618 | * <li> proj : the projection of this layer (only if it's defined)
|
||
619 | * <li> transparency : transparency level of this layer (only if it's defined)
|
||
620 | * </ul>
|
||
621 | * </p>
|
||
622 | 7867 | sbayarri | *
|
623 | 14294 | jvidal | * @see FLyrDefault#getXMLEntity()
|
624 | *
|
||
625 | * @param xml an <code>XMLEntity</code> with the information
|
||
626 | *
|
||
627 | * @throws com.iver.cit.gvsig.fmap.layers.XMLException if there is an error obtaining the object.
|
||
628 | 14573 | vcaballero | *
|
629 | 14294 | jvidal | * @see #getXMLEntity()
|
630 | * @see #setXMLEntity(XMLEntity)
|
||
631 | 2183 | fernando | */
|
632 | 5923 | fjp | public void setXMLEntity03(XMLEntity xml) throws XMLException { |
633 | 7463 | azabala | // active = xml.getBooleanProperty("active");
|
634 | status.active = xml.getBooleanProperty("active");
|
||
635 | 2183 | fernando | name = xml.getStringProperty("name");
|
636 | 5923 | fjp | minScale = xml.getDoubleProperty("minScale");
|
637 | maxScale = xml.getDoubleProperty("maxScale");
|
||
638 | 7463 | azabala | // visible = xml.getBooleanProperty("visible");
|
639 | status.visible = xml.getBooleanProperty("visible");
|
||
640 | 2183 | fernando | if (xml.contains("proj")) { |
641 | 6164 | luisw2 | setProjection(CRSFactory.getCRS(xml.getStringProperty("proj")));
|
642 | 2183 | fernando | } |
643 | if (xml.contains("transparency")) |
||
644 | transparency = xml.getIntProperty("transparency");
|
||
645 | } |
||
646 | |||
647 | 14294 | jvidal | /*
|
648 | * (non-Javadoc)
|
||
649 | 6881 | cesar | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getMapContext()
|
650 | 694 | fernando | */
|
651 | 6881 | cesar | public MapContext getMapContext() {
|
652 | 884 | fernando | if (getParentLayer() != null) { |
653 | 6881 | cesar | return getParentLayer().getMapContext();
|
654 | 884 | fernando | } else {
|
655 | return null; |
||
656 | } |
||
657 | 694 | fernando | } |
658 | |||
659 | 14294 | jvidal | /*
|
660 | * (non-Javadoc)
|
||
661 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#addLayerListener(com.iver.cit.gvsig.fmap.layers.LayerListener)
|
||
662 | 884 | fernando | */
|
663 | 727 | fernando | public boolean addLayerListener(LayerListener o) { |
664 | 4370 | caballero | if (layerListeners.contains(o))
|
665 | return false; |
||
666 | 727 | fernando | return layerListeners.add(o);
|
667 | } |
||
668 | 14294 | jvidal | /*
|
669 | * (non-Javadoc)
|
||
670 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getLayerListeners()
|
||
671 | */
|
||
672 | 5908 | caballero | public LayerListener[] getLayerListeners() { |
673 | return (LayerListener[])layerListeners.toArray(new LayerListener[0]); |
||
674 | } |
||
675 | 14294 | jvidal | /*
|
676 | * (non-Javadoc)
|
||
677 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#removeLayerListener(com.iver.cit.gvsig.fmap.layers.LayerListener)
|
||
678 | 884 | fernando | */
|
679 | 727 | fernando | public boolean removeLayerListener(LayerListener o) { |
680 | return layerListeners.remove(o);
|
||
681 | } |
||
682 | 884 | fernando | /**
|
683 | 14294 | jvidal | * Called by the method {@linkplain #setName(String)}. Notifies all listeners associated to this layer,
|
684 | * that its name has changed.
|
||
685 | 7867 | sbayarri | *
|
686 | 14294 | jvidal | * @param e a layer event with the name of the property that has changed
|
687 | 14573 | vcaballero | *
|
688 | 14294 | jvidal | * @see #setName(String)
|
689 | 884 | fernando | */
|
690 | private void callNameChanged(LayerEvent e) { |
||
691 | 727 | fernando | for (Iterator iter = layerListeners.iterator(); iter.hasNext();) { |
692 | LayerListener listener = (LayerListener) iter.next(); |
||
693 | 884 | fernando | |
694 | 727 | fernando | listener.nameChanged(e); |
695 | } |
||
696 | } |
||
697 | 884 | fernando | |
698 | /**
|
||
699 | 14294 | jvidal | * Called by the method {@linkplain #setVisible(boolean)}. Notifies all listeners associated to this layer,
|
700 | * that its visibility has changed.
|
||
701 | 7867 | sbayarri | *
|
702 | 14294 | jvidal | * @param e a layer event with the name of the property that has changed
|
703 | 14573 | vcaballero | *
|
704 | 14294 | jvidal | * @see #setVisible(boolean)
|
705 | 884 | fernando | */
|
706 | private void callVisibilityChanged(LayerEvent e) { |
||
707 | 727 | fernando | for (Iterator iter = layerListeners.iterator(); iter.hasNext();) { |
708 | LayerListener listener = (LayerListener) iter.next(); |
||
709 | 884 | fernando | |
710 | 727 | fernando | listener.visibilityChanged(e); |
711 | } |
||
712 | } |
||
713 | 884 | fernando | |
714 | /**
|
||
715 | 14294 | jvidal | * Called by the method {@linkplain #setActive(boolean)}. Notifies all listeners associated to this layer,
|
716 | * that its active state has changed.
|
||
717 | 7867 | sbayarri | *
|
718 | 14294 | jvidal | * @param e a layer event with the name of the property that has changed
|
719 | 14573 | vcaballero | *
|
720 | 14294 | jvidal | * @see #setActive(boolean)
|
721 | 884 | fernando | */
|
722 | private void callActivationChanged(LayerEvent e) { |
||
723 | 727 | fernando | for (Iterator iter = layerListeners.iterator(); iter.hasNext();) { |
724 | LayerListener listener = (LayerListener) iter.next(); |
||
725 | 884 | fernando | |
726 | 727 | fernando | listener.activationChanged(e); |
727 | } |
||
728 | } |
||
729 | 745 | fjp | |
730 | 884 | fernando | /**
|
731 | 14294 | jvidal | * Returns the virtual layers associated to this layer.
|
732 | 7867 | sbayarri | *
|
733 | 14294 | jvidal | * @return a node with the layers
|
734 | 14573 | vcaballero | *
|
735 | 14294 | jvidal | * @see #setVirtualLayers(FLayers)
|
736 | 884 | fernando | */
|
737 | 745 | fjp | public FLayers getVirtualLayers() {
|
738 | return virtualLayers;
|
||
739 | } |
||
740 | 884 | fernando | |
741 | /**
|
||
742 | 14294 | jvidal | * Inserts virtual layers to this layer.
|
743 | 7867 | sbayarri | *
|
744 | 14294 | jvidal | * @param virtualLayers a node with the layers
|
745 | 14573 | vcaballero | *
|
746 | 14294 | jvidal | * @see #getVirtualLayers()
|
747 | 884 | fernando | */
|
748 | 745 | fjp | public void setVirtualLayers(FLayers virtualLayers) { |
749 | this.virtualLayers = virtualLayers;
|
||
750 | } |
||
751 | 884 | fernando | |
752 | /**
|
||
753 | 14294 | jvidal | * Sets transformation coordinates for this layer.
|
754 | 7867 | sbayarri | *
|
755 | 14294 | jvidal | * @param ct an object that implements the <code>ICoordTrans</code> interface, and with the transformation coordinates
|
756 | 14573 | vcaballero | *
|
757 | 14294 | jvidal | * @see #getCoordTrans()
|
758 | 885 | fjp | */
|
759 | public void setCoordTrans(ICoordTrans ct) { |
||
760 | this.ct = ct;
|
||
761 | } |
||
762 | |||
763 | /**
|
||
764 | 14294 | jvidal | * Returns the transformation coordinates of this layer.
|
765 | 7867 | sbayarri | *
|
766 | 14294 | jvidal | * @return ct an object that implements the <code>ICoordTrans</code> interface, and with the transformation coordinates
|
767 | 14573 | vcaballero | *
|
768 | 14294 | jvidal | * @see #setCoordTrans(ICoordTrans)
|
769 | 885 | fjp | */
|
770 | public ICoordTrans getCoordTrans() {
|
||
771 | return ct;
|
||
772 | } |
||
773 | 5908 | caballero | |
774 | 4376 | nacho | /**
|
775 | 14294 | jvidal | * <p>Method called by {@link FLayers FLayers} to notify this layer that is going to be added.
|
776 | * This previous notification is useful for the layers that need do something before being added. For
|
||
777 | * example, the raster needs reopen a file that could have been closed recently.</p>
|
||
778 | 4376 | nacho | */
|
779 | 10627 | caballero | public void wakeUp() throws LoadLayerException { |
780 | 5923 | fjp | } |
781 | 14294 | jvidal | /*
|
782 | * (non-Javadoc)
|
||
783 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getMinScale()
|
||
784 | */
|
||
785 | 5923 | fjp | public double getMinScale() { |
786 | return minScale;
|
||
787 | } |
||
788 | 1176 | fjp | |
789 | 5923 | fjp | /*
|
790 | * (non-Javadoc)
|
||
791 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getMaxScale()
|
||
792 | */
|
||
793 | public double getMaxScale() { |
||
794 | return maxScale;
|
||
795 | } |
||
796 | 14294 | jvidal | /*
|
797 | * (non-Javadoc)
|
||
798 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setMinScale(double)
|
||
799 | */
|
||
800 | 5923 | fjp | public void setMinScale(double minScale) { |
801 | this.minScale = minScale;
|
||
802 | } |
||
803 | 14294 | jvidal | /*
|
804 | * (non-Javadoc)
|
||
805 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setMaxScale(double)
|
||
806 | */
|
||
807 | 5923 | fjp | public void setMaxScale(double maxScale) { |
808 | this.maxScale = maxScale;
|
||
809 | } |
||
810 | 14294 | jvidal | /*
|
811 | * (non-Javadoc)
|
||
812 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#isWithinScale(double)
|
||
813 | */
|
||
814 | 5923 | fjp | public boolean isWithinScale(double scale) { |
815 | 5908 | caballero | |
816 | 5923 | fjp | boolean bVisible = true; |
817 | if (getMinScale() != -1) { |
||
818 | if (scale < getMinScale())
|
||
819 | bVisible = false;
|
||
820 | } |
||
821 | if (getMaxScale() != -1) { |
||
822 | if (scale > getMaxScale())
|
||
823 | bVisible = false;
|
||
824 | } |
||
825 | 5908 | caballero | |
826 | 5923 | fjp | return bVisible;
|
827 | } |
||
828 | 14294 | jvidal | /**
|
829 | * Returns the strategy of drawing and processing for this layer.
|
||
830 | *
|
||
831 | * @return an object that implements the <code>Strategy</code> interface.
|
||
832 | 14573 | vcaballero | *
|
833 | 14294 | jvidal | * @see #setStrategy(Strategy)
|
834 | */
|
||
835 | 5923 | fjp | public Strategy getStrategy() {
|
836 | return privateStrategy;
|
||
837 | } |
||
838 | 14294 | jvidal | /**
|
839 | * Inserts the strategy of drawing and processing this layer.
|
||
840 | *
|
||
841 | * @param s an object that implements the <code>Strategy</code> interface.
|
||
842 | 14573 | vcaballero | *
|
843 | 14294 | jvidal | * @see #getStrategy()
|
844 | */
|
||
845 | 5923 | fjp | public void setStrategy(Strategy s) { |
846 | privateStrategy = s; |
||
847 | } |
||
848 | 14294 | jvidal | /*
|
849 | * (non-Javadoc)
|
||
850 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setEditing(boolean)
|
||
851 | */
|
||
852 | 10627 | caballero | public void setEditing(boolean b) throws StartEditionLayerException { |
853 | 7463 | azabala | // isediting = b;
|
854 | status.editing = b; |
||
855 | 6002 | fjp | setDirty(true);
|
856 | setCachingDrawnLayers(b); |
||
857 | 3690 | caballero | } |
858 | 14294 | jvidal | /**
|
859 | 14573 | vcaballero | * Called by some version of the method {@linkplain #setEditing(boolean)} overwritten. Notifies
|
860 | 14294 | jvidal | * all listeners associated to this layer, that its edition state has changed.
|
861 | *
|
||
862 | * @param e a layer event with the name of the property that has changed
|
||
863 | 14573 | vcaballero | *
|
864 | 14294 | jvidal | * @see #setEditing(boolean)
|
865 | */
|
||
866 | 4147 | fjp | protected void callEditionChanged(LayerEvent e) { |
867 | 4144 | fjp | for (Iterator iter = layerListeners.iterator(); iter.hasNext();) { |
868 | LayerListener listener = (LayerListener) iter.next(); |
||
869 | |||
870 | listener.editionChanged(e); |
||
871 | } |
||
872 | } |
||
873 | 14294 | jvidal | /*
|
874 | * (non-Javadoc)
|
||
875 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#isEditing()
|
||
876 | */
|
||
877 | 5923 | fjp | public boolean isEditing() { |
878 | 7463 | azabala | // return isediting;
|
879 | return status.editing;
|
||
880 | 3690 | caballero | } |
881 | 14294 | jvidal | /*
|
882 | * (non-Javadoc)
|
||
883 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getTocImageIcon()
|
||
884 | */
|
||
885 | 5923 | fjp | public ImageIcon getTocImageIcon() { |
886 | return null; |
||
887 | } |
||
888 | 14294 | jvidal | /*
|
889 | * (non-Javadoc)
|
||
890 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#isInTOC()
|
||
891 | */
|
||
892 | 5923 | fjp | public boolean isInTOC() { |
893 | 7463 | azabala | // return isInTOC;
|
894 | return status.inTOC;
|
||
895 | 5923 | fjp | } |
896 | 14294 | jvidal | /*
|
897 | * (non-Javadoc)
|
||
898 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setInTOC(boolean)
|
||
899 | */
|
||
900 | 13566 | caballero | public void setInTOC(boolean b) { |
901 | status.inTOC=b; |
||
902 | } |
||
903 | 14294 | jvidal | /*
|
904 | * (non-Javadoc)
|
||
905 | 5923 | fjp | * @see com.iver.cit.gvsig.fmap.layers.FLayer#isCachingDrawnLayers()
|
906 | */
|
||
907 | public boolean isCachingDrawnLayers() { |
||
908 | 7463 | azabala | // return bCacheDrawnLayers;
|
909 | return status.cacheDrawnLayers;
|
||
910 | 5923 | fjp | } |
911 | |||
912 | 14294 | jvidal | |
913 | /*
|
||
914 | * (non-Javadoc)
|
||
915 | 5923 | fjp | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setCachingDrawnLayers(boolean)
|
916 | */
|
||
917 | public void setCachingDrawnLayers(boolean bCacheDrawnLayers) { |
||
918 | 7463 | azabala | // this.bCacheDrawnLayers = bCacheDrawnLayers;
|
919 | status.cacheDrawnLayers = bCacheDrawnLayers; |
||
920 | if (status.cacheDrawnLayers == false) |
||
921 | 5997 | fjp | this.cacheImageDrawnLayers = null; |
922 | 5923 | fjp | } |
923 | 14294 | jvidal | /*
|
924 | * (non-Javadoc)
|
||
925 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getCacheImageDrawnLayers()
|
||
926 | */
|
||
927 | 5923 | fjp | public BufferedImage getCacheImageDrawnLayers() { |
928 | return cacheImageDrawnLayers;
|
||
929 | } |
||
930 | 14294 | jvidal | /*
|
931 | * (non-Javadoc)
|
||
932 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setCacheImageDrawnLayers(java.awt.image.BufferedImage)
|
||
933 | */
|
||
934 | 5923 | fjp | public void setCacheImageDrawnLayers(BufferedImage cacheImageDrawnLayers) { |
935 | this.cacheImageDrawnLayers = cacheImageDrawnLayers;
|
||
936 | } |
||
937 | 14294 | jvidal | /*
|
938 | * (non-Javadoc)
|
||
939 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#isDirty()
|
||
940 | */
|
||
941 | 5923 | fjp | public boolean isDirty() { |
942 | 7463 | azabala | return status.dirty;
|
943 | 5923 | fjp | } |
944 | 14294 | jvidal | /*
|
945 | * (non-Javadoc)
|
||
946 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setDirty(boolean)
|
||
947 | */
|
||
948 | 5923 | fjp | public void setDirty(boolean dirty) { |
949 | 7463 | azabala | status.dirty = dirty; |
950 | 5923 | fjp | } |
951 | 14294 | jvidal | /*
|
952 | * (non-Javadoc)
|
||
953 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#isAvailable()
|
||
954 | */
|
||
955 | 6543 | jmvivo | public boolean isAvailable() { |
956 | 7463 | azabala | return status.available;
|
957 | 6400 | jmvivo | } |
958 | 14294 | jvidal | /*
|
959 | * (non-Javadoc)
|
||
960 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setAvailable(boolean)
|
||
961 | */
|
||
962 | 6532 | jmvivo | public void setAvailable(boolean available) { |
963 | 7463 | azabala | status.available = available; |
964 | 6400 | jmvivo | } |
965 | 14294 | jvidal | /*
|
966 | * (non-Javadoc)
|
||
967 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#reload()
|
||
968 | */
|
||
969 | 10627 | caballero | public void reload() throws ReloadLayerException { |
970 | 6532 | jmvivo | this.setAvailable(true); |
971 | } |
||
972 | 7867 | sbayarri | |
973 | 14294 | jvidal | /*
|
974 | * (non-Javadoc)
|
||
975 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getFLayerStatus()
|
||
976 | 7463 | azabala | */
|
977 | public FLayerStatus getFLayerStatus(){
|
||
978 | return status;
|
||
979 | } |
||
980 | 14294 | jvidal | /*
|
981 | * (non-Javadoc)
|
||
982 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#setFLayerStatus(com.iver.cit.gvsig.fmap.layers.FLayerStatus)
|
||
983 | 7463 | azabala | */
|
984 | public void setFLayerStatus(FLayerStatus status){ |
||
985 | this.status = status;
|
||
986 | } |
||
987 | 7867 | sbayarri | |
988 | 7463 | azabala | /*
|
989 | * This stuff is to save error's info that causes
|
||
990 | * unavailable status.
|
||
991 | * */
|
||
992 | 7867 | sbayarri | |
993 | 14294 | jvidal | /*
|
994 | * (non-Javadoc)
|
||
995 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#isOk()
|
||
996 | */
|
||
997 | |||
998 | 7463 | azabala | public boolean isOk(){ |
999 | return status.isOk();
|
||
1000 | } |
||
1001 | 14294 | jvidal | /*
|
1002 | * (non-Javadoc)
|
||
1003 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getNumErrors()
|
||
1004 | */
|
||
1005 | 7463 | azabala | public int getNumErrors(){ |
1006 | return status.getNumErrors();
|
||
1007 | } |
||
1008 | 7867 | sbayarri | |
1009 | 10627 | caballero | public BaseException getError(int i){ |
1010 | 7463 | azabala | return status.getError(i);
|
1011 | } |
||
1012 | 14294 | jvidal | /*
|
1013 | * (non-Javadoc)
|
||
1014 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getErrors()
|
||
1015 | */
|
||
1016 | 7463 | azabala | public List getErrors(){ |
1017 | return status.getErrors();
|
||
1018 | } |
||
1019 | 7867 | sbayarri | |
1020 | 14294 | jvidal | /*
|
1021 | * (non-Javadoc)
|
||
1022 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#addError(com.iver.cit.gvsig.fmap.DriverException)
|
||
1023 | */
|
||
1024 | 10627 | caballero | public void addError(BaseException exception){ |
1025 | status.addLayerError(exception); |
||
1026 | 7463 | azabala | } |
1027 | 14294 | jvidal | /*
|
1028 | * (non-Javadoc)
|
||
1029 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#visibleRequired()
|
||
1030 | */
|
||
1031 | 6532 | jmvivo | public boolean visibleRequired() { |
1032 | 7463 | azabala | return status.visible;
|
1033 | 6532 | jmvivo | } |
1034 | 14294 | jvidal | /*
|
1035 | * (non-Javadoc)
|
||
1036 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getInfoString()
|
||
1037 | */
|
||
1038 | 6532 | jmvivo | public String getInfoString() { |
1039 | return null; |
||
1040 | } |
||
1041 | 14294 | jvidal | /*
|
1042 | * (non-Javadoc)
|
||
1043 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#isWritable()
|
||
1044 | */
|
||
1045 | 6856 | fjp | public boolean isWritable() { |
1046 | 7463 | azabala | return status.writable;
|
1047 | 6856 | fjp | } |
1048 | 10627 | caballero | |
1049 | 14294 | jvidal | /*
|
1050 | * (non-Javadoc)
|
||
1051 | 9923 | fjp | * @see com.iver.cit.gvsig.fmap.layers.FLayer#cloneLayer()
|
1052 | */
|
||
1053 | public FLayer cloneLayer() throws Exception { |
||
1054 | return this; |
||
1055 | } |
||
1056 | 14573 | vcaballero | /*
|
1057 | * (non-Javadoc)
|
||
1058 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getTocStatusImage()
|
||
1059 | */
|
||
1060 | public Image getTocStatusImage() { |
||
1061 | return tocStatusImage;
|
||
1062 | } |
||
1063 | 5923 | fjp | |
1064 | 14573 | vcaballero | /**
|
1065 | * Inserts the image icon that will be shown in the TOC next to this layer, according its status.
|
||
1066 | *
|
||
1067 | * @param tocStatusImage the image
|
||
1068 | *
|
||
1069 | * @see #getTocStatusImage()
|
||
1070 | */
|
||
1071 | public void setTocStatusImage(Image tocStatusImage) { |
||
1072 | this.tocStatusImage = tocStatusImage;
|
||
1073 | logger.debug("setTocStatusImage " + tocStatusImage + " sobre capa " + this.getName()); |
||
1074 | } |
||
1075 | 14294 | jvidal | /*
|
1076 | * (non-Javadoc)
|
||
1077 | 10932 | jmvivo | * @see com.iver.cit.gvsig.fmap.layers.FLayer#newComposedLayer()
|
1078 | */
|
||
1079 | 13558 | evercher | public ComposedLayer newComposedLayer() {
|
1080 | 10932 | jmvivo | return null; |
1081 | } |
||
1082 | 6856 | fjp | |
1083 | 13558 | evercher | /**
|
1084 | * FLyrDefault does not allow HyperLinks.
|
||
1085 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#allowLinks()
|
||
1086 | */
|
||
1087 | 14294 | jvidal | public boolean allowLinks() |
1088 | { |
||
1089 | return false; |
||
1090 | } |
||
1091 | 10932 | jmvivo | |
1092 | 14294 | jvidal | /**
|
1093 | * Return null because does not allow HyperLinks
|
||
1094 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getLinkProperties()
|
||
1095 | */
|
||
1096 | public AbstractLinkProperties getLinkProperties()
|
||
1097 | { |
||
1098 | return null; |
||
1099 | } |
||
1100 | /**
|
||
1101 | * Return null because does not allow HyperLinks
|
||
1102 | * @see com.iver.cit.gvsig.fmap.layers.FLayer#getLink()
|
||
1103 | */
|
||
1104 | public URI[] getLink(Point2D point, double tolerance) |
||
1105 | { |
||
1106 | //return linkProperties.getLink(this)
|
||
1107 | return null; |
||
1108 | } |
||
1109 | 13952 | jaume | |
1110 | 14294 | jvidal | /**
|
1111 | * A?ade un LegendListener a la lista de Listeners.
|
||
1112 | *
|
||
1113 | * @param listener
|
||
1114 | * LegendListener.
|
||
1115 | */
|
||
1116 | public void addLegendListener(LegendListener listener) { |
||
1117 | layerChangeSupport.addLayerListener(listener); |
||
1118 | } |
||
1119 | 13952 | jaume | |
1120 | 14294 | jvidal | /**
|
1121 | * Llamada al m?todo callLegendChanged de los listener.
|
||
1122 | *
|
||
1123 | * @param e
|
||
1124 | * Evento.
|
||
1125 | */
|
||
1126 | protected void callLegendChanged(LegendChangedEvent e) { |
||
1127 | layerChangeSupport.callLegendChanged(e); |
||
1128 | if(parentLayer != null) |
||
1129 | parentLayer.callLegendChanged(e); |
||
1130 | } |
||
1131 | 13952 | jaume | |
1132 | 14294 | jvidal | /**
|
1133 | * Borra un LegendListener de la lista de Listeners
|
||
1134 | *
|
||
1135 | * @param listener
|
||
1136 | * LegendListener.
|
||
1137 | */
|
||
1138 | public void removeLegendListener(LegendListener listener) { |
||
1139 | layerChangeSupport.removeLayerListener(listener); |
||
1140 | } |
||
1141 | |||
1142 | 214 | fernando | } |