Revision 19196 trunk/prototypes/mobile/desktop/extensions/extExportMobile/src/es/prodevelop/gvsig/exportMobile/layerexporters/RasterExporter.java

View differences:

RasterExporter.java
19 19

  
20 20
import es.prodevelop.gvsig.exportMobile.xml.XmlProjectTags;
21 21

  
22
/**
23
 * Exportation subtask
24
 * Allows a raster layer to be exported
25
 * 
26
 * @author jcarras
27
 *
28
 */
22 29
public class RasterExporter extends ExporterSubTask{
23 30

  
24 31
	private Logger logger = Logger.getLogger(RasterExporter.class.getClass());
......
26 33
	private static int INDX_PATH = 10;
27 34
	private FLyrRaster inLyrRast;
28 35

  
36
	/**
37
	 * COnstructor with all the needed attributes
38
	 * 
39
	 * @param parentProcess
40
	 * @param layer
41
	 * @param rect this parameter is not used currently
42
	 * @param outputdir
43
	 * @param xml
44
	 */
29 45
	public RasterExporter(AbstractMonitorableTask parentProcess, FLayer layer,
30 46
			Rectangle2D rect, File outputdir, XmlBuilder xml) {
31 47
		super(parentProcess, layer, rect, xml);
......
75 91
	}
76 92

  
77 93

  
94
	/**
95
	 * Searches the WLD file associated with the layer
96
	 * 
97
	 * @param img_file
98
	 * @return
99
	 */
78 100
	private File findWldFile(File img_file) {
79 101
		
80 102
		String img_path = img_file.getAbsolutePath();
......
106 128
	}
107 129

  
108 130
	/**
109
	 * Create the new output file in output file
131
	 * Copies the in file to the outdir directory
110 132
	 * 
111
	 * @param in,
112
	 *            old file
113
	 * @param outdir,
114
	 *            output dir
133
	 * @param in
134
	 * @param outdir
135
	 * @param numStepsToReport the copy will report this number of steps
115 136
	 * @throws Exception
116 137
	 */
117 138
	public void copyFileToDir(File in, File outdir, int numStepsToReport) throws Exception {
118 139

  
119 140
		File f = new File(outdir.getAbsolutePath() + File.separator + in.getName());
120
		/*
121
		long flenght = f.length();
122
		int currStep = 0;
123
		long bytesPerStep = flenght / numStepsToReport;
124
		long bytesCopied = 0;
125 141
		
126
		
127
		FileInputStream fis = new FileInputStream(in);
128
		FileOutputStream fos = new FileOutputStream(f);
129
		byte[] buf = new byte[1024];
130
		int i = 0;
131
		while ((i = fis.read(buf)) != -1) {
132
			fos.write(buf, 0, i);
133
			bytesCopied+=i;
134
			int newStep = (int)(bytesCopied % bytesPerStep);
135
			if (newStep>currStep){
136
				reportSteps(newStep-currStep);
137
				currStep=newStep;
138
			}
139
		}
140
		fis.close();
141
		fos.close();*/
142
		
143 142
		copyFileToFile(in, f, numStepsToReport);
144 143
	}
145 144
	/**
146
	 * Create the new output file in output file
145
	 * Copies the in file data to the outFile file
147 146
	 * 
148
	 * @param in,
149
	 *            old file
150
	 * @param outdir,
151
	 *            output dir
147
	 * @param in
148
	 * @param outFile
149
	 * @param numStepsToReport the copy will report this number of steps
152 150
	 * @throws Exception
153 151
	 */
154 152
	public void copyFileToFile(File in, File outFile, int numStepsToReport) throws Exception {
......
178 176
	}
179 177

  
180 178

  
181

  
182
	@Override
179
	/**
180
	 * Number of steps this subtask report
181
	 */
183 182
	public int getFinalStep() {
184
		// TODO Auto-generated method stub
185 183
		return 100;
186 184
	}
187 185

  
188 186

  
189

  
190

  
191
	@Override
187
	/**
188
	 * runs the exportation
189
	 */
192 190
	public void run() {
193 191
		export();
194 192
	}
195 193
	
194
	/**
195
	 * Writes the layer attributes on the gvsig mobile xml project file 
196
	 * 
197
	 * @param name
198
	 * @param path
199
	 */
196 200
	private void writeXML(String name, String path){
197 201
		//<Type>
198 202
		xml.writeTag(XmlProjectTags.TYPE, "RASTER");

Also available in: Unified diff