+
+
+ /**
+ * Select the given DataPoint
+ * @param inPoint DataPoint object to select
+ */
+ public void selectPoint(DataPoint inPoint)
+ {
+ selectPoint(_track.getPointIndex(inPoint));
+ }
+
+ /**
+ * Select the data point with the given index
+ * @param inPointIndex index of DataPoint to select, or -1 for none
+ */
+ public void selectPoint(int inPointIndex)
+ {
+ if (_selection.getCurrentPointIndex() == inPointIndex || inPointIndex >= _track.getNumPoints()) {return;}
+ DataPoint selectedPoint = _track.getPoint(inPointIndex);
+ // get the index of the current photo
+ int photoIndex = _selection.getCurrentPhotoIndex();
+ // Check if point has photo or not
+ boolean pointHasPhoto = inPointIndex >= 0 && selectedPoint.getPhoto() != null;
+ if (pointHasPhoto) {
+ photoIndex = _photoList.getPhotoIndex(selectedPoint.getPhoto());
+ }
+ else if (photoIndex < 0 || _photoList.getPhoto(photoIndex).isConnected()) {
+ // selected point hasn't got a photo - deselect photo if necessary
+ photoIndex = -1;
+ }
+ // Check if point has an audio item or not
+ int audioIndex = _selection.getCurrentAudioIndex();
+ boolean pointHasAudio = inPointIndex >= 0 && selectedPoint.getAudio() != null;
+ if (pointHasAudio) {
+ audioIndex = _audioList.getAudioIndex(selectedPoint.getAudio());
+ }
+ else if (audioIndex < 0 || _audioList.getAudio(audioIndex).isConnected()) {
+ // deselect current audio file
+ audioIndex = -1;
+ }
+ // give to selection
+ _selection.selectPointPhotoAudio(inPointIndex, photoIndex, audioIndex);
+ }
+
+ /**
+ * Select the given Photo and its point if any
+ * @param inPhotoIndex index of photo to select
+ */
+ public void selectPhoto(int inPhotoIndex)
+ {
+ if (_selection.getCurrentPhotoIndex() == inPhotoIndex) {return;}
+ // Photo is primary selection here, not as a result of a point selection
+ // Therefore the photo selection takes priority, deselecting point if necessary
+ // Find Photo object
+ Photo photo = _photoList.getPhoto(inPhotoIndex);
+ int pointIndex = _selection.getCurrentPointIndex();
+ DataPoint currPoint = getCurrentPoint();
+ if (photo != null)
+ {
+ // Has the photo got a point?
+ if (photo.isConnected()) {
+ pointIndex = _track.getPointIndex(photo.getDataPoint());
+ }
+ else {
+ // Check whether to deselect current point or not if photo not correlated
+ if (pointIndex >= 0 && _track.getPoint(pointIndex).getPhoto() != null) {
+ pointIndex = -1;
+ }
+ }
+ }
+ else {
+ // no photo, but maybe need to deselect point
+ if (currPoint != null && currPoint.getPhoto() != null) {
+ pointIndex = -1;
+ }
+ }
+ // Has the new point got an audio file?
+ DataPoint selectedPoint = _track.getPoint(pointIndex);
+ int audioIndex = _selection.getCurrentAudioIndex();
+ if (selectedPoint != null) {
+ if (selectedPoint.getAudio() != null) audioIndex = _audioList.getAudioIndex(selectedPoint.getAudio());
+ }
+ else {
+ if (selectedPoint != currPoint && currPoint.getAudio() != null) {audioIndex = -1;}
+ }
+ // give to selection object
+ _selection.selectPointPhotoAudio(pointIndex, inPhotoIndex, audioIndex);
+ }
+
+ /**
+ * Select the given audio object and its point if any
+ * @param inAudioIndex index of audio item to select
+ */
+ public void selectAudio(int inAudioIndex)
+ {
+ if (_selection.getCurrentAudioIndex() == inAudioIndex) {return;}
+ // Audio selection takes priority, deselecting point if necessary
+ AudioFile audio = _audioList.getAudio(inAudioIndex);
+ int pointIndex = _selection.getCurrentPointIndex();
+ DataPoint currPoint = getCurrentPoint();
+ if (audio != null)
+ {
+ // Find point object and its index
+ if (audio.isConnected()) {
+ pointIndex = _track.getPointIndex(audio.getDataPoint());
+ }
+ else {
+ // Check whether to deselect current point or not if audio not correlated
+ if (pointIndex >= 0 && _track.getPoint(pointIndex).getAudio() != null) {
+ pointIndex = -1;
+ }
+ }
+ }
+ else {
+ // check if current point has audio or not
+ if (currPoint != null && currPoint.getAudio() != null) {
+ pointIndex = -1;
+ }
+ }
+ // Has the new point got a photo?
+ DataPoint selectedPoint = _track.getPoint(pointIndex);
+ int photoIndex = _selection.getCurrentPhotoIndex();
+ if (selectedPoint != null) {
+ if (selectedPoint.getPhoto() != null) photoIndex = _photoList.getPhotoIndex(selectedPoint.getPhoto());
+ }
+ else {
+ if (selectedPoint != currPoint && currPoint.getPhoto() != null) {photoIndex = -1;}
+ }
+ // give to selection object
+ _selection.selectPointPhotoAudio(pointIndex, photoIndex, inAudioIndex);
+ }
+
+
+ /**
+ * Extend the current selection to end at the given point, eg by shift-clicking
+ * @param inPointNum index of end point
+ */
+ public void extendSelection(int inPointNum)
+ {
+ // See whether to start selection from current range start or current point
+ int rangeStart = _selection.getStart();
+ if (rangeStart < 0 || _selection.getCurrentPointIndex() != _selection.getEnd()) {
+ rangeStart = _selection.getCurrentPointIndex();
+ }
+ selectPoint(inPointNum);
+ if (rangeStart < inPointNum) {
+ _selection.selectRange(rangeStart, inPointNum);
+ }
+ }