Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLayer.java @ 6531

History | View | Annotate | Download (8.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 com.iver.cit.gvsig.fmap.DriverException;
44
import com.iver.cit.gvsig.fmap.FMap;
45
import com.iver.cit.gvsig.fmap.ViewPort;
46
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
47
import com.iver.cit.gvsig.fmap.edition.EditionException;
48

    
49
import com.iver.utiles.XMLEntity;
50
import com.iver.utiles.swing.threads.Cancellable;
51

    
52
import org.cresques.cts.ICoordTrans;
53

    
54
import org.cresques.geo.Projected;
55

    
56
import java.awt.Graphics2D;
57
import java.awt.geom.Rectangle2D;
58
import java.awt.image.BufferedImage;
59

    
60
import javax.swing.ImageIcon;
61

    
62

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

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

    
84
        /**
85
         * Inserta las propiedades del XMLEntity al objeto actual.
86
         *
87
         * @param xml XMLEntity
88
         *
89
         * @throws XMLException
90
         */
91
        void setXMLEntity03(XMLEntity xml) throws XMLException;
92

    
93
        /**
94
         * Pone la capa actual a activa o inactiva seg?n el boolean que se pasa
95
         * como par?metro.
96
         *
97
         * @param selected activa.
98
         */
99
        void setActive(boolean selected);
100

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

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

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

    
122
        /**
123
         * Realiza las operaciones de inicializaci?n de la capa. El m?todo es
124
         * invocado una ?nica vez durante la vida de la capa y justo antes de
125
         * visualizar la capa
126
         *
127
         * @throws DriverIOException
128
         */
129
        void load() throws DriverIOException;
130

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

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

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

    
157
        /**
158
         * Devuelve el FMap al que est? a?adida la capa o null si la capa no ha
159
         * sido a?adida a ning?n FMap
160
         *
161
         * @return FMap
162
         */
163
        public FMap getFMap();
164

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

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

    
181
        /**
182
         * Dibuja la capa
183
         *
184
         * @param image Imagen utilizada para acelerar el dibujado en pantalla.
185
         * @param g Graphics2D sobre el que dibujar.
186
         * @param viewPort Propiedades de la vista.
187
         * @param cancel PAra poder cancelar el dibujado.
188
         *
189
         * @throws DriverException
190
         */
191
        void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
192
                Cancellable cancel,double scale) throws DriverException;
193

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

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

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

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

    
238
        public boolean isWithinScale(double scale);
239

    
240

    
241
        /**
242
         * La capa no se visualiza si est? por debajo de esa escala
243
         * @return la escala minima de visualizaci?n
244
         */
245
        public double getMinScale();
246

    
247
        /**
248
         * La capa no se visualiza si est? por encima de esa escala
249
         * @return la escala m?xima de visualizaci?n
250
         */
251
        public double getMaxScale();
252

    
253
        public void setMinScale(double minScale);
254
        public void setMaxScale(double maxScale);
255
        public void setEditing(boolean b) throws EditionException;
256
        public boolean isEditing();
257
        
258
        public boolean isCachingDrawnLayers();
259
        /**
260
         * Set true if you want this layer to store an image of previous layers
261
         * Then, if you perform and "FLayers.invalidateLayer(lyr)", the system will
262
         * redraw only the layers you are requesting.
263
         * Otra opci?n ser?a guardar una imagen de cada capa dibujada, y poner una
264
         * llamada en cada una de ellas, algo como "invalidate()". Al renderizar, 
265
         * se puede ver si est? invalidada, y si no lo est?, pegar la imagen cacheada.
266
         * ERROR!: Luis tiene raz?n en esto: No puedes cachear esa imagen porque 
267
         * si el fondo ha cambiado, el antialiasing afectar? al dibujado de esa capa.
268
         * Sin embargo, s? ser?a ?til si lo que se hace es dibujar la imagen cacheada
269
         * de cada una de las capas que no est?n invalidadas, y a partir de que aparezca
270
         * una de ellas invalidada, el resto ya se tienen que dibujar.
271
         * La pega de que consumes m?s memoria sigue estando presente. 
272
         * @param bCacheDrawnLayers
273
         */
274
        public void setCachingDrawnLayers(boolean bCacheDrawnLayers);
275
        
276
        /**
277
         * Icono a mostrar en el TOC junto a la capa
278
         * @return el icono
279
         */
280
        public ImageIcon getTocImageIcon();
281

    
282
        /**
283
         * If the layer appears in the TOC then <b>true</b> is returned,
284
         * if <b>false</b> the layer will not be displayed at the TOC
285
         * although it remains in the view and in the project
286
         */
287
        boolean isInTOC();
288
        
289
        /**
290
         * @return true if this layer need a repaint.
291
         */
292
        public boolean isDirty();
293

    
294
        /**
295
         * true if this layer need a repaint. By default, all layers will be
296
         * set to dirty when the extent changes. But for events like changing
297
         * its legend, or editing a layer, we can perform some optimization
298
         * in the method prepareDrawing from FMap.
299
         * @param dirty
300
         */
301
        public void setDirty(boolean dirty);
302
        
303
        public BufferedImage getCacheImageDrawnLayers();
304

    
305
        public void setCacheImageDrawnLayers(BufferedImage cacheImageDrawnLayers);
306

    
307
        /**
308
         * @return set layer aviable or not.
309
         */
310
        public void setAvailable(boolean aviable);
311
        
312
        /**
313
         * @return true if this layer is aviable.
314
         * 
315
         * Default value is true.
316
         */        
317
        public boolean isAvialable();
318
        
319
        /**
320
         * Intenta recuperar una capa ante un posible error.
321
         * Si tiene algun problema en la carga, marca
322
         * el avialable a false y lanza una excepcion.
323
         *
324
         * @throws DriverIOException
325
         */
326
        public void reload() throws DriverIOException;
327
        
328
        
329
        /**
330
         * Devuelve true si la capa esta establecida como visible.
331
         *
332
         * @return visibilidad.
333
         */
334
        boolean visibleRequired();
335

    
336
        /**
337
         * Devuelve una cadena con informacion sobre la capa.
338
         *
339
         * @return visibilidad.
340
         */
341
        public String getInfoString();
342

    
343

    
344
}