public class GpxLayer extends AbstractModifiableLayer implements ExpertToggleAction.ExpertModeChangeListener
Modifier and Type | Class and Description |
---|---|
static class |
GpxLayer.CombineTracksToSegmentedTrackAction
Action to merge tracks into a single segmented track
|
static class |
GpxLayer.SplitTrackSegementsToTracksAction
Action to split track segments into a multiple tracks with one segment each
|
static class |
GpxLayer.SplitTracksToLayersAction
Action to split tracks of one gpx layer into multiple gpx layers,
the result is one GPX track per gpx layer.
|
Layer.LayerAction, Layer.LayerGpxExportAction, Layer.LayerSaveAction, Layer.LayerSaveAsAction, Layer.MultiLayerAction, Layer.SeparatorLayerAction
AbstractMapViewPaintable.CompatibilityModeLayerPainter
MapViewPaintable.LayerPainter, MapViewPaintable.MapViewEvent, MapViewPaintable.PaintableInvalidationEvent, MapViewPaintable.PaintableInvalidationListener
Modifier and Type | Field and Description |
---|---|
GpxData |
data
GPX data
|
private GpxData.GpxDataChangeListener |
dataChangeListener
Added as field to be kept as reference.
|
private boolean |
isExpertMode |
private boolean |
isLocalFile |
private MarkerLayer |
linkedMarkerLayer
The MarkerLayer imported from the same file.
|
boolean[] |
trackVisibility
used by
ChooseTrackVisibilityAction to determine which tracks to show/hide
Call AbstractMapViewPaintable.invalidate() after each change!
TODO: Make it private, make it respond to track changes. |
FILTER_STATE_PROP, NAME_PROP, OPACITY_PROP, propertyChangeSupport, VISIBLE_PROP
Constructor and Description |
---|
GpxLayer(GpxData d)
Constructs a new
GpxLayer without name. |
GpxLayer(GpxData d,
java.lang.String name)
Constructs a new
GpxLayer with a given name. |
GpxLayer(GpxData d,
java.lang.String name,
boolean isLocal)
Constructs a new
GpxLayer with a given name, that can be attached to a local file. |
Modifier and Type | Method and Description |
---|---|
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. |
protected MapViewPaintable.LayerPainter |
createMapViewPainter(MapViewPaintable.MapViewEvent event)
Creates a new LayerPainter.
|
void |
expertChanged(boolean isExpert)
The expert mode changed.
|
void |
filterTracksByDate(java.util.Date fromDate,
java.util.Date toDate,
boolean showWithoutDate)
Shows/hides all tracks of a given date range by setting them to visible/invisible.
|
java.io.File |
getAssociatedFile()
Gets the associated file for this layer.
|
java.lang.String |
getChangesetSourceTag()
Get the source for the layer
|
java.awt.Color |
getColor()
Return the current color of the layer
|
LayerPositionStrategy |
getDefaultLayerPosition()
Gets the strategy that specifies where this layer should be inserted in a layer list.
|
javax.swing.Icon |
getIcon()
Return a representative small image for this layer.
|
java.lang.Object |
getInfoComponent()
Gets the layer information to display to the user.
|
MarkerLayer |
getLinkedMarkerLayer() |
javax.swing.Action[] |
getMenuEntries()
Returns list of actions.
|
static java.lang.String |
getTimespanForTrack(IGpxTrack trk)
Returns a human readable string that shows the timespan of the given track
|
java.lang.String |
getToolTipText() |
boolean |
hasColor() |
boolean |
isInfoResizable()
Determines if info dialog can be resized (false by default).
|
boolean |
isLocalFile()
Determines if data is attached to a local file.
|
boolean |
isMergable(Layer other) |
boolean |
isModified()
Determines if data managed by this layer has been modified.
|
boolean |
isSavable()
Replies the savable state of this layer (i.e if it can be saved through a "File->Save" dialog).
|
void |
mergeFrom(GpxLayer from,
boolean cutOverlapping,
boolean connect)
Merges the given GpxLayer into this layer and can remove timewise overlapping parts of the given track
|
void |
mergeFrom(Layer from)
Merges the given layer into this layer.
|
void |
onPostSaveToFile()
Initializes the layer after a successful save of data to a file.
|
void |
paint(java.awt.Graphics2D g,
MapView mv,
Bounds bbox)
Paint the dataset using the engine set.
|
void |
projectionChanged(Projection oldValue,
Projection newValue) |
boolean |
requiresSaveToFile()
Determines if the data managed by this layer needs to be saved to
a file.
|
void |
setAssociatedFile(java.io.File file)
Sets the associated file for this layer.
|
void |
setColor(java.awt.Color color)
Sets the color for this layer.
|
void |
setLinkedMarkerLayer(MarkerLayer linkedMarkerLayer) |
void |
visitBoundingBox(BoundingXYVisitor v)
Visits the content bounds of this layer.
|
createUploadTask, getUploadDialog, isDownloadable, isLocked, isUploadable, isUploadDiscouraged, isUploadInProgress, lock, onPostUploadToServer, requiresUploadToServer, unlock
addPropertyChangeListener, destroy, fireFilterStateChanged, fireOpacityChanged, fireVisibleChanged, getName, getOpacity, getViewProjectionBounds, hookUpMapView, isBackgroundLayer, isProjectionSupported, isRenamed, isVisible, nameSupportedProjections, onPostLoadFromFile, removePropertyChangeListener, rename, setBackgroundLayer, setFilterStateChanged, setName, setOpacity, setVisible, toggleVisible, toString
addInvalidationListener, attachToMapView, invalidate, removeInvalidationListener
private boolean isLocalFile
private boolean isExpertMode
public boolean[] trackVisibility
ChooseTrackVisibilityAction
to determine which tracks to show/hide
Call AbstractMapViewPaintable.invalidate()
after each change!
TODO: Make it private, make it respond to track changes.private final GpxData.GpxDataChangeListener dataChangeListener
private MarkerLayer linkedMarkerLayer
public GpxLayer(GpxData d)
GpxLayer
without name.d
- GPX datapublic GpxLayer(GpxData d, java.lang.String name)
GpxLayer
with a given name.d
- GPX dataname
- layer namepublic java.awt.Color getColor()
Layer
public void setColor(java.awt.Color color)
Layer
public boolean hasColor()
public static java.lang.String getTimespanForTrack(IGpxTrack trk)
trk
- The GPX track for which timespan is displayedpublic javax.swing.Icon getIcon()
Layer
public java.lang.Object getInfoComponent()
Layer
getInfoComponent
in class Layer
Component
describing the layer.public boolean isInfoResizable()
Layer
isInfoResizable
in class Layer
true
if the info dialog can be resized, false
otherwisepublic javax.swing.Action[] getMenuEntries()
Layer
Layer.SeparatorLayerAction.INSTANCE
instead of new JSeparatorgetMenuEntries
in class Layer
public boolean isLocalFile()
true
if data is attached to a local file, false
otherwisepublic java.lang.String getToolTipText()
getToolTipText
in class Layer
public boolean isMergable(Layer other)
isMergable
in class Layer
other
- The other layer that is tested to be mergable with this.public void filterTracksByDate(java.util.Date fromDate, java.util.Date toDate, boolean showWithoutDate)
fromDate
- The min datetoDate
- The max dateshowWithoutDate
- Include tracks that don't have any date set..public void mergeFrom(Layer from)
Layer
public void mergeFrom(GpxLayer from, boolean cutOverlapping, boolean connect)
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 cutspublic void visitBoundingBox(BoundingXYVisitor v)
Layer
visitBoundingBox
in class Layer
v
- The visitor that gets notified about the contents of this layer.public java.io.File getAssociatedFile()
Layer
getAssociatedFile
in class Layer
null
if it is unset.Layer.setAssociatedFile(File)
public void setAssociatedFile(java.io.File file)
Layer
setAssociatedFile
in class Layer
file
- The file, may be null
public MarkerLayer getLinkedMarkerLayer()
public void setLinkedMarkerLayer(MarkerLayer linkedMarkerLayer)
linkedMarkerLayer
- the linked MarkerLayerpublic void projectionChanged(Projection oldValue, Projection newValue)
projectionChanged
in interface ProjectionChangeListener
projectionChanged
in class Layer
public boolean isSavable()
Layer
isSavable
in interface SaveToFile
isSavable
in class Layer
public boolean checkSaveConditions()
Layer
checkSaveConditions
in class Layer
true
, if it is safe to save.public java.io.File createAndOpenSaveFileChooser()
Layer
createAndOpenSaveFileChooser
in class Layer
File
SaveActionBase.createAndOpenSaveFileChooser(java.lang.String, org.openstreetmap.josm.actions.ExtensionFileFilter)
public LayerPositionStrategy getDefaultLayerPosition()
Layer
getDefaultLayerPosition
in class Layer
public void paint(java.awt.Graphics2D g, MapView mv, Bounds bbox)
MapViewPaintable
paint
in interface MapViewPaintable
g
- Graphicsmv
- The object that can translate GeoPoints to screen coordinates.bbox
- Bounding boxprotected MapViewPaintable.LayerPainter createMapViewPainter(MapViewPaintable.MapViewEvent event)
AbstractMapViewPaintable
createMapViewPainter
in class AbstractMapViewPaintable
event
- The event that triggered the creation.public void expertChanged(boolean isExpert)
ExpertToggleAction.ExpertModeChangeListener
expertChanged
in interface ExpertToggleAction.ExpertModeChangeListener
isExpert
- true
if expert mode was enabled, false otherwise.public boolean isModified()
AbstractModifiableLayer
isModified
in class AbstractModifiableLayer
public boolean requiresSaveToFile()
SaveToFile
requiresSaveToFile
in interface SaveToFile
requiresSaveToFile
in class AbstractModifiableLayer
true
if the data managed by this layer needs to be saved to a file; false
, otherwisepublic void onPostSaveToFile()
SaveToFile
onPostSaveToFile
in interface SaveToFile
onPostSaveToFile
in class AbstractModifiableLayer
public java.lang.String getChangesetSourceTag()
Layer
getChangesetSourceTag
in class Layer
null