svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / px / PxRaster.java @ 1809
History | View | Annotate | Download (14.8 KB)
1 | 2 | luisw | /*
|
---|---|---|---|
2 | * PxRaster.java
|
||
3 | */
|
||
4 | package org.cresques.px; |
||
5 | |||
6 | import java.awt.Color; |
||
7 | 130 | luisw | import java.awt.Component; |
8 | 2 | luisw | import java.awt.Graphics2D; |
9 | import java.awt.Image; |
||
10 | 1527 | luisw | import java.awt.geom.GeneralPath; |
11 | import java.awt.geom.Point2D; |
||
12 | 1679 | luisw | import java.awt.image.DataBuffer; |
13 | 2 | luisw | import java.awt.image.ImageObserver; |
14 | 1717 | luisw | import java.lang.reflect.InvocationTargetException; |
15 | 210 | luisw | import java.util.Date; |
16 | 30 | luisw | import java.util.Vector; |
17 | 2 | luisw | |
18 | 94 | luisw | import org.cresques.cts.ICoordTrans; |
19 | import org.cresques.cts.IProjection; |
||
20 | 30 | luisw | import org.cresques.geo.Projected; |
21 | 91 | luisw | import org.cresques.geo.ViewPortData; |
22 | 1679 | luisw | import org.cresques.io.GdalFile; |
23 | 2 | luisw | import org.cresques.io.GeoRasterFile; |
24 | 1679 | luisw | import org.cresques.io.raster.ComputeMinMaxFilter; |
25 | import org.cresques.io.raster.ComputeMinMaxImageFilter; |
||
26 | 1808 | igbrotru | import org.cresques.io.raster.RasterFilterStack; |
27 | 1679 | luisw | import org.cresques.io.raster.LinearEnhancementFilter; |
28 | import org.cresques.io.raster.LinearEnhancementImageFilter; |
||
29 | 1791 | luisw | import org.cresques.io.raster.PercentTailTrimFilter; |
30 | import org.cresques.io.raster.PercentTailTrimImageFilter; |
||
31 | 1679 | luisw | import org.cresques.io.raster.RasterBuf; |
32 | import org.cresques.io.raster.RasterStats; |
||
33 | import org.cresques.io.raster.RasterToImageFilter; |
||
34 | 1776 | igbrotru | import org.cresques.io.raster.TransparencyFilter; |
35 | import org.cresques.io.raster.TransparencyImageFilter; |
||
36 | 2 | luisw | |
37 | 30 | luisw | public class PxRaster extends PxObj implements Projected { |
38 | 1738 | igbrotru | public GeoRasterFile geoFile = null; |
39 | 24 | luisw | protected ImageObserver component = null; |
40 | 30 | luisw | Vector pts = null; |
41 | 210 | luisw | // Soporte para n bandas, visibles de 3 en 3, en ficheros separados
|
42 | protected GeoRasterFile [] colorBand = null; |
||
43 | protected int rBand = 1, gBand = 2, bBand = 3; |
||
44 | 2 | luisw | |
45 | 1777 | igbrotru | public RasterStats stats = new RasterStats(); |
46 | 56 | luisw | int transparente = 0x10ffff80; |
47 | 2 | luisw | |
48 | String vName = null; |
||
49 | 96 | luisw | protected boolean pintaMarco = false; //true; |
50 | 94 | luisw | IProjection proj = null;
|
51 | 34 | luisw | protected Extent extentOrig = null; |
52 | 94 | luisw | ICoordTrans rp = null;
|
53 | 2 | luisw | |
54 | 1808 | igbrotru | public RasterFilterStack filterStack = new RasterFilterStack(stats); |
55 | 1804 | igbrotru | |
56 | /*public boolean transparencyFilterEnabled = false;
|
||
57 | 1800 | igbrotru | public boolean enhancedFilterEnabled = false;
|
58 | 1804 | igbrotru | public boolean tailFilterEnabled = false;*/
|
59 | 1800 | igbrotru | |
60 | 2 | luisw | /**
|
61 | * Constructor.
|
||
62 | * @param component
|
||
63 | 141 | luisw | */
|
64 | 24 | luisw | public PxRaster(ImageObserver component) { |
65 | this.component = component;
|
||
66 | } |
||
67 | |||
68 | 94 | luisw | public PxRaster(IProjection proj, String fname, ImageObserver component) { |
69 | 53 | efejotape | geoFile = GeoRasterFile.openFile(proj, fname);//loadECW(fname);
|
70 | 130 | luisw | geoFile.setUpdatable((Component) component);
|
71 | 53 | efejotape | this.proj = proj;
|
72 | 2 | luisw | this.component = component;
|
73 | 56 | luisw | setExtent(geoFile.getExtent()); |
74 | 2 | luisw | geoFile.setView(geoFile.getExtent()); |
75 | 34 | luisw | extentOrig = extent; |
76 | 1527 | luisw | if (geoFile.getBandCount()>2) { |
77 | setBand(GeoRasterFile.RED_BAND, 0);
|
||
78 | setBand(GeoRasterFile.GREEN_BAND, 1);
|
||
79 | setBand(GeoRasterFile.BLUE_BAND, 2);
|
||
80 | } else {
|
||
81 | setBand(GeoRasterFile.RED_BAND|GeoRasterFile.GREEN_BAND|GeoRasterFile.BLUE_BAND, 0);
|
||
82 | } |
||
83 | 2 | luisw | } |
84 | |||
85 | 56 | luisw | /*public PxRaster(String fname, ImageObserver component, Extent view) {
|
86 | 50 | luisw | geoFile = GeoRasterFile.openFile(null, fname);//loadECW(fname);
|
87 | 2 | luisw | this.component = component;
|
88 | 56 | luisw | setExtent(geoFile.getExtent());
|
89 | 2 | luisw | geoFile.setView(view);
|
90 | 34 | luisw | extentOrig = extent;
|
91 | 2 | luisw | |
92 | //double x = 680800,y = 4128600;
|
||
93 | //setView(new Extent(x, y, x+4200, y-4200),"Huelva capital");
|
||
94 | 56 | luisw | }*/
|
95 | 2 | luisw | |
96 | 210 | luisw | public PxRaster(IProjection proj, String [] fnames, ImageObserver component) { |
97 | this.proj = proj;
|
||
98 | this.component = component;
|
||
99 | colorBand = new GeoRasterFile[fnames.length];
|
||
100 | 1345 | luisw | for (int i=0; i<colorBand.length; i++) { |
101 | 210 | luisw | colorBand[i] = GeoRasterFile.openFile(proj, fnames[i]);//loadECW(fname);
|
102 | colorBand[i].setUpdatable((Component) component);
|
||
103 | setExtent(colorBand[i].getExtent()); |
||
104 | colorBand[i].setView(colorBand[i].getExtent()); |
||
105 | } |
||
106 | 1345 | luisw | geoFile = colorBand[0];
|
107 | 210 | luisw | extentOrig = extent; |
108 | 1527 | luisw | if (fnames.length >= 3 || geoFile.getBandCount()>2) { |
109 | setBand(GeoRasterFile.RED_BAND, 0);
|
||
110 | setBand(GeoRasterFile.GREEN_BAND, 1);
|
||
111 | setBand(GeoRasterFile.BLUE_BAND, 2);
|
||
112 | 210 | luisw | } else {
|
113 | 1527 | luisw | setBand(GeoRasterFile.RED_BAND|GeoRasterFile.GREEN_BAND|GeoRasterFile.BLUE_BAND, 0);
|
114 | 210 | luisw | } |
115 | } |
||
116 | |||
117 | 50 | luisw | public PxRaster(GeoRasterFile eFile, ImageObserver component, Extent view) { |
118 | 2 | luisw | geoFile = eFile;//loadECW(fname);
|
119 | 553 | luisw | geoFile.setUpdatable((Component) component);
|
120 | setProjection(geoFile.getProjection()); |
||
121 | 2 | luisw | this.component = component;
|
122 | 553 | luisw | |
123 | setExtent(geoFile.getExtent()); |
||
124 | geoFile.setView(view); //geoFile.getExtent());
|
||
125 | 34 | luisw | extentOrig = extent; |
126 | 1527 | luisw | if (geoFile.getBandCount()>2) { |
127 | setBand(GeoRasterFile.RED_BAND, 0);
|
||
128 | setBand(GeoRasterFile.GREEN_BAND, 1);
|
||
129 | setBand(GeoRasterFile.BLUE_BAND, 2);
|
||
130 | } else {
|
||
131 | setBand(GeoRasterFile.RED_BAND|GeoRasterFile.GREEN_BAND|GeoRasterFile.BLUE_BAND, 0);
|
||
132 | } |
||
133 | 2 | luisw | } |
134 | 210 | luisw | |
135 | public int getBandCount() { return geoFile.getBandCount(); } |
||
136 | |||
137 | 1527 | luisw | public GeoRasterFile [] getFiles() { |
138 | if (colorBand != null) |
||
139 | return colorBand;
|
||
140 | |||
141 | GeoRasterFile [] ret = {geoFile};
|
||
142 | return ret;
|
||
143 | } |
||
144 | |||
145 | 210 | luisw | /**
|
146 | * Asocia un colorBand al rojo, verde o azul.
|
||
147 | * @param flag cual (o cuales) de las bandas.
|
||
148 | * @param nBand que colorBand
|
||
149 | */
|
||
150 | |||
151 | public void setBand(int flag, int nBand) { |
||
152 | 1527 | luisw | if (colorBand != null) { |
153 | if ((flag & GeoRasterFile.RED_BAND) == GeoRasterFile.RED_BAND)
|
||
154 | rBand = nBand; |
||
155 | else if ((flag & GeoRasterFile.GREEN_BAND) == GeoRasterFile.GREEN_BAND) |
||
156 | gBand = nBand; |
||
157 | else if ((flag & GeoRasterFile.BLUE_BAND) == GeoRasterFile.BLUE_BAND) |
||
158 | bBand = nBand; |
||
159 | } else
|
||
160 | geoFile.setBand(flag, nBand); |
||
161 | 210 | luisw | } |
162 | 2 | luisw | |
163 | 210 | luisw | /**
|
164 | * Devuelve el colorBand activo en la banda especificada.
|
||
165 | * @param flag banda.
|
||
166 | */
|
||
167 | |||
168 | public int getBand(int flag) { |
||
169 | 1527 | luisw | if (colorBand != null) { |
170 | if (flag == GeoRasterFile.RED_BAND)
|
||
171 | return rBand;
|
||
172 | else if (flag == GeoRasterFile.GREEN_BAND) |
||
173 | return gBand;
|
||
174 | else if (flag == GeoRasterFile.BLUE_BAND) |
||
175 | return bBand;
|
||
176 | else
|
||
177 | return -1; |
||
178 | } else
|
||
179 | return geoFile.getBand(flag);
|
||
180 | 210 | luisw | } |
181 | |||
182 | 553 | luisw | public void setDrawBorder(boolean pm) { pintaMarco = pm; } |
183 | |||
184 | 130 | luisw | public String getFName() { |
185 | return geoFile.getName();
|
||
186 | } |
||
187 | |||
188 | /**
|
||
189 | * Devuelve la anchura total del fichero, en pixeles.
|
||
190 | * @return ancho en pixeles
|
||
191 | */
|
||
192 | public int getFWidth() { |
||
193 | return geoFile.getWidth();
|
||
194 | } |
||
195 | |||
196 | /**
|
||
197 | * Devuelve la altura total del fichero, en pixeles.
|
||
198 | * @return alto en pixeles
|
||
199 | */
|
||
200 | public int getFHeight() { |
||
201 | return geoFile.getHeight();
|
||
202 | } |
||
203 | |||
204 | 2 | luisw | public void setTransparency(boolean t) {geoFile.setTransparency(t);} |
205 | 181 | luisw | public void setTransparency(int t) {geoFile.setTransparency(t);} |
206 | 2 | luisw | |
207 | 1455 | luisw | public int getAlpha() { return geoFile.getAlpha(); } |
208 | |||
209 | 30 | luisw | public void setExtent(Extent e) { |
210 | super.extent = e;
|
||
211 | pts = new Vector(); |
||
212 | pts.add(proj.createPoint(e.minX(), e.minY())); |
||
213 | pts.add(proj.createPoint(e.maxX(), e.minY())); |
||
214 | pts.add(proj.createPoint(e.maxX(), e.maxY())); |
||
215 | pts.add(proj.createPoint(e.minX(), e.maxY())); |
||
216 | } |
||
217 | |||
218 | 2 | luisw | /**
|
219 | * Cambia la vista (viewport) sobre el raster.
|
||
220 | *
|
||
221 | * @param v
|
||
222 | * @param vName
|
||
223 | */
|
||
224 | public void setView(Extent v, String vName) { |
||
225 | geoFile.setView(v); |
||
226 | this.vName = vName;
|
||
227 | } |
||
228 | |||
229 | /**
|
||
230 | * Obtiene la escala.
|
||
231 | *
|
||
232 | * @param width
|
||
233 | * @param height
|
||
234 | * @return
|
||
235 | */
|
||
236 | |||
237 | public double[] getScale(int width, int height) { |
||
238 | double scale[] = new double[2]; |
||
239 | 820 | luisw | scale[0] = ((double) width) /geoFile.getView().width(); |
240 | scale[1] = ((double) height)/geoFile.getView().height(); |
||
241 | 2 | luisw | return scale;
|
242 | } |
||
243 | |||
244 | /**
|
||
245 | * 'Normaliza' la vista en funci?n del extent del raster.
|
||
246 | *
|
||
247 | * @param mat
|
||
248 | * @param sz
|
||
249 | */
|
||
250 | |||
251 | 553 | luisw | protected void calculateNewView(Extent sz) { |
252 | 2 | luisw | double vx = sz.minX(), vy = sz.minY(), vx2 = sz.maxX(), vy2 = sz.maxY();
|
253 | if (sz.minX() < extent.minX()) vx = extent.minX();
|
||
254 | if (sz.minY() < extent.minY()) vy = extent.minY();
|
||
255 | if (sz.maxX() > extent.maxX()) vx2 = extent.maxX();
|
||
256 | if (sz.maxY() > extent.maxY()) vy2 = extent.maxY();
|
||
257 | 1345 | luisw | if (colorBand != null) { // multiBands |
258 | for (int i=0; i<colorBand.length; i++) |
||
259 | colorBand[i].setView(new Extent(vx, vy, vx2, vy2));
|
||
260 | } else if (geoFile != null) { // Una sola banda |
||
261 | geoFile.setView(new Extent(vx, vy, vx2, vy2));
|
||
262 | } else { // no cargada |
||
263 | System.err.println("PxRaster.calculateNewView(): Foto no cargada."); |
||
264 | } |
||
265 | 2 | luisw | } |
266 | |||
267 | /**
|
||
268 | * Dibuja el raster
|
||
269 | */
|
||
270 | |||
271 | 91 | luisw | public void draw(Graphics2D g, ViewPortData vp) { |
272 | 210 | luisw | Image geoImage = null; |
273 | long t2, t1 = new Date().getTime(); |
||
274 | 13 | luisw | System.out.println("PxRaster.draw(): vp.extent = "+ vp.getExtent()); |
275 | System.out.println("PxRaster.draw(): extent = "+ getExtent()); |
||
276 | 2 | luisw | if (vp.getExtent().minX()> extent.maxX()) return; |
277 | if (vp.getExtent().minY()> extent.maxY()) return; |
||
278 | if (vp.getExtent().maxX()< extent.minX()) return; |
||
279 | if (vp.getExtent().maxY()< extent.minY()) return; |
||
280 | 9 | luisw | calculateNewView(vp.getExtent()); |
281 | 2 | luisw | Extent v = geoFile.getView(); |
282 | double x = v.minX();
|
||
283 | double y = v.minY();
|
||
284 | double w = v.width();
|
||
285 | double h = v.height();
|
||
286 | System.out.println("Pinto PxRaster:" + v); |
||
287 | |||
288 | double scalex = vp.mat.getScaleX() /* g.getTransform().getScaleX()*/ , |
||
289 | scaley = vp.mat.getScaleY() /* g.getTransform().getScaleY() */;
|
||
290 | 820 | luisw | int wImg = (int) Math.abs(w*scalex)+1, hImg = (int) Math.abs(h*scaley)+1; |
291 | 25 | luisw | System.out.println("Sz=("+wImg+","+hImg+"); scale=("+scalex+","+scaley+")"); |
292 | 2 | luisw | if (wImg <= 0 || hImg <= 0) return; |
293 | |||
294 | Point2D.Double pt = new Point2D.Double(x, y+h); |
||
295 | try {
|
||
296 | System.out.println("Dibujando PxRaster: pt0 = "+pt); |
||
297 | vp.mat.transform(pt, pt); |
||
298 | System.out.println("Dibujando PxRaster: pt1 = "+pt); |
||
299 | 1679 | luisw | if (colorBand == null && geoFile instanceof GdalFile && |
300 | 1527 | luisw | (geoFile.getDataType() != DataBuffer.TYPE_BYTE)) {
|
301 | System.out.println("PxRaster: Has dado con un Raster de 16 bits"); |
||
302 | System.out.println("Dibujando PxRaster sz=("+wImg+","+hImg+"..."); |
||
303 | 1533 | luisw | RasterBuf raster = ((GdalFile) geoFile).getRaster(wImg, hImg, rp); |
304 | t2 = new Date().getTime(); |
||
305 | System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs. Obteniendo"); t1 = t2; |
||
306 | 1527 | luisw | geoImage = renderizeRaster(raster); |
307 | t2 = new Date().getTime(); |
||
308 | 1533 | luisw | System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs. Filtrando/Renderizando");t1 = t2; |
309 | 1808 | igbrotru | |
310 | filterStack.setDataTypeInFilter(RasterBuf.TYPE_SHORT); |
||
311 | filterStack.setInitRasterBuf(raster); |
||
312 | |||
313 | 1527 | luisw | g.drawImage(geoImage, (int) Math.round(pt.getX()), (int) Math.round(pt.getY()), component); |
314 | 1533 | luisw | t2 = new Date().getTime(); |
315 | System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs. Dibujando"); |
||
316 | 1679 | luisw | } else if (colorBand != null) { // multiBands |
317 | 1527 | luisw | System.out.println("Dibujando PxRaster (Multifile) ..."); |
318 | 1345 | luisw | //if (doTransparency)
|
319 | //geoImage = new BufferedImage(wImg, hImg, BufferedImage.TYPE_INT_ARGB);
|
||
320 | //else
|
||
321 | // geoImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||
322 | geoImage = colorBand[rBand].updateImage(wImg, hImg, rp); //, geoImage, GeoRasterFile.RED_BAND);
|
||
323 | geoImage = colorBand[gBand].updateImage(wImg, hImg, rp, geoImage, GeoRasterFile.GREEN_BAND); |
||
324 | geoImage = colorBand[bBand].updateImage(wImg, hImg, rp, geoImage, GeoRasterFile.BLUE_BAND); |
||
325 | 1804 | igbrotru | |
326 | 1808 | igbrotru | filterStack.setDataTypeInFilter(RasterBuf.TYPE_IMAGE); //Image
|
327 | filterStack.setInitRasterBuf(geoImage); |
||
328 | |||
329 | 1679 | luisw | geoImage = renderizeRaster(geoImage); |
330 | 1557 | luisw | g.drawImage(geoImage, (int) Math.round(pt.getX()), (int) Math.round(pt.getY()), component); |
331 | 210 | luisw | t2 = new Date().getTime(); |
332 | System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs."); |
||
333 | 1345 | luisw | |
334 | } else if (geoFile != null) { // Una sola banda |
||
335 | geoImage = geoFile.updateImage(wImg, hImg, rp); |
||
336 | 1527 | luisw | System.out.println("Dibujando PxRaster sz=("+wImg+","+hImg+"..."); |
337 | 1808 | igbrotru | |
338 | filterStack.setDataTypeInFilter(RasterBuf.TYPE_IMAGE); //Image
|
||
339 | filterStack.setInitRasterBuf(geoImage); |
||
340 | |||
341 | 1679 | luisw | geoImage = renderizeRaster(geoImage); |
342 | 1808 | igbrotru | g.drawImage(geoImage, (int) Math.round(pt.getX()), (int) Math.round(pt.getY()), component); |
343 | 210 | luisw | t2 = new Date().getTime(); |
344 | System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs."); |
||
345 | } else { // no cargada |
||
346 | 2 | luisw | System.err.println("Dibujando PxRaster: Foto no cargada."); |
347 | } |
||
348 | } catch (Exception e) { |
||
349 | e.printStackTrace(); |
||
350 | }; |
||
351 | 1804 | igbrotru | |
352 | 2 | luisw | if (pintaMarco) {
|
353 | 13 | luisw | drawMarco(g, vp); |
354 | 2 | luisw | } |
355 | } |
||
356 | 1527 | luisw | |
357 | 1801 | igbrotru | /**
|
358 | *
|
||
359 | * @param raster
|
||
360 | * @return
|
||
361 | */
|
||
362 | 1533 | luisw | public Image renderizeRaster(RasterBuf raster) { |
363 | 1808 | igbrotru | if (filterStack != null){ |
364 | 1809 | igbrotru | filterStack.execute(raster); |
365 | 1800 | igbrotru | } |
366 | 1808 | igbrotru | |
367 | //Aplicamos el filtro para convertir a Image
|
||
368 | RasterToImageFilter rti = new RasterToImageFilter();
|
||
369 | rti.addParam("raster", raster);
|
||
370 | rti.addParam("alpha", new Integer(this.getAlpha())); |
||
371 | rti.execute(); |
||
372 | 1545 | luisw | raster = null;
|
373 | 1808 | igbrotru | return (Image)rti.getResult("raster"); |
374 | 1527 | luisw | } |
375 | 1533 | luisw | |
376 | 1801 | igbrotru | /**
|
377 | *
|
||
378 | * @param image
|
||
379 | * @return
|
||
380 | */
|
||
381 | 1800 | igbrotru | public Image renderizeRaster(Image image) { |
382 | 1808 | igbrotru | if (filterStack != null){ |
383 | 1809 | igbrotru | filterStack.execute(image); |
384 | 1557 | luisw | } |
385 | return image;
|
||
386 | } |
||
387 | 1801 | igbrotru | |
388 | /**
|
||
389 | *
|
||
390 | * @param g
|
||
391 | * @param vp
|
||
392 | */
|
||
393 | 91 | luisw | public void drawMarco(Graphics2D g, ViewPortData vp) { |
394 | 26 | luisw | // Color color = new Color(255,222,165,128), fillColor = new Color(255,214,132,128);
|
395 | 56 | luisw | Color color = new Color(128,128,128), fillColor = new Color(255,220,220,0x20); |
396 | 30 | luisw | GeneralPath gp = newGP(vp);
|
397 | g.setColor(fillColor); |
||
398 | g.fill(gp); |
||
399 | g.setColor(color); |
||
400 | g.draw(gp); |
||
401 | 13 | luisw | } |
402 | 30 | luisw | |
403 | 91 | luisw | private GeneralPath newGP(ViewPortData vp) { |
404 | 30 | luisw | //if (gp != null) return;
|
405 | GeneralPath gp = new GeneralPath(); |
||
406 | Point2D.Double pt0 = new Point2D.Double(0.0, 0.0); |
||
407 | Point2D.Double pt1 = new Point2D.Double(0.0, 0.0); |
||
408 | Point2D.Double pt2 = new Point2D.Double(0.0, 0.0); |
||
409 | Point2D.Double pt3 = new Point2D.Double(0.0, 0.0); |
||
410 | vp.mat.transform((Point2D) pts.get(0), pt0); |
||
411 | vp.mat.transform((Point2D) pts.get(1), pt1); |
||
412 | vp.mat.transform((Point2D) pts.get(2), pt2); |
||
413 | vp.mat.transform((Point2D) pts.get(3), pt3); |
||
414 | 110 | luisw | // Aspa desde el extent
|
415 | 30 | luisw | gp.moveTo( (float) pt0.getX(), (float) pt0.getY() ); |
416 | gp.lineTo( (float) pt2.getX(), (float) pt2.getY() ); |
||
417 | gp.moveTo( (float) pt1.getX(), (float) pt1.getY() ); |
||
418 | gp.lineTo( (float) pt3.getX(), (float) pt3.getY() ); |
||
419 | 110 | luisw | // Extent
|
420 | 30 | luisw | gp.moveTo( (float) pt0.getX(), (float) pt0.getY() ); |
421 | gp.lineTo( (float) pt1.getX(), (float) pt1.getY() ); |
||
422 | gp.lineTo( (float) pt2.getX(), (float) pt2.getY() ); |
||
423 | gp.lineTo( (float) pt3.getX(), (float) pt3.getY() ); |
||
424 | 34 | luisw | if (extentOrig != extent) {
|
425 | gp.lineTo( (float) pt0.getX(), (float) pt0.getY() ); |
||
426 | Vector pts = new Vector(); |
||
427 | pts.add(proj.createPoint(extentOrig.minX(), extentOrig.minY())); |
||
428 | pts.add(proj.createPoint(extentOrig.maxX(), extentOrig.minY())); |
||
429 | pts.add(proj.createPoint(extentOrig.maxX(), extentOrig.maxY())); |
||
430 | pts.add(proj.createPoint(extentOrig.minX(), extentOrig.maxY())); |
||
431 | |||
432 | vp.mat.transform((Point2D) pts.get(0), pt0); |
||
433 | vp.mat.transform((Point2D) pts.get(1), pt1); |
||
434 | vp.mat.transform((Point2D) pts.get(2), pt2); |
||
435 | vp.mat.transform((Point2D) pts.get(3), pt3); |
||
436 | gp.moveTo( (float) pt0.getX(), (float) pt0.getY() ); |
||
437 | gp.lineTo( (float) pt1.getX(), (float) pt1.getY() ); |
||
438 | gp.lineTo( (float) pt2.getX(), (float) pt2.getY() ); |
||
439 | gp.lineTo( (float) pt3.getX(), (float) pt3.getY() ); |
||
440 | } |
||
441 | 30 | luisw | gp.closePath(); |
442 | return gp;
|
||
443 | } |
||
444 | 13 | luisw | |
445 | 94 | luisw | public IProjection getProjection() { return proj; } |
446 | public void setProjection(IProjection p) { proj = p; } |
||
447 | 30 | luisw | |
448 | 94 | luisw | public void reProject(ICoordTrans rp) { |
449 | 40 | luisw | this.rp = rp.getInverted();
|
450 | System.out.println("PxRaster: reProject()"); |
||
451 | 34 | luisw | //geoFile.reProject(rp);
|
452 | 30 | luisw | Vector savePts = pts;
|
453 | |||
454 | pts = new Vector(); |
||
455 | 34 | luisw | extent = new Extent();
|
456 | 30 | luisw | Point2D ptDest = null; |
457 | for (int i=0; i<savePts.size(); i++) { |
||
458 | ptDest = rp.getPDest().createPoint(0.0,0.0); |
||
459 | 96 | luisw | ptDest = rp.convert((Point2D) savePts.get(i), ptDest);
|
460 | 30 | luisw | pts.add(ptDest); |
461 | 34 | luisw | extent.add(ptDest); |
462 | 30 | luisw | } |
463 | setProjection(rp.getPDest()); |
||
464 | } |
||
465 | 2 | luisw | } |