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

View differences:

ExportProcess.java
21 21

  
22 22
import es.prodevelop.gvsig.exportMobile.xml.Bounds;
23 23
import es.prodevelop.gvsig.exportMobile.xml.XmlProjectTags;
24

  
24
/**
25
 * 
26
 * This  process executes a series of tasks
27
 * 
28
 * @author jcarras
29
 *
30
 */
25 31
public class ExportProcess  extends AbstractMonitorableTask{
26
/**
27
 *  This process executes a series of tasks
28
 */ 
29 32
	private ArrayList tasks = new ArrayList();
30 33
	private int numSteps=0;
31 34
	private XmlBuilder xml = new XmlBuilder();
......
36 39
	public static String PROJECTEXTENSION = ".gvm";
37 40
	
38 41

  
39
	
42
	/**
43
	 * Constructor with all needed parameters 
44
	 * @param rectangle
45
	 * @param name
46
	 * @param dirPath
47
	 * @param projection
48
	 */
40 49
	public ExportProcess(Rectangle2D rectangle, String name, String dirPath, IProjection projection){
41 50
		setRect(rectangle);
42 51
		setName(name);
......
44 53
		setDirPath(dirPath);
45 54
	}
46 55
	
56
	/**
57
	 * Adds a ExporterSubTask task to the list of task to execute
58
	 * The order the tasks are added is the order they will be executed
59
	 * @param task
60
	 */
47 61
	public void addTask(ExporterSubTask task){
48 62
		tasks.add(task);
49 63
		numSteps+=task.getFinalStep();
50 64
	}
51 65
	
66
	/**
67
	 * Creates a VectorialExporterTask and adds it to the list of tasks to execute
68
	 * @param lyr
69
	 * @param outputFields
70
	 * @param processType
71
	 */
52 72
	public void addVectorialTask(FLayer lyr, FieldDescription[] outputFields, int processType){
53 73
		VectorialExporterTask task = new VectorialExporterTask(this,
54 74
				lyr,
......
60 80
		addTask(task);
61 81
	}
62 82
	
83
	/**
84
	 * Creates a RasterExporter task and adds it to the list of tasks to execute
85
	 * @param lyr
86
	 */
63 87
	public void addRasterTask(FLayer lyr){
64 88
		RasterExporter task = new RasterExporter(this,lyr,rect, new File(dirPath),xml);
65 89
		addTask(task);
66 90
	}
67 91
	
92
	/**
93
	 * Creates a WMSExporter task and adds it to the list of tasks to execute
94
	 * @param lyr
95
	 */
68 96
	public void addWMSTask(FLayer lyr){
69 97
		WMSExporter task = new WMSExporter(this,lyr,getRect(),xml);
70 98
		addTask(task);
71 99
	}
72 100
	
101
	/**
102
	 * Closes the oppened xml tags and stores the project file
103
	 */
73 104
	private void writeProjectFile(){
74 105
		// done
75 106
		
......
84 115
		createFile(fileout,xml.getXML());
85 116
	}
86 117
	
118
	/**
119
	 * Starts the xml to be ready for pushing the layers into
120
	 */
87 121
	private void initProjectFile(){
88 122
		xml.writeHeader();
89 123
		//<Project>
......
108 142
			xml.openTag(XmlProjectTags.LAYERS);
109 143
	}
110 144

  
145
	/**
146
	 * To be executed before running this
147
	 */
111 148
	public void preProcess(){
112 149
		setInitialStep(0);
113 150
		this.setFinalStep(numSteps);
114 151
		setDeterminatedProcess(true);
115 152
	}
116 153
	
154
	/**
155
	 * Executes all the tasks in the list, creates the project file and 
156
	 * reports the steps not reported yet
157
	 */
117 158
	public void run() throws Exception {
118 159
		
119 160
		initProjectFile();
......
135 176
		reportToEnd();
136 177
	}
137 178

  
179
	/**
180
	 * Reports steps to indicate the task list has been completed  
181
	 */
138 182
	private void reportToEnd(){
139 183
		while (getCurrentStep()<getFinalStep())
140 184
			reportStep();
141 185
	}
186
	
142 187
	public Rectangle2D getRect() {
143 188
		return rect;
144 189
	}
......
171 216
		this.dirPath = dirPath;
172 217
	}
173 218
	
219
	/**
220
	 * Writes the xml to the file
221
	 * 
222
	 * @param f
223
	 * @param xml
224
	 */
174 225
	public static void createFile(File f, String xml) {
175 226
		if (xml != null) {
176 227
			try {

Also available in: Unified diff