Statistics
| Revision:

root / trunk / extensions / extWCS / src / com / iver / cit / gvsig / fmap / layers / FLyrWCS.java @ 13951

History | View | Annotate | Download (37.8 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.Dimension;
44
import java.awt.Graphics2D;
45
import java.awt.Point;
46
import java.awt.Rectangle;
47
import java.awt.geom.AffineTransform;
48
import java.awt.geom.NoninvertibleTransformException;
49
import java.awt.geom.Point2D;
50
import java.awt.geom.Rectangle2D;
51
import java.awt.image.BufferedImage;
52
import java.awt.image.DataBuffer;
53
import java.io.File;
54
import java.io.IOException;
55
import java.lang.reflect.Constructor;
56
import java.lang.reflect.InvocationTargetException;
57
import java.net.MalformedURLException;
58
import java.net.URL;
59
import java.util.ArrayList;
60
import java.util.Hashtable;
61
import java.util.Iterator;
62
import java.util.Map;
63

    
64
import javax.print.attribute.PrintRequestAttributeSet;
65

    
66
import org.exolab.castor.xml.ValidationException;
67
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
68
import org.gvsig.fmap.raster.layers.IRasterLayerActions;
69
import org.gvsig.fmap.raster.layers.IStatusRaster;
70
import org.gvsig.fmap.raster.layers.StatusLayerRaster;
71
import org.gvsig.raster.dataset.CompositeDataset;
72
import org.gvsig.raster.dataset.FileNotOpenException;
73
import org.gvsig.raster.dataset.IBuffer;
74
import org.gvsig.raster.dataset.InvalidSetViewException;
75
import org.gvsig.raster.dataset.MosaicNotValidException;
76
import org.gvsig.raster.dataset.MultiRasterDataset;
77
import org.gvsig.raster.dataset.NotSupportedExtensionException;
78
import org.gvsig.raster.dataset.RasterDataset;
79
import org.gvsig.raster.dataset.RasterDriverException;
80
import org.gvsig.raster.datastruct.Extent;
81
import org.gvsig.raster.datastruct.ViewPortData;
82
import org.gvsig.raster.grid.GridTransparency;
83
import org.gvsig.raster.grid.filter.RasterFilterList;
84
import org.gvsig.raster.grid.filter.RasterFilterListManager;
85
import org.gvsig.raster.grid.filter.enhancement.LinearEnhancementFilter;
86
import org.gvsig.raster.grid.filter.statistics.TailTrimFilter;
87
import org.gvsig.remoteClient.wcs.WCSStatus;
88
import org.gvsig.remoteClient.wms.ICancellable;
89

    
90
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
91
import com.hardcode.gdbms.engine.data.driver.DriverException;
92
import com.iver.cit.gvsig.exceptions.layers.ConnectionErrorLayerException;
93
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException;
94
import com.iver.cit.gvsig.exceptions.layers.UnsupportedVersionLayerException;
95
import com.iver.cit.gvsig.fmap.MapContext;
96
import com.iver.cit.gvsig.fmap.MapControl;
97
import com.iver.cit.gvsig.fmap.ViewPort;
98
import com.iver.cit.gvsig.fmap.crs.CRSFactory;
99
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
100
import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriver;
101
import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriverFactory;
102
import com.iver.cit.gvsig.fmap.drivers.wcs.WCSDriverException;
103
import com.iver.cit.gvsig.fmap.layers.layerOperations.StringXMLItem;
104
import com.iver.cit.gvsig.fmap.layers.layerOperations.XMLItem;
105
import com.iver.cit.gvsig.fmap.rendering.ILegend;
106
import com.iver.cit.gvsig.fmap.rendering.LegendChangedEvent;
107
import com.iver.utiles.DoubleUtilities;
108
import com.iver.utiles.StringUtilities;
109
import com.iver.utiles.XMLEntity;
110
import com.iver.utiles.swing.threads.Cancellable;
111

    
112

    
113
/**
114
 * Class for the WCS layer.
115
 *
116
 * Capa para el WCS.
117
 * 
118
 * Las capas WCS son tileadas para descargarlas del servidor. Esto quiere decir que
119
 * est?n formadas por multiples ficheros raster. Por esto la fuente de datos raster (IRasterDatasource)
120
 * de la capa FLyrWCS es un objeto de tipo CompositeDataset. Este objeto est? compuesto por un array
121
 * bidimensional de MultiRasterDataset. Cada uno de los MultiRasterDataset corresponde con un tile
122
 * salvado en disco. Estos MultiRasterDataset se crean cada vez que se repinta ya que en WCS a cada
123
 * zoom varian los ficheros fuente. La secuencia de creaci?n de un CompositeDataset ser?a la siguiente:
124
 * <UL>
125
 * <LI>Se hace una petici?n de dibujado por parte del usuario llamando al m?todo draw de FLyrWCS</LI>
126
 * <LI>Se tilea la petici?n</LI>
127
 * <LI>Cada tile se dibuja abriendo una FLyrRaster para ese tile</LI>
128
 * <LI>Si es el primer dibujado se guarda una referencia en la capa WMS a las propiedades de renderizado, orden de bandas, 
129
 * transparencia, filtros aplicados, ...</LI>
130
 * <LI>Si no es el primer dibujado se asignan las propiedades de renderizado cuya referencia se guarda en la capa WMS</LI>
131
 * <LI>Se guarda el MultiRasterDataset de cada tile</LI>
132
 * <LI>Al acabar todos los tiles creamos un CompositeDataset con los MultiRasterDataset de todos los tiles</LI>
133
 * <LI>Asignamos a la capa la referencia de las propiedades de renderizado que tenemos almacenadas. De esta forma si hay
134
 * alguna modificaci?n desde el cuadro de propiedades ser? efectiva sobre los tiles que se dibujan.</LI>
135
 * </UL>
136
 *
137
 * @author jaume - jaume.dominguez@iver.es
138
 */
139
public class FLyrWCS extends FLyrRasterSE {
140
        private FMapWCSDriver wcs = null;
141

    
142
        private URL                                                 host;
143
        private String                                                coverageName;
144
        private Rectangle2D                                        fullExtent;
145
        private String                                                format;
146
        private String                                                srs;
147
        private String                                                time;
148
        private String                                                parameter;
149
        private Point2D                                                maxRes;
150
        private Hashtable                                         onlineResources = new Hashtable();
151

    
152
        private WCSStatus                                        wcsStatus = new WCSStatus();
153

    
154
        private int                                                 posX = 0, posY = 0;
155
        private double                                                 posXWC = 0, posYWC = 0;
156
        private int                                                 r = 0, g = 0, b = 0;
157
        private boolean                                         firstLoad = false;
158
        private VisualStatus                                visualStatus = new VisualStatus();
159

    
160
        private boolean                                         mustTileDraw = false;
161
        private int                                                 maxTileDrawWidth  = 1023;
162
        private int                                                        maxTileDrawHeight = 1023;
163
        private int                                                 maxTilePrintWidth  = 250;
164
        private int                                                        maxTilePrintHeight = 250;
165
        /**
166
         * Lista de filtros aplicada en la renderizaci?n
167
         */
168
        private RasterFilterList            filterList = null;
169
        private GridTransparency                        transparency = null;
170
        private int[]                       renderBands = null;
171
        private FLyrRasterSE                                layerRaster = null;
172
        private ArrayList                   filterArguments = null;
173
        private String[][]                                        fileNames = null;
174
        
175
        private class MyCancellable implements ICancellable
176
        {
177

    
178
                private Cancellable original;
179
                public MyCancellable(Cancellable cancelOriginal)
180
                {
181
                        this.original = cancelOriginal;
182
                }
183
                public boolean isCanceled() {
184
                        return original.isCanceled();
185
                }
186

    
187
        }
188
        
189
        public FLyrWCS(){
190
                super();
191
        }
192

    
193
        public FLyrWCS(Map args) throws DriverIOException{
194
                FMapWCSDriver drv = null;
195
                String host = (String)args.get("HOST");
196
                String sCoverage = (String) args.get((String) "COVERAGE");
197

    
198
                try {
199
                        this.setHost(new URL(host));
200
                } catch (MalformedURLException e) {
201
                        //e.printStackTrace();
202
                        throw new DriverIOException("Malformed host URL, '" + host + "' (" + e.toString() + ").");
203
                }
204
                try {
205
                        drv = this.getDriver();
206
                } catch (Exception e) {
207
                        // e.printStackTrace();
208
                        throw new DriverIOException("Can't get driver to host '" + host + "' (" + e.toString() + ").");
209
                }
210

    
211
                try{
212
                        if (!drv.connect(false, null)){
213
                                throw new DriverIOException("Can't connect to host '" + host + "'.");
214
                        }
215
                }catch(Exception e){
216
                        throw new DriverIOException("Can't connect to host '" + host + "'.");
217
                }
218

    
219
                WCSLayer wcsNode = drv.getLayer(sCoverage);
220

    
221
                if (wcsNode == null){
222
                        throw new DriverIOException("The server '" + host + "' doesn't has the coverage '" + sCoverage + "'.");
223
                }
224

    
225
                try{
226
                        this.setFullExtent(drv.getFullExtent(sCoverage,
227
                                        (String) args.get((String) "CRS")));
228
                        this.setFormat((String) args.get((String) "FORMAT"));
229
                        this.setParameter("BANDS=" + (String) args.get((String) "BANDS"));
230
                        this.setSRS((String) args.get((String) "CRS"));
231
                        this.setName(sCoverage);
232
                        this.setCoverageName(sCoverage);
233
                }catch (Exception e){
234
                        throw new DriverIOException("The server '" + host + "' is not able to load the coverage '" + sCoverage + "'.");
235
                }
236

    
237
        }
238

    
239
        /**
240
         * Clase que contiene los datos de visualizaci?n de WCS. Tiene datos que representan al
241
         * raster en la vista. Este raster puede estar compuesto por tiles por lo que valores
242
         * como el ancho total o el m?nimo o m?ximo deben ser calculados a partir de todos los
243
         * tiles visualizados.
244
         * @author Nacho Brodin (brodin_ign@gva.es)
245
         */
246
        private class VisualStatus {
247
                /**
248
                 * Ancho y alto de la imagen o del conjunto de tiles si los tiene. Coincide con
249
                 * el ancho y alto del viewPort
250
                 */
251
                private        int                                                        width = 0, height = 0;
252
                private double                                                minX = 0D, minY = 0D, maxX = 0D, maxY = 0D;
253
                private int                                                 bandCount = 0;
254
                private int                                                        dataType = DataBuffer.TYPE_UNDEFINED;
255

    
256
                /**
257
                 * Ancho y alto total del raster que ser? la suma de todos los tiles.
258
                 */
259
                private        int                                                        rasterWidth = 0, rasterHeight = 0;
260
                private        double                                                rasterMinX = Double.MAX_VALUE, rasterMinY = Double.MAX_VALUE;
261
                private        double                                                rasterMaxX = 0, rasterMaxY = 0;
262
                /**
263
                 * Lista de nombre de fichero que componen toda la visualizaci?n.
264
                 */
265
                private String[]                                        fileNames = null;
266
        }
267

    
268
        /**
269
         * @deprecated
270
         * @see com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint#getInfo
271
         */
272
        public String queryByPoint(Point p) {
273
                String data = "<file:"+getName().replaceAll("[^a-zA-Z0-9]","")+">\n";
274
                ArrayList attr = this.getAttributes();
275
                data += "  <raster\n";
276
                data += "    File=\""+getName()+"\"\n";
277
                for (int i=0; i<attr.size(); i++) {
278
                        Object [] a = (Object []) attr.get(i);
279

    
280
                        data += "    "+a[0].toString()+"=";
281
                        if (a[1].toString() instanceof String)
282
                                data += "\""+a[1].toString()+"\"\n";
283
                        else
284
                                data += a[1].toString()+"\n";
285
                }
286
                data += "    Point=\""+posX+" , "+posY+"\"\n";
287
                data += "    Point_WC=\""+posXWC+" , "+posYWC+"\"\n";
288
                data += "    RGB=\""+r+", "+g+", "+b+"\"\n";
289
                data += "  />\n";
290

    
291
                data += "</file:"+getName().replaceAll("[^a-zA-Z0-9]","")+">\n";
292
                System.out.println(data);
293
                return data;
294
        }
295
        
296
        /**
297
         * @see com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint#getInfo
298
         */
299
        public XMLItem[] getInfo(Point point, double tolerance, Cancellable cancel ) throws ReadDriverException {
300
                String data = "<file:"+getName().replaceAll("[^a-zA-Z0-9]","")+">\n";
301

    
302
                Point2D pReal = getMapContext().getViewPort().toMapPoint(point);
303
                Point2D px = null;
304
                if(        pReal.getX() > this.getMinX() &&
305
                        pReal.getX() < this.getMaxX() &&
306
                        pReal.getY() > this.getMinY() &&
307
                        pReal.getY() < this.getMaxY()){
308

    
309
                        px = new Point2D.Double();
310
                        double w = (visualStatus.rasterMaxX - visualStatus.rasterMinX);
311
                        double h = (visualStatus.rasterMaxY - visualStatus.rasterMinY);
312
                        px.setLocation(((pReal.getX() - visualStatus.rasterMinX) * visualStatus.rasterWidth) / w,
313
                                                        ((visualStatus.rasterMaxY - pReal.getY()) * visualStatus.rasterHeight) / h);
314
                }
315

    
316
                int[] rgb = this.getPixel(pReal.getX(), pReal.getY());
317

    
318
                StringXMLItem[] item = new StringXMLItem[1];
319

    
320
                data += "  <raster\n";
321
                data += "    View_Point=\""+point.getX()+" , "+point.getY()+"\"\n";
322
                data += "    World_Point=\""+DoubleUtilities.format(pReal.getX(), 3)+" , "+ DoubleUtilities.format(pReal.getY(), 3)+"\"\n";
323
                if(        px == null || px.getX() > visualStatus.rasterWidth || px.getX() < 0 ||
324
                        px.getY() > visualStatus.rasterHeight || px.getY() < 0)
325
                        data += "    Pixel_Point=\"Out\"\n";
326
                else
327
                        data += "    Pixel_Point=\""+(int)px.getX()+" , "+(int)px.getY()+"\"\n";
328
                if(rgb != null)
329
                        data += "    RGB=\""+rgb[1]+"  "+rgb[2]+"  "+rgb[3]+"\"\n";
330
                data += "    Band_Value=\"";
331

    
332
                try {
333
                        for (int file = 0; file < visualStatus.fileNames.length; file++) {
334
                                RasterDataset rd = RasterDataset.open(getMapContext().getViewPort().getProjection(), visualStatus.fileNames[file]);
335
                                Extent ex = rd.getExtent();
336
                                if (pReal.getX() >= ex.minX() && pReal.getX() <= ex.maxX() && pReal.getY() >= ex.minY() && pReal.getY() <= ex.maxY()) {
337
                                        if (visualStatus.dataType >= 0 && visualStatus.dataType <= 3) {
338
                                                for (int i = 0; i < visualStatus.bandCount; i++) {
339
                                                        Integer value = (Integer) rd.getData((int) px.getX(), (int) px.getY(), i);
340
                                                        if (value != null)
341
                                                                data += value.intValue() + "  ";
342
                                                }
343
                                        }
344
                                        if (visualStatus.dataType >= 4) {
345
                                                for (int i = 0; i < visualStatus.bandCount; i++) {
346
                                                        Float value = (Float) rd.getData((int) px.getX(), (int) px.getY(), i);
347
                                                        if (value != null)
348
                                                                data += value.floatValue() + "  ";
349
                                                }
350
                                        }
351
                                        if (visualStatus.dataType >= 5) {
352
                                                for (int i = 0; i < visualStatus.bandCount; i++) {
353
                                                        Double value = (Double) rd.getData((int) px.getX(), (int) px.getY(), i);
354
                                                        if (value != null)
355
                                                                data += value.doubleValue() + "  ";
356
                                                }
357
                                        }
358
                                }
359
                                rd.close();
360
                        }
361
                } catch (NotSupportedExtensionException e) {
362
                        throw new ReadDriverException("Extensi?n no soportada.", e);
363
                } catch (RasterDriverException e) {
364
                        throw new ReadDriverException("Error en la apertura del fichero.", e);
365
                } catch (FileNotOpenException e) {
366
                        throw new ReadDriverException("Error en la apertura del fichero.", e);
367
                } catch (InvalidSetViewException e) {
368
                        throw new ReadDriverException("Error al asignar la vista.", e);
369
                }
370

    
371
                data += "\"\n";
372
                data += "  />\n";
373
                data += "</file:"+getName().replaceAll("[^a-zA-Z0-9]","")+">\n";
374

    
375
                item[0] = new StringXMLItem(data, this);
376
                return item;
377
        }
378

    
379
        /*
380
         *  (non-Javadoc)
381
         * @see com.iver.cit.gvsig.fmap.layers.FLayer#getFullExtent()
382
         */
383
        public Rectangle2D getFullExtent() {
384
                return fullExtent;
385
        }
386

    
387
        /*
388
         *  (non-Javadoc)
389
         * @see com.iver.cit.gvsig.fmap.layers.FLayer#draw(java.awt.image.BufferedImage, java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.operations.Cancellable, double)
390
         */
391
        public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale) throws ReadDriverException {
392
                enableStopped();
393
                if (isWithinScale(scale)){
394
                        Point2D p = viewPort.getOffset();
395
                        // p will be (0, 0) when drawing a view or other when painting onto
396
                        // the Layout.
397
                        visualStatus.width =  viewPort.getImageWidth();
398
                        visualStatus.height =  viewPort.getImageHeight();
399
                        visualStatus.minX = viewPort.getAdjustedExtent().getMinX();
400
                        visualStatus.minY = viewPort.getAdjustedExtent().getMinY();
401
                        visualStatus.maxX = viewPort.getAdjustedExtent().getMaxX();
402
                        visualStatus.maxY = viewPort.getAdjustedExtent().getMaxY();
403
                        visualStatus.rasterWidth = 0;
404
                        visualStatus.rasterHeight = 0;
405
                        visualStatus.rasterMinX = Double.MAX_VALUE;
406
                        visualStatus.rasterMinY = Double.MAX_VALUE;
407
                        visualStatus.rasterMaxX = 0;
408
                        visualStatus.rasterMaxY = 0;
409
                        visualStatus.fileNames = new String[1];
410
                        try {
411
                                if(true){
412
                                        if(viewPort.getImageWidth()<= maxTileDrawWidth && viewPort.getImageHeight()<=maxTileDrawHeight) {
413
                                                drawTile(g, viewPort, cancel, 0, scale);
414
                                                dataset = layerRaster.getDataSource();
415
                                                getRender().setLastRenderBuffer(layerRaster.getRender().getLastRenderBuffer());
416
                                                initializeRasterLayer(null, new IBuffer[][]{{layerRaster.getRender().getLastRenderBuffer()}});
417
                                        } else {
418
                                                Rectangle r = new Rectangle((int) p.getX(), (int) p.getY(), viewPort.getImageWidth(), viewPort.getImageHeight());
419
                                                Tiling tiles = new Tiling(maxTileDrawWidth, maxTileDrawHeight, r);
420
                                                tiles.setAffineTransform((AffineTransform) viewPort.getAffineTransform().clone());
421
                                                MultiRasterDataset[][] datasets = new MultiRasterDataset[tiles.getNumRows()][tiles.getNumCols()];
422
                                                IBuffer[][] buf = new IBuffer[tiles.getNumRows()][tiles.getNumCols()];
423
                                                fileNames = new String[tiles.getNumRows()][tiles.getNumCols()];
424
                                                visualStatus.fileNames = new String[tiles.getNumTiles()];
425
                                                for (int tileNr=0; tileNr < tiles.getNumTiles(); tileNr++) {
426
                                                        // drawing part
427
                                                        try {
428
                                                                ViewPort vp = tiles.getTileViewPort(viewPort, tileNr);
429
                                                                drawTile(g, vp, cancel, tileNr, scale);
430
                                                                if(layerRaster != null) {
431
                                                                        datasets[(int)(tileNr / tiles.getNumCols())][tileNr % tiles.getNumCols()] = (MultiRasterDataset)layerRaster.getDataSource().copy();
432
                                                                        buf[(int)(tileNr / tiles.getNumCols())][tileNr % tiles.getNumCols()] = layerRaster.getRender().getLastRenderBuffer();
433
                                                                }
434
                                                        } catch (NoninvertibleTransformException e) {
435
                                                                e.printStackTrace();
436
                                                        }
437
                                                }
438
                                                try {
439
                                                        if(datasets != null && datasets[0][0] != null) {
440
                                                                dataset = new CompositeDataset(datasets);
441
                                                                initializeRasterLayer(datasets, buf);
442
                                                        }
443
                                                } catch (MosaicNotValidException e) {
444
                                                        throw new ReadDriverException("No hay continuidad en el mosaico.", e);
445
                                                } catch (LoadLayerException e) {
446
                                                        throw new ReadDriverException("Error inicializando la capa.", e);
447
                                                }
448
                                        }
449
                                } else {
450
                                        drawTile(g, viewPort, cancel, 0, scale);
451
                                        dataset = layerRaster.getDataSource();
452
                                        getRender().setLastRenderBuffer(layerRaster.getRender().getLastRenderBuffer());
453
                                        initializeRasterLayer(null, new IBuffer[][]{{layerRaster.getRender().getLastRenderBuffer()}});
454
                                }
455
                                
456
                        }catch (ConnectionErrorLayerException e) {
457
                                e.printStackTrace();
458
                        }catch (UnsupportedVersionLayerException e) {
459
                                e.printStackTrace();
460
                        }catch (LoadLayerException e) {
461
                                e.printStackTrace();
462
                        }
463
                }
464
                callLegendChanged(null);
465
                disableStopped();
466
                Runtime r = Runtime.getRuntime();
467
                long mem = r.totalMemory() - r.freeMemory();
468
                System.err.println("Memoria total: " + (mem / 1024) +"KB");
469
        }
470
        
471
        /**
472
         * Acciones que se realizan despu?s de asignar la fuente de datos a 
473
         * la capa raster.
474
         * 
475
         * @throws LoadLayerException
476
         */
477
        private void initializeRasterLayer(MultiRasterDataset[][] datasets, IBuffer[][] buf) throws LoadLayerException {
478
                if(this.filterList != null)
479
                        getRender().setFilterList(filterList);
480
                if(this.transparency != null)
481
                        getRender().setLastTransparency(transparency);
482
                if(this.renderBands != null)
483
                        getRender().setRenderBands(renderBands);
484
                if(datasets != null) {
485
                        String[][] names = new String[datasets.length][datasets[0].length];
486
                        for (int i = 0; i < datasets.length; i++) 
487
                                for (int j = 0; j < datasets[i].length; j++) 
488
                                        names[i][j] = datasets[i][j].getDataset(0)[0].getFName();
489
                        super.setLoadParams(names);                        
490
                }
491
                super.init();
492
                if(buf != null) {
493
                        int drawablesBandCount = layerRaster.getDataSource().getBands().getDrawableBandsCount();
494
                        IBuffer buff = null;
495
                        if(dataset instanceof CompositeDataset)
496
                                buff = ((CompositeDataset)dataset).generateBuffer(buf, drawablesBandCount);
497
                        else
498
                                buff = buf[0][0];
499
                        getRender().setLastRenderBuffer(buff);
500
                }
501
        }
502

    
503
        /**
504
         * This is the method used to draw a tile in a WCS mosaic layer.
505
         * @param tile Tile number to draw
506
         * @throws ReadDriverException 
507
         */
508
        private void drawTile(Graphics2D g, ViewPort vp, Cancellable cancel, int tile, double scale) throws LoadLayerException, ReadDriverException {
509

    
510
                // Compute the query geometry
511
                // 1. Check if it is within borders
512
                Rectangle2D extent = getFullExtent();
513
        if ((vp.getAdjustedExtent().getMinX() > extent.getMaxX()) ||
514
                (vp.getAdjustedExtent().getMinY() > extent.getMaxY()) ||
515
                (vp.getAdjustedExtent().getMaxX() < extent.getMinX()) ||
516
                (vp.getAdjustedExtent().getMaxY() < extent.getMinY())) {
517
            return;
518
        }
519

    
520
        // 2. Compute extent to be requested.
521
        Rectangle2D bBox = new Rectangle2D.Double();
522
        Rectangle2D.intersect(vp.getAdjustedExtent(), extent, bBox);
523

    
524
        // 3. Compute size in pixels
525
        double scalex = vp.getAffineTransform().getScaleX();
526
        double scaley = vp.getAffineTransform().getScaleY();
527
        int wImg = (int) Math.ceil(Math.abs(bBox.getWidth() * scalex) + 1);
528
        int hImg = (int) Math.ceil(Math.abs(bBox.getHeight() * scaley) + 1);
529
        Dimension sz = new Dimension(wImg, hImg);
530

    
531
        if ((wImg <= 0) || (hImg <= 0)) {
532
            return;
533
        }
534

    
535
                try {
536
                        sz = new Dimension(wImg, hImg);
537
                        
538
                        wcsStatus.setCoveraName( coverageName );
539
                        wcsStatus.setExtent( bBox );
540
                        wcsStatus.setFormat( format );
541
                        wcsStatus.setHeight( hImg );
542
                        wcsStatus.setWidth( wImg );
543
                        wcsStatus.setSrs(srs);
544
                        wcsStatus.setParameters( parameter );
545
                        wcsStatus.setTime( time );
546
                        wcsStatus.setOnlineResource((String) onlineResources.get("GetCoverage"));
547

    
548
                        File f = getDriver().getCoverage(wcsStatus, new MyCancellable(cancel));
549
                        if (f == null)
550
                                return;
551
                        String nameWordFile = f.getPath() + getExtensionWorldFile();
552
                        com.iver.andami.Utilities.createTemp(nameWordFile, this.getDataWorldFile(bBox, sz));
553

    
554
                        IStatusRaster status = super.getStatus();
555
                        if(status!=null && firstLoad){
556
                                status.applyStatus(this);
557
                                firstLoad = false;
558
                        }
559
                        ViewPortData vpData = new ViewPortData(
560
                                vp.getProjection(), new Extent(bBox), sz );
561
                        vpData.setMat(vp.getAffineTransform());
562

    
563
                        String filePath = f.getAbsolutePath();
564
                        visualStatus.fileNames[tile] = filePath;
565
                        
566
                        rasterProcess(filePath, g, vp, scale, cancel);
567
                        
568
//                        this.getRender().draw(g, vpData);
569
//                        rasterProcess(g, vpData, f);
570

    
571
//                } catch (ValidationException e) {
572
//                        UnknownResponseFormatExceptionType type =
573
//                                new UnknownResponseFormatExceptionType();
574
//                        type.setLayerName(getName());
575
//                        try {
576
//                                type.setDriverName(getDriver().getName());
577
//                        } catch (Exception e1) {
578
//                                e1.printStackTrace();
579
//                        }
580
//                        type.setFormat(format);
581
//                        type.setHost(host);
582
//                        type.setProtocol("WCS");
583
//                        ReadDriverException exception = new ReadDriverException("unknown_response_format",type);
584
//                        throw exception;
585
//        azabala                throw new DriverException(PluginServices.getText(this, "unknown_response_format"), e);
586
//                }
587
//                catch (UnsupportedVersionLayerException e) {
588
//                        UnsuportedProtocolVersionExceptionType type =
589
//                                new UnsuportedProtocolVersionExceptionType();
590
//                        type.setLayerName(getName());
591
//                        try {
592
//                                type.setDriverName(getDriver().getName());
593
//                        } catch (Exception ex){
594
//                        }
595
//                        type.setUrl(host);
596
//                        throw new ReadDriverException(PluginServices.getText(this, "version_conflict"), e, type);
597

    
598
//        azabala                throw new DriverException(PluginServices.getText(this, "version_conflict"), e);
599
                } catch (IOException e) {
600
//                        ConnectionErrorExceptionType type = new ConnectionErrorExceptionType();
601
//                        type.setLayerName(getName());
602
//                        try {
603
//                                type.setDriverName(getDriver().getName());
604
//                        } catch (Exception e1) {
605
//                        }
606
//                        type.setHost(host);
607
                        throw new ConnectionErrorLayerException(getName(),e);
608
                }
609
//                catch (WCSLayerException e) {
610
////azabala: la capturamos y la convertimos en DriverException
611
//                        WCSDriverExceptionType type = new WCSDriverExceptionType();
612
//                        type.setLayerName(getName());
613
//                        try {
614
//                                type.setDriverName(getDriver().getName());
615
//                        } catch (Exception e1) {
616
//                        }
617
//                        type.setWcsStatus(wcsStatus);
618
//                        this.setVisible(false);
619
//                        throw new WDriverException("Error WCS", e,  type);
620
//
621
////            JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), e.getMessage());
622
//
623
//        }//
624
                catch (WCSDriverException e) {
625
                        throw new LoadLayerException(getName(),e);
626
                } catch (IllegalStateException e) {
627
                        throw new LoadLayerException(getName(),e);
628
                }
629
        }
630

    
631
        /**
632
         * Devuelve el FMapWMSDriver.
633
         *
634
         * @return FMapWMSDriver
635
         *
636
         * @throws IllegalStateException
637
         * @throws ValidationException
638
         * @throws UnsupportedVersionLayerException
639
         * @throws IOException
640
         */
641
        private FMapWCSDriver getDriver() throws IllegalStateException, IOException {
642
                if (wcs == null) {
643
                        wcs = FMapWCSDriverFactory.getFMapDriverForURL(host);
644
                }
645
                return wcs;
646
        }
647

    
648
        /**
649
         * Calcula el contenido del fichero de georreferenciaci?n de una imagen.
650
         * @param bBox Tama?o y posici?n de la imagen (en coordenadas de usuario)
651
         * @param sz Tama?o de la imagen en pixeles.
652
         * @return el 'WorldFile', como String.
653
         * @throws IOException
654
         */
655
        public String getDataWorldFile(Rectangle2D bBox, Dimension sz) throws IOException {
656
                StringBuffer data = new StringBuffer();
657
            data.append((bBox.getMaxX() - bBox.getMinX())/(sz.getWidth() - 1)+"\n");
658
            data.append("0.0\n");
659
            data.append("0.0\n");
660
            data.append("-"+(bBox.getMaxY() - bBox.getMinY())/(sz.getHeight() - 1)+"\n");
661
            data.append(""+bBox.getMinX()+"\n");
662
            data.append(""+bBox.getMaxY()+"\n");
663
            return data.toString();
664
        }
665

    
666
        /**
667
         * Carga y dibuja el raster usando la librer?a
668
         * @param filePath Ruta al fichero en disco
669
         * @param g Graphics2D
670
         * @param vp ViewPort
671
         * @param scale Escala para el draw
672
         * @param cancel Cancelaci?n para el draw
673
         * @throws ReadDriverException
674
         * @throws LoadLayerException
675
         */
676
        private void rasterProcess(String filePath, Graphics2D g, ViewPort vp, double scale, Cancellable cancel) throws ReadDriverException, LoadLayerException {                
677
                //Cerramos el dataset asociado a la capa si est? abierto. 
678
                if(layerRaster != null) {
679
                        layerRaster.setRemoveRasterFlag(true);
680
                        layerRaster.getDataSource().close();
681
                }
682
                
683
                //Cargamos el dataset con el raster de disco. 
684
                layerRaster = FLyrRasterSE.createLayer("", filePath, vp.getProjection());
685
                layerRaster.getRender().setBufferFactory(layerRaster.getBufferFactory());
686
                                
687
                //En caso de cargar un proyecto con XMLEntity se crean los filtros 
688
                if(filterArguments != null) {
689
                        RasterFilterList fl = new RasterFilterList();
690
                        fl.addParam("IStatistics", layerRaster.getDataSource().getStatistics());
691
                        fl.addParam("MultiRasterDataset", layerRaster.getDataSource());
692
                        fl.setInitDataType(layerRaster.getDataType()[0]);
693
                        RasterFilterListManager filterListManager = new RasterFilterListManager(fl);
694
                        filterListManager.createFilterListFromStrings(filterArguments);
695
                        if(fl.move(TailTrimFilter.class, 0))
696
                                fl.move(LinearEnhancementFilter.class, 1);
697
                        else
698
                                fl.move(LinearEnhancementFilter.class, 0);
699
                        fl.controlTypes();
700
                        filterArguments = null;
701
                        filterList = fl;
702
                }
703
                
704
                //Como el raster se carga a cada zoom el render se crea nuevamente y la lista de
705
                //filtros siempre estar? vacia a cada visualizaci?n. Para evitarlo tenemos que
706
                //guardar la lista de filtro aplicada en la visualizaci?n anterior.
707
                if(this.filterList != null) 
708
                        layerRaster.getRender().setFilterList(filterList);
709
                if(this.transparency != null)
710
                        layerRaster.getRender().setLastTransparency(transparency);
711
                if(this.renderBands != null)
712
                        layerRaster.getRender().setRenderBands(renderBands);
713
                
714
                //Dibujamos
715
                layerRaster.draw(null, g, vp, cancel, scale);
716
                                
717
                //La primera vez asignamos la lista de filtros asociada al renderizador. Guardamos una referencia
718
                //en esta clase para que a cada zoom no se pierda.
719
                if (this.filterList == null)
720
                        filterList = layerRaster.getRender().getFilterList();
721
                if (this.transparency == null)
722
                        transparency = layerRaster.getRender().getLastTransparency();
723
                if (this.renderBands == null)
724
                        renderBands = layerRaster.getRender().getRenderBands();
725
                
726
        }
727

    
728
        /*
729
         * (non-Javadoc)
730
         * @see com.iver.cit.gvsig.fmap.layers.FLyrDefault#cloneLayer()
731
         */
732
        public FLayer cloneLayer() throws Exception {
733
                Object par = null;
734
                if(dataset instanceof CompositeDataset) 
735
                        par = ((CompositeDataset)dataset).getFileNames();
736
                else if(layerRaster != null)
737
                        par = layerRaster.getLoadParams();
738
                
739
                FLyrRasterSE newLayer = FLyrRasterSE.createLayer(this.getName(), par, this.getProjection());
740
                ArrayList filters = getRender().getFilterList().getStatusCloned();
741
                RasterFilterList filterList = new RasterFilterList();
742
                filterList.setInitDataType(newLayer.getDataType()[0]);
743
                filterList.setStatus(filters);
744
                newLayer.getRender().setFilterList(filterList);
745
                newLayer.getRender().setLastTransparency(new GridTransparency(getRenderTransparency()));
746
                return newLayer;
747
        }
748
        
749
        /*
750
         * (non-Javadoc)
751
         * @see org.gvsig.fmap.raster.IRasterRendering#getRenderFilterList()
752
         */
753
        public RasterFilterList getRenderFilterList(){
754
                return (filterList != null) ? filterList : getRender().getFilterList();
755
        }
756
        
757
        /*
758
         * (non-Javadoc)
759
         * @see org.gvsig.raster.hierarchy.IRasterRendering#setRenderFilterList(org.gvsig.raster.grid.filter.RasterFilterList)
760
         */
761
        public void setRenderFilterList(RasterFilterList filterList) {
762
                this.filterList = filterList;
763
                super.getRender().setFilterList(filterList);
764
        }
765
        
766
        /*
767
         * (non-Javadoc)
768
         * @see org.gvsig.fmap.raster.IRasterRendering#getRenderTransparency()
769
         */
770
        public GridTransparency getRenderTransparency() {
771
                return (transparency != null) ? transparency : getRender().getLastTransparency();
772
        }
773
        
774
        /*
775
         * (non-Javadoc)
776
         * @see org.gvsig.raster.hierarchy.IRasterRendering#getRenderBands()
777
         */
778
        public int[] getRenderBands() {
779
                return (renderBands != null) ? renderBands : getRender().getRenderBands();
780
        }
781
        
782
        /*
783
         * (non-Javadoc)
784
         * @see org.gvsig.raster.hierarchy.IRasterRendering#setRenderBands(int[])
785
         */
786
        public void setRenderBands(int[] renderBands) {
787
                this.renderBands = renderBands;
788
                getRender().setRenderBands(renderBands);
789
        }
790
        
791
        /*
792
         * (non-Javadoc)
793
         * @see org.gvsig.fmap.raster.layers.FLyrRasterSE#print(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.utiles.swing.threads.Cancellable, double, javax.print.attribute.PrintRequestAttributeSet)
794
         */
795
        public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties) throws ReadDriverException {
796
                draw(null, g, viewPort, cancel, scale);
797
        }
798

    
799
        /**
800
         * Returns the XMLEntity containing the necessary info for reproduce
801
         * the layer.
802
         *
803
         * Devuelve el XMLEntity con la informaci?n necesaria para reproducir
804
         * la capa.
805
         *
806
         * @return XMLEntity.
807
         * @throws XMLException
808
         */
809
        public XMLEntity getXMLEntity() throws XMLException {
810
                XMLEntity xml = super.getXMLEntity();
811

    
812
                xml.putProperty("wcs.host", getHost());
813
                xml.putProperty("wcs.fullExtent", StringUtilities.rect2String( fullExtent ));
814
                xml.putProperty("wcs.layerQuery", coverageName );
815
                xml.putProperty("wcs.format", format );
816
                xml.putProperty("wcs.srs", srs );
817
                xml.putProperty("wcs.time", time );
818
                xml.putProperty("wcs.parameter", parameter );
819
                xml.putProperty("wcs.coverageName", coverageName );
820
                xml.putProperty("wcs.maxResX", maxRes.getX());
821
                xml.putProperty("wcs.maxResY", maxRes.getY());
822

    
823
                Iterator it = onlineResources.keySet().iterator();
824
                String strOnlines = "";
825
                while (it.hasNext()) {
826
                        String key = (String) it.next();
827
                        String value = (String) onlineResources.get(key);
828
                        strOnlines += key+"~##SEP2##~"+value;
829
                        if (it.hasNext())
830
                                strOnlines += "~##SEP1##~";
831
                }
832
                xml.putProperty("onlineResources", strOnlines);
833

    
834
                IStatusRaster status = super.getStatus();
835
                if (status!=null)
836
                        status.getXMLEntity(xml, true, this);
837
                else{
838
                        status = new StatusLayerRaster();
839
                        status.getXMLEntity(xml, true, this);
840
                }
841
                return xml;
842
        }
843

    
844
        /**
845
         * Reproduces the layer from an XMLEntity.
846
         *
847
         * A partir del XMLEntity reproduce la capa.
848
         *
849
          * @param xml XMLEntity
850
         *
851
         * @throws XMLException
852
         * @throws DriverException
853
         * @throws DriverIOException
854
         */
855
        public void setXMLEntity(XMLEntity xml) throws XMLException {
856
                super.setXMLEntity(xml);
857

    
858
                // host
859
                try {
860
                        host = new URL(xml.getStringProperty("wcs.host"));
861
                } catch (MalformedURLException e) {
862
                        throw new XMLException(e);
863
                }
864

    
865
                // full extent
866
                fullExtent = StringUtilities.string2Rect(xml.getStringProperty("wcs.fullExtent"));
867

    
868
                // coverageQuery
869
                coverageName = xml.getStringProperty("wcs.layerQuery");
870

    
871
                // format
872
                format = xml.getStringProperty("wcs.format");
873

    
874
                // srs
875
                srs = xml.getStringProperty("wcs.srs");
876

    
877
                // time
878
                time = xml.getStringProperty("wcs.time");
879

    
880
                // parameter
881
                parameter = xml.getStringProperty("wcs.parameter");
882

    
883
                // coverage name
884
                coverageName = xml.getStringProperty("wcs.coverageName");
885

    
886
                // max resolution
887
                if (xml.contains("wcs.maxRes"))
888
                        maxRes = new Point2D.Double(xml.getDoubleProperty("wcs.maxRes"), xml.getDoubleProperty("wcs.maxRes"));
889
                else if (xml.contains("wcs.maxResX") && xml.contains("wcs.maxResY"))
890
                        maxRes = new Point2D.Double(xml.getDoubleProperty("wcs.maxResX"), xml.getDoubleProperty("wcs.maxResY"));
891

    
892
                // OnlineResources
893
        if (xml.contains("onlineResources")) {
894
                String[] operations = xml.getStringProperty("onlineResources").split("~##SEP1##~");
895
                for (int i = 0; i < operations.length; i++) {
896
                                String[] resources = operations[i].split("~##SEP2##~");
897
                                if (resources.length==2 && resources[1]!="")
898
                                        onlineResources.put(resources[0], resources[1]);
899
                        }
900
        }
901
                String claseStr = null;
902
                if (xml.contains("raster.class")) {
903
                        claseStr = xml.getStringProperty("raster.class");
904
                }
905
                
906
                IStatusRaster status = super.getStatus();
907
                if (status!=null)
908
                        status.setXMLEntity(xml, this);
909
                else {
910
                        //Cuando cargamos un proyecto
911

    
912
                        if(claseStr!=null && !claseStr.equals("")){
913
                                try{
914
                                        Class clase = LayerFactory.getLayerClassForLayerClassName(claseStr);
915
                                        Constructor constr = clase.getConstructor(null);
916
                                        status = (IStatusRaster)constr.newInstance(null);
917
                                        if(status != null) {
918
                                                status.setXMLEntity(xml, this);
919
                                                ((StatusLayerRaster)status).setNameClass(claseStr);
920
                                                filterArguments = status.getFilterArguments();
921
                                                transparency = status.getTransparency();
922
                                                renderBands = status.getRenderBands();
923
                                        }
924
                                } catch(ClassNotFoundException exc) {
925
                                        exc.printStackTrace();
926
                                } catch(InstantiationException exc) {
927
                                        exc.printStackTrace();
928
                                } catch(IllegalAccessException exc) {
929
                                        exc.printStackTrace();
930
                                } catch(NoSuchMethodException exc) {
931
                                        exc.printStackTrace();
932
                                } catch(InvocationTargetException exc) {
933
                                        exc.printStackTrace();
934
                                }
935
                        }
936
                }
937
                firstLoad = true;
938
        }
939

    
940
        public void setCoverageName(String coverageName) {
941
                this.coverageName = coverageName;
942
        }
943

    
944
        public void setParameter(String parametersString) {
945
                this.parameter = parametersString;
946
        }
947

    
948
        public void setTime(String time) {
949
                this.time = time;
950
        }
951

    
952
        public void setSRS(String srs) {
953
                this.srs = srs;
954
                setProjection(CRSFactory.getCRS(srs));
955
        }
956

    
957
        public void setFormat(String format) {
958
                this.format = format;
959
        }
960

    
961

    
962
        /**
963
         * Inserta el URL.
964
         *
965
         * @param host String.
966
         * @throws MalformedURLException
967
         */
968
        public void setHost(String host) {
969
                try {
970
                        setHost(new URL(host));
971
                } catch (MalformedURLException e) {
972

    
973
                }
974
        }
975

    
976
        /**
977
         * Inserta el URL.
978
         *
979
         * @param host URL.
980
         */
981
        public void setHost(URL host) {
982
                this.host = host;
983
        }
984

    
985
        /**
986
         * Sets the layer's full extent.
987
         *
988
         * Establece la extensi?n m?xima de la capa.
989
         *
990
         * @param rect
991
         */
992
        public void setFullExtent(Rectangle2D rect) {
993
                this.fullExtent = rect;
994
        }
995

    
996
        /**
997
         * Devuelve el URL.
998
         *
999
         * @return URL.
1000
         */
1001
        public URL getHost() {
1002
                return host;
1003
        }
1004

    
1005
        /**
1006
         * Remote source layers have a bunch of properties that are required for get them from
1007
         * the servers. This method supplies a hash table containing any needed field. This hash
1008
         * table may be used to let the client to connect to a server and restore a previously saved
1009
         * layer. So, the layer itself may not be saved to the disk since the actual saved
1010
         * info is just its properties.
1011
         *
1012
         * @return Returns a hash table containing all the required information for
1013
         * set up a wms layer
1014
         */
1015
        public Hashtable getProperties(){
1016
                Hashtable info = new Hashtable();
1017
                info.put(   "name", coverageName);
1018
                info.put(   "host", getHost());
1019
                info.put(    "crs", srs);
1020
                info.put( "format", format);
1021
                String str = time;
1022
                if (str==null)
1023
                        str = "";
1024
                info.put(   "time", str);
1025
                str = parameter;
1026
                if (str==null)
1027
                        str = "";
1028
                info.put("parameter", str);
1029

    
1030
                return info;
1031
        }
1032

    
1033
        /**
1034
         * Obtiene la extensi?n del fichero de georreferenciaci?n
1035
         * @return String con la extensi?n del fichero de georreferenciaci?n dependiendo
1036
         * del valor del formato obtenido del servidor. Por defecto asignaremos un .wld
1037
         */
1038
        private String getExtensionWorldFile(){
1039
                String extWorldFile = ".wld";
1040
            if (format.equals("image/tif") || format.equals("image/tiff"))
1041
                    extWorldFile = ".tfw";
1042
            if (format.equals("image/jpeg"))
1043
                    extWorldFile = ".jpgw";
1044
            return extWorldFile;
1045
        }
1046

    
1047
        public void setMaxResolution(Point2D maxResolution) {
1048
                this.maxRes = maxResolution;
1049
        }
1050

    
1051
        /**
1052
         * <p>
1053
         * Gets the max resolution allowed by the coverage. Requesting a higher resolution
1054
         * than this value does not cause any error, but the info responsed is just an
1055
         * interpolation. <br>
1056
         * </p>
1057
         * 
1058
         * <p>
1059
         * In exchange for obtaining a greater file and without additional information,
1060
         * we can easily fit it into the View. <br>
1061
         * </p>
1062
         *
1063
         * <p>
1064
         * Obtiene la resoluci?n m?xima soportada por la cobertura. La petici?n
1065
         * de una resoluci?n superior a la soportada no provoca ning?n error, aunque
1066
         * la informaci?n obtenida s?lo es una mera interpolaci?n de informaci?n. <br>
1067
         * </p>
1068
         * 
1069
         * <p>
1070
         * A cambio de obtener un archivo mayor y sin informaci?n adicional, podemos
1071
         * f?cilmente acoplarlo a la vista. <br>
1072
         * </p>
1073
         * 
1074
         * @return double
1075
         */
1076
        public Point2D getMaxResolution() {
1077
                if (maxRes==null)
1078
                        maxRes = wcs.getMaxResolution(coverageName);
1079
                return maxRes;
1080
        }
1081

    
1082

    
1083
        public void setDriver(FMapWCSDriver driver) {
1084
                this.wcs = driver;
1085
        }
1086

    
1087
        /*
1088
         *  (non-Javadoc)
1089
         * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getTileSize()
1090
         */
1091
        public int[] getTileSize() {
1092
                int[] size = {maxTileDrawWidth, maxTileDrawHeight};
1093
                return size;
1094
        }
1095

    
1096
        /*
1097
         *  (non-Javadoc)
1098
         * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#isTiled()
1099
         */
1100
        public boolean isTiled() {
1101
                return mustTileDraw;
1102
        }
1103
        
1104
        /*
1105
         * (non-Javadoc)
1106
         * @see org.gvsig.fmap.raster.layers.FLyrRasterSE#isActionEnabled(int)
1107
         */
1108
        public boolean isActionEnabled(int action) {
1109
                switch (action) {
1110
                        case IRasterLayerActions.ZOOM_PIXEL_RESOLUTION:
1111
                        case IRasterLayerActions.FLYRASTER_BAR_TOOLS:
1112
                        case IRasterLayerActions.BANDS_FILE_LIST:
1113
                        case IRasterLayerActions.PANSHARPENING:
1114
                                return false;
1115
                        case IRasterLayerActions.BANDS_RGB:
1116
                                return true;
1117
                }
1118

    
1119
                return super.isActionEnabled(action);
1120
        }
1121
        
1122
}