]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/data/DataPoint.java
Version 13, August 2011
[GpsPrune.git] / tim / prune / data / DataPoint.java
index 7acd4f9e364314985d0ea2abb85996901352037b..3d17cbc5edec4797a3dd63fee6e58579bcdd6025 100644 (file)
@@ -17,7 +17,10 @@ public class DataPoint
        private Coordinate _latitude = null, _longitude = null;
        private Altitude _altitude;
        private Timestamp _timestamp = null;
+       /** Attached photo */
        private Photo _photo = null;
+       /** Attached audio clip */
+       private AudioClip _audio = null;
        private String _waypointName = null;
        private boolean _startOfSegment = false;
        private boolean _markedForDeletion = false;
@@ -152,12 +155,7 @@ public class DataPoint
                _fieldValues[fieldIndex] = inValue;
                // Increment edit count on all field edits except segment
                if (inField != Field.NEW_SEGMENT) {
-                       if (!inUndo) {
-                               _modifyCount++;
-                       }
-                       else {
-                               _modifyCount--;
-                       }
+                       setModified(inUndo);
                }
                // Change Coordinate, Altitude, Name or Timestamp fields after edit
                if (_altitude != null && _altitude.getFormat() != Altitude.Format.NO_FORMAT) {
@@ -170,6 +168,20 @@ public class DataPoint
                }
        }
 
+       /**
+        * Either increment or decrement the modify count, depending on whether it's an undo or not
+        * @param inUndo true for undo, false otherwise
+        */
+       public void setModified(boolean inUndo)
+       {
+               if (!inUndo) {
+                       _modifyCount++;
+               }
+               else {
+                       _modifyCount--;
+               }
+       }
+
        /**
         * @return field list for this point
         */
@@ -290,20 +302,51 @@ public class DataPoint
         * Set the photo for this data point
         * @param inPhoto Photo object
         */
-       public void setPhoto(Photo inPhoto)
-       {
+       public void setPhoto(Photo inPhoto) {
                _photo = inPhoto;
+               _modifyCount++;
        }
 
-
        /**
         * @return associated Photo object
         */
-       public Photo getPhoto()
-       {
+       public Photo getPhoto() {
                return _photo;
        }
 
+       /**
+        * Set the audio clip for this point
+        * @param inAudio audio object
+        */
+       public void setAudio(AudioClip inAudio) {
+               _audio = inAudio;
+               _modifyCount++;
+       }
+
+       /**
+        * @return associated audio object
+        */
+       public AudioClip getAudio() {
+               return _audio;
+       }
+
+       /**
+        * Attach the given media object according to type
+        * @param inMedia either a photo or an audio clip
+        */
+       public void attachMedia(MediaObject inMedia)
+       {
+               if (inMedia != null) {
+                       if (inMedia instanceof Photo) {
+                               setPhoto((Photo) inMedia);
+                               inMedia.setDataPoint(this);
+                       }
+                       else if (inMedia instanceof AudioClip) {
+                               setAudio((AudioClip) inMedia);
+                               inMedia.setDataPoint(this);
+                       }
+               }
+       }
 
        /**
         * @return true if the point is valid
@@ -313,6 +356,13 @@ public class DataPoint
                return _latitude.isValid() && _longitude.isValid();
        }
 
+       /**
+        * @return true if the point has either a photo or audio attached
+        */
+       public boolean hasMedia() {
+               return _photo != null || _audio != null;
+       }
+
        /**
         * Interpolate a set of points between this one and the given one
         * @param inEndPoint end point of interpolation