source: josm/trunk/src/org/openstreetmap/josm/data/gpx/IGpxTrack.java@ 15496

Last change on this file since 15496 was 15496, checked in by Don-vip, 4 years ago

fix #16796 - Rework of GPX track colors / layer preferences (patch by Bjoeni)

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.gpx;
3
4import java.awt.Color;
5import java.util.Collection;
6
7import org.openstreetmap.josm.data.Bounds;
8
9/**
10 * Gpx track. Implementations don't have to be immutable, but should always be thread safe.
11 * @since 15496
12 */
13public interface IGpxTrack extends IWithAttributes {
14
15 /**
16 * Returns the track segments.
17 * @return the track segments
18 */
19 Collection<IGpxTrackSegment> getSegments();
20
21 /**
22 * Returns the track bounds.
23 * @return the track bounds
24 */
25 Bounds getBounds();
26
27 /**
28 * Returns the track length.
29 * @return the track length
30 */
31 double length();
32
33 /**
34 * Gets the color of this track.
35 * @return The color, <code>null</code> if not set or not supported by the implementation.
36 * @since 15496
37 */
38 default Color getColor() {
39 return null;
40 }
41
42 /**
43 * Sets the color of this track. Not necessarily supported by all implementations.
44 * @param color
45 * @since 15496
46 */
47 default void setColor(Color color) {}
48
49 /**
50 * Add a listener that listens to changes in the GPX track.
51 * @param l The listener
52 */
53 default void addListener(GpxTrackChangeListener l) {
54 // nop
55 }
56
57 /**
58 * Remove a listener that listens to changes in the GPX track.
59 * @param l The listener
60 */
61 default void removeListener(GpxTrackChangeListener l) {
62 // nop
63 }
64
65 /**
66 * A listener that listens to GPX track changes.
67 * @author Michael Zangl
68 * @since 15496
69 */
70 @FunctionalInterface
71 interface GpxTrackChangeListener {
72 /**
73 * Called when the gpx data changed.
74 * @param e The event
75 */
76 void gpxDataChanged(GpxTrackChangeEvent e);
77 }
78
79 /**
80 * A track change event for the current track.
81 * @author Michael Zangl
82 * @since 15496
83 */
84 class GpxTrackChangeEvent {
85 private final IGpxTrack source;
86
87 GpxTrackChangeEvent(IGpxTrack source) {
88 super();
89 this.source = source;
90 }
91
92 /**
93 * Get the track that was changed.
94 * @return The track.
95 */
96 public IGpxTrack getSource() {
97 return source;
98 }
99 }
100}
Note: See TracBrowser for help on using the repository browser.