Package org.openstreetmap.josm.actions
Class DownloadAlongAction
java.lang.Object
javax.swing.AbstractAction
org.openstreetmap.josm.actions.JosmAction
org.openstreetmap.josm.actions.DownloadAlongAction
- All Implemented Interfaces:
ActionListener,Serializable,Cloneable,EventListener,Action,Destroyable
- Direct Known Subclasses:
DownloadAlongTrackAction,DownloadAlongWayAction
Abstract superclass of DownloadAlongTrackAction and DownloadAlongWayAction
- Since:
- 6054
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.openstreetmap.josm.actions.JosmAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter -
Field Summary
Fields inherited from class org.openstreetmap.josm.actions.JosmAction
scFields inherited from class javax.swing.AbstractAction
changeSupport, enabledFields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDownloadAlongAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean registerInToolbar) Constructs a newDownloadAlongAction -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected static voidaddToDownload(Area a, Rectangle2D r, Collection<Rectangle2D> results, double maxArea) protected static Collection<LatLon>calcBetweenPoints(LatLon p1, LatLon p2, double bufferDist) Calculate list of points between two given points so that the distance between two consecutive points is below a limit.protected static voidconfirmAndDownloadAreas(Area a, double maxArea, boolean osmDownload, boolean gpxDownload, String title, boolean newLayer) Area "a" contains the hull that we would like to download data for.protected PleaseWaitRunnablecreateCalcTask(Path2D alongPath, DownloadAlongPanel panel, String confirmTitle, boolean newLayer) Create task that downloads areas along the given path using the values specified in the panel.protected abstract PleaseWaitRunnableSub classes must override this method.Methods inherited from class org.openstreetmap.josm.actions.JosmAction
buildActiveLayerChangeAdapter, buildLayerChangeAdapter, checkAndConfirmOutlyingOperation, destroy, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, listenToSelectionChange, setHelpId, setToolbarId, setTooltip, updateEnabledState, updateEnabledState, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFutureMethods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
Constructor Details
-
DownloadAlongAction
protected DownloadAlongAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean registerInToolbar) Constructs a newDownloadAlongAction- Parameters:
name- the action's text as displayed in the menuiconName- the filename of the icon to usetooltip- a longer description of the action that will be displayed in the tooltip. Please note that html is not supported for menu actions on some platforms.shortcut- a ready-created shortcut object or null if you don't want a shortcut. But you always do want a shortcut, remember you can always register it with group=none, so you won't be assigned a shortcut unless the user configures one. If you pass null here, the user CANNOT configure a shortcut for your action.registerInToolbar- register this action for the toolbar preferences?
-
-
Method Details
-
createTask
Sub classes must override this method.- Returns:
- the task to start or null if nothing to do
-
addToDownload
protected static void addToDownload(Area a, Rectangle2D r, Collection<Rectangle2D> results, double maxArea) -
confirmAndDownloadAreas
protected static void confirmAndDownloadAreas(Area a, double maxArea, boolean osmDownload, boolean gpxDownload, String title, boolean newLayer) Area "a" contains the hull that we would like to download data for. however we can only download rectangles, so the following is an attempt at finding a number of rectangles to download. The idea is simply: Start out with the full bounding box. If it is too large, then split it in half and repeat recursively for each half until you arrive at something small enough to download. The algorithm is improved by always using the intersection between the rectangle and the actual desired area. For example, if you have a track that goes like this: +----+ | /| | / | | / | |/ | +----+ then we would first look at downloading the whole rectangle (assume it's too big), after that we split it in half (upper and lower half), but we do not request the full upper and lower rectangle, only the part of the upper/lower rectangle that actually has something in it. This functions calculates the rectangles, asks the user to continue and downloads the areas if applicable.- Parameters:
a- download area hullmaxArea- maximum area size for a single downloadosmDownload- Set to true if OSM data should be downloadedgpxDownload- Set to true if GPX data should be downloadedtitle- the title string for the confirmation dialognewLayer- Set to true if all areas should be put into a single new layer
-
calcBetweenPoints
Calculate list of points between two given points so that the distance between two consecutive points is below a limit.- Parameters:
p1- first point or nullp2- second point (must not be null)bufferDist- the maximum distance- Returns:
- a list of points with at least one point (p2) and maybe more.
-
createCalcTask
protected PleaseWaitRunnable createCalcTask(Path2D alongPath, DownloadAlongPanel panel, String confirmTitle, boolean newLayer) Create task that downloads areas along the given path using the values specified in the panel.- Parameters:
alongPath- the path along which the areas are to be downloadedpanel- the panel that was displayed to the user and now contains his selectionsconfirmTitle- the title to display in the confirmation panelnewLayer- Set to true if all areas should be put into a single new layer- Returns:
- the task or null if canceled by user
-
actionPerformed
-