Revision 20756 trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/gui/wizards/FileOpenRaster.java

View differences:

FileOpenRaster.java
27 27
import org.cresques.cts.IProjection;
28 28
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
29 29
import org.gvsig.raster.Configuration;
30
import org.gvsig.raster.RasterProcess;
30 31
import org.gvsig.raster.gui.wizards.projection.RasterProjectionActionsDialog;
31 32
import org.gvsig.raster.gui.wizards.projection.RasterProjectionActionsPanel;
32 33
import org.gvsig.raster.util.RasterToolsUtil;
33 34
import org.gvsig.raster.util.RasterUtilities;
34 35
import org.gvsig.rastertools.RasterModule;
35 36
import org.gvsig.rastertools.geolocation.ui.GeoLocationOpeningRasterDialog;
37
import org.gvsig.rastertools.overviews.OverviewsProcess;
36 38
import org.gvsig.rastertools.raw.ui.main.OpenRawFileDefaultView;
37 39
import org.kxml2.io.KXmlParser;
38 40
import org.xmlpull.v1.XmlPullParser;
......
52 54
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
53 55
 */
54 56
public class FileOpenRaster extends AbstractFileOpen {
55
	public static int                         CHANGE_VIEW_PROJECTION = 0;
56
	public static int                         REPROJECT              = 1;
57
	public static int                         IGNORE                 = 2;
58
	public static int                         NOTLOAD                = 3;
57
	public static int                     CHANGE_VIEW_PROJECTION = 0;
58
	public static int                     REPROJECT              = 1;
59
	public static int                     IGNORE                 = 2;
60
	public static int                     NOTLOAD                = 3;
59 61
	/**
60
	 * Acci?n a realizar con la capa. Por defecto ignora la proyecci?n y la carga en la vista
61
	 * pero esta opci?n puede ser cambiada por el usuario desde el dialogo.
62
	 * Acci?n a realizar con la capa. Por defecto ignora la proyecci?n y la carga
63
	 * en la vista pero esta opci?n puede ser cambiada por el usuario desde el
64
	 * dialogo.
62 65
	 */
63
	public static int                         defaultActionLayer     = IGNORE;
66
	public static int                     defaultActionLayer     = IGNORE;
64 67
	/**
65 68
	 * Lista de acciones. Una por capa a a?adir.
66 69
	 */
67
	private ArrayList                         actionList             = new ArrayList();;
70
	private ArrayList                     actionList             = new ArrayList(); ;
71

  
72
	private ArrayList                     lyrsRaster             = new ArrayList();
73
	private RasterProjectionActionsDialog dialog                 = null;
74
	private MapControl                    mapControl             = null;
75
	private boolean                       firstTaskOverview      = true;
76
	private boolean                       execOverview           = false;
68 77
	
69
	private ArrayList                         lyrsRaster             = new ArrayList();
70
	private RasterProjectionActionsDialog     dialog                 = null;
71
	private MapControl                        mapControl             = null;
72
	
73 78
	/**
74 79
	 * Constructor de FileOpenRaster
75 80
	 */
......
80 85

  
81 86
	/*
82 87
	 * (non-Javadoc)
88
	 * @see com.iver.cit.gvsig.addlayer.fileopen.AbstractFileOpen#pre()
89
	 */
90
	public void pre() {
91
		firstTaskOverview = true;
92
	}
93
	
94
	/*
95
	 * (non-Javadoc)
83 96
	 * @see org.gvsig.raster.gui.wizards.IFileOpen#post(java.io.File[])
84 97
	 */
85 98
	public File post(File file) {
......
107 120
			FLyrRasterSE lyrRaster = null;
108 121
			lyrRaster = FLyrRasterSE.createLayer(file.getName(), file, null);
109 122
			
123
			// Si hay que generar las overviews por el panel de preferencias
124
			if (Configuration.getValue("overviews_ask_before_loading", Boolean.FALSE).booleanValue() == true) {
125
				try {
126
					boolean generate = false;
127
					for (int i = 0; i < lyrRaster.getFileCount(); i++) {
128
						if (lyrRaster.getDataSource().getDataset(i)[0].getOverviewCount(0) == 0) {
129
							generate = true;
130
							break;
131
						}
132
					}
133
					if (generate) {
134
						if (firstTaskOverview) {
135
							execOverview = RasterToolsUtil.messageBoxYesOrNot("generar_overviews", this);
136
							firstTaskOverview = false;
137
						}
138
					
139
						if (execOverview) {
140
							RasterProcess process = new OverviewsProcess();
141
							process.addParam("layer", (FLyrRasterSE) lyrRaster);
142
							process.execute();
143
							lyrRaster = FLyrRasterSE.createLayer(file.getName(), file, null);
144
						}
145
					}
146
				} catch (Exception e) {
147
					// Si no se puede generar la overview no hacemos nada
148
				}
149
			}
150

  
110 151
			//Mostramos el cuadro que pide la georreferenciaci?n si la capa no tiene y si la opci?n est? activa en preferencias
111 152
			if(RasterModule.askCoordinates) {
112 153
				if(	lyrRaster.getFullExtent().getMinX() == 0 && 
......
144 185
		this.mapControl = mapControl;
145 186
		String layerName = file.getName();
146 187
		int nLayer = -1;
147
		
148
		//Si hay capas en la lista la buscamos all?
149
		if(lyrsRaster.size() != 0) {   
188

  
189
		// Si hay capas en la lista la buscamos all?
190
		if (lyrsRaster.size() != 0) {
150 191
			for (int i = 0; i < lyrsRaster.size(); i++) {
151
				if(((FLyrRasterSE)lyrsRaster.get(i)).getName().equals(layerName)) {
152
					lyr = (FLyrRasterSE)lyrsRaster.get(i);
192
				if (((FLyrRasterSE) lyrsRaster.get(i)).getName().equals(layerName)) {
193
					lyr = (FLyrRasterSE) lyrsRaster.get(i);
153 194
					lyr.setProjection(proj);
154 195
					nLayer = i;
155 196
				}
156 197
			}
157 198
		}
158 199
		
159
		//Si no hay capa la cargamos
160
		if(lyr == null) {
200
		// Si no hay capa la cargamos
201
		if (lyr == null) {
161 202
			try {
162 203
				lyr = FLyrRasterSE.createLayer(layerName, file, proj);
163 204
				layerActions(defaultActionLayer, lyr);
......
165 206
				RasterToolsUtil.messageBoxError("error_carga_capa", this, e);
166 207
			}
167 208
		}
168
		
169
		if(lyr != null) {
170
			if(nLayer >= 0) {
209

  
210
		if (lyr != null) {
211
			if (nLayer >= 0) {
171 212
				Object obj = actionList.get(nLayer);
172
				if(obj != null && obj instanceof Integer)
173
					layerActions(((Integer)obj).intValue(), lyr);
213
				if (obj != null && obj instanceof Integer)
214
					layerActions(((Integer) obj).intValue(), lyr);
174 215
			} else
175 216
				layerActions(defaultActionLayer, lyr);
176 217
			return lyr.getFullExtent();
177 218
		}
178
						
219

  
179 220
		return null;
180 221
	}
181 222
	

Also available in: Unified diff