svn-gvsig-desktop / tags / v1_1_Build_1008 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLayer.java @ 12520
History | View | Annotate | Download (11.8 KB)
1 | 11946 | maquerol | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | 1100 | fjp | *
|
3 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | 11946 | maquerol | * Av. Blasco Ib??ez, 50
|
24 | 1100 | fjp | * 46010 VALENCIA
|
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | 214 | fernando | package com.iver.cit.gvsig.fmap.layers; |
42 | |||
43 | 8765 | jjdelcerro | import java.awt.Graphics2D; |
44 | 10401 | fjp | import java.awt.Image; |
45 | 8765 | jjdelcerro | import java.awt.geom.Rectangle2D; |
46 | import java.awt.image.BufferedImage; |
||
47 | 11925 | maquerol | import java.io.File; |
48 | 8765 | jjdelcerro | import java.util.List; |
49 | 9359 | fdiaz | import java.util.Map; |
50 | 8765 | jjdelcerro | |
51 | 9013 | caballero | import javax.print.attribute.PrintRequestAttributeSet; |
52 | 8765 | jjdelcerro | import javax.swing.ImageIcon; |
53 | |||
54 | import org.cresques.cts.ICoordTrans; |
||
55 | 11925 | maquerol | import org.cresques.cts.IProjection; |
56 | 8765 | jjdelcerro | import org.cresques.geo.Projected; |
57 | |||
58 | 651 | fernando | import com.iver.cit.gvsig.fmap.DriverException; |
59 | 6878 | cesar | import com.iver.cit.gvsig.fmap.MapContext; |
60 | 11925 | maquerol | import com.iver.cit.gvsig.fmap.MapControl; |
61 | 533 | vcaballero | import com.iver.cit.gvsig.fmap.ViewPort; |
62 | 442 | vcaballero | import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
63 | 5152 | fjp | import com.iver.cit.gvsig.fmap.edition.EditionException; |
64 | 11030 | jmvivo | import com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer; |
65 | 415 | fernando | import com.iver.utiles.XMLEntity; |
66 | 5317 | fjp | import com.iver.utiles.swing.threads.Cancellable; |
67 | 249 | vcaballero | |
68 | |||
69 | 217 | fernando | /**
|
70 | 1005 | vcaballero | * Interfaz que tienen que implementar todas las capas.
|
71 | 217 | fernando | */
|
72 | 533 | vcaballero | public interface FLayer extends Projected { |
73 | 523 | vcaballero | /**
|
74 | 11946 | maquerol | * Obtiene una representaci?n de la colecci?n de capas de forma recursiva
|
75 | 523 | vcaballero | *
|
76 | 1005 | vcaballero | * @return XMLEntity.
|
77 | 1828 | fernando | * @throws XMLException
|
78 | 523 | vcaballero | */
|
79 | 1828 | fernando | XMLEntity getXMLEntity() throws XMLException;
|
80 | 214 | fernando | |
81 | 523 | vcaballero | /**
|
82 | 1005 | vcaballero | * Inserta las propiedades del XMLEntity al objeto actual.
|
83 | 523 | vcaballero | *
|
84 | 1005 | vcaballero | * @param xml XMLEntity
|
85 | 523 | vcaballero | *
|
86 | * @throws XMLException
|
||
87 | */
|
||
88 | 1056 | vcaballero | void setXMLEntity(XMLEntity xml) throws XMLException; |
89 | 442 | vcaballero | |
90 | 523 | vcaballero | /**
|
91 | 2183 | fernando | * Inserta las propiedades del XMLEntity al objeto actual.
|
92 | *
|
||
93 | * @param xml XMLEntity
|
||
94 | *
|
||
95 | * @throws XMLException
|
||
96 | */
|
||
97 | void setXMLEntity03(XMLEntity xml) throws XMLException; |
||
98 | |||
99 | /**
|
||
100 | 11946 | maquerol | * Pone la capa actual a activa o inactiva seg?n el boolean que se pasa
|
101 | * como par?metro.
|
||
102 | 523 | vcaballero | *
|
103 | 1005 | vcaballero | * @param selected activa.
|
104 | 523 | vcaballero | */
|
105 | void setActive(boolean selected); |
||
106 | 214 | fernando | |
107 | 523 | vcaballero | /**
|
108 | 1005 | vcaballero | * Devuelve true si la capa esta activa.
|
109 | 523 | vcaballero | *
|
110 | 1005 | vcaballero | * @return activa.
|
111 | 523 | vcaballero | */
|
112 | boolean isActive();
|
||
113 | 214 | fernando | |
114 | 523 | vcaballero | /**
|
115 | 1005 | vcaballero | * Inserta un nombre a la capa.
|
116 | 523 | vcaballero | *
|
117 | 1005 | vcaballero | * @param name nombre.
|
118 | 523 | vcaballero | */
|
119 | void setName(String name); |
||
120 | 214 | fernando | |
121 | 523 | vcaballero | /**
|
122 | 1005 | vcaballero | * Devuelve el nombre de la capa.
|
123 | 523 | vcaballero | *
|
124 | 1005 | vcaballero | * @return nombre de la capa.
|
125 | 523 | vcaballero | */
|
126 | String getName();
|
||
127 | 214 | fernando | |
128 | 523 | vcaballero | /**
|
129 | 11946 | maquerol | * Realiza las operaciones de inicializaci?n de la capa. El m?todo es
|
130 | * invocado una ?nica vez durante la vida de la capa y justo antes de
|
||
131 | 523 | vcaballero | * visualizar la capa
|
132 | *
|
||
133 | 1005 | vcaballero | * @throws DriverIOException
|
134 | 523 | vcaballero | */
|
135 | void load() throws DriverIOException; |
||
136 | 214 | fernando | |
137 | 523 | vcaballero | /**
|
138 | 1005 | vcaballero | * Pone la capa en modo visible o no visible.
|
139 | 523 | vcaballero | *
|
140 | 1005 | vcaballero | * @param visibility visibilidad.
|
141 | 523 | vcaballero | */
|
142 | void setVisible(boolean visibility); |
||
143 | 214 | fernando | |
144 | 523 | vcaballero | /**
|
145 | 1005 | vcaballero | * Devuelve true si la capa es visible.
|
146 | 6531 | jmvivo | * Es dependiente isAvialable @link isAvialable
|
147 | 523 | vcaballero | *
|
148 | 1005 | vcaballero | * @return visibilidad.
|
149 | 6531 | jmvivo | *
|
150 | * @see isAvialable()
|
||
151 | * @see setAvialable()
|
||
152 | * @see visibleRequired()
|
||
153 | 523 | vcaballero | */
|
154 | boolean isVisible();
|
||
155 | 214 | fernando | |
156 | 523 | vcaballero | /**
|
157 | 1005 | vcaballero | * Devuelve el FLayers padre de la capa.
|
158 | 523 | vcaballero | *
|
159 | 1005 | vcaballero | * @return FLayers padre de la capa.
|
160 | 523 | vcaballero | */
|
161 | public FLayers getParentLayer();
|
||
162 | 249 | vcaballero | |
163 | 884 | fernando | /**
|
164 | 11946 | maquerol | * Devuelve el FMap al que est? a?adida la capa o null si la capa no ha
|
165 | * sido a?adida a ning?n FMap
|
||
166 | 885 | fjp | *
|
167 | 884 | fernando | * @return FMap
|
168 | */
|
||
169 | 6881 | cesar | public MapContext getMapContext();
|
170 | 884 | fernando | |
171 | 513 | fjp | /**
|
172 | 1005 | vcaballero | * Inserta el FLayers padre de la capa.
|
173 | 563 | fernando | *
|
174 | 1005 | vcaballero | * @param root capa padre.
|
175 | 563 | fernando | */
|
176 | public void setParentLayer(FLayers root); |
||
177 | |||
178 | /**
|
||
179 | 11946 | maquerol | * Obtiene la extensi?n completa de la capa
|
180 | 513 | fjp | *
|
181 | 1005 | vcaballero | * @return FullExtent.
|
182 | 513 | fjp | *
|
183 | 1005 | vcaballero | * @throws DriverException
|
184 | 513 | fjp | */
|
185 | 651 | fernando | Rectangle2D getFullExtent() throws DriverException; |
186 | 513 | fjp | |
187 | /**
|
||
188 | * Dibuja la capa
|
||
189 | *
|
||
190 | 1005 | vcaballero | * @param image Imagen utilizada para acelerar el dibujado en pantalla.
|
191 | * @param g Graphics2D sobre el que dibujar.
|
||
192 | * @param viewPort Propiedades de la vista.
|
||
193 | * @param cancel PAra poder cancelar el dibujado.
|
||
194 | 513 | fjp | *
|
195 | * @throws DriverException
|
||
196 | 563 | fernando | */
|
197 | void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
||
198 | 2531 | caballero | Cancellable cancel,double scale) throws DriverException; |
199 | 563 | fernando | |
200 | /**
|
||
201 | * Dibuja la capa
|
||
202 | *
|
||
203 | 1005 | vcaballero | * @param g Graphics2D de la impresora sobre el que dibujar.
|
204 | * @param viewPort Propiedades de la vista.
|
||
205 | 563 | fernando | * @param cancel
|
206 | *
|
||
207 | * @throws DriverException
|
||
208 | 513 | fjp | */
|
209 | 9013 | caballero | void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties) |
210 | 653 | fernando | throws DriverException;
|
211 | 727 | fernando | |
212 | 884 | fernando | /**
|
213 | 11946 | maquerol | * Inserta las coordenadas de transformaci?n.
|
214 | 884 | fernando | *
|
215 | 11946 | maquerol | * @param ct Coordenadas de transformaci?n.
|
216 | 885 | fjp | */
|
217 | void setCoordTrans(ICoordTrans ct);
|
||
218 | |||
219 | /**
|
||
220 | 11946 | maquerol | * Devuelve las coordenadas de transformaci?n.
|
221 | 885 | fjp | *
|
222 | 11946 | maquerol | * @return Coordenadas de transformaci?n.
|
223 | 885 | fjp | */
|
224 | ICoordTrans getCoordTrans(); |
||
225 | |||
226 | /**
|
||
227 | 11946 | maquerol | * A?ade un listener LayerListener a la lista de listeners.
|
228 | 885 | fjp | *
|
229 | 1005 | vcaballero | * @param o Listener.
|
230 | 884 | fernando | *
|
231 | 11946 | maquerol | * @return True si es correcta la inserci?n del listener.
|
232 | 884 | fernando | */
|
233 | 727 | fernando | public boolean addLayerListener(LayerListener o); |
234 | 5908 | caballero | public LayerListener[] getLayerListeners(); |
235 | 884 | fernando | /**
|
236 | 11946 | maquerol | * Borra de la lista el LayerListener que se pasa como par?metro.
|
237 | 884 | fernando | *
|
238 | 1005 | vcaballero | * @param o Listener.
|
239 | 884 | fernando | *
|
240 | 1005 | vcaballero | * @return True si es correcto el borrado del listener.
|
241 | 884 | fernando | */
|
242 | 727 | fernando | public boolean removeLayerListener(LayerListener o); |
243 | 5908 | caballero | |
244 | 2531 | caballero | public boolean isWithinScale(double scale); |
245 | 5908 | caballero | |
246 | |||
247 | 1176 | fjp | /**
|
248 | 11946 | maquerol | * La capa no se visualiza si est? por debajo de esa escala
|
249 | * @return la escala minima de visualizaci?n
|
||
250 | 1176 | fjp | */
|
251 | public double getMinScale(); |
||
252 | |||
253 | /**
|
||
254 | 11946 | maquerol | * La capa no se visualiza si est? por encima de esa escala
|
255 | * @return la escala m?xima de visualizaci?n
|
||
256 | 1176 | fjp | */
|
257 | public double getMaxScale(); |
||
258 | 5908 | caballero | |
259 | 1176 | fjp | public void setMinScale(double minScale); |
260 | public void setMaxScale(double maxScale); |
||
261 | 5152 | fjp | public void setEditing(boolean b) throws EditionException; |
262 | 3690 | caballero | public boolean isEditing(); |
263 | 5923 | fjp | |
264 | public boolean isCachingDrawnLayers(); |
||
265 | 5760 | jmvivo | /**
|
266 | 5923 | fjp | * Set true if you want this layer to store an image of previous layers
|
267 | * Then, if you perform and "FLayers.invalidateLayer(lyr)", the system will
|
||
268 | * redraw only the layers you are requesting.
|
||
269 | 11946 | maquerol | * Otra opci?n ser?a guardar una imagen de cada capa dibujada, y poner una
|
270 | 5923 | fjp | * llamada en cada una de ellas, algo como "invalidate()". Al renderizar,
|
271 | 11946 | maquerol | * se puede ver si est? invalidada, y si no lo est?, pegar la imagen cacheada.
|
272 | * ERROR!: Luis tiene raz?n en esto: No puedes cachear esa imagen porque
|
||
273 | * si el fondo ha cambiado, el antialiasing afectar? al dibujado de esa capa.
|
||
274 | * Sin embargo, s? ser?a ?til si lo que se hace es dibujar la imagen cacheada
|
||
275 | * de cada una de las capas que no est?n invalidadas, y a partir de que aparezca
|
||
276 | 5923 | fjp | * una de ellas invalidada, el resto ya se tienen que dibujar.
|
277 | 11946 | maquerol | * La pega de que consumes m?s memoria sigue estando presente.
|
278 | 5923 | fjp | * @param bCacheDrawnLayers
|
279 | */
|
||
280 | public void setCachingDrawnLayers(boolean bCacheDrawnLayers); |
||
281 | |||
282 | /**
|
||
283 | 5760 | jmvivo | * Icono a mostrar en el TOC junto a la capa
|
284 | * @return el icono
|
||
285 | */
|
||
286 | public ImageIcon getTocImageIcon(); |
||
287 | 5802 | jaume | |
288 | /**
|
||
289 | 5803 | jaume | * If the layer appears in the TOC then <b>true</b> is returned,
|
290 | * if <b>false</b> the layer will not be displayed at the TOC
|
||
291 | * although it remains in the view and in the project
|
||
292 | 5802 | jaume | */
|
293 | boolean isInTOC();
|
||
294 | 5923 | fjp | |
295 | /**
|
||
296 | * @return true if this layer need a repaint.
|
||
297 | */
|
||
298 | public boolean isDirty(); |
||
299 | |||
300 | /**
|
||
301 | * true if this layer need a repaint. By default, all layers will be
|
||
302 | * set to dirty when the extent changes. But for events like changing
|
||
303 | * its legend, or editing a layer, we can perform some optimization
|
||
304 | * in the method prepareDrawing from FMap.
|
||
305 | * @param dirty
|
||
306 | */
|
||
307 | public void setDirty(boolean dirty); |
||
308 | |||
309 | public BufferedImage getCacheImageDrawnLayers(); |
||
310 | |||
311 | public void setCacheImageDrawnLayers(BufferedImage cacheImageDrawnLayers); |
||
312 | 6531 | jmvivo | |
313 | 8765 | jjdelcerro | |
314 | 6531 | jmvivo | /**
|
315 | 8765 | jjdelcerro | * Returns the status of the layer
|
316 | */
|
||
317 | public FLayerStatus getFLayerStatus();
|
||
318 | /**
|
||
319 | * Sets the status of the layer
|
||
320 | * @param status
|
||
321 | */
|
||
322 | public void setFLayerStatus(FLayerStatus status); |
||
323 | |||
324 | |||
325 | /*
|
||
326 | * This stuff is to save error's info that causes
|
||
327 | * unavailable status.
|
||
328 | * */
|
||
329 | /**
|
||
330 | * Return if the layer is in OK status
|
||
331 | * (it hasnt got errors)
|
||
332 | */
|
||
333 | public boolean isOk(); |
||
334 | /**
|
||
335 | * returns the number of errors that causes layer
|
||
336 | * unavailable status
|
||
337 | * @return
|
||
338 | */
|
||
339 | public int getNumErrors(); |
||
340 | |||
341 | /**
|
||
342 | * return the specified error
|
||
343 | * @param i
|
||
344 | * @return
|
||
345 | */
|
||
346 | public DriverException getError(int i); |
||
347 | |||
348 | /**
|
||
349 | * add an error cause to describe the layer's wrong status
|
||
350 | * @param error
|
||
351 | */
|
||
352 | public void addError(DriverException error); |
||
353 | |||
354 | /**
|
||
355 | * Returns a list with all layer errors
|
||
356 | * @return
|
||
357 | */
|
||
358 | public List getErrors(); |
||
359 | |||
360 | |||
361 | /**
|
||
362 | 6531 | jmvivo | * @return set layer aviable or not.
|
363 | */
|
||
364 | 6543 | jmvivo | public void setAvailable(boolean available); |
365 | 5923 | fjp | |
366 | 6531 | jmvivo | /**
|
367 | * @return true if this layer is aviable.
|
||
368 | *
|
||
369 | * Default value is true.
|
||
370 | */
|
||
371 | 6543 | jmvivo | public boolean isAvailable(); |
372 | 6531 | jmvivo | |
373 | /**
|
||
374 | * Intenta recuperar una capa ante un posible error.
|
||
375 | * Si tiene algun problema en la carga, marca
|
||
376 | * el avialable a false y lanza una excepcion.
|
||
377 | *
|
||
378 | * @throws DriverIOException
|
||
379 | */
|
||
380 | public void reload() throws DriverIOException; |
||
381 | |||
382 | |||
383 | /**
|
||
384 | * Devuelve true si la capa esta establecida como visible.
|
||
385 | *
|
||
386 | * @return visibilidad.
|
||
387 | */
|
||
388 | boolean visibleRequired();
|
||
389 | |||
390 | /**
|
||
391 | * Devuelve una cadena con informacion sobre la capa.
|
||
392 | *
|
||
393 | * @return visibilidad.
|
||
394 | */
|
||
395 | public String getInfoString(); |
||
396 | 6856 | fjp | |
397 | /**
|
||
398 | * @return true if this layer can be put in edition mode and save the
|
||
399 | * edits in itself.
|
||
400 | */
|
||
401 | public boolean isWritable(); |
||
402 | 8765 | jjdelcerro | |
403 | /**
|
||
404 | * Useful to associate any object to a layer. For example, you
|
||
405 | * can attach a network definition to key "network" and
|
||
406 | * check if a layer has a network loaded if getAssociatedObject("network")
|
||
407 | * is not null
|
||
408 | *
|
||
409 | * @param key
|
||
410 | * @return null if key is not found
|
||
411 | */
|
||
412 | public Object getProperty(Object key); |
||
413 | |||
414 | /**
|
||
415 | * @param key
|
||
416 | * @param obj
|
||
417 | */
|
||
418 | public void setProperty(Object key, Object obj); |
||
419 | 6531 | jmvivo | |
420 | 9225 | fjp | /**
|
421 | * This method can be used to have a fast cloned layer. The implementations should take care of
|
||
422 | * NOT recreate the layer. Instead of this, is better to use the same source (driver) and deepclone
|
||
423 | * the legend. Exception=> the labels aren't deepcloned to avoid memory consumption.
|
||
424 | * Note: Labels are memory consuming to speed up layers like PostGIS and so on.
|
||
425 | * @return clonedLayer
|
||
426 | * @throws Exception
|
||
427 | */
|
||
428 | public FLayer cloneLayer() throws Exception; |
||
429 | 9359 | fdiaz | |
430 | public Map getExtendedProperties(); |
||
431 | 10401 | fjp | |
432 | /**
|
||
433 | 11030 | jmvivo | * Return a new instance of ComposedLayer.
|
434 | * This allow make a single draw for a group
|
||
435 | * of layers with the same source.
|
||
436 | *
|
||
437 | * If this operation is not aplicable for this
|
||
438 | * kind of layer this method returns null.
|
||
439 | *
|
||
440 | * @see com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer
|
||
441 | * @return ComposedLayer instance or null
|
||
442 | */
|
||
443 | public ComposedLayer newComposedLayer();
|
||
444 | |||
445 | /**
|
||
446 | 10401 | fjp | * @return
|
447 | */
|
||
448 | Image getTocStatusImage();
|
||
449 | 9359 | fdiaz | |
450 | 11925 | maquerol | /**
|
451 | * Devuelve true en el caso de que la capa sea de un tipo reproyectable.
|
||
452 | * @return
|
||
453 | */
|
||
454 | public boolean isReprojectable(); |
||
455 | |||
456 | /**
|
||
457 | 11946 | maquerol | * M?todo que se encarga de reproyectar la capa. En cada tipo de capa se sobrecargar?
|
458 | * este m?todo para que se realicen las operaciones necesarias.
|
||
459 | 11925 | maquerol | * @return Devuelve true en el caso de que sea AddLayer la clase que se tenga que encargar de crear
|
460 | 11946 | maquerol | * la capa. Devolver? false si se pasa el control de la carga de la capa al m?todo de reproyecci?n
|
461 | 11925 | maquerol | */
|
462 | 11937 | maquerol | public boolean reProject(MapControl mapC); |
463 | 11925 | maquerol | |
464 | /**
|
||
465 | 11946 | maquerol | * Inserta una proyecci?n.
|
466 | * @param proj, proyecci?n.
|
||
467 | 11925 | maquerol | */
|
468 | public void setProjection(IProjection proj); |
||
469 | 6531 | jmvivo | |
470 | 214 | fernando | } |