Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_2_Build_914 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLayer.java @ 12200

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