Package org.openstreetmap.josm.gui.layer
Class GpxLayer
java.lang.Object
org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable
org.openstreetmap.josm.gui.layer.Layer
org.openstreetmap.josm.gui.layer.AbstractModifiableLayer
org.openstreetmap.josm.gui.layer.GpxLayer
- All Implemented Interfaces:
ExpertToggleAction.ExpertModeChangeListener,GpxDataContainer,Lockable,ProjectionChangeListener,DownloadFromServer,JumpToMarkerActions.JumpToMarkerLayer,MapViewPaintable,SaveToFile,UploadToServer,Destroyable
public class GpxLayer
extends AbstractModifiableLayer
implements GpxDataContainer, ExpertToggleAction.ExpertModeChangeListener, JumpToMarkerActions.JumpToMarkerLayer
A layer that displays data from a Gpx file / the OSM gpx downloads.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAction to merge tracks into a single segmented trackstatic classAction to split track segments into a multiple tracks with one segment eachstatic classAction to split tracks of one gpx layer into multiple gpx layers, the result is one GPX track per gpx layer.Nested classes/interfaces inherited from class org.openstreetmap.josm.gui.layer.Layer
Layer.LayerAction, Layer.LayerGpxExportAction, Layer.LayerSaveAction, Layer.LayerSaveAsAction, Layer.MultiLayerAction, Layer.SeparatorLayerActionNested classes/interfaces inherited from class org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable
AbstractMapViewPaintable.CompatibilityModeLayerPainterNested classes/interfaces inherited from interface org.openstreetmap.josm.gui.layer.MapViewPaintable
MapViewPaintable.LayerPainter, MapViewPaintable.MapViewEvent, MapViewPaintable.PaintableInvalidationEvent, MapViewPaintable.PaintableInvalidationListener -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate IGpxTrackSegmentCurrent segment forJumpToMarkerActions.JumpToMarkerLayer.GPX dataprivate final GpxData.GpxDataChangeListenerAdded as field to be kept as reference.private booleanprivate booleanprivate MarkerLayerThe MarkerLayer imported from the same file.boolean[]used byChooseTrackVisibilityActionto determine which tracks to show/hideFields inherited from class org.openstreetmap.josm.gui.layer.AbstractModifiableLayer
IS_DIRTY_SYMBOL, REQUIRES_SAVE_TO_DISK_PROPFields inherited from class org.openstreetmap.josm.gui.layer.Layer
FILTER_STATE_PROP, NAME_PROP, OPACITY_PROP, propertyChangeSupport, VISIBLE_PROP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether it is ok to launch a save (whether we have data, there is no conflict etc.)Creates a new "Save" dialog for this layer and makes it visible.protected MapViewPaintable.LayerPainterCreates a new LayerPainter.voiddestroy()Called, when the layer is removed from the mapview and is going to be destroyed.voidexpertChanged(boolean isExpert) The expert mode changed.private voidprivate voidvoidfilterTracksByDate(Instant fromDate, Instant toDate, boolean showWithoutDate) Shows/hides all tracks of a given date range by setting them to visible/invisible.Gets the associated file for this layer.Get the source for the layergetColor()Return the current color of the layergetData()Get the data for the modifiable layerGets the strategy that specifies where this layer should be inserted in a layer list.Returns the GPX data.getIcon()Return a representative small image for this layer.Gets the layer information to display to the user.getLabel()Replies a label for this layer useful for UI elements.Returns the linked MarkerLayer.Action[]Returns list of actions.static StringReturns a human readable string that shows the timespan of the given trackReturns a small tooltip hint about some statistics for this layer.booleanhasColor()Determines whether the layer has / can handle colors.booleanDetermines if info dialog can be resized (false by default).booleanDetermines if data is attached to a local file.booleanisMergable(Layer other) Determines if the other layer can be merged into this layer.booleanDetermines if data managed by this layer has been modified.booleanReplies the savable state of this layer (i.e., if it can be saved through a "File → Save" dialog).private voidjumpToNext(List<IGpxTrackSegment> segments) voidJump (move the viewport) to the next track segment.voidJump (move the viewport) to the previous track segment.voidMerges the given GpxLayer into this layer and can remove timewise overlapping parts of the given trackvoidMerges the given layer into this layer.voidInitializes the layer after a successful save of data to a file.voidpaint(Graphics2D g, MapView mv, Bounds bbox) Paint the dataset using the engine set.voidprojectionChanged(Projection oldValue, Projection newValue) booleanDetermines if the data managed by this layer needs to be saved to a file.voidsetAssociatedFile(File file) Sets the associated file for this layer.voidSets the color for this layer.voidsetLinkedMarkerLayer(MarkerLayer linkedMarkerLayer) Sets the linked MarkerLayer.voidVisits the content bounds of this layer.Methods inherited from class org.openstreetmap.josm.gui.layer.AbstractModifiableLayer
autosave, createUploadTask, getUploadDialog, isDirty, isDownloadable, isLocked, isUploadable, isUploadDiscouraged, isUploadInProgress, lock, onPostUploadToServer, requiresUploadToServer, unlockMethods inherited from class org.openstreetmap.josm.gui.layer.Layer
addPropertyChangeListener, fireFilterStateChanged, fireOpacityChanged, fireVisibleChanged, getName, getOpacity, getViewProjectionBounds, hookUpMapView, isBackgroundLayer, isProjectionSupported, isRenamed, isVisible, nameSupportedProjections, onPostLoadFromFile, removePropertyChangeListener, rename, setBackgroundLayer, setFilterStateChanged, setName, setOpacity, setVisible, toggleVisible, toStringMethods inherited from class org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable
addInvalidationListener, attachToMapView, invalidate, removeInvalidationListener
-
Field Details
-
data
GPX data -
isLocalFile
-
isExpertMode
-
trackVisibility
used byChooseTrackVisibilityActionto determine which tracks to show/hideCall
AbstractMapViewPaintable.invalidate()after each change!TODO: Make it private, make it respond to track changes.
-
dataChangeListener
Added as field to be kept as reference. -
linkedMarkerLayer
The MarkerLayer imported from the same file. -
currentSegment
Current segment forJumpToMarkerActions.JumpToMarkerLayer.
-
-
Constructor Details
-
GpxLayer
Constructs a newGpxLayerwithout name.- Parameters:
d- GPX data
-
GpxLayer
Constructs a newGpxLayerwith a given name.- Parameters:
d- GPX dataname- layer name
-
GpxLayer
Constructs a newGpxLayerwith a given name, that can be attached to a local file.- Parameters:
d- GPX dataname- layer nameisLocal- whether data is attached to a local file
-
-
Method Details
-
getColor
Description copied from class:LayerReturn the current color of the layer -
setColor
Description copied from class:LayerSets the color for this layer. Nothing happens if not supported by the layer -
hasColor
Description copied from class:LayerDetermines whether the layer has / can handle colors. -
getTimespanForTrack
Returns a human readable string that shows the timespan of the given track- Parameters:
trk- The GPX track for which timespan is displayed- Returns:
- The timespan as a string
-
getIcon
Description copied from class:LayerReturn a representative small image for this layer. The image must not be larger than 64 pixel in any dimension. -
getInfoComponent
Description copied from class:LayerGets the layer information to display to the user. This is used if the user requests information about this layer. It should display a description of the layer content.- Specified by:
getInfoComponentin classLayer- Returns:
- Either a String or a
Componentdescribing the layer.
-
fillDataInfoComponent
-
isInfoResizable
Description copied from class:LayerDetermines if info dialog can be resized (false by default).- Overrides:
isInfoResizablein classLayer- Returns:
trueif the info dialog can be resized,falseotherwise
-
getMenuEntries
Description copied from class:LayerReturns 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
Layer.SeparatorLayerAction.INSTANCEinstead of new JSeparator- Specified by:
getMenuEntriesin classLayer- Returns:
- menu actions for this layer
-
isLocalFile
Determines if data is attached to a local file.- Returns:
trueif data is attached to a local file,falseotherwise
-
getToolTipText
Description copied from class:LayerReturns a small tooltip hint about some statistics for this layer.- Specified by:
getToolTipTextin classLayer- Returns:
- A small tooltip hint about some statistics for this layer.
-
fillDataToolTipText
-
isMergable
Description copied from class:LayerDetermines if the other layer can be merged into this layer.- Specified by:
isMergablein classLayer- Parameters:
other- The other layer that is tested to be mergable with this.- Returns:
- Whether the other layer can be merged into this layer.
-
filterTracksByDate
Shows/hides all tracks of a given date range by setting them to visible/invisible.- Parameters:
fromDate- The min datetoDate- The max dateshowWithoutDate- Include tracks that don't have any date set..
-
mergeFrom
Description copied from class:LayerMerges the given layer into this layer. Throws if the layer types are incompatible. -
mergeFrom
Merges the given GpxLayer into this layer and can remove timewise overlapping parts of the given track- Parameters:
from- The GpxLayer that gets merged into this onecutOverlapping- whether overlapping parts of the given track should be removedconnect- whether the tracks should be connected on cuts- Since:
- 14338
-
getLabel
Description copied from class:LayerReplies a label for this layer useful for UI elements. Defaults to the layer name -
visitBoundingBox
Description copied from class:LayerVisits the content bounds of this layer. The behavior of this method depends on the layer, but each implementation should attempt to cover the relevant content of the layer in this method.- Specified by:
visitBoundingBoxin classLayer- Parameters:
v- The visitor that gets notified about the contents of this layer.
-
getAssociatedFile
Description copied from class:LayerGets the associated file for this layer.- Overrides:
getAssociatedFilein classLayer- Returns:
- The file or
nullif it is unset. - See Also:
-
setAssociatedFile
Description copied from class:LayerSets the associated file for this layer.The associated file might be the one that the user opened.
- Overrides:
setAssociatedFilein classLayer- Parameters:
file- The file, may benull
-
getLinkedMarkerLayer
Returns the linked MarkerLayer.- Returns:
- the linked MarkerLayer (imported from the same file)
- Since:
- 15496
-
setLinkedMarkerLayer
Sets the linked MarkerLayer.- Parameters:
linkedMarkerLayer- the linked MarkerLayer- Since:
- 15496
-
projectionChanged
- Specified by:
projectionChangedin interfaceProjectionChangeListener- Overrides:
projectionChangedin classLayer
-
isSavable
Description copied from class:LayerReplies the savable state of this layer (i.e., if it can be saved through a "File → Save" dialog).- Specified by:
isSavablein interfaceSaveToFile- Overrides:
isSavablein classLayer- Returns:
- true if this layer can be saved to a file
-
checkSaveConditions
Description copied from class:LayerChecks whether it is ok to launch a save (whether we have data, there is no conflict etc.)- Overrides:
checkSaveConditionsin classLayer- Returns:
true, if it is safe to save.
-
createAndOpenSaveFileChooser
Description copied from class:LayerCreates a new "Save" dialog for this layer and makes it visible.When the user has chosen a file, checks the file extension, and confirms overwriting if needed.
- Overrides:
createAndOpenSaveFileChooserin classLayer- Returns:
- The output
File - See Also:
-
getDefaultLayerPosition
Description copied from class:LayerGets the strategy that specifies where this layer should be inserted in a layer list.- Overrides:
getDefaultLayerPositionin classLayer- Returns:
- That strategy.
-
paint
Description copied from interface:MapViewPaintablePaint the dataset using the engine set.- Specified by:
paintin interfaceMapViewPaintable- Parameters:
g- Graphicsmv- The object that can translate GeoPoints to screen coordinates.bbox- Bounding box
-
createMapViewPainter
Description copied from class:AbstractMapViewPaintableCreates a new LayerPainter.- Overrides:
createMapViewPainterin classAbstractMapViewPaintable- Parameters:
event- The event that triggered the creation.- Returns:
- The painter.
-
expertChanged
Description copied from interface:ExpertToggleAction.ExpertModeChangeListenerThe expert mode changed.- Specified by:
expertChangedin interfaceExpertToggleAction.ExpertModeChangeListener- Parameters:
isExpert-trueif expert mode was enabled, false otherwise.
-
isModified
Description copied from class:AbstractModifiableLayerDetermines if data managed by this layer has been modified.- Specified by:
isModifiedin classAbstractModifiableLayer- Returns:
- true if data has been modified; false, otherwise
-
requiresSaveToFile
Description copied from interface:SaveToFileDetermines if the data managed by this layer needs to be saved to a file. Only replies true if a file is assigned to this layer and if the data managed by this layer has been modified since the last save operation to the file.- Specified by:
requiresSaveToFilein interfaceSaveToFile- Overrides:
requiresSaveToFilein classAbstractModifiableLayer- Returns:
trueif the data managed by this layer needs to be saved to a file;false, otherwise
-
onPostSaveToFile
Description copied from interface:SaveToFileInitializes the layer after a successful save of data to a file.- Specified by:
onPostSaveToFilein interfaceSaveToFile- Overrides:
onPostSaveToFilein classAbstractModifiableLayer
-
getChangesetSourceTag
Description copied from class:LayerGet the source for the layer- Overrides:
getChangesetSourceTagin classLayer- Returns:
- The string for the changeset source tag or
null
-
getData
Description copied from class:AbstractModifiableLayerGet the data for the modifiable layer- Overrides:
getDatain classAbstractModifiableLayer- Returns:
- The data object
-
getGpxData
Description copied from interface:GpxDataContainerReturns the GPX data.- Specified by:
getGpxDatain interfaceGpxDataContainer- Returns:
- the GPX data
-
jumpToNextMarker
Jump (move the viewport) to the next track segment.- Specified by:
jumpToNextMarkerin interfaceJumpToMarkerActions.JumpToMarkerLayer
-
jumpToPreviousMarker
Jump (move the viewport) to the previous track segment.- Specified by:
jumpToPreviousMarkerin interfaceJumpToMarkerActions.JumpToMarkerLayer
-
jumpToNext
-
destroy
Description copied from class:LayerCalled, when the layer is removed from the mapview and is going to be destroyed.This is because the Layer constructor cannot add itself safely as a listener to the layerlist dialog, because there may be no such dialog yet (loaded via command line parameter).
- Specified by:
destroyin interfaceDestroyable- Overrides:
destroyin classLayer
-