Statistics
| Revision:

svn-gvsig-desktop / tags / v1_1_Build_1005 / extensions / extGeoreferencing / src / com / iver / cit / gvsig / fmap / layers / FLyrGeoRaster.java @ 12355

History | View | Annotate | Download (18.8 KB)

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