svn-gvsig-desktop / tags / v1_0_RELEASE / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLayer.java @ 9167
History | View | Annotate | Download (10 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 |
|
48 |
import javax.print.attribute.PrintRequestAttributeSet; |
49 |
import javax.swing.ImageIcon; |
50 |
|
51 |
import org.cresques.cts.ICoordTrans; |
52 |
import org.cresques.geo.Projected; |
53 |
|
54 |
import com.iver.cit.gvsig.fmap.DriverException; |
55 |
import com.iver.cit.gvsig.fmap.MapContext; |
56 |
import com.iver.cit.gvsig.fmap.ViewPort; |
57 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
58 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
59 |
import com.iver.utiles.XMLEntity; |
60 |
import com.iver.utiles.swing.threads.Cancellable; |
61 |
|
62 |
|
63 |
/**
|
64 |
* Interfaz que tienen que implementar todas las capas.
|
65 |
*/
|
66 |
public interface FLayer extends Projected { |
67 |
/**
|
68 |
* Obtiene una representaci?n de la colecci?n de capas de forma recursiva
|
69 |
*
|
70 |
* @return XMLEntity.
|
71 |
* @throws XMLException
|
72 |
*/
|
73 |
XMLEntity getXMLEntity() throws XMLException;
|
74 |
|
75 |
/**
|
76 |
* Inserta las propiedades del XMLEntity al objeto actual.
|
77 |
*
|
78 |
* @param xml XMLEntity
|
79 |
*
|
80 |
* @throws XMLException
|
81 |
*/
|
82 |
void setXMLEntity(XMLEntity xml) throws XMLException; |
83 |
|
84 |
/**
|
85 |
* Inserta las propiedades del XMLEntity al objeto actual.
|
86 |
*
|
87 |
* @param xml XMLEntity
|
88 |
*
|
89 |
* @throws XMLException
|
90 |
*/
|
91 |
void setXMLEntity03(XMLEntity xml) throws XMLException; |
92 |
|
93 |
/**
|
94 |
* Pone la capa actual a activa o inactiva seg?n el boolean que se pasa
|
95 |
* como par?metro.
|
96 |
*
|
97 |
* @param selected activa.
|
98 |
*/
|
99 |
void setActive(boolean selected); |
100 |
|
101 |
/**
|
102 |
* Devuelve true si la capa esta activa.
|
103 |
*
|
104 |
* @return activa.
|
105 |
*/
|
106 |
boolean isActive();
|
107 |
|
108 |
/**
|
109 |
* Inserta un nombre a la capa.
|
110 |
*
|
111 |
* @param name nombre.
|
112 |
*/
|
113 |
void setName(String name); |
114 |
|
115 |
/**
|
116 |
* Devuelve el nombre de la capa.
|
117 |
*
|
118 |
* @return nombre de la capa.
|
119 |
*/
|
120 |
String getName();
|
121 |
|
122 |
/**
|
123 |
* Realiza las operaciones de inicializaci?n de la capa. El m?todo es
|
124 |
* invocado una ?nica vez durante la vida de la capa y justo antes de
|
125 |
* visualizar la capa
|
126 |
*
|
127 |
* @throws DriverIOException
|
128 |
*/
|
129 |
void load() throws DriverIOException; |
130 |
|
131 |
/**
|
132 |
* Pone la capa en modo visible o no visible.
|
133 |
*
|
134 |
* @param visibility visibilidad.
|
135 |
*/
|
136 |
void setVisible(boolean visibility); |
137 |
|
138 |
/**
|
139 |
* Devuelve true si la capa es visible.
|
140 |
* Es dependiente isAvialable @link isAvialable
|
141 |
*
|
142 |
* @return visibilidad.
|
143 |
*
|
144 |
* @see isAvialable()
|
145 |
* @see setAvialable()
|
146 |
* @see visibleRequired()
|
147 |
*/
|
148 |
boolean isVisible();
|
149 |
|
150 |
/**
|
151 |
* Devuelve el FLayers padre de la capa.
|
152 |
*
|
153 |
* @return FLayers padre de la capa.
|
154 |
*/
|
155 |
public FLayers getParentLayer();
|
156 |
|
157 |
/**
|
158 |
* Devuelve el FMap al que est? a?adida la capa o null si la capa no ha
|
159 |
* sido a?adida a ning?n FMap
|
160 |
*
|
161 |
* @return FMap
|
162 |
*/
|
163 |
public MapContext getMapContext();
|
164 |
|
165 |
/**
|
166 |
* Inserta el FLayers padre de la capa.
|
167 |
*
|
168 |
* @param root capa padre.
|
169 |
*/
|
170 |
public void setParentLayer(FLayers root); |
171 |
|
172 |
/**
|
173 |
* Obtiene la extensi?n completa de la capa
|
174 |
*
|
175 |
* @return FullExtent.
|
176 |
*
|
177 |
* @throws DriverException
|
178 |
*/
|
179 |
Rectangle2D getFullExtent() throws DriverException; |
180 |
|
181 |
/**
|
182 |
* Dibuja la capa
|
183 |
*
|
184 |
* @param image Imagen utilizada para acelerar el dibujado en pantalla.
|
185 |
* @param g Graphics2D sobre el que dibujar.
|
186 |
* @param viewPort Propiedades de la vista.
|
187 |
* @param cancel PAra poder cancelar el dibujado.
|
188 |
*
|
189 |
* @throws DriverException
|
190 |
*/
|
191 |
void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
192 |
Cancellable cancel,double scale) throws DriverException; |
193 |
|
194 |
/**
|
195 |
* Dibuja la capa
|
196 |
*
|
197 |
* @param g Graphics2D de la impresora sobre el que dibujar.
|
198 |
* @param viewPort Propiedades de la vista.
|
199 |
* @param cancel
|
200 |
*
|
201 |
* @throws DriverException
|
202 |
*/
|
203 |
void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties) |
204 |
throws DriverException;
|
205 |
|
206 |
/**
|
207 |
* Inserta las coordenadas de transformaci?n.
|
208 |
*
|
209 |
* @param ct Coordenadas de transformaci?n.
|
210 |
*/
|
211 |
void setCoordTrans(ICoordTrans ct);
|
212 |
|
213 |
/**
|
214 |
* Devuelve las coordenadas de transformaci?n.
|
215 |
*
|
216 |
* @return Coordenadas de transformaci?n.
|
217 |
*/
|
218 |
ICoordTrans getCoordTrans(); |
219 |
|
220 |
/**
|
221 |
* A?ade un listener LayerListener a la lista de listeners.
|
222 |
*
|
223 |
* @param o Listener.
|
224 |
*
|
225 |
* @return True si es correcta la inserci?n del listener.
|
226 |
*/
|
227 |
public boolean addLayerListener(LayerListener o); |
228 |
public LayerListener[] getLayerListeners(); |
229 |
/**
|
230 |
* Borra de la lista el LayerListener que se pasa como par?metro.
|
231 |
*
|
232 |
* @param o Listener.
|
233 |
*
|
234 |
* @return True si es correcto el borrado del listener.
|
235 |
*/
|
236 |
public boolean removeLayerListener(LayerListener o); |
237 |
|
238 |
public boolean isWithinScale(double scale); |
239 |
|
240 |
|
241 |
/**
|
242 |
* La capa no se visualiza si est? por debajo de esa escala
|
243 |
* @return la escala minima de visualizaci?n
|
244 |
*/
|
245 |
public double getMinScale(); |
246 |
|
247 |
/**
|
248 |
* La capa no se visualiza si est? por encima de esa escala
|
249 |
* @return la escala m?xima de visualizaci?n
|
250 |
*/
|
251 |
public double getMaxScale(); |
252 |
|
253 |
public void setMinScale(double minScale); |
254 |
public void setMaxScale(double maxScale); |
255 |
public void setEditing(boolean b) throws EditionException; |
256 |
public boolean isEditing(); |
257 |
|
258 |
public boolean isCachingDrawnLayers(); |
259 |
/**
|
260 |
* Set true if you want this layer to store an image of previous layers
|
261 |
* Then, if you perform and "FLayers.invalidateLayer(lyr)", the system will
|
262 |
* redraw only the layers you are requesting.
|
263 |
* Otra opci?n ser?a guardar una imagen de cada capa dibujada, y poner una
|
264 |
* llamada en cada una de ellas, algo como "invalidate()". Al renderizar,
|
265 |
* se puede ver si est? invalidada, y si no lo est?, pegar la imagen cacheada.
|
266 |
* ERROR!: Luis tiene raz?n en esto: No puedes cachear esa imagen porque
|
267 |
* si el fondo ha cambiado, el antialiasing afectar? al dibujado de esa capa.
|
268 |
* Sin embargo, s? ser?a ?til si lo que se hace es dibujar la imagen cacheada
|
269 |
* de cada una de las capas que no est?n invalidadas, y a partir de que aparezca
|
270 |
* una de ellas invalidada, el resto ya se tienen que dibujar.
|
271 |
* La pega de que consumes m?s memoria sigue estando presente.
|
272 |
* @param bCacheDrawnLayers
|
273 |
*/
|
274 |
public void setCachingDrawnLayers(boolean bCacheDrawnLayers); |
275 |
|
276 |
/**
|
277 |
* Icono a mostrar en el TOC junto a la capa
|
278 |
* @return el icono
|
279 |
*/
|
280 |
public ImageIcon getTocImageIcon(); |
281 |
|
282 |
/**
|
283 |
* If the layer appears in the TOC then <b>true</b> is returned,
|
284 |
* if <b>false</b> the layer will not be displayed at the TOC
|
285 |
* although it remains in the view and in the project
|
286 |
*/
|
287 |
boolean isInTOC();
|
288 |
|
289 |
/**
|
290 |
* @return true if this layer need a repaint.
|
291 |
*/
|
292 |
public boolean isDirty(); |
293 |
|
294 |
/**
|
295 |
* true if this layer need a repaint. By default, all layers will be
|
296 |
* set to dirty when the extent changes. But for events like changing
|
297 |
* its legend, or editing a layer, we can perform some optimization
|
298 |
* in the method prepareDrawing from FMap.
|
299 |
* @param dirty
|
300 |
*/
|
301 |
public void setDirty(boolean dirty); |
302 |
|
303 |
public BufferedImage getCacheImageDrawnLayers(); |
304 |
|
305 |
public void setCacheImageDrawnLayers(BufferedImage cacheImageDrawnLayers); |
306 |
|
307 |
|
308 |
/**
|
309 |
* Returns the status of the layer
|
310 |
*/
|
311 |
public FLayerStatus getFLayerStatus();
|
312 |
/**
|
313 |
* Sets the status of the layer
|
314 |
* @param status
|
315 |
*/
|
316 |
public void setFLayerStatus(FLayerStatus status); |
317 |
|
318 |
|
319 |
/*
|
320 |
* This stuff is to save error's info that causes
|
321 |
* unavailable status.
|
322 |
* */
|
323 |
/**
|
324 |
* Return if the layer is in OK status
|
325 |
* (it hasnt got errors)
|
326 |
*/
|
327 |
public boolean isOk(); |
328 |
/**
|
329 |
* returns the number of errors that causes layer
|
330 |
* unavailable status
|
331 |
* @return
|
332 |
*/
|
333 |
public int getNumErrors(); |
334 |
|
335 |
/**
|
336 |
* return the specified error
|
337 |
* @param i
|
338 |
* @return
|
339 |
*/
|
340 |
public DriverException getError(int i); |
341 |
|
342 |
/**
|
343 |
* add an error cause to describe the layer's wrong status
|
344 |
* @param error
|
345 |
*/
|
346 |
public void addError(DriverException error); |
347 |
|
348 |
/**
|
349 |
* Returns a list with all layer errors
|
350 |
* @return
|
351 |
*/
|
352 |
public List getErrors(); |
353 |
|
354 |
|
355 |
/**
|
356 |
* @return set layer aviable or not.
|
357 |
*/
|
358 |
public void setAvailable(boolean available); |
359 |
|
360 |
/**
|
361 |
* @return true if this layer is aviable.
|
362 |
*
|
363 |
* Default value is true.
|
364 |
*/
|
365 |
public boolean isAvailable(); |
366 |
|
367 |
/**
|
368 |
* Intenta recuperar una capa ante un posible error.
|
369 |
* Si tiene algun problema en la carga, marca
|
370 |
* el avialable a false y lanza una excepcion.
|
371 |
*
|
372 |
* @throws DriverIOException
|
373 |
*/
|
374 |
public void reload() throws DriverIOException; |
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 |
* Useful to associate any object to a layer. For example, you
|
399 |
* can attach a network definition to key "network" and
|
400 |
* check if a layer has a network loaded if getAssociatedObject("network")
|
401 |
* is not null
|
402 |
*
|
403 |
* @param key
|
404 |
* @return null if key is not found
|
405 |
*/
|
406 |
public Object getProperty(Object key); |
407 |
|
408 |
/**
|
409 |
* @param key
|
410 |
* @param obj
|
411 |
*/
|
412 |
public void setProperty(Object key, Object obj); |
413 |
|
414 |
|
415 |
} |