Statistics
| Revision:

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

History | View | Annotate | Download (11.3 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.cit.gvsig.fmap.layers.layerOperations.ComposedLayer;
64
import com.iver.utiles.XMLEntity;
65
import com.iver.utiles.swing.threads.Cancellable;
66

    
67

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

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

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

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

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

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

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

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

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

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

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

    
161
        /**
162
         * Devuelve el FMap al que est? a?adida la capa o null si la capa no ha
163
         * sido a?adida a ning?n FMap
164
         *
165
         * @return FMap
166
         */
167
        public MapContext getMapContext();
168

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

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

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

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

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

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

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

    
240
        public boolean isWithinScale(double scale);
241

    
242

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

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

    
255
        public void setMinScale(double minScale);
256
        public void setMaxScale(double maxScale);
257
        public void setEditing(boolean b) throws StartEditionLayerException;
258
        public boolean isEditing();
259

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

    
278
        /**
279
         * Icono a mostrar en el TOC junto a la capa
280
         * @return el icono
281
         */
282
        public ImageIcon getTocImageIcon();
283

    
284
        /**
285
         * If the layer appears in the TOC then <b>true</b> is returned,
286
         * if <b>false</b> the layer will not be displayed at the TOC
287
         * although it remains in the view and in the project
288
         */
289
        boolean isInTOC();
290

    
291
        /**
292
         * @return true if this layer need a repaint.
293
         */
294
        public boolean isDirty();
295

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

    
305
        public BufferedImage getCacheImageDrawnLayers();
306

    
307
        public void setCacheImageDrawnLayers(BufferedImage cacheImageDrawnLayers);
308

    
309

    
310
        /**
311
         * Returns the status of the layer
312
         */
313
        public FLayerStatus getFLayerStatus();
314
        /**
315
         * Sets the status of the layer
316
         * @param status
317
         */
318
        public void setFLayerStatus(FLayerStatus status);
319

    
320

    
321
        /*
322
         * This stuff is to save error's info that causes
323
         * unavailable status.
324
         * */
325
        /**
326
         * Return if the layer is in OK status
327
         * (it hasnt got errors)
328
         */
329
        public boolean isOk();
330
        /**
331
         * returns the number of errors that causes layer
332
         * unavailable status
333
         * @return
334
         */
335
        public int getNumErrors();
336

    
337
        /**
338
         * return the specified error
339
         * @param i
340
         * @return
341
         */
342
        public BaseException getError(int i);
343

    
344
        /**
345
         * add an error cause to describe the layer's wrong status
346
         * @param exception TODO
347
         */
348
        public void addError(BaseException exception);
349

    
350
        /**
351
         * Returns a list with all layer errors
352
         * @return
353
         */
354
        public List getErrors();
355

    
356

    
357
        /**
358
         * @return set layer aviable or not.
359
         */
360
        public void setAvailable(boolean available);
361

    
362
        /**
363
         * @return true if this layer is aviable.
364
         *
365
         * Default value is true.
366
         */
367
        public boolean isAvailable();
368

    
369
        /**
370
         * Intenta recuperar una capa ante un posible error.
371
         * Si tiene algun problema en la carga, marca
372
         * el avialable a false y lanza una excepcion.
373
         * @throws ReloadLayerException TODO
374
         */
375
        public void reload() throws ReloadLayerException;
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
         * This method can be used to have a fast cloned layer. The implementations should take care of
400
         * NOT recreate the layer. Instead of this, is better to use the same source (driver) and deepclone
401
         * the legend. Exception=> the labels aren't deepcloned to avoid memory consumption.
402
         * Note: Labels are memory consuming to speed up layers like PostGIS and so on.
403
         * @return clonedLayer
404
         * @throws Exception
405
         */
406
        public FLayer cloneLayer() throws Exception;
407

    
408

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

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

    
426
        public Map getExtendedProperties();
427

    
428
        /**
429
         * Return a new instance of ComposedLayer. 
430
         * This allow make a single draw for a group
431
         * of layers with the same source.
432
         * 
433
         * If this operation is not aplicable for this 
434
         * kind of layer this method returns null.
435
         * 
436
         * @see com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer
437
         * @return ComposedLayer instance or null
438
         */
439
        public ComposedLayer  newComposedLayer();
440
        
441

    
442
}