svn-gvsig-desktop / tags / v1_0_2_Build_905 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLayer.java @ 10767
History | View | Annotate | Download (10.6 KB)
1 | 1100 | fjp | /* 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 | 214 | fernando | package com.iver.cit.gvsig.fmap.layers; |
42 | |||
43 | 8765 | jjdelcerro | import java.awt.Graphics2D; |
44 | 10401 | fjp | import java.awt.Image; |
45 | 8765 | jjdelcerro | import java.awt.geom.Rectangle2D; |
46 | import java.awt.image.BufferedImage; |
||
47 | import java.util.List; |
||
48 | 9359 | fdiaz | import java.util.Map; |
49 | 8765 | jjdelcerro | |
50 | 9013 | caballero | import javax.print.attribute.PrintRequestAttributeSet; |
51 | 8765 | jjdelcerro | import javax.swing.ImageIcon; |
52 | |||
53 | import org.cresques.cts.ICoordTrans; |
||
54 | import org.cresques.geo.Projected; |
||
55 | |||
56 | 651 | fernando | import com.iver.cit.gvsig.fmap.DriverException; |
57 | 6878 | cesar | import com.iver.cit.gvsig.fmap.MapContext; |
58 | 533 | vcaballero | import com.iver.cit.gvsig.fmap.ViewPort; |
59 | 442 | vcaballero | import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
60 | 5152 | fjp | import com.iver.cit.gvsig.fmap.edition.EditionException; |
61 | 415 | fernando | import com.iver.utiles.XMLEntity; |
62 | 5317 | fjp | import com.iver.utiles.swing.threads.Cancellable; |
63 | 249 | vcaballero | |
64 | |||
65 | 217 | fernando | /**
|
66 | 1005 | vcaballero | * Interfaz que tienen que implementar todas las capas.
|
67 | 217 | fernando | */
|
68 | 533 | vcaballero | public interface FLayer extends Projected { |
69 | 523 | vcaballero | /**
|
70 | * Obtiene una representaci?n de la colecci?n de capas de forma recursiva
|
||
71 | *
|
||
72 | 1005 | vcaballero | * @return XMLEntity.
|
73 | 1828 | fernando | * @throws XMLException
|
74 | 523 | vcaballero | */
|
75 | 1828 | fernando | XMLEntity getXMLEntity() throws XMLException;
|
76 | 214 | fernando | |
77 | 523 | vcaballero | /**
|
78 | 1005 | vcaballero | * Inserta las propiedades del XMLEntity al objeto actual.
|
79 | 523 | vcaballero | *
|
80 | 1005 | vcaballero | * @param xml XMLEntity
|
81 | 523 | vcaballero | *
|
82 | * @throws XMLException
|
||
83 | */
|
||
84 | 1056 | vcaballero | void setXMLEntity(XMLEntity xml) throws XMLException; |
85 | 442 | vcaballero | |
86 | 523 | vcaballero | /**
|
87 | 2183 | fernando | * Inserta las propiedades del XMLEntity al objeto actual.
|
88 | *
|
||
89 | * @param xml XMLEntity
|
||
90 | *
|
||
91 | * @throws XMLException
|
||
92 | */
|
||
93 | void setXMLEntity03(XMLEntity xml) throws XMLException; |
||
94 | |||
95 | /**
|
||
96 | 1005 | vcaballero | * Pone la capa actual a activa o inactiva seg?n el boolean que se pasa
|
97 | * como par?metro.
|
||
98 | 523 | vcaballero | *
|
99 | 1005 | vcaballero | * @param selected activa.
|
100 | 523 | vcaballero | */
|
101 | void setActive(boolean selected); |
||
102 | 214 | fernando | |
103 | 523 | vcaballero | /**
|
104 | 1005 | vcaballero | * Devuelve true si la capa esta activa.
|
105 | 523 | vcaballero | *
|
106 | 1005 | vcaballero | * @return activa.
|
107 | 523 | vcaballero | */
|
108 | boolean isActive();
|
||
109 | 214 | fernando | |
110 | 523 | vcaballero | /**
|
111 | 1005 | vcaballero | * Inserta un nombre a la capa.
|
112 | 523 | vcaballero | *
|
113 | 1005 | vcaballero | * @param name nombre.
|
114 | 523 | vcaballero | */
|
115 | void setName(String name); |
||
116 | 214 | fernando | |
117 | 523 | vcaballero | /**
|
118 | 1005 | vcaballero | * Devuelve el nombre de la capa.
|
119 | 523 | vcaballero | *
|
120 | 1005 | vcaballero | * @return nombre de la capa.
|
121 | 523 | vcaballero | */
|
122 | String getName();
|
||
123 | 214 | fernando | |
124 | 523 | vcaballero | /**
|
125 | * Realiza las operaciones de inicializaci?n de la capa. El m?todo es
|
||
126 | * invocado una ?nica vez durante la vida de la capa y justo antes de
|
||
127 | * visualizar la capa
|
||
128 | *
|
||
129 | 1005 | vcaballero | * @throws DriverIOException
|
130 | 523 | vcaballero | */
|
131 | void load() throws DriverIOException; |
||
132 | 214 | fernando | |
133 | 523 | vcaballero | /**
|
134 | 1005 | vcaballero | * Pone la capa en modo visible o no visible.
|
135 | 523 | vcaballero | *
|
136 | 1005 | vcaballero | * @param visibility visibilidad.
|
137 | 523 | vcaballero | */
|
138 | void setVisible(boolean visibility); |
||
139 | 214 | fernando | |
140 | 523 | vcaballero | /**
|
141 | 1005 | vcaballero | * Devuelve true si la capa es visible.
|
142 | 6531 | jmvivo | * Es dependiente isAvialable @link isAvialable
|
143 | 523 | vcaballero | *
|
144 | 1005 | vcaballero | * @return visibilidad.
|
145 | 6531 | jmvivo | *
|
146 | * @see isAvialable()
|
||
147 | * @see setAvialable()
|
||
148 | * @see visibleRequired()
|
||
149 | 523 | vcaballero | */
|
150 | boolean isVisible();
|
||
151 | 214 | fernando | |
152 | 523 | vcaballero | /**
|
153 | 1005 | vcaballero | * Devuelve el FLayers padre de la capa.
|
154 | 523 | vcaballero | *
|
155 | 1005 | vcaballero | * @return FLayers padre de la capa.
|
156 | 523 | vcaballero | */
|
157 | public FLayers getParentLayer();
|
||
158 | 249 | vcaballero | |
159 | 884 | fernando | /**
|
160 | 1005 | vcaballero | * Devuelve el FMap al que est? a?adida la capa o null si la capa no ha
|
161 | * sido a?adida a ning?n FMap
|
||
162 | 885 | fjp | *
|
163 | 884 | fernando | * @return FMap
|
164 | */
|
||
165 | 6881 | cesar | public MapContext getMapContext();
|
166 | 884 | fernando | |
167 | 513 | fjp | /**
|
168 | 1005 | vcaballero | * Inserta el FLayers padre de la capa.
|
169 | 563 | fernando | *
|
170 | 1005 | vcaballero | * @param root capa padre.
|
171 | 563 | fernando | */
|
172 | public void setParentLayer(FLayers root); |
||
173 | |||
174 | /**
|
||
175 | 513 | fjp | * Obtiene la extensi?n completa de la capa
|
176 | *
|
||
177 | 1005 | vcaballero | * @return FullExtent.
|
178 | 513 | fjp | *
|
179 | 1005 | vcaballero | * @throws DriverException
|
180 | 513 | fjp | */
|
181 | 651 | fernando | Rectangle2D getFullExtent() throws DriverException; |
182 | 513 | fjp | |
183 | /**
|
||
184 | * Dibuja la capa
|
||
185 | *
|
||
186 | 1005 | vcaballero | * @param image Imagen utilizada para acelerar el dibujado en pantalla.
|
187 | * @param g Graphics2D sobre el que dibujar.
|
||
188 | * @param viewPort Propiedades de la vista.
|
||
189 | * @param cancel PAra poder cancelar el dibujado.
|
||
190 | 513 | fjp | *
|
191 | * @throws DriverException
|
||
192 | 563 | fernando | */
|
193 | void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
||
194 | 2531 | caballero | Cancellable cancel,double scale) throws DriverException; |
195 | 563 | fernando | |
196 | /**
|
||
197 | * Dibuja la capa
|
||
198 | *
|
||
199 | 1005 | vcaballero | * @param g Graphics2D de la impresora sobre el que dibujar.
|
200 | * @param viewPort Propiedades de la vista.
|
||
201 | 563 | fernando | * @param cancel
|
202 | *
|
||
203 | * @throws DriverException
|
||
204 | 513 | fjp | */
|
205 | 9013 | caballero | void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties) |
206 | 653 | fernando | throws DriverException;
|
207 | 727 | fernando | |
208 | 884 | fernando | /**
|
209 | 1005 | vcaballero | * Inserta las coordenadas de transformaci?n.
|
210 | 884 | fernando | *
|
211 | 1005 | vcaballero | * @param ct Coordenadas de transformaci?n.
|
212 | 885 | fjp | */
|
213 | void setCoordTrans(ICoordTrans ct);
|
||
214 | |||
215 | /**
|
||
216 | 1005 | vcaballero | * Devuelve las coordenadas de transformaci?n.
|
217 | 885 | fjp | *
|
218 | 1005 | vcaballero | * @return Coordenadas de transformaci?n.
|
219 | 885 | fjp | */
|
220 | ICoordTrans getCoordTrans(); |
||
221 | |||
222 | /**
|
||
223 | 1005 | vcaballero | * A?ade un listener LayerListener a la lista de listeners.
|
224 | 885 | fjp | *
|
225 | 1005 | vcaballero | * @param o Listener.
|
226 | 884 | fernando | *
|
227 | 1005 | vcaballero | * @return True si es correcta la inserci?n del listener.
|
228 | 884 | fernando | */
|
229 | 727 | fernando | public boolean addLayerListener(LayerListener o); |
230 | 5908 | caballero | public LayerListener[] getLayerListeners(); |
231 | 884 | fernando | /**
|
232 | 1005 | vcaballero | * Borra de la lista el LayerListener que se pasa como par?metro.
|
233 | 884 | fernando | *
|
234 | 1005 | vcaballero | * @param o Listener.
|
235 | 884 | fernando | *
|
236 | 1005 | vcaballero | * @return True si es correcto el borrado del listener.
|
237 | 884 | fernando | */
|
238 | 727 | fernando | public boolean removeLayerListener(LayerListener o); |
239 | 5908 | caballero | |
240 | 2531 | caballero | public boolean isWithinScale(double scale); |
241 | 5908 | caballero | |
242 | |||
243 | 1176 | fjp | /**
|
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 | 5908 | caballero | |
255 | 1176 | fjp | public void setMinScale(double minScale); |
256 | public void setMaxScale(double maxScale); |
||
257 | 5152 | fjp | public void setEditing(boolean b) throws EditionException; |
258 | 3690 | caballero | public boolean isEditing(); |
259 | 5923 | fjp | |
260 | public boolean isCachingDrawnLayers(); |
||
261 | 5760 | jmvivo | /**
|
262 | 5923 | fjp | * 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 | 5760 | jmvivo | * Icono a mostrar en el TOC junto a la capa
|
280 | * @return el icono
|
||
281 | */
|
||
282 | public ImageIcon getTocImageIcon(); |
||
283 | 5802 | jaume | |
284 | /**
|
||
285 | 5803 | jaume | * 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 | 5802 | jaume | */
|
289 | boolean isInTOC();
|
||
290 | 5923 | fjp | |
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 | 6531 | jmvivo | |
309 | 8765 | jjdelcerro | |
310 | 6531 | jmvivo | /**
|
311 | 8765 | jjdelcerro | * 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 DriverException getError(int i); |
||
343 | |||
344 | /**
|
||
345 | * add an error cause to describe the layer's wrong status
|
||
346 | * @param error
|
||
347 | */
|
||
348 | public void addError(DriverException error); |
||
349 | |||
350 | /**
|
||
351 | * Returns a list with all layer errors
|
||
352 | * @return
|
||
353 | */
|
||
354 | public List getErrors(); |
||
355 | |||
356 | |||
357 | /**
|
||
358 | 6531 | jmvivo | * @return set layer aviable or not.
|
359 | */
|
||
360 | 6543 | jmvivo | public void setAvailable(boolean available); |
361 | 5923 | fjp | |
362 | 6531 | jmvivo | /**
|
363 | * @return true if this layer is aviable.
|
||
364 | *
|
||
365 | * Default value is true.
|
||
366 | */
|
||
367 | 6543 | jmvivo | public boolean isAvailable(); |
368 | 6531 | jmvivo | |
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 | *
|
||
374 | * @throws DriverIOException
|
||
375 | */
|
||
376 | public void reload() throws DriverIOException; |
||
377 | |||
378 | |||
379 | /**
|
||
380 | * Devuelve true si la capa esta establecida como visible.
|
||
381 | *
|
||
382 | * @return visibilidad.
|
||
383 | */
|
||
384 | boolean visibleRequired();
|
||
385 | |||
386 | /**
|
||
387 | * Devuelve una cadena con informacion sobre la capa.
|
||
388 | *
|
||
389 | * @return visibilidad.
|
||
390 | */
|
||
391 | public String getInfoString(); |
||
392 | 6856 | fjp | |
393 | /**
|
||
394 | * @return true if this layer can be put in edition mode and save the
|
||
395 | * edits in itself.
|
||
396 | */
|
||
397 | public boolean isWritable(); |
||
398 | 8765 | jjdelcerro | |
399 | /**
|
||
400 | * Useful to associate any object to a layer. For example, you
|
||
401 | * can attach a network definition to key "network" and
|
||
402 | * check if a layer has a network loaded if getAssociatedObject("network")
|
||
403 | * is not null
|
||
404 | *
|
||
405 | * @param key
|
||
406 | * @return null if key is not found
|
||
407 | */
|
||
408 | public Object getProperty(Object key); |
||
409 | |||
410 | /**
|
||
411 | * @param key
|
||
412 | * @param obj
|
||
413 | */
|
||
414 | public void setProperty(Object key, Object obj); |
||
415 | 6531 | jmvivo | |
416 | 9225 | fjp | /**
|
417 | * This method can be used to have a fast cloned layer. The implementations should take care of
|
||
418 | * NOT recreate the layer. Instead of this, is better to use the same source (driver) and deepclone
|
||
419 | * the legend. Exception=> the labels aren't deepcloned to avoid memory consumption.
|
||
420 | * Note: Labels are memory consuming to speed up layers like PostGIS and so on.
|
||
421 | * @return clonedLayer
|
||
422 | * @throws Exception
|
||
423 | */
|
||
424 | public FLayer cloneLayer() throws Exception; |
||
425 | 9359 | fdiaz | |
426 | public Map getExtendedProperties(); |
||
427 | 10401 | fjp | |
428 | /**
|
||
429 | * @return
|
||
430 | */
|
||
431 | Image getTocStatusImage();
|
||
432 | 9359 | fdiaz | |
433 | 6531 | jmvivo | |
434 | 214 | fernando | } |