root / trunk / extensions / extGeoreferencing / src / com / iver / cit / gvsig / fmap / layers / FLyrGeoRaster.java @ 7304
History | View | Annotate | Download (18.7 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 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 |
package com.iver.cit.gvsig.fmap.layers; |
20 |
|
21 |
import java.awt.Graphics2D; |
22 |
import java.awt.geom.Point2D; |
23 |
import java.awt.geom.Rectangle2D; |
24 |
import java.awt.image.BufferedImage; |
25 |
import java.io.BufferedReader; |
26 |
import java.io.File; |
27 |
import java.io.FileInputStream; |
28 |
import java.io.FileNotFoundException; |
29 |
import java.io.IOException; |
30 |
import java.io.InputStreamReader; |
31 |
import java.util.ArrayList; |
32 |
|
33 |
import org.cresques.io.data.RasterMetaFileTags; |
34 |
import org.cresques.px.Extent; |
35 |
|
36 |
import com.iver.andami.PluginServices; |
37 |
import com.iver.cit.gvsig.fmap.DriverException; |
38 |
import com.iver.cit.gvsig.fmap.MapContext; |
39 |
import com.iver.cit.gvsig.fmap.ViewPort; |
40 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
41 |
import com.iver.utiles.XMLEntity; |
42 |
import com.iver.utiles.swing.threads.Cancellable; |
43 |
|
44 |
|
45 |
/**
|
46 |
* Clase de capa raster georeferenciada.
|
47 |
*
|
48 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
49 |
*/
|
50 |
public class FLyrGeoRaster extends FLyrRaster{ |
51 |
|
52 |
//**********************Vars****************************************
|
53 |
private Extent assignExtent = null; |
54 |
private IStackZoom zoom = null; |
55 |
private FLyrPoints lyrPoints = null; |
56 |
private double widthPxImg, heightPxImg; |
57 |
private ViewPort viewPortWithoutTransformation = null; |
58 |
/**
|
59 |
* Dialogo de georreferenciaci?n asociado a la capa.
|
60 |
*/
|
61 |
private IGeoUi geoUI = null; |
62 |
private IPersistence persistence = null; |
63 |
//**********************End Vars************************************
|
64 |
|
65 |
//**********************Methods*************************************
|
66 |
|
67 |
/**
|
68 |
* Constructor
|
69 |
*/
|
70 |
public FLyrGeoRaster(){}
|
71 |
|
72 |
/**
|
73 |
* Contructor
|
74 |
*/
|
75 |
public FLyrGeoRaster(IPersistence persistence, IStackZoom zoom){
|
76 |
this.persistence = persistence;
|
77 |
this.zoom = zoom;
|
78 |
} |
79 |
|
80 |
/**
|
81 |
* Funci?n encargada de realizar la transformaci?n para las coordenadas
|
82 |
* del viewPort que se quiere dibujar. Para esta transformaci?n se tiene
|
83 |
* en cuenta que la imagen tiene un extent propio y uno asignado por el
|
84 |
* usuario por lo que habr? que transformar las coordenadas que solicita
|
85 |
* el usuario en coordenadas de la imagen.
|
86 |
* @param vp ViewPort solicitado por el usuario.
|
87 |
* @return ViewPort transformado a coordenadas de la imagen.
|
88 |
*/
|
89 |
public ViewPort toImageCoord(ViewPort vp) throws DriverException{ |
90 |
this.viewPortWithoutTransformation = vp;
|
91 |
|
92 |
if(this.assignExtent == null) |
93 |
return vp;
|
94 |
|
95 |
//Para la transformaci?n trasladamos virtualmente los extents, el real de la imagen
|
96 |
// y el asignado al centro del eje de coordenadas. Despu?s trasladamos el viewPort
|
97 |
//(vpTrasExtent) y con las proporciones de los 2 extents hallamos en ancho, alto y
|
98 |
//coordenada de inicio del viewport. Todo esto equivale a trasladar y escalar el
|
99 |
//viewPort para hallar el nuevo.
|
100 |
|
101 |
Rectangle2D userExtent = new Rectangle2D.Double(assignExtent.minX(), |
102 |
assignExtent.minY(), |
103 |
assignExtent.width(), |
104 |
assignExtent.height()); |
105 |
Rectangle2D imageExtent = super.getFullExtent(); |
106 |
Rectangle2D vpExtent = vp.getExtent();
|
107 |
|
108 |
//Traslaci?n del viewport estando el extent posicionado en el 0,0
|
109 |
Rectangle2D vpTrasExtent = new Rectangle2D.Double( vpExtent.getMinX() - userExtent.getMinX(), |
110 |
vpExtent.getMinY() - userExtent.getMinY(), |
111 |
vpExtent.getWidth(), |
112 |
vpExtent.getHeight()); |
113 |
double x = 0D, y = 0D, width = 0D, height = 0D; |
114 |
|
115 |
//Escalado de la anchura y altura. No hace falta traslaci?n
|
116 |
width = (vpExtent.getWidth() * imageExtent.getWidth())/assignExtent.width(); |
117 |
height = (vpExtent.getHeight() * imageExtent.getHeight())/assignExtent.height(); |
118 |
|
119 |
//Escalado del min del viewport para hallar el min del nuevo
|
120 |
x = (vpTrasExtent.getMinX() * imageExtent.getWidth())/assignExtent.width(); |
121 |
y = (vpTrasExtent.getMinY() * imageExtent.getHeight())/assignExtent.height(); |
122 |
|
123 |
//Traslaci?n
|
124 |
x += imageExtent.getMinX(); |
125 |
y += imageExtent.getMinY(); |
126 |
|
127 |
Rectangle2D newExtent = new Rectangle2D.Double(x, y, width, height); |
128 |
|
129 |
ViewPort viewPort = new ViewPort(vp.getProjection());
|
130 |
viewPort.setExtent(newExtent); |
131 |
viewPort.setImageSize(vp.getImageSize()); |
132 |
viewPort.refreshExtent(); |
133 |
|
134 |
return viewPort;
|
135 |
} |
136 |
|
137 |
/**
|
138 |
* Dibujado de la capa de raster georeferenciado aplicando la
|
139 |
* transformaci?n del viewPort.
|
140 |
*/
|
141 |
public void draw(BufferedImage image, Graphics2D g, ViewPort vp, |
142 |
Cancellable cancel,double scale) throws DriverException { |
143 |
super.draw(image, g, this.toImageCoord(vp), cancel, scale); |
144 |
} |
145 |
|
146 |
/**
|
147 |
* Impresi?n de la capa de raster georeferenciado aplicando la
|
148 |
* transformaci?n del viewPort.
|
149 |
*/
|
150 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
151 |
double scale)throws DriverException { |
152 |
super.print(g, this.toImageCoord(viewPort), cancel, scale); |
153 |
} |
154 |
|
155 |
/**
|
156 |
* Impresi?n de la capa de raster georeferenciado aplicando la
|
157 |
* transformaci?n del viewPort.
|
158 |
*/
|
159 |
public void _print(Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale) |
160 |
throws DriverException {
|
161 |
_print(g, this.toImageCoord(viewPort), cancel, scale);
|
162 |
} |
163 |
|
164 |
/**
|
165 |
* Transforma un pixel de la imagen cuyas coordenadas son (0..maxWidth, 0..maxHeight)
|
166 |
* en coordenadas del mundo real a partir del extent asignado a la imagen.
|
167 |
* @param pixel Pixel de la imagen
|
168 |
* @return Coordenadas del mundo de ese pixel
|
169 |
*/
|
170 |
public Point2D img2World(Point2D pixel){ |
171 |
Point2D p = new Point2D.Double(); |
172 |
double wcWidth = 0.0, wcHeight = 0.0; |
173 |
double mapImgX = 0, mapImgY = 0; |
174 |
try{
|
175 |
wcWidth = getFullExtent().getWidth(); |
176 |
wcHeight = getFullExtent().getHeight(); |
177 |
|
178 |
//La esquina superior izquierda de la vista es minX,maxY y la de la imagen minX,minY
|
179 |
double pixelImgX = pixel.getX();
|
180 |
double pixelImgY = getImageHeight() - pixel.getY();
|
181 |
|
182 |
//Hallamos el pto en coordenadas reales con una regla de tres
|
183 |
mapImgX = (((pixelImgX * wcWidth) / widthPxImg)); |
184 |
mapImgY = (((pixelImgY * wcHeight) / heightPxImg)); |
185 |
|
186 |
//Trasladamos a su ubicaci?n real
|
187 |
mapImgX += this.getFullExtent().getMinX();
|
188 |
mapImgY += this.getFullExtent().getMinY();
|
189 |
|
190 |
|
191 |
}catch(DriverException ex){}
|
192 |
p.setLocation(mapImgX, mapImgY); |
193 |
return p;
|
194 |
} |
195 |
|
196 |
/**
|
197 |
* Transforma un pixel de la imagen cuyas coordenadas son (0..maxWidth, 0..maxHeight)
|
198 |
* en coordenadas del mundo real a partir del extent asignado a la imagen.
|
199 |
* @param x Coordenada X del pixel de la imagen
|
200 |
* @param y Coordenada Y del pixel de la imagen
|
201 |
* @return Coordenadas del mundo de ese pixel
|
202 |
*/
|
203 |
public Point2D img2World(double x, double y){ |
204 |
Point2D p = new Point2D.Double(); |
205 |
p.setLocation(x, y); |
206 |
return this.img2World(p); |
207 |
} |
208 |
|
209 |
/**
|
210 |
* Transforma una coordenada del mundo real a un pixel (0..maxWidth, 0..maxHeight)
|
211 |
* en coordenadas de la imagen a partir del extent asignado a esta.
|
212 |
* @param wcPoint coordenada del mundo
|
213 |
* @return Pixel de la imagen
|
214 |
*/
|
215 |
public Point2D world2Img(Point2D wcPoint){ |
216 |
//Si el punto cae fuera de la imagen salimos devolviendo null
|
217 |
|
218 |
if( wcPoint.getX() < this.getMinX() || |
219 |
wcPoint.getX() > this.getMaxX() ||
|
220 |
wcPoint.getY() < this.getMinY() ||
|
221 |
wcPoint.getY() > this.getMaxY())
|
222 |
return null; |
223 |
|
224 |
//Hallamos pixelImg q son las coordenadas en pixeles de la imagen que corresponden
|
225 |
//con el punto wcPoint
|
226 |
double wcWidth = 0.0, wcHeight = 0.0, ptoWCX = 0.0, ptoWCY = 0.0; |
227 |
double pixelImgX = 0, pixelImgY = 0; |
228 |
try{
|
229 |
wcWidth = getFullExtent().getWidth(); |
230 |
wcHeight = getFullExtent().getHeight(); |
231 |
//Traslaci?n al origen ya que la imagen empieza en 0,0
|
232 |
ptoWCX = wcPoint.getX() - getFullExtent().getMinX(); |
233 |
ptoWCY = wcPoint.getY() - getFullExtent().getMinY(); |
234 |
//Hallamos el pto en pixeles con una regla de tres
|
235 |
pixelImgX = ((ptoWCX * getImageWidth()) / wcWidth); |
236 |
pixelImgY = ((ptoWCY * getImageHeight()) / wcHeight); |
237 |
//La esquina superior izquierda de la vista es minX,maxY y la de la imagen minX,minY
|
238 |
pixelImgY = getImageHeight() - pixelImgY; |
239 |
}catch(DriverException ex){}
|
240 |
|
241 |
Point2D result = new Point2D.Double(); |
242 |
result.setLocation(pixelImgX, pixelImgY); |
243 |
return result;
|
244 |
} |
245 |
|
246 |
/**
|
247 |
* Transforma una coordenada del mundo real a un pixel (0..maxWidth, 0..maxHeight)
|
248 |
* en coordenadas de la imagen a partir del extent asignado a esta.
|
249 |
* @param x wcPoint coordenada X del mundo
|
250 |
* @param y wcPoint coordenada Y del mundo
|
251 |
* @return Pixel de la imagen
|
252 |
*/
|
253 |
public Point2D world2Img(double x, double y){ |
254 |
Point2D p = new Point2D.Double(); |
255 |
p.setLocation(x, y); |
256 |
return this.world2Img(p); |
257 |
} |
258 |
|
259 |
|
260 |
/**
|
261 |
* Recupera el extent asignado, si existe y llama al setXMLEntity de la capa de puntos
|
262 |
*/
|
263 |
public void setXMLEntity(XMLEntity xml)throws XMLException { |
264 |
super.setXMLEntity(xml);
|
265 |
|
266 |
if (xml.contains("raster.assignExtent.minX") && |
267 |
xml.contains("raster.assignExtent.minY") &&
|
268 |
xml.contains("raster.assignExtent.maxX") &&
|
269 |
xml.contains("raster.assignExtent.maxY")){
|
270 |
|
271 |
//Comprobamos si existe el fichero .rmf y si existe analizamos el contenido
|
272 |
//buscando el bloque que contiene georreferenciaci?n. Si tiene este bloque
|
273 |
//no utilizaremos el extent asignado que lleva el proyecto para que use la
|
274 |
//georreferenciaci?n de la imagen.
|
275 |
boolean georefRmf = false; |
276 |
String path = ((RasterFileAdapter)getSource()).getFile().getPath();
|
277 |
String rmfName = path.substring(0, path.lastIndexOf(".")) + ".rmf"; |
278 |
File rmfFile = new File(rmfName); |
279 |
try{
|
280 |
BufferedReader inGrf = new BufferedReader(new InputStreamReader(new FileInputStream(rmfFile))); |
281 |
String str = inGrf.readLine();
|
282 |
while( str != null && |
283 |
!str.startsWith("</"+RasterMetaFileTags.LAYER) &&
|
284 |
!str.startsWith("</"+RasterMetaFileTags.GEOPOINT))
|
285 |
str = inGrf.readLine(); |
286 |
if(str.startsWith("</"+RasterMetaFileTags.LAYER)) |
287 |
georefRmf = true;
|
288 |
}catch(FileNotFoundException ex){ |
289 |
//Si no encuentra el fichero no se modifica la variable georefRmf
|
290 |
}catch(IOException ex){ |
291 |
//Si da un error de I/O no se modifica la variable georefRmf
|
292 |
} |
293 |
|
294 |
if(!georefRmf){
|
295 |
this.assignExtent = new Extent(xml.getDoubleProperty("raster.assignExtent.minX"), |
296 |
xml.getDoubleProperty("raster.assignExtent.minY"),
|
297 |
xml.getDoubleProperty("raster.assignExtent.maxX"),
|
298 |
xml.getDoubleProperty("raster.assignExtent.maxY"));
|
299 |
} |
300 |
if (xml.contains("raster.assignExtent.imageWidth") && |
301 |
xml.contains("raster.assignExtent.imageHeight")){
|
302 |
this.widthPxImg = xml.getDoubleProperty("raster.assignExtent.imageWidth"); |
303 |
this.heightPxImg = xml.getDoubleProperty("raster.assignExtent.imageHeight"); |
304 |
} |
305 |
} |
306 |
} |
307 |
|
308 |
/**
|
309 |
* Cambia el nombre a la capa de puntos si esta empieza por * para que no se salve con ese
|
310 |
* nombre y llama a getXMLEntity del padre. Salva el extent asignado, si existe y llama a
|
311 |
* getXMLEntity de la capa de puntos para que se guarden los puntos de control en el proyecto.
|
312 |
* @throws XMLException
|
313 |
*/
|
314 |
public XMLEntity getXMLEntity() throws XMLException { |
315 |
boolean active = false; |
316 |
if(getName().startsWith("*")){ |
317 |
setName(getName().substring(1, getName().length()));
|
318 |
active = true;
|
319 |
} |
320 |
|
321 |
XMLEntity xml = super.getXMLEntity();
|
322 |
|
323 |
if(active)
|
324 |
setName("*"+getName());
|
325 |
|
326 |
if(this.assignExtent != null){ |
327 |
xml.putProperty("raster.assignExtent.minX", assignExtent.getMin().getX());
|
328 |
xml.putProperty("raster.assignExtent.minY", assignExtent.getMin().getY());
|
329 |
xml.putProperty("raster.assignExtent.maxX", assignExtent.getMax().getX());
|
330 |
xml.putProperty("raster.assignExtent.maxY", assignExtent.getMax().getY());
|
331 |
xml.putProperty("raster.assignExtent.imageWidth", this.getImageWidth()); |
332 |
xml.putProperty("raster.assignExtent.imageHeight", this.getImageHeight()); |
333 |
} |
334 |
|
335 |
try{
|
336 |
geoUI.savePoints(); |
337 |
}catch(Exception ex){ |
338 |
//La capa de puntos no est? cargada por lo que no podemos salvar
|
339 |
} |
340 |
return xml;
|
341 |
} |
342 |
|
343 |
/**
|
344 |
* A partir de nuevas coordenadas actualiza la vista, minimagen, capa de puntos el
|
345 |
* dialogo y la tabla.
|
346 |
*
|
347 |
*/
|
348 |
public void updateData(int nPunto, Point2D pixel, Point2D map, View view){ |
349 |
this.geoUI.updateData(nPunto, pixel, map, view);
|
350 |
} |
351 |
|
352 |
/**
|
353 |
* Borra de la lista de listeners el que se pasa como par?metro.
|
354 |
*
|
355 |
* @param o LayerListener a borrar.
|
356 |
*
|
357 |
* @return True si ha sido correcto el borrado del Listener.
|
358 |
*/
|
359 |
public boolean removeLayerListener(LayerListener o) { |
360 |
try{
|
361 |
//Hacemos invisible LyrPoints para que la capa gr?fica de Fmap no dibuje nada
|
362 |
this.getLyrPoints().setVisible(false); |
363 |
|
364 |
geoUI.close(); |
365 |
}catch(NullPointerException ex){ |
366 |
//Si geoUI es null no hace falta que cerremos la ventana
|
367 |
} |
368 |
return super.removeLayerListener(o); |
369 |
} |
370 |
//**********************End Methods**********************************
|
371 |
|
372 |
//**********************Setters & Getters****************************
|
373 |
/**
|
374 |
* @return Returns the viewPortWithoutTransform.
|
375 |
*/
|
376 |
public ViewPort getViewPortWithoutTransformation() {
|
377 |
return viewPortWithoutTransformation;
|
378 |
} |
379 |
|
380 |
/**
|
381 |
* Asigna la capa de puntos asociada a la capa Georraster
|
382 |
* @param lyr Capa de puntos
|
383 |
*/
|
384 |
public void setFLyrPoints(FLyrPoints lyr){ |
385 |
this.lyrPoints = lyr;
|
386 |
} |
387 |
|
388 |
/**
|
389 |
* Obtiene la capa de puntos asociada a la capa Georraster. Si no existe
|
390 |
* crear? una.
|
391 |
* @return Capa de puntos
|
392 |
*/
|
393 |
public FLyrPoints getFLyrPoints()throws ClassCastException{ |
394 |
//Si no existe una capa de puntos la creamos
|
395 |
if(lyrPoints == null){ |
396 |
View theView = (View) PluginServices.getMDIManager().getActiveWindow(); |
397 |
MapContext fmap = theView.getMapControl().getMapContext(); |
398 |
lyrPoints = new FLyrPoints(this, persistence); |
399 |
fmap.setGraphicsLayer(lyrPoints); |
400 |
} |
401 |
return lyrPoints;
|
402 |
} |
403 |
|
404 |
/**
|
405 |
* Asigna la dimensi?n de la imagen de disco en pixeles
|
406 |
* @param w Ancho
|
407 |
* @param h Alto
|
408 |
*/
|
409 |
public void setImageDimension(double w, double h){ |
410 |
this.widthPxImg = w;
|
411 |
this.heightPxImg = h;
|
412 |
} |
413 |
|
414 |
/**
|
415 |
* Obtiene el ancho de la imagen de disco en pixeles. Si no se tiene valor es
|
416 |
* porque se ha abierto un proyecto con una imagen con rmf asociado. En este
|
417 |
* caso se tendr? que leer el ancho de los atributos de la capa.
|
418 |
* @return
|
419 |
*/
|
420 |
public double getImageWidth(){ |
421 |
if(this.widthPxImg == 0){ |
422 |
ArrayList attr = getSource().getAttributes();
|
423 |
for (int i=0; i<attr.size(); i++) { |
424 |
Object [] a = (Object []) attr.get(i); |
425 |
if(((String)a[0]).equals("Width")) |
426 |
widthPxImg = ((Integer)a[1]).intValue(); |
427 |
} |
428 |
} |
429 |
return this.widthPxImg; |
430 |
} |
431 |
|
432 |
/**
|
433 |
* Obtiene el alto de la imagen de disco en pixeles. Si no se tiene valor es
|
434 |
* porque se ha abierto un proyecto con una imagen con rmf asociado. En este
|
435 |
* caso se tendr? que leer el ancho de los atributos de la capa.
|
436 |
* @return
|
437 |
*/
|
438 |
public double getImageHeight(){ |
439 |
if(this.heightPxImg == 0){ |
440 |
ArrayList attr = getSource().getAttributes();
|
441 |
for (int i=0; i<attr.size(); i++) { |
442 |
Object [] a = (Object []) attr.get(i); |
443 |
if(((String)a[0]).equals("Height")) |
444 |
heightPxImg = ((Integer)a[1]).intValue(); |
445 |
} |
446 |
} |
447 |
return this.heightPxImg; |
448 |
} |
449 |
/**
|
450 |
* @return Returns the geoDialog.
|
451 |
*/
|
452 |
public IGeoUi getGeoDialog() {
|
453 |
return geoUI;
|
454 |
} |
455 |
/**
|
456 |
* @param geoDialog The geoDialog to set.
|
457 |
*/
|
458 |
public void setGeoDialog(IGeoUi geoDialog) { |
459 |
this.geoUI = geoDialog;
|
460 |
} |
461 |
/**
|
462 |
* Obtiene el extent de la capa
|
463 |
* @return extent en Rectangle2D.
|
464 |
*/
|
465 |
public Rectangle2D getFullExtent()throws DriverException { |
466 |
if(assignExtent == null) |
467 |
return super.getFullExtent(); |
468 |
return assignExtent.toRectangle2D();
|
469 |
} |
470 |
|
471 |
/**
|
472 |
* Obtiene el extent de la capa
|
473 |
* @return extent de la capa
|
474 |
*/
|
475 |
public Extent getAssignExtent(){
|
476 |
try{
|
477 |
if(assignExtent == null) |
478 |
return new Extent( super.getFullExtent().getMinX(), |
479 |
super.getFullExtent().getMinY(),
|
480 |
super.getFullExtent().getMaxX(),
|
481 |
super.getFullExtent().getMaxY());
|
482 |
}catch(DriverException ex){}
|
483 |
return assignExtent;
|
484 |
} |
485 |
|
486 |
/**
|
487 |
* Obtiene la coordenada X m?xima
|
488 |
*/
|
489 |
public double getMaxX(){ |
490 |
if(assignExtent == null) |
491 |
return super.getMaxX(); |
492 |
return assignExtent.maxX();
|
493 |
} |
494 |
|
495 |
/**
|
496 |
* Obtiene la coordenada Y m?xima
|
497 |
*/
|
498 |
public double getMaxY(){ |
499 |
if(assignExtent == null) |
500 |
return super.getMaxY(); |
501 |
return assignExtent.maxY();
|
502 |
} |
503 |
|
504 |
/**
|
505 |
* Obtiene la coordenada X m?nima
|
506 |
*/
|
507 |
public double getMinX(){ |
508 |
if(assignExtent == null) |
509 |
return super.getMinX(); |
510 |
return assignExtent.minX();
|
511 |
} |
512 |
|
513 |
/**
|
514 |
* Obtiene la coordenada Y m?nima
|
515 |
*/
|
516 |
public double getMinY(){ |
517 |
if(assignExtent == null) |
518 |
return super.getMinY(); |
519 |
return assignExtent.minY();
|
520 |
} |
521 |
|
522 |
/**
|
523 |
* Obtiene el alto
|
524 |
*/
|
525 |
public double getHeight(){ |
526 |
if(assignExtent == null) |
527 |
return super.getHeight(); |
528 |
return assignExtent.height();
|
529 |
} |
530 |
|
531 |
/**
|
532 |
* Obtiene el ancho
|
533 |
*/
|
534 |
public double getWidth(){ |
535 |
if(assignExtent == null) |
536 |
return super.getWidth(); |
537 |
return assignExtent.width();
|
538 |
} |
539 |
|
540 |
/**
|
541 |
* @param assignExtent The assignExtent to set.
|
542 |
*/
|
543 |
public void setAssignExtent(Extent assignExtent) { |
544 |
if(assignExtent.getMax().distance(assignExtent.getMin()) > 0){ |
545 |
this.assignExtent = assignExtent;
|
546 |
setAssignZoomIntoStack(); |
547 |
} |
548 |
} |
549 |
|
550 |
/**
|
551 |
* Guarda el zoom asignado a la capa en la pila de zooms
|
552 |
*/
|
553 |
public void setAssignZoomIntoStack(){ |
554 |
zoom.setZoom(assignExtent); |
555 |
} |
556 |
|
557 |
/**
|
558 |
* Asigna el ?ltimo extent seleccionado si hay alguno
|
559 |
*/
|
560 |
public void setLastExtent(){ |
561 |
Extent e = null;
|
562 |
e = zoom.getLastZoom(); |
563 |
if(e != null) |
564 |
this.assignExtent = e;
|
565 |
} |
566 |
|
567 |
/**
|
568 |
* Asigna el siguiente extent de la pila si hay alguno
|
569 |
*/
|
570 |
public void setNextExtent(){ |
571 |
Extent e = null;
|
572 |
e = zoom.getNextZoom(); |
573 |
if(e != null) |
574 |
this.assignExtent = e;
|
575 |
} |
576 |
|
577 |
/**
|
578 |
* Obtiene la pila de extents aplicados
|
579 |
* @return pila de extents
|
580 |
*/
|
581 |
public IStackZoom getStackZoom(){
|
582 |
return zoom;
|
583 |
} |
584 |
|
585 |
/**
|
586 |
* Obtiene la capa de puntos
|
587 |
* @return FLyrPoints
|
588 |
*/
|
589 |
public FLyrPoints getLyrPoints() {
|
590 |
return lyrPoints;
|
591 |
} |
592 |
|
593 |
/**
|
594 |
* Obtiene el objeto que gestiona la persistencia
|
595 |
* @return interfaz IPersistence
|
596 |
*/
|
597 |
public IPersistence getPersistence() {
|
598 |
return persistence;
|
599 |
} |
600 |
|
601 |
/**
|
602 |
* Asigna el objeto que gestiona la persistencia
|
603 |
* @param persistence
|
604 |
*/
|
605 |
public void setPersistence(IPersistence persistence) { |
606 |
this.persistence = persistence;
|
607 |
if(this.lyrPoints != null) |
608 |
this.lyrPoints.setPersistence(persistence);
|
609 |
} |
610 |
|
611 |
/**
|
612 |
* Obtiene el objeto que gestiona la pila de zooms
|
613 |
* @return IStackZoom
|
614 |
*/
|
615 |
public IStackZoom getZoom() {
|
616 |
return zoom;
|
617 |
} |
618 |
|
619 |
/**
|
620 |
* Asigna el objeto que gestiona la pila de zooms
|
621 |
* @param IStackZoom
|
622 |
*/
|
623 |
public void setZoom(IStackZoom zoom) { |
624 |
if(this.zoom == null) |
625 |
this.zoom = zoom;
|
626 |
} |
627 |
//**********************End Setters & Getters************************
|
628 |
|
629 |
} |