|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface DownloadTask
Interface defining a general download task used to download geographic data (OSM data, GPX tracks, etc.) for a given URL or geographic area.
| Method Summary | |
|---|---|
boolean |
acceptsUrl(java.lang.String url)
Returns true if the task is able to open the given URL, false otherwise. |
void |
cancel()
Cancels the asynchronous download task. |
java.util.concurrent.Future<?> |
download(boolean newLayer,
Bounds downloadArea,
ProgressMonitor progressMonitor)
Asynchronously launches the download task for a given bounding box. |
java.util.List<java.lang.Object> |
getErrorObjects()
Replies the error objects of the task. |
java.util.concurrent.Future<?> |
loadUrl(boolean newLayer,
java.lang.String url,
ProgressMonitor progressMonitor)
Asynchronously launches the download task for a given bounding URL. |
| Method Detail |
|---|
java.util.concurrent.Future<?> download(boolean newLayer,
Bounds downloadArea,
ProgressMonitor progressMonitor)
progressMonitor to null, if the task should create, open, and close a progress monitor.
Set progressMonitor to NullProgressMonitor.INSTANCE if progress information is to
be discarded.
You can wait for the asynchronous download task to finish by synchronizing on the returned
Future, but make sure not to freeze up JOSM. Example:
Future> future = task.download(...);
// DON'T run this on the Swing EDT or JOSM will freeze
future.get(); // waits for the dowload task to complete
The following example uses a pattern which is better suited if a task is launched from
the Swing EDT:
final Future> future = task.download(...);
Runnable runAfterTask = new Runnable() {
public void run() {
// this is not strictly necessary because of the type of executor service
// Main.worker is initialized with, but it doesn't harm either
//
future.get(); // wait for the download task to complete
doSomethingAfterTheTaskCompleted();
}
}
Main.worker.submit(runAfterTask);
newLayer - true, if the data is to be downloaded into a new layer. If false, the task
selects one of the existing layers as download layer, preferably the active layer.downloadArea - the area to downloadprogressMonitor - the progressMonitor
java.util.concurrent.Future<?> loadUrl(boolean newLayer,
java.lang.String url,
ProgressMonitor progressMonitor)
NullProgressMonitor.INSTANCE if progress information is to
be discarded.
newLayer - newLayer true, if the data is to be downloaded into a new layer. If false, the task
selects one of the existing layers as download layer, preferably the active layer.url - the url to download fromprogressMonitor - the progressMonitor
download(boolean, Bounds, ProgressMonitor)boolean acceptsUrl(java.lang.String url)
url - the url to download from
java.util.List<java.lang.Object> getErrorObjects()
Strings with error messages or Exceptions.
void cancel()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||