Package org.openstreetmap.josm.data.gpx
Class GpxTrack
- java.lang.Object
-
- org.openstreetmap.josm.data.gpx.WithAttributes
-
- org.openstreetmap.josm.data.gpx.GpxTrack
-
- All Implemented Interfaces:
GpxConstants
,IGpxTrack
,IWithAttributes
public class GpxTrack extends WithAttributes implements IGpxTrack
GPX track. Note that the color attributes are not immutable and may be modified by the user.- Since:
- 15496
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.data.gpx.GpxConstants
GpxConstants.ColorFormat
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.data.gpx.IGpxTrack
IGpxTrack.GpxTrackChangeEvent, IGpxTrack.GpxTrackChangeListener
-
-
Field Summary
Fields Modifier and Type Field Description private Bounds
bounds
private static java.util.HashMap<java.awt.Color,java.lang.String>
closestGarminColorCache
private java.awt.Color
colorCache
private GpxConstants.ColorFormat
colorFormat
private double
length
private ListenerList<IGpxTrack.GpxTrackChangeListener>
listeners
private java.util.List<IGpxTrackSegment>
segments
-
Fields inherited from class org.openstreetmap.josm.data.gpx.WithAttributes
attr
-
Fields inherited from interface org.openstreetmap.josm.data.gpx.GpxConstants
EXTENSION_ABBREVIATIONS, FIX_VALUES, GARMIN_COLORS, GPX_CMT, GPX_DESC, GPX_NAME, GPX_PREFIX, GPX_SRC, JOSM_CREATOR_NAME, META_AUTHOR_EMAIL, META_AUTHOR_LINK, META_AUTHOR_NAME, META_BOUNDS, META_COPYRIGHT_AUTHOR, META_COPYRIGHT_LICENSE, META_COPYRIGHT_YEAR, META_DESC, META_KEYWORDS, META_LINKS, META_NAME, META_PREFIX, META_TIME, PT_AGEOFDGPSDATA, PT_DGPSID, PT_ELE, PT_FIX, PT_GEOIDHEIGHT, PT_HDOP, PT_MAGVAR, PT_PDOP, PT_SAT, PT_STD_HDEV, PT_STD_VDEV, PT_SYM, PT_TIME, PT_TYPE, PT_VDOP, RTE_TRK_KEYS, RTKLIB_AGE, RTKLIB_Q, RTKLIB_RATIO, RTKLIB_SDE, RTKLIB_SDEU, RTKLIB_SDN, RTKLIB_SDNE, RTKLIB_SDU, RTKLIB_SDUN, WPT_KEYS, XML_URI_EXTENSIONS_DRAWING, XML_URI_EXTENSIONS_GARMIN, XML_URI_EXTENSIONS_JOSM, XML_URI_XSD, XML_XSD_EXTENSIONS_DRAWING, XML_XSD_EXTENSIONS_GARMIN, XML_XSD_EXTENSIONS_JOSM
-
-
Constructor Summary
Constructors Constructor Description GpxTrack(java.util.Collection<java.util.Collection<WayPoint>> trackSegs, java.util.Map<java.lang.String,java.lang.Object> attributes)
Constructs a newGpxTrack
.GpxTrack(java.util.List<IGpxTrackSegment> trackSegs, java.util.Map<java.lang.String,java.lang.Object> attributes)
Constructs a newGpxTrack
fromGpxTrackSegment
objects.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(IGpxTrack.GpxTrackChangeListener l)
Add a listener that listens to changes in the GPX track.private Bounds
calculateBounds()
private double
calculateLength()
private double
colorDist(java.awt.Color c1, java.awt.Color c2)
void
convertColor(GpxConstants.ColorFormat cFormat)
Converts the color to the given format, if present.boolean
equals(java.lang.Object obj)
private void
fireInvalidate()
Bounds
getBounds()
Returns the track bounds.java.awt.Color
getColor()
Gets the color of this track.private java.awt.Color
getColorFromExtension()
java.util.Collection<IGpxTrackSegment>
getSegments()
Returns the track segments.int
hashCode()
void
invalidate()
Resets the color cachedouble
length()
Returns the track length.void
put(java.lang.String key, java.lang.Object value)
Put a key / value pair as a new attribute.void
removeListener(IGpxTrack.GpxTrackChangeListener l)
Remove a listener that listens to changes in the GPX track.void
setColor(java.awt.Color color)
Sets the color of this track.private void
setColorExtensionGPXD(java.awt.Color color, boolean invalidate)
-
Methods inherited from class org.openstreetmap.josm.data.gpx.WithAttributes
get, getAttributes, getCollection, getExtensions, getString, hasExtensions
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.data.gpx.IWithAttributes
get, getAttributes, getCollection, getExtensions, getString, hasExtensions
-
-
-
-
Field Detail
-
segments
private final java.util.List<IGpxTrackSegment> segments
-
length
private final double length
-
colorCache
private java.awt.Color colorCache
-
listeners
private final ListenerList<IGpxTrack.GpxTrackChangeListener> listeners
-
closestGarminColorCache
private static final java.util.HashMap<java.awt.Color,java.lang.String> closestGarminColorCache
-
colorFormat
private GpxConstants.ColorFormat colorFormat
-
-
Constructor Detail
-
GpxTrack
public GpxTrack(java.util.Collection<java.util.Collection<WayPoint>> trackSegs, java.util.Map<java.lang.String,java.lang.Object> attributes)
Constructs a newGpxTrack
.- Parameters:
trackSegs
- track segmentsattributes
- track attributes
-
GpxTrack
public GpxTrack(java.util.List<IGpxTrackSegment> trackSegs, java.util.Map<java.lang.String,java.lang.Object> attributes)
Constructs a newGpxTrack
fromGpxTrackSegment
objects.- Parameters:
trackSegs
- The segments to build the track from. Input is not deep-copied, which means the caller may reuse the same segments to build multiple GpxTrack instances from. This should not be a problem, since this object cannot modifythis.segments
.attributes
- Attributes for the GpxTrack, the input map is copied.
-
-
Method Detail
-
calculateLength
private double calculateLength()
-
calculateBounds
private Bounds calculateBounds()
-
setColor
public void setColor(java.awt.Color color)
Description copied from interface:IGpxTrack
Sets the color of this track. Not necessarily supported by all implementations.
-
setColorExtensionGPXD
private void setColorExtensionGPXD(java.awt.Color color, boolean invalidate)
-
getColor
public java.awt.Color getColor()
Description copied from interface:IGpxTrack
Gets the color of this track.
-
getColorFromExtension
private java.awt.Color getColorFromExtension()
-
convertColor
public void convertColor(GpxConstants.ColorFormat cFormat)
Converts the color to the given format, if present.- Parameters:
cFormat
- can be aGpxConstants.ColorFormat
-
colorDist
private double colorDist(java.awt.Color c1, java.awt.Color c2)
-
put
public void put(java.lang.String key, java.lang.Object value)
Description copied from class:WithAttributes
Put a key / value pair as a new attribute. Overrides key / value pair with the same key (if present).- Specified by:
put
in interfaceIWithAttributes
- Overrides:
put
in classWithAttributes
- Parameters:
key
- the keyvalue
- the value
-
fireInvalidate
private void fireInvalidate()
-
getBounds
public Bounds getBounds()
Description copied from interface:IGpxTrack
Returns the track bounds.
-
length
public double length()
Description copied from interface:IGpxTrack
Returns the track length.
-
getSegments
public java.util.Collection<IGpxTrackSegment> getSegments()
Description copied from interface:IGpxTrack
Returns the track segments.- Specified by:
getSegments
in interfaceIGpxTrack
- Returns:
- the track segments
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classWithAttributes
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classWithAttributes
-
addListener
public void addListener(IGpxTrack.GpxTrackChangeListener l)
Description copied from interface:IGpxTrack
Add a listener that listens to changes in the GPX track.- Specified by:
addListener
in interfaceIGpxTrack
- Parameters:
l
- The listener
-
removeListener
public void removeListener(IGpxTrack.GpxTrackChangeListener l)
Description copied from interface:IGpxTrack
Remove a listener that listens to changes in the GPX track.- Specified by:
removeListener
in interfaceIGpxTrack
- Parameters:
l
- The listener
-
invalidate
public void invalidate()
Resets the color cache
-
-