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