public class DownloadGpsTask extends AbstractDownloadTask
| Modifier and Type | Class and Description |
|---|---|
(package private) class |
DownloadGpsTask.DownloadTask |
| Modifier and Type | Field and Description |
|---|---|
private DownloadGpsTask.DownloadTask |
downloadTask |
protected java.lang.String |
newLayerName |
private static java.lang.String |
PATTERN_EXTERNAL_GPX_FILE |
private static java.lang.String |
PATTERN_EXTERNAL_GPX_SCRIPT |
private static java.lang.String |
PATTERN_TRACE_ID |
private static java.lang.String |
PATTERN_TRACKPOINTS_BBOX |
| Constructor and Description |
|---|
DownloadGpsTask() |
| Modifier and Type | Method and Description |
|---|---|
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.lang.String |
getConfirmationMessage(java.net.URL url)
Replies the HTML-formatted confirmation message to be shown to user when the given URL needs to be confirmed before loading.
|
java.lang.String[] |
getPatterns()
Returns regular expressions that match the URLs
|
java.lang.String |
getTitle()
Returns human-readable description of the task
|
static boolean |
isFromServer(java.lang.String url)
Determines if the given URL denotes an OSM gpx-related API call.
|
boolean |
isSafeForRemotecontrolRequests()
Check / decide if the task is safe for remotecontrol.
|
java.util.concurrent.Future<?> |
loadUrl(boolean newLayer,
java.lang.String url,
ProgressMonitor progressMonitor)
Asynchronously launches the download task for a given bounding URL.
|
acceptsDocumentationSummary, acceptsUrl, acceptsUrl, getErrorObjects, isCanceled, isFailed, rememberErrorMessage, rememberException, setCanceled, setFailedprivate DownloadGpsTask.DownloadTask downloadTask
private static final java.lang.String PATTERN_TRACE_ID
private static final java.lang.String PATTERN_TRACKPOINTS_BBOX
private static final java.lang.String PATTERN_EXTERNAL_GPX_SCRIPT
private static final java.lang.String PATTERN_EXTERNAL_GPX_FILE
protected java.lang.String newLayerName
public DownloadGpsTask()
public java.lang.String[] getPatterns()
DownloadTaskgetPatterns in interface DownloadTaskgetPatterns in class AbstractDownloadTaskpublic java.lang.String getTitle()
DownloadTaskgetTitle in interface DownloadTaskgetTitle in class AbstractDownloadTaskpublic java.util.concurrent.Future<?> download(boolean newLayer, Bounds downloadArea, ProgressMonitor progressMonitor)
DownloadTaskprogressMonitor 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 progressMonitorpublic java.util.concurrent.Future<?> loadUrl(boolean newLayer, java.lang.String url, ProgressMonitor progressMonitor)
DownloadTaskNullProgressMonitor.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 progressMonitorDownloadTask.download(boolean, Bounds, ProgressMonitor)public void cancel()
DownloadTaskpublic java.lang.String getConfirmationMessage(java.net.URL url)
DownloadTaskurl - The URL to be confirmedpublic boolean isSafeForRemotecontrolRequests()
AbstractDownloadTaskisSafeForRemotecontrolRequests in class AbstractDownloadTaskpublic static final boolean isFromServer(java.lang.String url)
url - The url to checkGpxData.fromServer