Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLayer.java @ 10627

History | View | Annotate | Download (10.8 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
import org.gvsig.exceptions.BaseException;
55

    
56
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
57
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException;
58
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException;
59
import com.iver.cit.gvsig.exceptions.layers.ReloadLayerException;
60
import com.iver.cit.gvsig.exceptions.layers.StartEditionLayerException;
61
import com.iver.cit.gvsig.fmap.MapContext;
62
import com.iver.cit.gvsig.fmap.ViewPort;
63
import com.iver.utiles.XMLEntity;
64
import com.iver.utiles.swing.threads.Cancellable;
65

    
66

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

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

    
88
        /**
89
         * Inserta las propiedades del XMLEntity al objeto actual.
90
         *
91
         * @param xml XMLEntity
92
         *
93
         * @throws XMLException
94
         */
95
        void setXMLEntity03(XMLEntity xml) throws XMLException;
96

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

    
105
        /**
106
         * Devuelve true si la capa esta activa.
107
         *
108
         * @return activa.
109
         */
110
        boolean isActive();
111

    
112
        /**
113
         * Inserta un nombre a la capa.
114
         *
115
         * @param name nombre.
116
         */
117
        void setName(String name);
118

    
119
        /**
120
         * Devuelve el nombre de la capa.
121
         *
122
         * @return nombre de la capa.
123
         */
124
        String getName();
125

    
126
        /**
127
         * Realiza las operaciones de inicializaci?n de la capa. El m?todo es
128
         * invocado una ?nica vez durante la vida de la capa y justo antes de
129
         * visualizar la capa
130
         * @throws LoadLayerException TODO
131
         */
132
        void load() throws LoadLayerException;
133

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

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

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

    
160
        /**
161
         * 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
         *
164
         * @return FMap
165
         */
166
        public MapContext getMapContext();
167

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

    
175
        /**
176
         * Obtiene la extensi?n completa de la capa
177
         *
178
         * @return FullExtent.
179
         * @throws ReadDriverException
180
         * @throws ExpansionFileReadException
181
         */
182
        Rectangle2D getFullExtent() throws ReadDriverException, ExpansionFileReadException;
183

    
184
        /**
185
         * Dibuja la capa
186
         *
187
         * @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
         * @throws ReadDriverException TODO
192
         */
193
        void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
194
                Cancellable cancel,double scale) throws ReadDriverException;
195

    
196
        /**
197
         * Dibuja la capa
198
         *
199
         * @param g Graphics2D de la impresora sobre el que dibujar.
200
         * @param viewPort Propiedades de la vista.
201
         * @param cancel
202
         * @throws ReadDriverException TODO
203
         */
204
        void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties)
205
                throws ReadDriverException;
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 StartEditionLayerException;
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 BaseException getError(int i);
342

    
343
        /**
344
         * add an error cause to describe the layer's wrong status
345
         * @param exception TODO
346
         */
347
        public void addError(BaseException exception);
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
         * @throws ReloadLayerException TODO
373
         */
374
        public void reload() throws ReloadLayerException;
375

    
376

    
377
        /**
378
         * Devuelve true si la capa esta establecida como visible.
379
         *
380
         * @return visibilidad.
381
         */
382
        boolean visibleRequired();
383

    
384
        /**
385
         * Devuelve una cadena con informacion sobre la capa.
386
         *
387
         * @return visibilidad.
388
         */
389
        public String getInfoString();
390

    
391
        /**
392
         * @return true if this layer can be put in edition mode and save the
393
         * edits in itself.
394
         */
395
        public boolean isWritable();
396

    
397
        /**
398
         * This method can be used to have a fast cloned layer. The implementations should take care of
399
         * NOT recreate the layer. Instead of this, is better to use the same source (driver) and deepclone
400
         * the legend. Exception=> the labels aren't deepcloned to avoid memory consumption.
401
         * Note: Labels are memory consuming to speed up layers like PostGIS and so on.
402
         * @return clonedLayer
403
         * @throws Exception
404
         */
405
        public FLayer cloneLayer() throws Exception;
406

    
407

    
408
        /**
409
         * Useful to associate any object to a layer. For example, you
410
         * can attach a network definition to key "network" and
411
         * check if a layer has a network loaded if getAssociatedObject("network")
412
         * is not null
413
         *
414
         * @param key
415
         * @return null if key is not found
416
         */
417
        public Object getProperty(Object key);
418

    
419
        /**
420
         * @param key
421
         * @param obj
422
         */
423
        public void setProperty(Object key, Object obj);
424

    
425
        public Map getExtendedProperties();
426

    
427

    
428
}