root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLayer.java @ 10977
History | View | Annotate | Download (11.3 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 | 7460 | azabala | import java.awt.Graphics2D; |
44 | import java.awt.geom.Rectangle2D; |
||
45 | import java.awt.image.BufferedImage; |
||
46 | import java.util.List; |
||
47 | 9224 | jjdelcerro | import java.util.Map; |
48 | 7460 | azabala | |
49 | 9010 | caballero | import javax.print.attribute.PrintRequestAttributeSet; |
50 | 7460 | azabala | import javax.swing.ImageIcon; |
51 | |||
52 | import org.cresques.cts.ICoordTrans; |
||
53 | import org.cresques.geo.Projected; |
||
54 | 10627 | caballero | import org.gvsig.exceptions.BaseException; |
55 | 7460 | azabala | |
56 | 10627 | caballero | 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 | 6878 | cesar | import com.iver.cit.gvsig.fmap.MapContext; |
62 | 533 | vcaballero | import com.iver.cit.gvsig.fmap.ViewPort; |
63 | 10932 | jmvivo | import com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer; |
64 | 415 | fernando | import com.iver.utiles.XMLEntity; |
65 | 5317 | fjp | import com.iver.utiles.swing.threads.Cancellable; |
66 | 249 | vcaballero | |
67 | |||
68 | 217 | fernando | /**
|
69 | 1005 | vcaballero | * Interfaz que tienen que implementar todas las capas.
|
70 | 217 | fernando | */
|
71 | 533 | vcaballero | public interface FLayer extends Projected { |
72 | 523 | vcaballero | /**
|
73 | * Obtiene una representaci?n de la colecci?n de capas de forma recursiva
|
||
74 | *
|
||
75 | 1005 | vcaballero | * @return XMLEntity.
|
76 | 1828 | fernando | * @throws XMLException
|
77 | 523 | vcaballero | */
|
78 | 1828 | fernando | XMLEntity getXMLEntity() throws XMLException;
|
79 | 214 | fernando | |
80 | 523 | vcaballero | /**
|
81 | 1005 | vcaballero | * Inserta las propiedades del XMLEntity al objeto actual.
|
82 | 523 | vcaballero | *
|
83 | 1005 | vcaballero | * @param xml XMLEntity
|
84 | 523 | vcaballero | *
|
85 | * @throws XMLException
|
||
86 | */
|
||
87 | 1056 | vcaballero | void setXMLEntity(XMLEntity xml) throws XMLException; |
88 | 442 | vcaballero | |
89 | 523 | vcaballero | /**
|
90 | 2183 | fernando | * 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 | 1005 | vcaballero | * Pone la capa actual a activa o inactiva seg?n el boolean que se pasa
|
100 | * como par?metro.
|
||
101 | 523 | vcaballero | *
|
102 | 1005 | vcaballero | * @param selected activa.
|
103 | 523 | vcaballero | */
|
104 | void setActive(boolean selected); |
||
105 | 214 | fernando | |
106 | 523 | vcaballero | /**
|
107 | 1005 | vcaballero | * Devuelve true si la capa esta activa.
|
108 | 523 | vcaballero | *
|
109 | 1005 | vcaballero | * @return activa.
|
110 | 523 | vcaballero | */
|
111 | boolean isActive();
|
||
112 | 214 | fernando | |
113 | 523 | vcaballero | /**
|
114 | 1005 | vcaballero | * Inserta un nombre a la capa.
|
115 | 523 | vcaballero | *
|
116 | 1005 | vcaballero | * @param name nombre.
|
117 | 523 | vcaballero | */
|
118 | void setName(String name); |
||
119 | 214 | fernando | |
120 | 523 | vcaballero | /**
|
121 | 1005 | vcaballero | * Devuelve el nombre de la capa.
|
122 | 523 | vcaballero | *
|
123 | 1005 | vcaballero | * @return nombre de la capa.
|
124 | 523 | vcaballero | */
|
125 | String getName();
|
||
126 | 214 | fernando | |
127 | 523 | vcaballero | /**
|
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 | 10627 | caballero | * @throws LoadLayerException TODO
|
132 | 523 | vcaballero | */
|
133 | 10627 | caballero | void load() throws LoadLayerException; |
134 | 214 | fernando | |
135 | 523 | vcaballero | /**
|
136 | 1005 | vcaballero | * Pone la capa en modo visible o no visible.
|
137 | 523 | vcaballero | *
|
138 | 1005 | vcaballero | * @param visibility visibilidad.
|
139 | 523 | vcaballero | */
|
140 | void setVisible(boolean visibility); |
||
141 | 214 | fernando | |
142 | 523 | vcaballero | /**
|
143 | 1005 | vcaballero | * Devuelve true si la capa es visible.
|
144 | 9010 | caballero | * Es dependiente isAvialable @link isAvialable
|
145 | 523 | vcaballero | *
|
146 | 1005 | vcaballero | * @return visibilidad.
|
147 | 9010 | caballero | *
|
148 | 6531 | jmvivo | * @see isAvialable()
|
149 | * @see setAvialable()
|
||
150 | * @see visibleRequired()
|
||
151 | 523 | vcaballero | */
|
152 | boolean isVisible();
|
||
153 | 214 | fernando | |
154 | 523 | vcaballero | /**
|
155 | 1005 | vcaballero | * Devuelve el FLayers padre de la capa.
|
156 | 523 | vcaballero | *
|
157 | 1005 | vcaballero | * @return FLayers padre de la capa.
|
158 | 523 | vcaballero | */
|
159 | public FLayers getParentLayer();
|
||
160 | 249 | vcaballero | |
161 | 884 | fernando | /**
|
162 | 1005 | vcaballero | * 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 | 885 | fjp | *
|
165 | 884 | fernando | * @return FMap
|
166 | */
|
||
167 | 6881 | cesar | public MapContext getMapContext();
|
168 | 884 | fernando | |
169 | 513 | fjp | /**
|
170 | 1005 | vcaballero | * Inserta el FLayers padre de la capa.
|
171 | 563 | fernando | *
|
172 | 1005 | vcaballero | * @param root capa padre.
|
173 | 563 | fernando | */
|
174 | public void setParentLayer(FLayers root); |
||
175 | |||
176 | /**
|
||
177 | 513 | fjp | * Obtiene la extensi?n completa de la capa
|
178 | *
|
||
179 | 1005 | vcaballero | * @return FullExtent.
|
180 | 10627 | caballero | * @throws ReadDriverException
|
181 | * @throws ExpansionFileReadException
|
||
182 | 513 | fjp | */
|
183 | 10627 | caballero | Rectangle2D getFullExtent() throws ReadDriverException, ExpansionFileReadException; |
184 | 513 | fjp | |
185 | /**
|
||
186 | * Dibuja la capa
|
||
187 | *
|
||
188 | 1005 | vcaballero | * @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 | 10627 | caballero | * @throws ReadDriverException TODO
|
193 | 563 | fernando | */
|
194 | void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
||
195 | 10627 | caballero | Cancellable cancel,double scale) throws ReadDriverException; |
196 | 563 | fernando | |
197 | /**
|
||
198 | * Dibuja la capa
|
||
199 | *
|
||
200 | 1005 | vcaballero | * @param g Graphics2D de la impresora sobre el que dibujar.
|
201 | * @param viewPort Propiedades de la vista.
|
||
202 | 563 | fernando | * @param cancel
|
203 | 10627 | caballero | * @throws ReadDriverException TODO
|
204 | 513 | fjp | */
|
205 | 9010 | caballero | void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties) |
206 | 10627 | caballero | throws ReadDriverException;
|
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 | 10627 | caballero | public void setEditing(boolean b) throws StartEditionLayerException; |
258 | 3690 | caballero | public boolean isEditing(); |
259 | 9010 | caballero | |
260 | 5923 | fjp | 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 | 9010 | caballero | * llamada en cada una de ellas, algo como "invalidate()". Al renderizar,
|
267 | 5923 | fjp | * se puede ver si est? invalidada, y si no lo est?, pegar la imagen cacheada.
|
268 | 9010 | caballero | * ERROR!: Luis tiene raz?n en esto: No puedes cachear esa imagen porque
|
269 | 5923 | fjp | * 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 | 9010 | caballero | * La pega de que consumes m?s memoria sigue estando presente.
|
274 | 5923 | fjp | * @param bCacheDrawnLayers
|
275 | */
|
||
276 | public void setCachingDrawnLayers(boolean bCacheDrawnLayers); |
||
277 | 9010 | caballero | |
278 | 5923 | fjp | /**
|
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 | 9010 | caballero | |
291 | 5923 | fjp | /**
|
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 | 9010 | caballero | |
305 | 5923 | fjp | public BufferedImage getCacheImageDrawnLayers(); |
306 | |||
307 | public void setCacheImageDrawnLayers(BufferedImage cacheImageDrawnLayers); |
||
308 | 6531 | jmvivo | |
309 | 9010 | caballero | |
310 | 6531 | jmvivo | /**
|
311 | 7460 | azabala | * 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 | 9010 | caballero | |
320 | |||
321 | 7460 | azabala | /*
|
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 | 9010 | caballero | |
337 | 7460 | azabala | /**
|
338 | * return the specified error
|
||
339 | * @param i
|
||
340 | * @return
|
||
341 | */
|
||
342 | 10627 | caballero | public BaseException getError(int i); |
343 | 9010 | caballero | |
344 | 7460 | azabala | /**
|
345 | * add an error cause to describe the layer's wrong status
|
||
346 | 10627 | caballero | * @param exception TODO
|
347 | 7460 | azabala | */
|
348 | 10627 | caballero | public void addError(BaseException exception); |
349 | 9010 | caballero | |
350 | 7460 | azabala | /**
|
351 | * Returns a list with all layer errors
|
||
352 | * @return
|
||
353 | */
|
||
354 | public List getErrors(); |
||
355 | |||
356 | 9010 | caballero | |
357 | 7460 | azabala | /**
|
358 | 6531 | jmvivo | * @return set layer aviable or not.
|
359 | */
|
||
360 | 6543 | jmvivo | public void setAvailable(boolean available); |
361 | 9010 | caballero | |
362 | 6531 | jmvivo | /**
|
363 | * @return true if this layer is aviable.
|
||
364 | 9010 | caballero | *
|
365 | 6531 | jmvivo | * Default value is true.
|
366 | 9010 | caballero | */
|
367 | 6543 | jmvivo | public boolean isAvailable(); |
368 | 9010 | caballero | |
369 | 6531 | jmvivo | /**
|
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 | 10627 | caballero | * @throws ReloadLayerException TODO
|
374 | 6531 | jmvivo | */
|
375 | 10627 | caballero | public void reload() throws ReloadLayerException; |
376 | 9010 | caballero | |
377 | |||
378 | 6531 | jmvivo | /**
|
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 | 9010 | caballero | |
392 | 6856 | fjp | /**
|
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 | 9010 | caballero | |
398 | 7884 | fjp | /**
|
399 | 9923 | fjp | * 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 | 10627 | caballero | * the legend. Exception=> the labels aren't deepcloned to avoid memory consumption.
|
402 | 9923 | fjp | * Note: Labels are memory consuming to speed up layers like PostGIS and so on.
|
403 | * @return clonedLayer
|
||
404 | 10627 | caballero | * @throws Exception
|
405 | 9923 | fjp | */
|
406 | public FLayer cloneLayer() throws Exception; |
||
407 | |||
408 | |||
409 | /**
|
||
410 | 7884 | fjp | * 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 | 9010 | caballero | *
|
415 | 7884 | fjp | * @param key
|
416 | * @return null if key is not found
|
||
417 | */
|
||
418 | public Object getProperty(Object key); |
||
419 | 9010 | caballero | |
420 | 7884 | fjp | /**
|
421 | * @param key
|
||
422 | * @param obj
|
||
423 | */
|
||
424 | public void setProperty(Object key, Object obj); |
||
425 | 6531 | jmvivo | |
426 | 9224 | jjdelcerro | public Map getExtendedProperties(); |
427 | 6531 | jmvivo | |
428 | 10932 | jmvivo | /**
|
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 | 10627 | caballero | |
442 | 214 | fernando | } |