Revision 19196
trunk/prototypes/mobile/desktop/extensions/extExportMobile/src/es/prodevelop/gvsig/exportMobile/files/NewDir.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
|
11 | 11 |
/** |
12 |
* Create a new directory |
|
12 |
* Manages the directory when a gvsig mobile project |
|
13 |
* with his data will be stored |
|
14 |
* |
|
13 | 15 |
* @author Anabel Moreno |
14 | 16 |
* |
15 | 17 |
*/ |
trunk/prototypes/mobile/desktop/extensions/extExportMobile/src/es/prodevelop/gvsig/exportMobile/ClipExtension.java | ||
---|---|---|
13 | 13 |
|
14 | 14 |
|
15 | 15 |
/** |
16 |
* This extension will be visible if any view is execute. Get the layers are in |
|
17 |
* TOC and the exents of the view to work with them. |
|
18 |
* If are any group of layers in TOC, we work with its layers as |
|
19 |
* if this gropu doesn?t exists. |
|
20 | 16 |
* |
17 |
* This extension allows a user to export all the layers in a view |
|
18 |
* |
|
21 | 19 |
* @author amoreno |
22 | 20 |
* |
23 | 21 |
*/ |
24 | 22 |
public class ClipExtension extends Extension { |
25 | 23 |
|
24 |
/** |
|
25 |
* Starts the extension |
|
26 |
*/ |
|
26 | 27 |
public void initialize() { |
27 | 28 |
// //Initialiser SOAP writer with the desination SOAP file |
28 | 29 |
//File destFile = new File("SOAPComEventModif.xml"); |
29 | 30 |
//CommMessageWriterManager.registerManager(new CommMessageWriterManager(new SOAPCommMessageWriter(destFile))); |
30 | 31 |
} |
31 | 32 |
|
33 |
|
|
32 | 34 |
public boolean isEnabled() { |
33 | 35 |
|
34 | 36 |
return true; |
35 | 37 |
} |
36 | 38 |
|
39 |
/** |
|
40 |
* is visible when a view is the active window |
|
41 |
*/ |
|
37 | 42 |
public boolean isVisible() { |
38 | 43 |
com.iver.andami.ui.mdiManager.IWindow f = (com.iver.andami.ui.mdiManager.IWindow) PluginServices |
39 | 44 |
.getMDIManager().getActiveWindow(); |
... | ... | |
45 | 50 |
return (f instanceof View); |
46 | 51 |
} |
47 | 52 |
|
53 |
/** |
|
54 |
* @param actionCommand not used |
|
55 |
* It's called when the export to gvsig mobile button is pressed |
|
56 |
*/ |
|
48 | 57 |
public void execute(String actionCommand) { |
49 | 58 |
|
50 | 59 |
View view = (View) PluginServices.getMDIManager().getActiveWindow(); |
trunk/prototypes/mobile/desktop/extensions/extExportMobile/src/es/prodevelop/gvsig/exportMobile/rectangle/DrawRectangle.java | ||
---|---|---|
19 | 19 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
20 | 20 |
|
21 | 21 |
/** |
22 |
* Draw a poligon with the same dimension that mapControl
|
|
22 |
* Utility to create layers with rectangles
|
|
23 | 23 |
* |
24 | 24 |
* @author Anabel Moreno |
25 | 25 |
* |
trunk/prototypes/mobile/desktop/extensions/extExportMobile/src/es/prodevelop/gvsig/exportMobile/CreateImage.java | ||
---|---|---|
7 | 7 |
import org.apache.log4j.Logger; |
8 | 8 |
|
9 | 9 |
/** |
10 |
* To create an Image Icon
|
|
10 |
* Class to access the icons used by the extension
|
|
11 | 11 |
* @author amoreno |
12 | 12 |
* |
13 | 13 |
*/ |
... | ... | |
36 | 36 |
* where the image is into. |
37 | 37 |
* @param description |
38 | 38 |
* of the image. |
39 |
* @return |
|
39 |
* @return ImageIcon
|
|
40 | 40 |
*/ |
41 | 41 |
public ImageIcon createImageIcon(URL path, String description) { |
42 | 42 |
|
trunk/prototypes/mobile/desktop/extensions/extExportMobile/src/es/prodevelop/gvsig/exportMobile/layerexporters/WMSExporter.java | ||
---|---|---|
10 | 10 |
import es.prodevelop.gvsig.exportMobile.xml.XMLwms; |
11 | 11 |
|
12 | 12 |
/** |
13 |
* Create a new xml file with the WMSCONFIG into the output directory selected
|
|
13 |
* Exports a gvsig wms layer to a gvsig mobile wms layer
|
|
14 | 14 |
* @author Anabel Moreno |
15 | 15 |
* |
16 | 16 |
*/ |
17 | 17 |
public class WMSExporter extends ExporterSubTask{ |
18 | 18 |
|
19 |
/** |
|
20 |
* Constructor with all the required attributes |
|
21 |
* @param parentProcess |
|
22 |
* @param layer |
|
23 |
* @param rect |
|
24 |
* @param xml |
|
25 |
*/ |
|
19 | 26 |
public WMSExporter(AbstractMonitorableTask parentProcess, FLayer layer, |
20 | 27 |
Rectangle2D rect, XmlBuilder xml) { |
21 | 28 |
super(parentProcess, layer, rect, xml); |
... | ... | |
24 | 31 |
|
25 | 32 |
|
26 | 33 |
/** |
27 |
* export the new xml file |
|
28 |
* @param layerWMS |
|
29 |
* @param outfile |
|
30 |
* @param boxWMS |
|
34 |
* Adds to the xml the layer attributes |
|
31 | 35 |
*/ |
32 | 36 |
public void export(){ |
33 | 37 |
initXML(); |
... | ... | |
39 | 43 |
closeXML(); |
40 | 44 |
} |
41 | 45 |
|
42 |
@Override |
|
46 |
/** |
|
47 |
* Number of steps the layer will report |
|
48 |
*/ |
|
43 | 49 |
public int getFinalStep() { |
44 |
// TODO Auto-generated method stub |
|
45 | 50 |
return 100; |
46 | 51 |
} |
47 | 52 |
|
48 |
@Override |
|
53 |
/** |
|
54 |
* Starts the exportation task |
|
55 |
*/ |
|
49 | 56 |
public void run() { |
50 |
// TODO Auto-generated method stub |
|
51 | 57 |
export(); |
52 | 58 |
} |
53 | 59 |
} |
trunk/prototypes/mobile/desktop/extensions/extExportMobile/src/es/prodevelop/gvsig/exportMobile/layerexporters/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 { |
trunk/prototypes/mobile/desktop/extensions/extExportMobile/src/es/prodevelop/gvsig/exportMobile/layerexporters/VectorialExporterTask.java | ||
---|---|---|
47 | 47 |
import es.prodevelop.gvsig.exportMobile.xml.Style; |
48 | 48 |
import es.prodevelop.gvsig.exportMobile.xml.XmlProjectTags; |
49 | 49 |
|
50 |
/** |
|
51 |
* Exportation subtask to export a vectorial layer |
|
52 |
* It supports selecting features by rect, clipping |
|
53 |
* features by rect and exporting all features |
|
54 |
* It splits the input data in polygons, lines and |
|
55 |
* points to save it as shapefiles. |
|
56 |
* |
|
57 |
* @author jcarras |
|
58 |
* |
|
59 |
*/ |
|
50 | 60 |
public class VectorialExporterTask extends ExporterSubTask { |
51 | 61 |
|
52 | 62 |
public static final int CLIPRECT = 1; |
... | ... | |
68 | 78 |
public static final String NOSUFFIX = ""; |
69 | 79 |
public static final String SHAPESUFFIX = ".shp"; |
70 | 80 |
|
81 |
/** |
|
82 |
* Returns the suffix associated wit the input process type |
|
83 |
* @param processType |
|
84 |
* @return the corresponding suffix |
|
85 |
*/ |
|
71 | 86 |
public String getSuffix(int processType){ |
72 | 87 |
if (processType == CLIPRECT) |
73 | 88 |
return CLIPSUFFIX; |
... | ... | |
78 | 93 |
return NOSUFFIX; |
79 | 94 |
} |
80 | 95 |
|
81 |
|
|
96 |
/** |
|
97 |
* Remove the defined suffixes of the input string with the objective |
|
98 |
* of not adding twice the suffixes on several exportations |
|
99 |
* |
|
100 |
* @param name |
|
101 |
* @return the input string without the suffixes |
|
102 |
*/ |
|
82 | 103 |
public String removeSuffixes(String name){ |
83 | 104 |
String res = name; |
84 | 105 |
|
... | ... | |
107 | 128 |
|
108 | 129 |
private Logger logger = Logger.getLogger(this.getClass()); |
109 | 130 |
|
131 |
/** |
|
132 |
* Constructor with all the needed attributes |
|
133 |
* @param parentProcess |
|
134 |
* @param layer |
|
135 |
* @param rect |
|
136 |
* @param destPath |
|
137 |
* @param processType One of those VectorialExporterTask.CLIPRECT, VectorialExporterTask.ALL or VectorialExporterTask.SELECTRECT |
|
138 |
* @param fieldsDescription Description of the fields of the resulting layers |
|
139 |
* @param xml |
|
140 |
*/ |
|
110 | 141 |
public VectorialExporterTask(AbstractMonitorableTask parentProcess, |
111 | 142 |
FLayer layer, Rectangle2D rect, String destPath, int processType, |
112 | 143 |
FieldDescription[] fieldsDescription, XmlBuilder xml) { |
... | ... | |
189 | 220 |
|
190 | 221 |
} |
191 | 222 |
|
192 |
public void clipFeatures(IWriter writer, Driver reader, FBitSet bitSet, ShpSchemaManager schemaManager, ILayerDefinition outputDef, int numStepsToReport){
|
|
223 |
private void clipFeatures(IWriter writer, Driver reader, FBitSet bitSet, ShpSchemaManager schemaManager, ILayerDefinition outputDef, int numStepsToReport){
|
|
193 | 224 |
ClipProcess clip = new ClipProcess( |
194 | 225 |
inLayerVec, |
195 | 226 |
fieldsDescription, bitSet); |
... | ... | |
211 | 242 |
|
212 | 243 |
} |
213 | 244 |
|
245 |
/** |
|
246 |
* Makes the exportation |
|
247 |
*/ |
|
214 | 248 |
public void export() { |
215 | 249 |
setNote(PluginServices.getText(this, "exporting_") + " " + inLayer.getName()); |
216 | 250 |
|
... | ... | |
386 | 420 |
|
387 | 421 |
} |
388 | 422 |
|
423 |
/** |
|
424 |
* It iterates over every feature to return a bitSet with the features of |
|
425 |
* the input type and inside the input rectangle |
|
426 |
* @param rect |
|
427 |
* @param type |
|
428 |
* @return |
|
429 |
* @throws DriverException |
|
430 |
*/ |
|
389 | 431 |
public FBitSet queryByRectAndType(Rectangle2D rect, int type) |
390 | 432 |
throws DriverException { |
391 | 433 |
|
... | ... | |
437 | 479 |
|
438 | 480 |
} |
439 | 481 |
|
440 |
/** |
|
441 |
* @param file |
|
442 |
* @return |
|
443 |
* @throws IOException |
|
444 |
*/ |
|
445 |
public IndexedShpDriver getOpenShpDriver(File file) throws IOException { |
|
482 |
|
|
483 |
private IndexedShpDriver getOpenShpDriver(File file) throws IOException { |
|
446 | 484 |
|
447 | 485 |
IndexedShpDriver drv = new IndexedShpDriver(); |
448 | 486 |
if (!file.exists()) { |
... | ... | |
459 | 497 |
return drv; |
460 | 498 |
} |
461 | 499 |
|
462 |
/** |
|
463 |
* Name agreed with descripExLyr2 |
|
464 |
* |
|
465 |
* @param sds2 |
|
466 |
* @param descripExLyr2 |
|
467 |
* @param i |
|
468 |
* @return |
|
469 |
* @throws com.hardcode.gdbms.engine.data.driver.DriverException |
|
470 |
*/ |
|
471 | 500 |
private Value[] extractValues(SelectableDataSource sds2, |
472 | 501 |
FieldDescription[] descripExLyr2, int i) |
473 | 502 |
throws com.hardcode.gdbms.engine.data.driver.DriverException { |
... | ... | |
528 | 557 |
return index; |
529 | 558 |
} |
530 | 559 |
|
531 |
@Override |
|
560 |
/** |
|
561 |
* Number of steps the Exportation will report |
|
562 |
*/ |
|
532 | 563 |
public int getFinalStep() { |
533 | 564 |
return 100; |
534 | 565 |
} |
535 | 566 |
|
536 |
@Override |
|
567 |
/** |
|
568 |
* Runs the exportation task |
|
569 |
*/ |
|
537 | 570 |
public void run() { |
538 | 571 |
export(); |
539 | 572 |
} |
540 | 573 |
|
574 |
/** |
|
575 |
* Writes the layer attributes to the input xml |
|
576 |
* @param name |
|
577 |
* @param shpType |
|
578 |
* @param path |
|
579 |
*/ |
|
541 | 580 |
private void writeXML(String name, int shpType, String path){ |
542 | 581 |
//xml.openTag(XmlProjectTags.LAYER); |
543 | 582 |
//<Type> |
trunk/prototypes/mobile/desktop/extensions/extExportMobile/src/es/prodevelop/gvsig/exportMobile/layerexporters/ExporterSubTask.java | ||
---|---|---|
13 | 13 |
import es.prodevelop.gvsig.exportMobile.xml.XmlProjectTags; |
14 | 14 |
|
15 | 15 |
/** |
16 |
* |
|
17 |
* This class mother has to be the ancestor of every class |
|
18 |
* executable in an ExportProcess |
|
19 |
* |
|
16 | 20 |
* @author jcarras |
17 | 21 |
* |
18 | 22 |
*/ |
... | ... | |
27 | 31 |
private int currentStep = 0; |
28 | 32 |
private boolean isCancelled = false; |
29 | 33 |
|
30 |
private ExporterSubTask(){ |
|
31 |
|
|
32 |
} |
|
33 |
|
|
34 | 34 |
public abstract void run(); |
35 | 35 |
|
36 |
/** |
|
37 |
* Constructor |
|
38 |
* |
|
39 |
* @param parentProcess |
|
40 |
* @param layer |
|
41 |
* @param rect |
|
42 |
* @param xml |
|
43 |
*/ |
|
36 | 44 |
public ExporterSubTask(AbstractMonitorableTask parentProcess, FLayer layer, Rectangle2D rect, XmlBuilder xml){ |
37 | 45 |
this.inLayer=layer; |
38 | 46 |
this.rect=rect; |
... | ... | |
40 | 48 |
this.xml=xml; |
41 | 49 |
} |
42 | 50 |
|
51 |
/** |
|
52 |
* Indicates to the ExportProcess that the task is going on |
|
53 |
* reportStep has to be called exactly getFinalStep() times |
|
54 |
*/ |
|
43 | 55 |
public void reportStep(){ |
44 | 56 |
currentStep++; |
45 | 57 |
parent.reportStep(); |
46 | 58 |
} |
47 | 59 |
|
60 |
/** |
|
61 |
* It reports numSteps Steps |
|
62 |
* @param numSteps |
|
63 |
*/ |
|
48 | 64 |
public void reportSteps(int numSteps){ |
49 | 65 |
for (int i=0; i<numSteps; i++) |
50 | 66 |
reportStep(); |
51 | 67 |
} |
52 | 68 |
|
69 |
/** |
|
70 |
* Changes the status text of the task |
|
71 |
* @param statusMessage |
|
72 |
*/ |
|
53 | 73 |
public void setStatusMessage(String statusMessage){ |
54 | 74 |
parent.setStatusMessage(statusMessage); |
55 | 75 |
} |
56 | 76 |
|
77 |
/** |
|
78 |
* Changes the note of the task |
|
79 |
* (It is showed on progress dialog) |
|
80 |
* |
|
81 |
* @param note |
|
82 |
*/ |
|
57 | 83 |
public void setNote(String note){ |
58 | 84 |
parent.setNote(note); |
59 | 85 |
} |
60 | 86 |
|
87 |
/** |
|
88 |
* Any class extending ExporterSubClass has to implement this method |
|
89 |
* to comunicate the number of steps it will report |
|
90 |
* @return |
|
91 |
*/ |
|
61 | 92 |
public abstract int getFinalStep(); |
62 | 93 |
|
63 |
|
|
94 |
/** |
|
95 |
* If the proposed file exists, this method returns one not existing |
|
96 |
* file similar to the proposed one |
|
97 |
* |
|
98 |
* @param proposedFile |
|
99 |
* @return |
|
100 |
*/ |
|
64 | 101 |
public File getFreeFile(File proposedFile){ |
65 | 102 |
if (!proposedFile.exists()) |
66 | 103 |
return proposedFile; |
... | ... | |
79 | 116 |
return null; |
80 | 117 |
} |
81 | 118 |
|
119 |
/** |
|
120 |
* Starts the XML with the layer heading |
|
121 |
*/ |
|
82 | 122 |
protected void initXML(){ |
83 | 123 |
//<Layer> |
84 | 124 |
xml.openTag(XmlProjectTags.LAYER); |
85 | 125 |
xmlInited=true; |
86 | 126 |
} |
127 |
|
|
128 |
/** |
|
129 |
* Add the layer footer to the XML |
|
130 |
*/ |
|
87 | 131 |
protected void closeXML(){ |
88 | 132 |
if (isXmlInited()) |
89 | 133 |
xml.closeTag(); |
trunk/prototypes/mobile/desktop/extensions/extExportMobile/src/es/prodevelop/gvsig/exportMobile/layerexporters/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