svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / raster / gui / wizards / FileOpenRaster.java @ 13874
History | View | Annotate | Download (2.98 KB)
1 | 13543 | bsanchez | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2005 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 org.gvsig.raster.gui.wizards; |
||
20 | |||
21 | import java.awt.Component; |
||
22 | import java.awt.geom.Rectangle2D; |
||
23 | import java.io.File; |
||
24 | import java.util.ArrayList; |
||
25 | |||
26 | import javax.swing.JOptionPane; |
||
27 | |||
28 | import org.cresques.cts.IProjection; |
||
29 | import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
||
30 | |||
31 | import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
||
32 | import com.iver.andami.PluginServices; |
||
33 | import com.iver.cit.gvsig.addlayer.fileopen.IFileOpen; |
||
34 | import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException; |
||
35 | import com.iver.cit.gvsig.exceptions.layers.LoadLayerException; |
||
36 | import com.iver.cit.gvsig.fmap.MapControl; |
||
37 | import com.iver.cit.gvsig.fmap.layers.FLayer; |
||
38 | /**
|
||
39 | * Clase que indicar? que ficheros puede tratar al panel de apertura de ficheros
|
||
40 | *
|
||
41 | * @version 04/09/2007
|
||
42 | * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
||
43 | */
|
||
44 | public class FileOpenRaster implements IFileOpen { |
||
45 | private ArrayList arrayFileFilter; |
||
46 | |||
47 | /**
|
||
48 | * Constructor de FileOpenRaster
|
||
49 | */
|
||
50 | public FileOpenRaster() {
|
||
51 | arrayFileFilter = new ArrayList(); |
||
52 | arrayFileFilter.add(new DriverFileFilter());
|
||
53 | } |
||
54 | |||
55 | /*
|
||
56 | * (non-Javadoc)
|
||
57 | * @see org.gvsig.raster.gui.wizards.IFileOpen#pre()
|
||
58 | */
|
||
59 | public void pre() { |
||
60 | 13697 | nacho | } |
61 | 13543 | bsanchez | |
62 | /*
|
||
63 | * (non-Javadoc)
|
||
64 | * @see org.gvsig.raster.gui.wizards.IFileOpen#post(java.io.File[])
|
||
65 | */
|
||
66 | public void post(File[] file) { |
||
67 | } |
||
68 | |||
69 | /*
|
||
70 | * (non-Javadoc)
|
||
71 | * @see org.gvsig.raster.gui.wizards.IFileOpen#getFileFilter()
|
||
72 | */
|
||
73 | public ArrayList getFileFilter() { |
||
74 | return arrayFileFilter;
|
||
75 | } |
||
76 | |||
77 | /*
|
||
78 | * (non-Javadoc)
|
||
79 | * @see org.gvsig.raster.gui.wizards.IFileOpen#execute(java.io.File[])
|
||
80 | */
|
||
81 | public Rectangle2D createLayer(File file, MapControl mapControl, String driverName, IProjection proj) { |
||
82 | FLayer lyr = null;
|
||
83 | |||
84 | String layerName = file.getName();
|
||
85 | try {
|
||
86 | lyr = FLyrRasterSE.createLayer(layerName, file, proj); |
||
87 | } catch (LoadLayerException e) {
|
||
88 | 13697 | nacho | JOptionPane.showMessageDialog((Component) PluginServices.getMainFrame(), PluginServices.getText(this, "error_carga_capa")); |
89 | 13543 | bsanchez | } |
90 | |||
91 | if (lyr != null) { |
||
92 | lyr.setVisible(true);
|
||
93 | mapControl.getMapContext().getLayers().addLayer(lyr); |
||
94 | try {
|
||
95 | return lyr.getFullExtent();
|
||
96 | } catch (ReadDriverException e) {
|
||
97 | 13874 | jaume | } |
98 | 13543 | bsanchez | } |
99 | return null; |
||
100 | } |
||
101 | } |