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 Boundsboundsprivate static java.util.HashMap<java.awt.Color,java.lang.String>closestGarminColorCacheprivate java.awt.ColorcolorCacheprivate GpxConstants.ColorFormatcolorFormatprivate doublelengthprivate ListenerList<IGpxTrack.GpxTrackChangeListener>listenersprivate 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_COURSE, 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 newGpxTrackfromGpxTrackSegmentobjects.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(IGpxTrack.GpxTrackChangeListener l)Add a listener that listens to changes in the GPX track.private BoundscalculateBounds()private doublecalculateLength()private doublecolorDist(java.awt.Color c1, java.awt.Color c2)voidconvertColor(GpxConstants.ColorFormat cFormat)Converts the color to the given format, if present.booleanequals(java.lang.Object obj)private voidfireInvalidate()BoundsgetBounds()Returns the track bounds.java.awt.ColorgetColor()Gets the color of this track.private java.awt.ColorgetColorFromExtension()java.util.Collection<IGpxTrackSegment>getSegments()Returns the track segments.inthashCode()voidinvalidate()Resets the color cachedoublelength()Returns the track length.voidput(java.lang.String key, java.lang.Object value)Put a key / value pair as a new attribute.voidremoveListener(IGpxTrack.GpxTrackChangeListener l)Remove a listener that listens to changes in the GPX track.voidsetColor(java.awt.Color color)Sets the color of this track.private voidsetColorExtensionGPXD(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 newGpxTrackfromGpxTrackSegmentobjects.- 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:IGpxTrackSets 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:IGpxTrackGets 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:WithAttributesPut a key / value pair as a new attribute. Overrides key / value pair with the same key (if present).- Specified by:
putin interfaceIWithAttributes- Overrides:
putin classWithAttributes- Parameters:
key- the keyvalue- the value
-
fireInvalidate
private void fireInvalidate()
-
getBounds
public Bounds getBounds()
Description copied from interface:IGpxTrackReturns the track bounds.
-
length
public double length()
Description copied from interface:IGpxTrackReturns the track length.
-
getSegments
public java.util.Collection<IGpxTrackSegment> getSegments()
Description copied from interface:IGpxTrackReturns the track segments.- Specified by:
getSegmentsin interfaceIGpxTrack- Returns:
- the track segments
-
hashCode
public int hashCode()
- Overrides:
hashCodein classWithAttributes
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classWithAttributes
-
addListener
public void addListener(IGpxTrack.GpxTrackChangeListener l)
Description copied from interface:IGpxTrackAdd a listener that listens to changes in the GPX track.- Specified by:
addListenerin interfaceIGpxTrack- Parameters:
l- The listener
-
removeListener
public void removeListener(IGpxTrack.GpxTrackChangeListener l)
Description copied from interface:IGpxTrackRemove a listener that listens to changes in the GPX track.- Specified by:
removeListenerin interfaceIGpxTrack- Parameters:
l- The listener
-
invalidate
public void invalidate()
Resets the color cache
-
-