public class GpxLayer extends 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 GpxDrawHelper |
drawHelper |
private boolean |
isLocalFile |
private java.util.List<GpxTrack> |
lastTracks |
private int |
lastUpdateCount |
boolean[] |
trackVisibility |
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, thah 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. |
void |
destroy()
Called, when the layer is removed from the mapview and is going to be destroyed.
|
private void |
ensureTrackVisibilityLength()
ensures the trackVisibility array has the correct length without losing data.
|
void |
filterTracksByDate(java.util.Date fromDate,
java.util.Date toDate,
boolean showWithoutDate) |
java.io.File |
getAssociatedFile() |
protected ColorProperty |
getBaseColorProperty()
Gets the color property that stores the default color for this 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() |
javax.swing.Action[] |
getMenuEntries()
Returns list of actions.
|
static java.lang.String |
getTimespanForTrack(GpxTrack trk)
Returns a human readable string that shows the timespan of the given track
|
java.lang.String |
getToolTipText() |
boolean |
isChanged()
Check changed status of layer
|
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 |
isSavable()
Replies the savable state of this layer (i.e if it can be saved through a "File->Save" dialog).
|
private java.util.List<WayPoint> |
listVisibleSegments(Bounds box) |
void |
mergeFrom(Layer from)
Merges the given layer into this layer.
|
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) |
addPropertyChangeListener, fireFilterStateChanged, fireOpacityChanged, fireVisibleChanged, getColorProperty, getName, getOpacity, getViewProjectionBounds, hookUpMapView, isBackgroundLayer, isProjectionSupported, isRenamed, isVisible, nameSupportedProjections, onPostLoadFromFile, removePropertyChangeListener, rename, setBackgroundLayer, setFilterStateChanged, setName, setOpacity, setVisible, toggleVisible, toString
addInvalidationListener, attachToMapView, createMapViewPainter, invalidate, removeInvalidationListener
private final boolean isLocalFile
public boolean[] trackVisibility
private final java.util.List<GpxTrack> lastTracks
private int lastUpdateCount
private final GpxDrawHelper drawHelper
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 nameprotected ColorProperty getBaseColorProperty()
Layer
getBaseColorProperty
in class Layer
null
if this layer is not colored.public static java.lang.String getTimespanForTrack(GpxTrack trk)
trk
- The GPX track for which timespan is displayedpublic javax.swing.Icon getIcon()
Layer
public java.lang.Object getInfoComponent()
getInfoComponent
in class 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.private int sumUpdateCount()
public boolean isChanged()
Layer
public void filterTracksByDate(java.util.Date fromDate, java.util.Date toDate, boolean showWithoutDate)
public void mergeFrom(Layer from)
Layer
public void paint(java.awt.Graphics2D g, MapView mv, Bounds box)
MapViewPaintable
g
- Graphicsmv
- The object that can translate GeoPoints to screen coordinates.box
- Bounding boxprivate java.util.List<WayPoint> listVisibleSegments(Bounds box)
public void visitBoundingBox(BoundingXYVisitor v)
visitBoundingBox
in class Layer
public java.io.File getAssociatedFile()
getAssociatedFile
in class Layer
public void setAssociatedFile(java.io.File file)
setAssociatedFile
in class Layer
private void ensureTrackVisibilityLength()
public void projectionChanged(Projection oldValue, Projection newValue)
projectionChanged
in interface ProjectionChangeListener
projectionChanged
in class Layer
public boolean isSavable()
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 destroy()
Layer
destroy
in interface Destroyable
destroy
in class Layer