org.openstreetmap.josm.gui.layer
Class GpxLayer

java.lang.Object
  extended by org.openstreetmap.josm.gui.layer.Layer
      extended by org.openstreetmap.josm.gui.layer.GpxLayer
All Implemented Interfaces:
ProjectionChangeListener, MapViewPaintable, Destroyable

public class GpxLayer
extends Layer


Nested Class Summary
 class GpxLayer.ChooseTrackVisibilityAction
          allows the user to choose which of the downloaded tracks should be displayed.
(package private) static class GpxLayer.colorModes
           
 class GpxLayer.ConvertToDataLayerAction
           
private  class GpxLayer.CustomizeDrawing
           
 class GpxLayer.DownloadAlongTrackAction
          Action that issues a series of download requests to the API, following the GPX track.
 class GpxLayer.DownloadWmsAlongTrackAction
           
private  class GpxLayer.ImportAudio
           
private  class GpxLayer.ImportImages
           
private static class GpxLayer.Markers
           
private  class GpxLayer.MarkersFromNamedPoins
           
 
Nested classes/interfaces inherited from class org.openstreetmap.josm.gui.layer.Layer
Layer.LayerAction, Layer.LayerGpxExportAction, Layer.LayerSaveAction, Layer.LayerSaveAsAction, Layer.MultiLayerAction, Layer.SeparatorLayerAction
 
Field Summary
private static java.awt.Color[] colors
           
private static java.awt.Color[] colors_cyclic
           
private  boolean computeCacheColorDynamic
           
private  GpxLayer.colorModes computeCacheColored
           
private  int computeCacheColorTracksTune
           
private  java.awt.Color computeCacheColorUsed
           
private  boolean computeCacheInSync
           
private  int computeCacheMaxLineLengthUsed
           
 GpxData data
           
private static int[][] dir
           
private  boolean isLocalFile
           
private  java.util.List<GpxTrack> lastTracks
           
private  int lastUpdateCount
           
private static int ll0
           
protected static double PHI
           
private static java.lang.String PREF_DOWNLOAD_ALONG_TRACK_AREA
           
private static java.lang.String PREF_DOWNLOAD_ALONG_TRACK_DISTANCE
           
private static java.lang.String PREF_DOWNLOAD_ALONG_TRACK_NEAR
           
private static int sl4
           
private static int sl9
           
private  boolean[] trackVisibility
           
 
Fields inherited from class org.openstreetmap.josm.gui.layer.Layer
ICON_SIZE, NAME_PROP, OPACITY_PROP, propertyChangeSupport, VISIBLE_PROP
 
Constructor Summary
GpxLayer(GpxData d)
           
GpxLayer(GpxData d, java.lang.String name)
           
GpxLayer(GpxData d, java.lang.String name, boolean isLocal)
           
 
Method Summary
private static void addToDownload(java.awt.geom.Area a, java.awt.geom.Rectangle2D r, java.util.Collection<java.awt.geom.Rectangle2D> results, double max_area)
           
 boolean checkSaveConditions()
          Checks whether it is ok to launch a save (whether we have data, there is no conflict etc.)
 java.io.File createAndOpenSaveFileChooser()
          Creates a new "Save" dialog for this layer and makes it visible.
When the user has chosen a file, checks the file extension, and confirms overwrite if needed.
private  void ensureTrackVisibilityLength()
          ensures the trackVisibility array has the correct length without losing data.
 java.io.File getAssociatedFile()
           
 java.awt.Color getColor(boolean ignoreCustom)
          Return a Color for this layer.
 GpxLayer.colorModes getColorMode()
           
static java.awt.Color getGenericColor()
           
 javax.swing.Icon getIcon()
          Return a representative small image for this layer.
 java.lang.Object getInfoComponent()
           
 javax.swing.Action[] getMenuEntries()
          Returns list of actions.
private static java.lang.String getTimespanForTrack(GpxTrack trk)
          returns a human readable string that shows the timespan of the given track
 java.lang.String getToolTipText()
           
private  void importAudio(java.io.File wavFile, MarkerLayer ml, double firstStartTime, GpxLayer.Markers markers)
          Makes a new marker layer derived from this GpxLayer containing at least one audio marker which the given audio file is associated with.
 boolean isChanged()
          Check changed status of layer
 boolean isMergable(Layer other)
           
 boolean isSavable()
          Replies the savable state of this layer (i.e if it can be saved through a "File->Save" dialog).
 void mergeFrom(Layer from)
          Merges the given layer into this layer.
 WayPoint nearestPointOnTrack(EastNorth P, double tolerance)
          Makes a WayPoint at the projection of point P onto the track providing P is less than tolerance away from the track
 void paint(java.awt.Graphics2D g, MapView mv, Bounds box)
          Paint the dataset using the engine set.
 void projectionChanged(Projection oldValue, Projection newValue)
           
 void setAssociatedFile(java.io.File file)
           
private  int sumUpdateCount()
           
 void visitBoundingBox(BoundingXYVisitor v)
           
private static float w(float x)
          transition function: w(0)=1, w(1)=0, 0<=w(x)<=1
 
Methods inherited from class org.openstreetmap.josm.gui.layer.Layer
addPropertyChangeListener, destroy, fireOpacityChanged, fireVisibleChanged, getName, getOpacity, hookUpMapView, isBackgroundLayer, isProjectionSupported, isVisible, nameSupportedProjections, onPostLoadFromFile, removePropertyChangeListener, setBackgroundLayer, setName, setOpacity, setVisible, toggleVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREF_DOWNLOAD_ALONG_TRACK_DISTANCE

private static final java.lang.String PREF_DOWNLOAD_ALONG_TRACK_DISTANCE
See Also:
Constant Field Values

PREF_DOWNLOAD_ALONG_TRACK_AREA

private static final java.lang.String PREF_DOWNLOAD_ALONG_TRACK_AREA
See Also:
Constant Field Values

PREF_DOWNLOAD_ALONG_TRACK_NEAR

private static final java.lang.String PREF_DOWNLOAD_ALONG_TRACK_NEAR
See Also:
Constant Field Values

data

public GpxData data

PHI

protected static final double PHI

computeCacheInSync

private boolean computeCacheInSync

computeCacheMaxLineLengthUsed

private int computeCacheMaxLineLengthUsed

computeCacheColorUsed

private java.awt.Color computeCacheColorUsed

computeCacheColorDynamic

private boolean computeCacheColorDynamic

computeCacheColored

private GpxLayer.colorModes computeCacheColored

computeCacheColorTracksTune

private int computeCacheColorTracksTune

isLocalFile

private boolean isLocalFile

trackVisibility

private boolean[] trackVisibility

lastTracks

private final java.util.List<GpxTrack> lastTracks

lastUpdateCount

private int lastUpdateCount

colors

private static final java.awt.Color[] colors

colors_cyclic

private static final java.awt.Color[] colors_cyclic

ll0

private static final int ll0
See Also:
Constant Field Values

sl4

private static final int sl4
See Also:
Constant Field Values

sl9

private static final int sl9
See Also:
Constant Field Values

dir

private static final int[][] dir
Constructor Detail

GpxLayer

public GpxLayer(GpxData d)

GpxLayer

public GpxLayer(GpxData d,
                java.lang.String name)

GpxLayer

public GpxLayer(GpxData d,
                java.lang.String name,
                boolean isLocal)
Method Detail

getTimespanForTrack

private static java.lang.String getTimespanForTrack(GpxTrack trk)
returns a human readable string that shows the timespan of the given track


getIcon

public javax.swing.Icon getIcon()
Description copied from class: Layer
Return a representative small image for this layer. The image must not be larger than 64 pixel in any dimension.

Specified by:
getIcon in class Layer

getInfoComponent

public java.lang.Object getInfoComponent()
Specified by:
getInfoComponent in class Layer

getColor

public java.awt.Color getColor(boolean ignoreCustom)
Description copied from class: Layer
Return a Color for this layer. Return null when no color specified.

Overrides:
getColor in class Layer
Parameters:
ignoreCustom - Custom color should return null, as no default color is used. When this is true, then even for custom coloring the base color is returned - mainly for layer internal use.

getColorMode

public GpxLayer.colorModes getColorMode()

getGenericColor

public static java.awt.Color getGenericColor()

getMenuEntries

public javax.swing.Action[] getMenuEntries()
Description copied from class: Layer
Returns list of actions. Action can implement LayerAction interface when it needs to be represented by other menu component than JMenuItem or when it supports multiple layers. Actions that support multiple layers should also have correct equals implementation. Use SeparatorLayerAction.INSTANCE instead of new JSeparator

Specified by:
getMenuEntries in class Layer

getToolTipText

public java.lang.String getToolTipText()
Specified by:
getToolTipText in class Layer
Returns:
A small tooltip hint about some statistics for this layer.

isMergable

public boolean isMergable(Layer other)
Specified by:
isMergable in class Layer
Parameters:
other - The other layer that is tested to be mergable with this.
Returns:
Whether the other layer can be merged into this layer.

sumUpdateCount

private int sumUpdateCount()

isChanged

public boolean isChanged()
Description copied from class: Layer
Check changed status of layer

Overrides:
isChanged in class Layer
Returns:
True if layer was changed since last paint

mergeFrom

public void mergeFrom(Layer from)
Description copied from class: Layer
Merges the given layer into this layer. Throws if the layer types are incompatible.

Specified by:
mergeFrom in class Layer
Parameters:
from - The layer that get merged into this one. After the merge, the other layer is not usable anymore and passing to one others mergeFrom should be one of the last things to do with a layer.

w

private static float w(float x)
transition function: w(0)=1, w(1)=0, 0<=w(x)<=1

Parameters:
x - number: 0<=x<=1
Returns:
the weighted value

paint

public void paint(java.awt.Graphics2D g,
                  MapView mv,
                  Bounds box)
Description copied from class: Layer
Paint the dataset using the engine set.

Specified by:
paint in interface MapViewPaintable
Specified by:
paint in class Layer
mv - The object that can translate GeoPoints to screen coordinates.

visitBoundingBox

public void visitBoundingBox(BoundingXYVisitor v)
Specified by:
visitBoundingBox in class Layer

getAssociatedFile

public java.io.File getAssociatedFile()
Overrides:
getAssociatedFile in class Layer

setAssociatedFile

public void setAssociatedFile(java.io.File file)
Overrides:
setAssociatedFile in class Layer

ensureTrackVisibilityLength

private final void ensureTrackVisibilityLength()
ensures the trackVisibility array has the correct length without losing data. additional entries are initialized to true;


addToDownload

private static void addToDownload(java.awt.geom.Area a,
                                  java.awt.geom.Rectangle2D r,
                                  java.util.Collection<java.awt.geom.Rectangle2D> results,
                                  double max_area)

importAudio

private void importAudio(java.io.File wavFile,
                         MarkerLayer ml,
                         double firstStartTime,
                         GpxLayer.Markers markers)
Makes a new marker layer derived from this GpxLayer containing at least one audio marker which the given audio file is associated with. Markers are derived from the following (a) explict waypoints in the GPX layer, or (b) named trackpoints in the GPX layer, or (d) timestamp on the wav file (e) (in future) voice recognised markers in the sound recording (f) a single marker at the beginning of the track

Parameters:
wavFile - : the file to be associated with the markers in the new marker layer
markers - : keeps track of warning messages to avoid repeated warnings

nearestPointOnTrack

public WayPoint nearestPointOnTrack(EastNorth P,
                                    double tolerance)
Makes a WayPoint at the projection of point P onto the track providing P is less than tolerance away from the track

Parameters:
P - : the point to determine the projection for
tolerance - : must be no further than this from the track
Returns:
the closest point on the track to P, which may be the first or last point if off the end of a segment, or may be null if nothing close enough

projectionChanged

public void projectionChanged(Projection oldValue,
                              Projection newValue)
Specified by:
projectionChanged in interface ProjectionChangeListener
Overrides:
projectionChanged in class Layer

isSavable

public boolean isSavable()
Description copied from class: Layer
Replies the savable state of this layer (i.e if it can be saved through a "File->Save" dialog).

Overrides:
isSavable in class Layer
Returns:
true if this layer can be saved to a file

checkSaveConditions

public boolean checkSaveConditions()
Description copied from class: Layer
Checks whether it is ok to launch a save (whether we have data, there is no conflict etc.)

Overrides:
checkSaveConditions in class Layer
Returns:
true, if it is safe to save.

createAndOpenSaveFileChooser

public java.io.File createAndOpenSaveFileChooser()
Description copied from class: Layer
Creates a new "Save" dialog for this layer and makes it visible.
When the user has chosen a file, checks the file extension, and confirms overwrite if needed.

Overrides:
createAndOpenSaveFileChooser in class Layer
Returns:
The output File
See Also:
SaveActionBase.createAndOpenSaveFileChooser(java.lang.String, org.openstreetmap.josm.actions.ExtensionFileFilter)


JOSM