From: gmungoc Date: Thu, 5 Jan 2017 16:00:23 +0000 (+0000) Subject: JAL-2374 fix popup out by one and multiple groups bugs X-Git-Tag: Release_2_10_3b1~383 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=d2177decb24a93432ad55175b2123741bb3d8ac7;p=jalview.git JAL-2374 fix popup out by one and multiple groups bugs --- diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index 8d6e683..4278744 100644 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -1425,19 +1425,12 @@ public class SeqPanel extends Panel implements MouseMotionListener, if (stretchGroup == null) { - stretchGroup = av.getAlignment().findGroup(sequence); - if (stretchGroup != null && res > stretchGroup.getStartRes() - && res < stretchGroup.getEndRes()) - { - av.setSelectionGroup(stretchGroup); - } - else - { - stretchGroup = null; - } + stretchGroup = av.getAlignment().findGroup(sequence, res); + av.setSelectionGroup(stretchGroup); } - else if (!stretchGroup.getSequences(null).contains(sequence) + if (stretchGroup == null + || !stretchGroup.getSequences(null).contains(sequence) || stretchGroup.getStartRes() > res || stretchGroup.getEndRes() < res) { diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index d651c1d..90bdcae 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -366,17 +366,18 @@ public class Alignment implements AlignmentI * @see jalview.datamodel.AlignmentI#findGroup(jalview.datamodel.SequenceI) */ @Override - public SequenceGroup findGroup(SequenceI s) + public SequenceGroup findGroup(SequenceI seq, int position) { synchronized (groups) { - for (int i = 0; i < this.groups.size(); i++) + for (SequenceGroup sg : groups) { - SequenceGroup sg = groups.get(i); - - if (sg.getSequences(null).contains(s)) + if (sg.getSequences(null).contains(seq)) { - return sg; + if (position >= sg.getStartRes() && position <= sg.getEndRes()) + { + return sg; + } } } } diff --git a/src/jalview/datamodel/AlignmentI.java b/src/jalview/datamodel/AlignmentI.java index 7274e5f..2df099a 100755 --- a/src/jalview/datamodel/AlignmentI.java +++ b/src/jalview/datamodel/AlignmentI.java @@ -156,15 +156,16 @@ public interface AlignmentI extends AnnotatedCollectionI int findIndex(SequenceI s); /** - * Finds group that given sequence is part of. + * Returns the first group (in the order in which groups were added) that + * includes the given sequence and aligned position (base 0), or null if none + * found * - * @param s - * Sequence in alignment. + * @param seq + * @param position * - * @return First group found for sequence. WARNING : Sequences may be members - * of several groups. This method is incomplete. + * @return */ - SequenceGroup findGroup(SequenceI s); + SequenceGroup findGroup(SequenceI seq, int position); /** * Finds all groups that a given sequence is part of. diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 8726c4a..5b87445 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -60,7 +60,6 @@ import java.awt.event.MouseWheelListener; import java.util.ArrayList; import java.util.List; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.ToolTipManager; @@ -1589,19 +1588,11 @@ public class SeqPanel extends JPanel implements MouseListener, if (stretchGroup == null) { - stretchGroup = av.getAlignment().findGroup(sequence); - - if ((stretchGroup != null) && (res > stretchGroup.getStartRes()) - && (res < stretchGroup.getEndRes())) - { - av.setSelectionGroup(stretchGroup); - } - else - { - stretchGroup = null; - } + stretchGroup = av.getAlignment().findGroup(sequence, res); + av.setSelectionGroup(stretchGroup); } - else if (!stretchGroup.getSequences(null).contains(sequence) + if (stretchGroup == null + || !stretchGroup.getSequences(null).contains(sequence) || (stretchGroup.getStartRes() > res) || (stretchGroup.getEndRes() < res)) {