Statistics
| Revision:

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

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