root / branches / Mobile_Compatible_Hito_1 / libFMap / src / es / prodevelop / gvsig / mobile / fmap / driver / raster / DefaultRasterDriver.java @ 21606
History | View | Annotate | Download (5.77 KB)
1 |
/*
|
---|---|
2 |
* Created on 17-dic-2004
|
3 |
*/
|
4 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Generalitat Valenciana
|
25 |
* Conselleria d'Infraestructures i Transport
|
26 |
* Av. Blasco Ib??ez, 50
|
27 |
* 46010 VALENCIA
|
28 |
* SPAIN
|
29 |
*
|
30 |
* +34 963862235
|
31 |
* gvsig@gva.es
|
32 |
* www.gvsig.gva.es
|
33 |
*
|
34 |
* or
|
35 |
*
|
36 |
* IVER T.I. S.A
|
37 |
* Salamanca 50
|
38 |
* 46005 Valencia
|
39 |
* Spain
|
40 |
*
|
41 |
* +34 963163400
|
42 |
* dac@iver.es
|
43 |
*/
|
44 |
/************************************************
|
45 |
* *
|
46 |
* Modfied By: *
|
47 |
* Prodevelop Integraci?n de Tecnolog?as SL *
|
48 |
* Conde Salvatierra de ?lava , 34-10 *
|
49 |
* 46004 Valencia *
|
50 |
* Spain *
|
51 |
* *
|
52 |
* +34 963 510 612 *
|
53 |
* +34 963 510 968 *
|
54 |
* gis@prodevelop.es *
|
55 |
* http://www.prodevelop.es *
|
56 |
* *
|
57 |
* gvSIG Mobile Team 2006 *
|
58 |
* *
|
59 |
************************************************/
|
60 |
|
61 |
package es.prodevelop.gvsig.mobile.fmap.driver.raster; |
62 |
|
63 |
import java.awt.Graphics2D; |
64 |
import java.awt.geom.AffineTransform; |
65 |
import java.awt.geom.Rectangle2D; |
66 |
import java.io.File; |
67 |
import java.io.IOException; |
68 |
|
69 |
import es.prodevelop.gvsig.mobile.fmap.driver.FMapDriverException; |
70 |
import es.prodevelop.gvsig.mobile.fmap.proj.IProjection; |
71 |
import es.prodevelop.gvsig.mobile.fmap.viewport.ViewPort; |
72 |
|
73 |
/**
|
74 |
* Driver de raster (tal y como los abre CMS.
|
75 |
* Primera aproximaci?n al raster. Borrador para revisar.
|
76 |
*
|
77 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
78 |
*/
|
79 |
public class DefaultRasterDriver implements GeorreferencedRasterDriver { |
80 |
|
81 |
public final static int FILE_TYPE_UKW = -1; |
82 |
public final static int FILE_TYPE_ECW = 0; |
83 |
public final static int FILE_TYPE_TIF = 1; |
84 |
public final static int FILE_TYPE_GIF = 2; |
85 |
public final static int FILE_TYPE_JPG = 3; |
86 |
|
87 |
private int type = FILE_TYPE_UKW; |
88 |
private File file = null; |
89 |
private String filePath = ""; |
90 |
private IProjection proj = null; |
91 |
int trans = 255; |
92 |
|
93 |
public String getFilePath() { |
94 |
return filePath;
|
95 |
} |
96 |
|
97 |
public String getName() { |
98 |
return "gvSIG Image Driver"; |
99 |
} |
100 |
|
101 |
public void open(File f) throws IOException { |
102 |
file = f; |
103 |
} |
104 |
|
105 |
public void close() throws IOException { |
106 |
} |
107 |
|
108 |
/* (non-Javadoc)
|
109 |
* @see com.iver.cit.gvsig.fmap.drivers.RasterDriver#initialize()
|
110 |
*/
|
111 |
public void initialize() throws IOException { |
112 |
if (proj != null){ |
113 |
filePath = file.getCanonicalPath(); |
114 |
type = getType(filePath); |
115 |
|
116 |
switch (type) {
|
117 |
|
118 |
case FILE_TYPE_UKW:
|
119 |
throw new IOException("Tipo desconocido."); |
120 |
case FILE_TYPE_ECW:
|
121 |
break;
|
122 |
case FILE_TYPE_TIF:
|
123 |
break;
|
124 |
case FILE_TYPE_GIF:
|
125 |
break;
|
126 |
case FILE_TYPE_JPG:
|
127 |
break;
|
128 |
|
129 |
} |
130 |
|
131 |
} else {
|
132 |
throw new IOException("Proyecci?n no asignada"); |
133 |
} |
134 |
|
135 |
} |
136 |
|
137 |
private int getType(String path) { |
138 |
|
139 |
int ind_ext = path.lastIndexOf("."); |
140 |
if (ind_ext == -1) { |
141 |
return FILE_TYPE_UKW;
|
142 |
} |
143 |
String ext = filePath.substring(ind_ext + 1, filePath.length()); |
144 |
if (ext.compareToIgnoreCase("ecw") == 0) return FILE_TYPE_ECW; |
145 |
if (ext.compareToIgnoreCase("tif") == 0) return FILE_TYPE_TIF; |
146 |
if (ext.compareToIgnoreCase("tiff") == 0) return FILE_TYPE_TIF; |
147 |
if (ext.compareToIgnoreCase("gif") == 0) return FILE_TYPE_GIF; |
148 |
if (ext.compareToIgnoreCase("jpg") == 0) return FILE_TYPE_JPG; |
149 |
return FILE_TYPE_UKW;
|
150 |
} |
151 |
|
152 |
|
153 |
/**
|
154 |
* @see com.iver.cit.gvsig.fmap.drivers.GeorreferencedRasterDriver#initialize(org.cresques.cts.IProjection)
|
155 |
*/
|
156 |
public void initialize(IProjection p) throws IOException { |
157 |
proj = p; |
158 |
} |
159 |
|
160 |
|
161 |
public int getTransparency() { |
162 |
return trans;
|
163 |
} |
164 |
|
165 |
public void setTransparency(int t) { |
166 |
trans = t; |
167 |
} |
168 |
|
169 |
public IProjection getProjection() {
|
170 |
return proj;
|
171 |
} |
172 |
|
173 |
public void setProjection(IProjection p) { |
174 |
proj = p; |
175 |
} |
176 |
|
177 |
public int getNumBands() { |
178 |
return 0; |
179 |
} |
180 |
|
181 |
|
182 |
public int getRasterDataType() { |
183 |
return 0; |
184 |
} |
185 |
|
186 |
/* (non-Javadoc)
|
187 |
* @see com.iver.cit.gvsig.fmap.drivers.RasterDriver#getData(int, int, int)
|
188 |
*/
|
189 |
public Object getData(int x, int y, int band) { |
190 |
return null; |
191 |
} |
192 |
|
193 |
public boolean fileAccepted(File file) { |
194 |
|
195 |
try {
|
196 |
filePath = file.getCanonicalPath(); |
197 |
int ind_ext = filePath.lastIndexOf("."); |
198 |
if (ind_ext == -1) { |
199 |
return false; |
200 |
} |
201 |
String ext = filePath.substring(ind_ext + 1, filePath.length()); |
202 |
return acceptedExtension(ext);
|
203 |
} catch (IOException e) { |
204 |
return false; |
205 |
} |
206 |
} |
207 |
|
208 |
private boolean acceptedExtension(String ext) { |
209 |
|
210 |
if (ext.compareToIgnoreCase("ecw") == 0) return true; |
211 |
if (ext.compareToIgnoreCase("tif") == 0) return true; |
212 |
if (ext.compareToIgnoreCase("tiff") == 0) return true; |
213 |
if (ext.compareToIgnoreCase("gif") == 0) return true; |
214 |
if (ext.compareToIgnoreCase("jpg") == 0) return true; |
215 |
return false; |
216 |
} |
217 |
|
218 |
public int[] getPixel(double wcx, double wcy){ |
219 |
return null; |
220 |
} |
221 |
|
222 |
public boolean isGeoreferenced() { |
223 |
return true; |
224 |
} |
225 |
|
226 |
public void setAffineTransform(AffineTransform t){ |
227 |
} |
228 |
|
229 |
public AffineTransform getAffineTransform(){ |
230 |
return null; |
231 |
} |
232 |
|
233 |
public Rectangle2D getFullExtent() { |
234 |
// TODO Auto-generated method stub
|
235 |
return null; |
236 |
} |
237 |
|
238 |
public void draw(Graphics2D g, ViewPort viewPort) throws FMapDriverException { |
239 |
// TODO Auto-generated method stub
|
240 |
|
241 |
} |
242 |
|
243 |
} |