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:
java.awt.event.ActionListener
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,javax.swing.Action
,Destroyable
- Direct Known Subclasses:
DownloadAlongTrackAction
,DownloadAlongWayAction
public abstract class DownloadAlongAction extends JosmAction
Abstract superclass of DownloadAlongTrackAction and DownloadAlongWayAction- Since:
- 6054
- See Also:
- Serialized Form
-
-
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
sc
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DownloadAlongAction(java.lang.String name, java.lang.String iconName, java.lang.String tooltip, Shortcut shortcut, boolean registerInToolbar)
Constructs a newDownloadAlongAction
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
protected static void
addToDownload(java.awt.geom.Area a, java.awt.geom.Rectangle2D r, java.util.Collection<java.awt.geom.Rectangle2D> results, double maxArea)
protected static java.util.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 void
confirmAndDownloadAreas(java.awt.geom.Area a, double maxArea, boolean osmDownload, boolean gpxDownload, java.lang.String title, boolean newLayer)
Area "a" contains the hull that we would like to download data for.protected PleaseWaitRunnable
createCalcTask(java.awt.geom.Path2D alongPath, DownloadAlongPanel panel, java.lang.String confirmTitle, boolean newLayer)
Create task that downloads areas along the given path using the values specified in the panel.protected abstract PleaseWaitRunnable
createTask()
Sub 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, waitFuture
-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Constructor Detail
-
DownloadAlongAction
protected DownloadAlongAction(java.lang.String name, java.lang.String iconName, java.lang.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 Detail
-
createTask
protected abstract PleaseWaitRunnable createTask()
Sub classes must override this method.- Returns:
- the task to start or null if nothing to do
-
addToDownload
protected static void addToDownload(java.awt.geom.Area a, java.awt.geom.Rectangle2D r, java.util.Collection<java.awt.geom.Rectangle2D> results, double maxArea)
-
confirmAndDownloadAreas
protected static void confirmAndDownloadAreas(java.awt.geom.Area a, double maxArea, boolean osmDownload, boolean gpxDownload, java.lang.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
protected static java.util.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.- 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(java.awt.geom.Path2D alongPath, DownloadAlongPanel panel, java.lang.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
public void actionPerformed(java.awt.event.ActionEvent e)
-
-