Statistics
| Revision:

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

History | View | Annotate | Download (10.5 KB)

1
/* 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
package com.iver.cit.gvsig.fmap.layers;
42

    
43
import java.awt.Graphics2D;
44
import java.awt.geom.Rectangle2D;
45
import java.awt.image.BufferedImage;
46
import java.util.List;
47
import java.util.Map;
48

    
49
import javax.print.attribute.PrintRequestAttributeSet;
50
import javax.swing.ImageIcon;
51

    
52
import org.cresques.cts.ICoordTrans;
53
import org.cresques.geo.Projected;
54

    
55
import com.iver.cit.gvsig.fmap.DriverException;
56
import com.iver.cit.gvsig.fmap.MapContext;
57
import com.iver.cit.gvsig.fmap.ViewPort;
58
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
59
import com.iver.cit.gvsig.fmap.edition.EditionException;
60
import com.iver.utiles.XMLEntity;
61
import com.iver.utiles.swing.threads.Cancellable;
62

    
63

    
64
/**
65
 * Interfaz que tienen que implementar todas las capas.
66
 */
67
public interface FLayer extends Projected {
68
        /**
69
         * Obtiene una representaci?n de la colecci?n de capas de forma recursiva
70
         *
71
         * @return XMLEntity.
72
         * @throws XMLException
73
         */
74
        XMLEntity getXMLEntity() throws XMLException;
75

    
76
        /**
77
         * Inserta las propiedades del XMLEntity al objeto actual.
78
         *
79
         * @param xml XMLEntity
80
         *
81
         * @throws XMLException
82
         */
83
        void setXMLEntity(XMLEntity xml) throws XMLException;
84

    
85
        /**
86
         * 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
         * Pone la capa actual a activa o inactiva seg?n el boolean que se pasa
96
         * como par?metro.
97
         *
98
         * @param selected activa.
99
         */
100
        void setActive(boolean selected);
101

    
102
        /**
103
         * Devuelve true si la capa esta activa.
104
         *
105
         * @return activa.
106
         */
107
        boolean isActive();
108

    
109
        /**
110
         * Inserta un nombre a la capa.
111
         *
112
         * @param name nombre.
113
         */
114
        void setName(String name);
115

    
116
        /**
117
         * Devuelve el nombre de la capa.
118
         *
119
         * @return nombre de la capa.
120
         */
121
        String getName();
122

    
123
        /**
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
         * @throws DriverIOException
129
         */
130
        void load() throws DriverIOException;
131

    
132
        /**
133
         * Pone la capa en modo visible o no visible.
134
         *
135
         * @param visibility visibilidad.
136
         */
137
        void setVisible(boolean visibility);
138

    
139
        /**
140
         * Devuelve true si la capa es visible.
141
         * Es dependiente isAvialable @link isAvialable 
142
         *
143
         * @return visibilidad.
144
         * 
145
         * @see isAvialable()
146
         * @see setAvialable()
147
         * @see visibleRequired()
148
         */
149
        boolean isVisible();
150

    
151
        /**
152
         * Devuelve el FLayers padre de la capa.
153
         *
154
         * @return FLayers padre de la capa.
155
         */
156
        public FLayers getParentLayer();
157

    
158
        /**
159
         * 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
         *
162
         * @return FMap
163
         */
164
        public MapContext getMapContext();
165

    
166
        /**
167
         * Inserta el FLayers padre de la capa.
168
         *
169
         * @param root capa padre.
170
         */
171
        public void setParentLayer(FLayers root);
172

    
173
        /**
174
         * Obtiene la extensi?n completa de la capa
175
         *
176
         * @return FullExtent.
177
         *
178
         * @throws DriverException
179
         */
180
        Rectangle2D getFullExtent() throws DriverException;
181

    
182
        /**
183
         * Dibuja la capa
184
         *
185
         * @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
         *
190
         * @throws DriverException
191
         */
192
        void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
193
                Cancellable cancel,double scale) throws DriverException;
194

    
195
        /**
196
         * Dibuja la capa
197
         *
198
         * @param g Graphics2D de la impresora sobre el que dibujar.
199
         * @param viewPort Propiedades de la vista.
200
         * @param cancel
201
         *
202
         * @throws DriverException
203
         */
204
        void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties)
205
                throws DriverException;
206

    
207
        /**
208
         * Inserta las coordenadas de transformaci?n.
209
         *
210
         * @param ct Coordenadas de transformaci?n.
211
         */
212
        void setCoordTrans(ICoordTrans ct);
213

    
214
        /**
215
         * Devuelve las coordenadas de transformaci?n.
216
         *
217
         * @return Coordenadas de transformaci?n.
218
         */
219
        ICoordTrans getCoordTrans();
220

    
221
        /**
222
         * A?ade un listener LayerListener a la lista de listeners.
223
         *
224
         * @param o Listener.
225
         *
226
         * @return True si es correcta la inserci?n del listener.
227
         */
228
        public boolean addLayerListener(LayerListener o);
229
        public LayerListener[] getLayerListeners();
230
        /**
231
         * Borra de la lista el LayerListener que se pasa como par?metro.
232
         *
233
         * @param o Listener.
234
         *
235
         * @return True si es correcto el borrado del listener.
236
         */
237
        public boolean removeLayerListener(LayerListener o);
238

    
239
        public boolean isWithinScale(double scale);
240

    
241

    
242
        /**
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

    
254
        public void setMinScale(double minScale);
255
        public void setMaxScale(double maxScale);
256
        public void setEditing(boolean b) throws EditionException;
257
        public boolean isEditing();
258
        
259
        public boolean isCachingDrawnLayers();
260
        /**
261
         * 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
         * Icono a mostrar en el TOC junto a la capa
279
         * @return el icono
280
         */
281
        public ImageIcon getTocImageIcon();
282

    
283
        /**
284
         * 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
         */
288
        boolean isInTOC();
289
        
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

    
308
        
309
        /**
310
         * 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
         * @return set layer aviable or not.
358
         */
359
        public void setAvailable(boolean available);
360
        
361
        /**
362
         * @return true if this layer is aviable.
363
         * 
364
         * Default value is true.
365
         */        
366
        public boolean isAvailable();
367
        
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
        
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
        
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

    
415
        /**
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
        
425
        public Map getExtendedProperties();
426
        
427

    
428
}