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