|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openstreetmap.josm.actions.downloadtasks.AbstractDownloadTask
org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask
public class DownloadOsmTask
Open the download dialog and download the data. Run in the worker thread.
Nested Class Summary | |
---|---|
protected class |
DownloadOsmTask.DownloadTask
|
Field Summary | |
---|---|
protected Bounds |
currentBounds
|
protected DataSet |
downloadedData
|
protected DownloadOsmTask.DownloadTask |
downloadTask
|
protected java.lang.String |
newLayerName
|
protected OsmDataLayer |
targetLayer
|
Constructor Summary | |
---|---|
DownloadOsmTask()
|
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. |
protected java.util.concurrent.Future<?> |
download(DownloadOsmTask.DownloadTask downloadTask,
Bounds downloadArea)
|
java.util.concurrent.Future<?> |
download(OsmServerReader reader,
boolean newLayer,
Bounds downloadArea,
ProgressMonitor progressMonitor)
Asynchronously launches the download task for a given bounding box. |
protected void |
extractOsmFilename(java.lang.String pattern,
java.lang.String url)
|
DataSet |
getDownloadedData()
Replies the DataSet containing the downloaded OSM data. |
java.util.concurrent.Future<?> |
loadUrl(boolean new_layer,
java.lang.String url,
ProgressMonitor progressMonitor)
Loads a given URL from the OSM Server |
protected void |
rememberDownloadedData(DataSet ds)
|
Methods inherited from class org.openstreetmap.josm.actions.downloadtasks.AbstractDownloadTask |
---|
getErrorObjects, isCanceled, isFailed, rememberErrorMessage, rememberException, setCanceled, setFailed |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Bounds currentBounds
protected DataSet downloadedData
protected DownloadOsmTask.DownloadTask downloadTask
protected OsmDataLayer targetLayer
protected java.lang.String newLayerName
Constructor Detail |
---|
public DownloadOsmTask()
Method Detail |
---|
protected void rememberDownloadedData(DataSet ds)
public DataSet getDownloadedData()
DataSet
containing the downloaded OSM data.
DataSet
containing the downloaded OSM data.public java.util.concurrent.Future<?> download(boolean newLayer, Bounds downloadArea, ProgressMonitor progressMonitor)
DownloadTask
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 completeThe 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
public java.util.concurrent.Future<?> download(OsmServerReader reader, 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 completeThe 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);
reader
- the reader used to parse OSM data (see OsmServerReader.parseOsm(org.openstreetmap.josm.gui.progress.ProgressMonitor)
)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
protected java.util.concurrent.Future<?> download(DownloadOsmTask.DownloadTask downloadTask, Bounds downloadArea)
public java.util.concurrent.Future<?> loadUrl(boolean new_layer, java.lang.String url, ProgressMonitor progressMonitor)
new_layer
- True if the data should be saved to a new layerurl
- The URL as StringprogressMonitor
- the progressMonitor
DownloadTask.download(boolean, Bounds, ProgressMonitor)
protected final void extractOsmFilename(java.lang.String pattern, java.lang.String url)
public boolean acceptsUrl(java.lang.String url)
DownloadTask
url
- the url to download from
public void cancel()
DownloadTask
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |