Revision 4181 org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/DefaultFLyrRaster.java
DefaultFLyrRaster.java | ||
---|---|---|
2 | 2 |
* |
3 | 3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
4 | 4 |
* of the Valencian Government (CIT) |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* This program is free software; you can redistribute it and/or |
7 | 7 |
* modify it under the terms of the GNU General Public License |
8 | 8 |
* as published by the Free Software Foundation; either version 2 |
9 | 9 |
* of the License, or (at your option) any later version. |
10 |
*
|
|
10 |
* |
|
11 | 11 |
* This program is distributed in the hope that it will be useful, |
12 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | 14 |
* GNU General Public License for more details. |
15 |
*
|
|
15 |
* |
|
16 | 16 |
* You should have received a copy of the GNU General Public License |
17 | 17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 | 19 |
* MA 02110-1301, USA. |
20 |
*
|
|
20 |
* |
|
21 | 21 |
*/ |
22 | 22 |
package org.gvsig.raster.fmap.layers; |
23 | 23 |
|
... | ... | |
32 | 32 |
import java.awt.image.BufferedImage; |
33 | 33 |
import java.io.File; |
34 | 34 |
import java.io.IOException; |
35 |
import java.net.URI; |
|
35 | 36 |
import java.util.ArrayList; |
36 | 37 |
import java.util.HashMap; |
37 | 38 |
import java.util.List; |
38 | 39 |
import java.util.Set; |
39 | 40 |
|
40 | 41 |
import org.cresques.cts.IProjection; |
42 |
|
|
41 | 43 |
import org.gvsig.compat.print.PrintAttributes; |
42 | 44 |
import org.gvsig.fmap.crs.CRSFactory; |
43 | 45 |
import org.gvsig.fmap.dal.DataStore; |
... | ... | |
131 | 133 |
import org.gvsig.tools.task.SimpleTaskStatus; |
132 | 134 |
import org.gvsig.tools.task.TaskStatusManager; |
133 | 135 |
import org.gvsig.tools.task.impl.BaseTaskStatus; |
136 |
|
|
134 | 137 |
import org.slf4j.Logger; |
135 | 138 |
import org.slf4j.LoggerFactory; |
136 | 139 |
|
137 | 140 |
/** |
138 | 141 |
* Raster layer |
139 |
*
|
|
142 |
* |
|
140 | 143 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
141 | 144 |
*/ |
142 | 145 |
@SuppressWarnings("deprecation") |
143 | 146 |
public class DefaultFLyrRaster extends FLyrDefault implements FLyrRaster, Multiresolution, InfoByPoint, Classifiable, |
144 | 147 |
IRasterLayerActions, ILayerState, VisualPropertyListener, SingleLayer { |
148 |
|
|
145 | 149 |
public static final String PERSISTENT_NAME = "FLyrRasterSE_Persistent"; |
146 | 150 |
public static final String PERSISTENT_DESCRIPTION = "FLyrRasterSE Persistent"; |
147 | 151 |
private RasterManager rManager = RasterLocator.getManager(); |
... | ... | |
171 | 175 |
static private IConfiguration configuration = new DefaultLayerConfiguration(); |
172 | 176 |
protected int zoomLevel = 1; |
173 | 177 |
public boolean recalcLevel = true; |
174 |
private String uri = null;
|
|
175 |
|
|
178 |
private URI uri = null;
|
|
179 |
|
|
176 | 180 |
private static GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
177 | 181 |
private static final Logger logger = LoggerFactory.getLogger(DefaultFLyrRaster.class); |
178 | 182 |
protected FileUtils fileUtil = RasterLocator.getManager().getFileUtils(); |
179 | 183 |
protected RasterUtils rasterUtil = RasterLocator.getManager().getRasterUtils(); |
180 | 184 |
protected CRSUtils crsUtil = RasterLocator.getManager().getCRSUtils(); |
181 | 185 |
protected MathUtils mathUtil = RasterLocator.getManager().getMathUtils(); |
182 |
|
|
186 |
|
|
183 | 187 |
public class RasterTaskStatus extends BaseTaskStatus { |
184 | 188 |
Cancellable c = null; |
185 |
|
|
189 |
|
|
186 | 190 |
public RasterTaskStatus(String tittle, Cancellable c) { |
187 | 191 |
super(tittle); |
188 | 192 |
this.c = c; |
189 | 193 |
} |
190 |
|
|
194 |
|
|
191 | 195 |
public boolean isCancellationRequested() { |
192 | 196 |
if(c != null) |
193 | 197 |
return this.c.isCanceled(); |
194 | 198 |
return false; |
195 | 199 |
} |
196 |
|
|
200 |
|
|
197 | 201 |
public void cancelRequest() { |
198 | 202 |
if(c != null) |
199 | 203 |
this.c.setCanceled(true); |
... | ... | |
209 | 213 |
protected String readingData = null; |
210 | 214 |
//It is set to true if the method init has been called at least once |
211 | 215 |
private boolean layerInitialize = false; |
212 |
|
|
216 |
|
|
213 | 217 |
public DefaultFLyrRaster() { |
214 | 218 |
affineTransformList = rManager.createHistoricalService(); |
215 | 219 |
} |
216 |
|
|
220 |
|
|
217 | 221 |
public static void registerDynClass() { |
218 | 222 |
DynObjectManager manager = ToolsLocator.getDynObjectManager(); |
219 | 223 |
DynClass dynClass = manager.add("RasterInfo", "Raster layer Info by point"); |
... | ... | |
227 | 231 |
dynClass.addDynFieldString("Band Value"); |
228 | 232 |
dynClass.addDynFieldString("World Point"); |
229 | 233 |
} |
230 |
|
|
234 |
|
|
231 | 235 |
/** |
232 | 236 |
* Builds a new raster layer |
233 | 237 |
* @param fileName |
234 | 238 |
* @return |
235 |
* @throws RasterNotLoadException
|
|
236 |
* @throws LoadLayerException
|
|
239 |
* @throws RasterNotLoadException |
|
240 |
* @throws LoadLayerException |
|
237 | 241 |
*/ |
238 | 242 |
public static DefaultFLyrRaster createLayer(String layerName, File file) throws LoadLayerException { |
239 | 243 |
ProviderServices provServ = RasterLocator.getManager().getProviderServices(); |
240 | 244 |
RasterDataParameters storeParameters = provServ.createParameters(file.getName()); |
241 |
storeParameters.setURI(file.getPath());
|
|
242 |
|
|
245 |
storeParameters.setURI(file.toURI());
|
|
246 |
|
|
243 | 247 |
MapContextManager mcm = MapContextLocator.getMapContextManager(); |
244 | 248 |
DefaultFLyrRaster lyr = (DefaultFLyrRaster) mcm.createLayer(layerName, storeParameters); |
245 | 249 |
|
... | ... | |
273 | 277 |
|
274 | 278 |
enableStopped(); // Paramos la capa mientras se hace un load |
275 | 279 |
|
276 |
int test = -1;
|
|
280 |
boolean test = false;
|
|
277 | 281 |
DataStoreParameters params = getDataStore().getParameters(); |
278 | 282 |
DataStoreParameters p = params; |
279 | 283 |
if (params != null) { |
... | ... | |
286 | 290 |
if(params instanceof RasterDataParameters) |
287 | 291 |
uri = ((RasterDataParameters)p).getURI(); |
288 | 292 |
} |
289 |
test = uri.indexOf("ecwp:"); |
|
290 | 293 |
} |
291 | 294 |
|
292 |
if (test != -1) { |
|
293 |
String urlECW = uri.substring(test + 6); |
|
294 |
uri = "ecwp://" + urlECW; |
|
295 |
System.err.println(test + " " + uri); |
|
296 |
} |
|
297 |
|
|
298 | 295 |
try { |
299 | 296 |
if(!getDataStore().isOpen()) |
300 | 297 |
dataStore = rManager.getProviderServices().open(params); |
... | ... | |
306 | 303 |
throw new LoadLayerException(this.getName()); |
307 | 304 |
} |
308 | 305 |
} |
309 |
|
|
306 |
|
|
310 | 307 |
public void setLayerInitialized(boolean initialized) { |
311 | 308 |
layerInitialize = initialized; |
312 | 309 |
} |
313 | 310 |
|
314 | 311 |
/** |
315 | 312 |
* Acciones de inicializaci?n despu?s de que la fuente de datos |
316 |
* de la capa est? asignada.
|
|
317 |
* @throws FilePaletteException
|
|
313 |
* de la capa est? asignada. |
|
314 |
* @throws FilePaletteException |
|
318 | 315 |
*/ |
319 | 316 |
public void init() throws LoadLayerException, FilePaletteException { |
320 | 317 |
layerInitialize = true; |
321 |
|
|
318 |
|
|
322 | 319 |
if (getDataStore() == null) |
323 | 320 |
throw new LoadLayerException("Formato no valido", new IOException()); |
324 | 321 |
|
... | ... | |
365 | 362 |
} |
366 | 363 |
return render; |
367 | 364 |
} |
368 |
|
|
369 |
public String getURI() {
|
|
365 |
|
|
366 |
public URI getURI() {
|
|
370 | 367 |
return uri; |
371 | 368 |
} |
372 | 369 |
|
... | ... | |
380 | 377 |
|
381 | 378 |
/** |
382 | 379 |
* Initializes the filter list to render this raster layer |
383 |
* @throws FilePaletteException
|
|
380 |
* @throws FilePaletteException |
|
384 | 381 |
*/ |
385 | 382 |
protected void initFilters() throws FilePaletteException { |
386 | 383 |
if(getDataType() == null) |
387 | 384 |
return; |
388 |
|
|
385 |
|
|
389 | 386 |
RasterFilterList filterList = rManager.createEmptyFilterList(getDataType()[0]); |
390 | 387 |
if(loadedFromProject) { |
391 | 388 |
filterList = getDataStore().getRender().getFilterList(); |
... | ... | |
393 | 390 |
|
394 | 391 |
if(getDataStore() == null) |
395 | 392 |
return; |
396 |
|
|
393 |
|
|
397 | 394 |
if(getDataStore().getNoDataValue() != null) { |
398 | 395 |
getDataStore().getNoDataValue().load(); |
399 | 396 |
} |
... | ... | |
421 | 418 |
params.setParam("colorTable", table); |
422 | 419 |
colorTableManager.addFilter(params); |
423 | 420 |
} else //sino hace lo que dice en las preferencias |
424 |
if(getDataStore().needEnhanced() ||
|
|
425 |
(loadedFromProject && filterList.get("enhanced_stretch") != null))
|
|
421 |
if(getDataStore().needEnhanced() || |
|
422 |
(loadedFromProject && filterList.get("enhanced_stretch") != null)) |
|
426 | 423 |
loadEnhancedOrColorTable(filterList); |
427 | 424 |
colorTableLoadedFromProject = null; |
428 | 425 |
|
... | ... | |
446 | 443 |
* de color por defecto |
447 | 444 |
* @param filterManager |
448 | 445 |
* @throws FilterTypeException |
449 |
* @throws FilePaletteException
|
|
446 |
* @throws FilePaletteException |
|
450 | 447 |
*/ |
451 | 448 |
private void loadEnhancedOrColorTable(RasterFilterList filterList) throws FilterTypeException, FilterManagerException, FilePaletteException { |
452 | 449 |
String colorTableName = null; |
... | ... | |
527 | 524 |
public void draw(BufferedImage image, Graphics2D g, ViewPort vp, Cancellable cancel, double scale) throws ReadException { |
528 | 525 |
TaskEventManager task = rManager.getRasterTask(); |
529 | 526 |
task.setEvent(null); |
530 |
|
|
527 |
|
|
531 | 528 |
if(!layerInitialize) { |
532 | 529 |
if (getDataStore() != null) |
533 | 530 |
try { |
... | ... | |
545 | 542 |
|
546 | 543 |
enableStopped(); |
547 | 544 |
// callLegendChanged(null); |
548 |
|
|
545 |
|
|
549 | 546 |
//Solo el zoom normal recalcula el nivel dependiendo de la escala. El zoom por niveles asigna |
550 | 547 |
//?l el nivel de zoom por lo que no habr? que recalcularlo. |
551 | 548 |
if(recalcLevel) { |
... | ... | |
565 | 562 |
} |
566 | 563 |
|
567 | 564 |
if (isWithinScale(scale)) { |
568 |
|
|
565 |
|
|
569 | 566 |
if (mustTileDraw) { |
570 | 567 |
Point2D p = vp.getOffset(); |
571 | 568 |
Rectangle r = new Rectangle((int) p.getX(), (int) p.getY(), vp.getImageWidth(), vp.getImageHeight()); |
... | ... | |
590 | 587 |
System.out.println("Se ha cancelado el pintado"); |
591 | 588 |
} catch (QueryException e) { |
592 | 589 |
throw new ReadException("Error reading file.", e); |
593 |
}
|
|
590 |
} |
|
594 | 591 |
|
595 | 592 |
} |
596 |
|
|
593 |
|
|
597 | 594 |
//callLegendChanged(null); |
598 | 595 |
} finally { |
599 | 596 |
disableStopped(); |
... | ... | |
614 | 611 |
ViewPortData vp2 = rManager.getDataStructFactory().createViewPortData(vp.getProjection(), e, imgSz ); |
615 | 612 |
vp2.setMat(vp.getAffineTransform()); |
616 | 613 |
vp2.setDPI((int)vp.getDPI()); |
617 |
//vp2.setTime(vp.getTime());
|
|
618 |
|
|
614 |
//vp2.setTime(vp.getTime()); |
|
615 |
|
|
619 | 616 |
TaskStatusManager manager = ToolsLocator.getTaskStatusManager(); |
620 | 617 |
SimpleTaskStatus taskStatus = new RasterTaskStatus("Drawing " + getName() + "...", cancel); |
621 | 618 |
manager.add(taskStatus); |
622 | 619 |
taskStatus.setAutoremove(true); |
623 |
|
|
620 |
|
|
624 | 621 |
//Crea la reproyecci?n al vuelo la primera vez |
625 | 622 |
RasterDataParameters params = (RasterDataParameters)getDataStore().getParameters(); |
626 |
if(!getRender().isReprojectingOnTheFly() &&
|
|
623 |
if(!getRender().isReprojectingOnTheFly() && |
|
627 | 624 |
getDataStore().getProjection() != null && |
628 | 625 |
params.getReprojectionOption() == RasterDataParameters.ON_THE_FLY) { |
629 | 626 |
getRender().createReprojectionOnTheFly(getDataStore(), getCoordTrans(), taskStatus); |
630 | 627 |
} |
631 |
|
|
628 |
|
|
632 | 629 |
try { |
633 | 630 |
if(getDataStore().isTiled()) { |
634 | 631 |
getRender().drawTiledService(g, vp2, vp.getImageSize(), taskStatus); |
... | ... | |
654 | 651 |
logger.error("Error saving the projection", e); |
655 | 652 |
} |
656 | 653 |
} |
657 |
|
|
654 |
|
|
658 | 655 |
public void setProjection(IProjection proj, boolean persist) { |
659 | 656 |
try { |
660 | 657 |
getDataStore().setProjection(proj, persist); |
... | ... | |
676 | 673 |
.getMaxY(), SUBTYPES.GEOM2D); |
677 | 674 |
|
678 | 675 |
/* |
679 |
No es necesario
|
|
676 |
No es necesario |
|
680 | 677 |
ICoordTrans ct = getCoordTrans(); |
681 | 678 |
RasterDataParameters params = (RasterDataParameters)getDataStore().getParameters(); |
682 | 679 |
if (ct != null && params.getReprojectionOption() == RasterDataParameters.ON_THE_FLY) { |
... | ... | |
689 | 686 |
return null; |
690 | 687 |
} |
691 | 688 |
} |
692 |
|
|
689 |
|
|
693 | 690 |
/** |
694 | 691 |
* Obtiene el valor del pixel del Image en la posici?n x,y |
695 | 692 |
* @param x Posici?n x |
... | ... | |
800 | 797 |
|
801 | 798 |
if (/*!isOpen() ||*/ !isVisible() || !isWithinScale(scale)) |
802 | 799 |
return; |
803 |
|
|
800 |
|
|
804 | 801 |
TaskStatusManager manager = ToolsLocator.getTaskStatusManager(); |
805 | 802 |
SimpleTaskStatus taskStatus = new RasterTaskStatus("Printing raster " + getName() + "...", cancel); |
806 | 803 |
manager.add(taskStatus); |
... | ... | |
825 | 822 |
} |
826 | 823 |
} |
827 | 824 |
} |
828 |
|
|
825 |
|
|
829 | 826 |
taskStatus.terminate(); |
830 | 827 |
} |
831 | 828 |
|
... | ... | |
941 | 938 |
|
942 | 939 |
if (this.isRemoveRasterFlag()) { |
943 | 940 |
if (getDataStore() != null) { |
944 |
String[] files = getFileName().clone();
|
|
941 |
URI[] uris = getUris().clone();
|
|
945 | 942 |
|
946 | 943 |
try { |
947 | 944 |
getDataStore().close(); |
... | ... | |
955 | 952 |
// System.gc(); |
956 | 953 |
this.setRemoveRasterFlag(true); |
957 | 954 |
|
958 |
for (int i = 0; i < files.length; i++) {
|
|
959 |
File file = new File(files[i]);
|
|
955 |
for (int i = 0; i < uris.length; i++) {
|
|
956 |
File file = new File(uris[i]);
|
|
960 | 957 |
File dirTemp = fileUtil.getTemporalFile(); |
961 | 958 |
if(!file.exists()) |
962 | 959 |
continue; |
... | ... | |
1043 | 1040 |
return getDataStore().getFileSizeByProvider(); |
1044 | 1041 |
} |
1045 | 1042 |
|
1046 |
/** |
|
1047 |
* Gets the list of file names
|
|
1048 |
*/
|
|
1049 |
public String[] getFileName() {
|
|
1050 |
if (getDataStore() == null)
|
|
1051 |
return null;
|
|
1043 |
/**
|
|
1044 |
* Gets the list of URIs
|
|
1045 |
*/
|
|
1046 |
public URI[] getUris() {
|
|
1047 |
if (getDataStore() == null)
|
|
1048 |
return null;
|
|
1052 | 1049 |
|
1053 |
return getDataStore().getURIByProvider();
|
|
1054 |
}
|
|
1050 |
return getDataStore().getURIByProvider();
|
|
1051 |
}
|
|
1055 | 1052 |
|
1056 | 1053 |
/** |
1057 | 1054 |
* Returns the number of files in this raster layer |
... | ... | |
1089 | 1086 |
public void setRenderFilterList(RasterFilterList filterList) { |
1090 | 1087 |
getRender().setFilterList(filterList); |
1091 | 1088 |
} |
1092 |
|
|
1089 |
|
|
1093 | 1090 |
public DynObjectSet getInfo(org.gvsig.fmap.geom.primitive.Point p, double tolerance) throws LoadLayerException, DataException { |
1094 | 1091 |
DynObjectSetRasterInfo info = new DynObjectSetRasterInfo(); |
1095 |
|
|
1092 |
|
|
1096 | 1093 |
if (!isOpen()) { |
1097 | 1094 |
info.addField("Layer not open", normalizeAsXMLTag(getName()), 0); |
1098 | 1095 |
return info; |
1099 | 1096 |
} |
1100 |
|
|
1097 |
|
|
1101 | 1098 |
Point2D pReal = new Point2D.Double(p.getX(), p.getY()); |
1102 | 1099 |
Point2D px = new Point2D.Double(); |
1103 | 1100 |
if( pReal.getX() > this.getMinX() && |
... | ... | |
1108 | 1105 |
} |
1109 | 1106 |
//int[] rgb = getPixel((int) p.getX(), (int) p.getY()); |
1110 | 1107 |
//ColorConversion conv = rManager.getColorConversion(); |
1111 |
|
|
1108 |
|
|
1112 | 1109 |
info.addField("File", normalizeAsXMLTag(getName()), 0); |
1113 | 1110 |
info.addField("View Point", "[" + p.getX() + " , " + p.getY() + "]", 1); |
1114 | 1111 |
info.addField("World Point", "[" + mathUtil.format(pReal.getX(), 3) + " , " + mathUtil.format(pReal.getY(), 3) + "]", 2); |
... | ... | |
1116 | 1113 |
info.addField("Pixel Point", "Out", 3); |
1117 | 1114 |
else |
1118 | 1115 |
info.addField("Pixel Point", "[" + (int) px.getX() + ", " + (int) px.getY() + "]", 3); |
1119 |
|
|
1116 |
|
|
1120 | 1117 |
//La informaci?n RGB no puede obtener de la capa |
1121 |
|
|
1118 |
|
|
1122 | 1119 |
/*info.addField("RGB", "[" + rgb[1] + ", " + rgb[2] + ", " + rgb[3] + "]", 4); |
1123 | 1120 |
double[] cmyk = conv.RGBtoCMYK(rgb[1] & 0xff, rgb[2] & 0xff, rgb[3] & 0xff, 1D); |
1124 | 1121 |
info.addField("CMYK", "[" + mathUtil.format(cmyk[0], 4) + ", " + mathUtil.format(cmyk[1], 4) + ", " + mathUtil.format(cmyk[2], 4) + ", " + mathUtil.format(cmyk[3], 4) + "]", 5); |
... | ... | |
1127 | 1124 |
hsl[2] = (int) (hsl[2] * 255. + 0.5); |
1128 | 1125 |
hsl[1] = (int) (hsl[1] * 255. + 0.5); |
1129 | 1126 |
info.addField("HSL", "[" + mathUtil.format(hsl[0], 4) + ", " + mathUtil.format(hsl[1], 4) + ", " + mathUtil.format(hsl[2], 4) + "]", 6);*/ |
1130 |
|
|
1127 |
|
|
1131 | 1128 |
String data = "["; |
1132 | 1129 |
try { |
1133 | 1130 |
if (px != null) { |
... | ... | |
1135 | 1132 |
for(int i = 0; i < getDataStore().getBandCount(); i++) { |
1136 | 1133 |
if(getDataStore().isInside(pReal)) { |
1137 | 1134 |
Point2D pxAux = transformPoint(pReal); |
1138 |
int val = ((Integer)getDataStore().getData((int)pxAux.getX(),
|
|
1135 |
int val = ((Integer)getDataStore().getData((int)pxAux.getX(), |
|
1139 | 1136 |
(int)pxAux.getY(), i)).intValue(); |
1140 | 1137 |
if(getDataType()[0] == Buffer.TYPE_BYTE) |
1141 | 1138 |
data += (val & 0x000000ff) + ", "; |
... | ... | |
1148 | 1145 |
for(int i = 0; i < getDataStore().getBandCount(); i++) { |
1149 | 1146 |
if(getDataStore().isInside(pReal)) { |
1150 | 1147 |
Point2D pxAux = transformPoint(pReal); |
1151 |
data += ((Float)getDataStore().getData((int)pxAux.getX(),
|
|
1148 |
data += ((Float)getDataStore().getData((int)pxAux.getX(), |
|
1152 | 1149 |
(int)pxAux.getY(), i)).floatValue() + ", "; |
1153 | 1150 |
} |
1154 | 1151 |
} |
... | ... | |
1157 | 1154 |
for(int i = 0; i < getDataStore().getBandCount(); i++) { |
1158 | 1155 |
if(getDataStore().isInside(pReal)) { |
1159 | 1156 |
Point2D pxAux = transformPoint(pReal); |
1160 |
data += ((Double)getDataStore().getData((int)pxAux.getX(),
|
|
1157 |
data += ((Double)getDataStore().getData((int)pxAux.getX(), |
|
1161 | 1158 |
(int)pxAux.getY(), i)).doubleValue() + ", "; |
1162 | 1159 |
} |
1163 | 1160 |
} |
... | ... | |
1174 | 1171 |
} |
1175 | 1172 |
return info; |
1176 | 1173 |
} |
1177 |
|
|
1174 |
|
|
1178 | 1175 |
/** |
1179 | 1176 |
* Transforma un punto real a coordenadas pixel |
1180 |
*
|
|
1177 |
* |
|
1181 | 1178 |
* @param numberBand |
1182 | 1179 |
* @param pReal |
1183 | 1180 |
* @return |
1184 |
* @throws LoadLayerException
|
|
1181 |
* @throws LoadLayerException |
|
1185 | 1182 |
* @throws ReadDriverException |
1186 | 1183 |
*/ |
1187 | 1184 |
private Point2D transformPoint(Point2D pReal) throws LoadLayerException { |
... | ... | |
1195 | 1192 |
throw new LoadLayerException("Error en la transformaci?n del punto", e); |
1196 | 1193 |
} |
1197 | 1194 |
} |
1198 |
|
|
1195 |
|
|
1199 | 1196 |
public Object getInfo(String key) { |
1200 | 1197 |
if (key.equals("DriverName")) |
1201 | 1198 |
return "gvSIG Raster Driver"; |
... | ... | |
1279 | 1276 |
public boolean isFileAccepted(File file) { |
1280 | 1277 |
return getDataStore().isFileSupported(file.getName()); |
1281 | 1278 |
} |
1282 |
|
|
1279 |
|
|
1283 | 1280 |
/** |
1284 | 1281 |
* Consulta si un fichero es aceptado o no para este tipo de capa. |
1285 | 1282 |
* @param file Fichero a consultar |
... | ... | |
1374 | 1371 |
return; |
1375 | 1372 |
|
1376 | 1373 |
getDataStore().saveGeoreferencingToRmf(); |
1377 |
|
|
1374 |
|
|
1378 | 1375 |
affineTransformList.clear(); |
1379 | 1376 |
affineTransformList.add(this.getAffineTransform()); |
1380 | 1377 |
} |
... | ... | |
1420 | 1417 |
state.disableStopped(); |
1421 | 1418 |
else |
1422 | 1419 |
enableStopped(); |
1423 |
|
|
1420 |
|
|
1424 | 1421 |
if(isAwake() || isClosed()) |
1425 | 1422 |
try { |
1426 | 1423 |
this.load(); |
1427 | 1424 |
} catch (LoadLayerException e) { |
1428 | 1425 |
e.printStackTrace(); |
1429 | 1426 |
} |
1430 |
|
|
1427 |
|
|
1431 | 1428 |
/* |
1432 | 1429 |
* Cuando se modifica la visibilidad de una capa raster se hace un updateDrawVersion de todas las |
1433 | 1430 |
* capas raster de ese MapContext. Esto es porque la estrategia utilizada por RasterDrawStrategy hace |
... | ... | |
1442 | 1439 |
if(listLayers.get(i) instanceof DefaultFLyrRaster) |
1443 | 1440 |
((DefaultFLyrRaster)listLayers.get(i)).updateDrawVersion(); |
1444 | 1441 |
} |
1445 |
|
|
1442 |
|
|
1446 | 1443 |
super.setVisible(visibility); |
1447 | 1444 |
} |
1448 | 1445 |
|
... | ... | |
1487 | 1484 |
public void setRois(List<ROI> rois) { |
1488 | 1485 |
getDataStore().setRois(rois); |
1489 | 1486 |
} |
1490 |
|
|
1487 |
|
|
1491 | 1488 |
public void setROIsFiles(List<File> file) throws RmfSerializerException { |
1492 | 1489 |
getDataStore().saveROIFileListToRmf(file); |
1493 | 1490 |
} |
1494 |
|
|
1491 |
|
|
1495 | 1492 |
public List<File> getROIsFiles() throws RmfSerializerException { |
1496 | 1493 |
return getDataStore().getROIFileListFromRmf(); |
1497 | 1494 |
} |
... | ... | |
1578 | 1575 |
newLayer.setName(getName()); |
1579 | 1576 |
newLayer.setOpenRasterStore(ds); |
1580 | 1577 |
newLayer.firstLoad = firstLoad; |
1581 |
|
|
1578 |
|
|
1582 | 1579 |
List<RasterFilter> filters = getRender().getFilterList().getStatusCloned(); |
1583 | 1580 |
|
1584 | 1581 |
//Hacemos una copia de las bandas a renderizar |
... | ... | |
1597 | 1594 |
if(getDataStore().getNoDataValue().isDefined()) |
1598 | 1595 |
newLayer.setNoDataTransparent(true); |
1599 | 1596 |
newLayer.enableOpen(); |
1600 |
|
|
1597 |
|
|
1601 | 1598 |
return newLayer; |
1602 | 1599 |
} |
1603 |
|
|
1600 |
|
|
1604 | 1601 |
public FLayer getFileLayer() throws RasterDriverException { |
1605 | 1602 |
try { |
1606 | 1603 |
return cloneLayer(); |
... | ... | |
1608 | 1605 |
} |
1609 | 1606 |
return null; |
1610 | 1607 |
} |
1611 |
|
|
1612 |
public void addFile(String file) throws InvalidSourceException {
|
|
1608 |
|
|
1609 |
public void addFile(File file) throws InvalidSourceException {
|
|
1613 | 1610 |
getDataStore().addFile(file); |
1614 | 1611 |
} |
1615 |
|
|
1616 |
public void removeFile(String file) {
|
|
1612 |
|
|
1613 |
public void removeFile(File file) {
|
|
1617 | 1614 |
getDataStore().removeFile(file); |
1618 | 1615 |
} |
1619 | 1616 |
|
... | ... | |
1682 | 1679 |
} |
1683 | 1680 |
return this.dataStore; |
1684 | 1681 |
} |
1685 |
|
|
1682 |
|
|
1686 | 1683 |
public IProjection getProjection() { |
1687 | 1684 |
if(getDataStore() == null) |
1688 | 1685 |
return null; |
1689 |
|
|
1686 |
|
|
1690 | 1687 |
RasterDataParameters p = (RasterDataParameters)getDataStore().getParameters(); |
1691 | 1688 |
if(p.getReprojectionOption() == RasterDataParameters.DONT_CHANGE_PROJECTION) |
1692 | 1689 |
return null; |
... | ... | |
1697 | 1694 |
if(dataStore instanceof CoverageStoreProviderServices) { |
1698 | 1695 |
try { |
1699 | 1696 |
this.dataStore = rManager.getProviderServices().open( |
1700 |
((CoverageStoreProviderServices) dataStore).getProvider(),
|
|
1697 |
((CoverageStoreProviderServices) dataStore).getProvider(), |
|
1701 | 1698 |
dataStore.getParameters()); |
1702 | 1699 |
} catch (NotSupportedExtensionException e) { |
1703 | 1700 |
throw new LoadLayerException("Extension not supported", e); |
... | ... | |
1720 | 1717 |
} |
1721 | 1718 |
} |
1722 | 1719 |
} |
1723 |
|
|
1720 |
|
|
1724 | 1721 |
public void setDataStore(DataStore dataStore) throws LoadLayerException { |
1725 | 1722 |
setOpenRasterStore(dataStore); |
1726 | 1723 |
load(); |
1727 | 1724 |
} |
1728 |
|
|
1725 |
|
|
1729 | 1726 |
public boolean isRemote() { |
1730 | 1727 |
return false; |
1731 | 1728 |
} |
1732 |
|
|
1729 |
|
|
1733 | 1730 |
/** |
1734 | 1731 |
* Returns true if exists a process reading data from this layer |
1735 | 1732 |
* @return |
... | ... | |
1746 | 1743 |
public synchronized void setReadingData(String readingData) { |
1747 | 1744 |
this.readingData = readingData; |
1748 | 1745 |
} |
1749 |
|
|
1746 |
|
|
1750 | 1747 |
public DynObjectSet getInfo(Point p, double tolerance, Cancellable cancel, |
1751 | 1748 |
boolean fast) |
1752 | 1749 |
throws LoadLayerException, DataException { |
... | ... | |
1774 | 1771 |
public void setZoomLevel(int zoomLevel) { |
1775 | 1772 |
this.zoomLevel = zoomLevel; |
1776 | 1773 |
} |
1777 |
|
|
1774 |
|
|
1778 | 1775 |
public boolean increaseZoomLevel() { |
1779 |
if(zoomLevel < (this.getDataStore().getZoomLevels() - 1)) {
|
|
1776 |
if(zoomLevel < (this.getDataStore().getZoomLevels() - 1)) { |
|
1780 | 1777 |
zoomLevel ++; |
1781 | 1778 |
recalcLevel = false; |
1782 | 1779 |
return true; |
1783 | 1780 |
} |
1784 | 1781 |
return false; |
1785 | 1782 |
} |
1786 |
|
|
1783 |
|
|
1787 | 1784 |
public boolean decreaseZoomLevel() { |
1788 |
if(zoomLevel > 0) {
|
|
1785 |
if(zoomLevel > 0) { |
|
1789 | 1786 |
zoomLevel --; |
1790 | 1787 |
recalcLevel = false; |
1791 | 1788 |
return true; |
1792 | 1789 |
} |
1793 | 1790 |
return false; |
1794 | 1791 |
} |
1795 |
|
|
1792 |
|
|
1796 | 1793 |
public Envelope getCoordsInLevel(Point2D center, int level, int w, int h) throws CreateEnvelopeException { |
1797 | 1794 |
Extent ex = getDataStore().getCoordsInLevel(center, level, w, h); |
1798 | 1795 |
return geomManager.createEnvelope(ex.getULX(), ex.getULY(), ex.getLRX(), ex.getLRY(), SUBTYPES.GEOM2D); |
1799 | 1796 |
} |
1800 |
|
|
1797 |
|
|
1801 | 1798 |
public boolean isEnabledMultiresolution() { |
1802 | 1799 |
return getDataStore().isTiled(); |
1803 | 1800 |
} |
1804 |
|
|
1801 |
|
|
1805 | 1802 |
public void setTileServer(Class<?> tileServer) throws InitializeException { |
1806 | 1803 |
getDataStore().setTileServer(tileServer); |
1807 | 1804 |
} |
1808 |
|
|
1805 |
|
|
1809 | 1806 |
@Override |
1810 | 1807 |
public void loadFromState(PersistentState state) |
1811 | 1808 |
throws PersistenceException { |
... | ... | |
1831 | 1828 |
@Override |
1832 | 1829 |
public void saveToState(PersistentState state) throws PersistenceException { |
1833 | 1830 |
super.saveToState(state); |
1834 |
|
|
1835 |
state.set("rasterdatastore", getDataStore());
|
|
1836 |
state.set("legend", lastLegend);
|
|
1837 |
state.set("colortable", getRender().getColorTable());
|
|
1838 |
state.set("zoomLevel", zoomLevel);
|
|
1839 |
state.set("recalcLevel", recalcLevel);
|
|
1840 |
}
|
|
1841 |
|
|
1831 |
|
|
1832 |
state.set("rasterdatastore", getDataStore()); |
|
1833 |
state.set("legend", lastLegend); |
|
1834 |
state.set("colortable", getRender().getColorTable()); |
|
1835 |
state.set("zoomLevel", zoomLevel); |
|
1836 |
state.set("recalcLevel", recalcLevel); |
|
1837 |
} |
|
1838 |
|
|
1842 | 1839 |
public static void registerPersistence() { |
1843 | 1840 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
1844 | 1841 |
DynStruct definition = manager.getDefinition(PERSISTENT_NAME); |
... | ... | |
1847 | 1844 |
DefaultFLyrRaster.class, |
1848 | 1845 |
PERSISTENT_NAME, |
1849 | 1846 |
PERSISTENT_DESCRIPTION, |
1850 |
null,
|
|
1847 |
null, |
|
1851 | 1848 |
null |
1852 | 1849 |
); |
1853 | 1850 |
definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, "FLyrDefault"); |
1854 |
|
|
1851 |
|
|
1855 | 1852 |
registerPersistence(definition); |
1856 | 1853 |
} |
1857 | 1854 |
} |
1858 |
|
|
1855 |
|
|
1859 | 1856 |
public static void registerPersistence(DynStruct definition) { |
1860 | 1857 |
definition.addDynFieldObject("rasterdatastore").setClassOfValue(RasterDataStore.class).setMandatory(false); |
1861 | 1858 |
definition.addDynFieldObject("legend").setClassOfValue(ILegend.class).setMandatory(false); |
... | ... | |
1871 | 1868 |
throw new ReadException(getDataStore().getName(), e); |
1872 | 1869 |
} catch (GeometryTypeNotValidException e) { |
1873 | 1870 |
throw new ReadException(getDataStore().getName(), e); |
1874 |
}
|
|
1871 |
} |
|
1875 | 1872 |
} |
1876 |
|
|
1873 |
|
|
1877 | 1874 |
public void setDataStore(DataStore dataStore, String domain) throws LoadLayerException { |
1878 | 1875 |
setDataStore(dataStore); |
1879 | 1876 |
} |
1880 |
|
|
1877 |
|
|
1881 | 1878 |
protected void finalize() { |
1882 | 1879 |
layerChangeSupport = null; |
1883 | 1880 |
state = null; |
Also available in: Unified diff