From fc2dbe249bddd693c94bfa88b3468abc41c6d80b Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 31 Aug 2016 15:36:33 +0100 Subject: [PATCH] =?utf8?q?JAL-2034=20moved=20=E2=80=98isDefinedGroup=E2=80=99?= =?utf8?q?=20flag=20to=20a=20test=20method=20on=20AlignViewportI=20so=20cont?= =?utf8?q?roller=20doesn=E2=80=99t=20have=20to=20track=20datamodel=20state.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/api/AlignViewportI.java | 8 ++++++++ src/jalview/appletgui/SeqPanel.java | 23 ++++++----------------- src/jalview/gui/SeqPanel.java | 18 +++++++----------- src/jalview/viewmodel/AlignmentViewport.java | 26 ++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 28 deletions(-) diff --git a/src/jalview/api/AlignViewportI.java b/src/jalview/api/AlignViewportI.java index 8343f0b..df57cc0 100644 --- a/src/jalview/api/AlignViewportI.java +++ b/src/jalview/api/AlignViewportI.java @@ -397,4 +397,12 @@ public interface AlignViewportI extends ViewStyleI public void applyFeaturesStyle(FeatureSettingsModelI featureSettings); + + /** + * check if current selection group is defined on the view, or is simply a + * temporary group. + * + * @return true if group is defined on the alignment + */ + boolean isSelectionDefinedGroup(); } diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index 02172d6..a437960 100644 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -927,13 +927,6 @@ public class SeqPanel extends Panel implements MouseMotionListener, */ private boolean needOverviewUpdate; // TODO: refactor to avcontroller - /** - * set if av.getSelectionGroup() refers to a group that is defined on the - * alignment view, rather than a transient selection - */ - private boolean editingDefinedGroup = false; // TODO: refactor to avcontroller - // or viewModel - @Override public void mouseDragged(MouseEvent evt) { @@ -1436,12 +1429,10 @@ public class SeqPanel extends Panel implements MouseMotionListener, && res < stretchGroup.getEndRes()) { av.setSelectionGroup(stretchGroup); - editingDefinedGroup = true; } else { stretchGroup = null; - editingDefinedGroup = false; } } @@ -1461,7 +1452,6 @@ public class SeqPanel extends Panel implements MouseMotionListener, && allGroups[i].getEndRes() >= res) { stretchGroup = allGroups[i]; - editingDefinedGroup = true; break; } } @@ -1517,7 +1507,6 @@ public class SeqPanel extends Panel implements MouseMotionListener, sg.setEndRes(res); sg.addSequence(sequence, false); av.setSelectionGroup(sg); - editingDefinedGroup = false; stretchGroup = sg; if (av.getConservationSelected()) @@ -1543,7 +1532,8 @@ public class SeqPanel extends Panel implements MouseMotionListener, // always do this - annotation has own state // but defer colourscheme update until hidden sequences are passed in boolean vischange = stretchGroup.recalcConservation(true); - needOverviewUpdate |= vischange && editingDefinedGroup; + // here we rely on stretchGroup == av.getSelection() + needOverviewUpdate |= vischange && av.isSelectionDefinedGroup(); if (stretchGroup.cs != null) { stretchGroup.cs.alignmentChanged(stretchGroup, @@ -1563,7 +1553,6 @@ public class SeqPanel extends Panel implements MouseMotionListener, PaintRefresher.Refresh(ap, av.getSequenceSetId()); ap.paintAlignment(needOverviewUpdate); needOverviewUpdate =false; - editingDefinedGroup = false; changeEndRes = false; changeStartRes = false; stretchGroup = null; @@ -1618,7 +1607,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, if (res > (stretchGroup.getStartRes() - 1)) { stretchGroup.setEndRes(res); - needOverviewUpdate |= editingDefinedGroup; + needOverviewUpdate |= av.isSelectionDefinedGroup(); } } else if (changeStartRes) @@ -1626,7 +1615,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, if (res < (stretchGroup.getEndRes() + 1)) { stretchGroup.setStartRes(res); - needOverviewUpdate |= editingDefinedGroup; + needOverviewUpdate |= av.isSelectionDefinedGroup(); } } @@ -1660,7 +1649,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, if (stretchGroup.getSequences(null).contains(nextSeq)) { stretchGroup.deleteSequence(seq, false); - needOverviewUpdate |= editingDefinedGroup; + needOverviewUpdate |= av.isSelectionDefinedGroup(); } else { @@ -1670,7 +1659,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, } stretchGroup.addSequence(nextSeq, false); - needOverviewUpdate |= editingDefinedGroup; + needOverviewUpdate |= av.isSelectionDefinedGroup(); } } diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index f476d41..348c21c 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -836,7 +836,8 @@ public class SeqPanel extends JPanel implements MouseListener, * set if av.getSelectionGroup() refers to a group that is defined on the * alignment view, rather than a transient selection */ - private boolean editingDefinedGroup = false; // TODO: refactor to avcontroller or viewModel + // private boolean editingDefinedGroup = false; // TODO: refactor to + // avcontroller or viewModel /** * Set status message in alignment panel @@ -1583,12 +1584,10 @@ public class SeqPanel extends JPanel implements MouseListener, && (res < stretchGroup.getEndRes())) { av.setSelectionGroup(stretchGroup); - editingDefinedGroup = true; } else { stretchGroup = null; - editingDefinedGroup = false; } } else if (!stretchGroup.getSequences(null).contains(sequence) @@ -1607,7 +1606,6 @@ public class SeqPanel extends JPanel implements MouseListener, && (allGroups[i].getEndRes() >= res)) { stretchGroup = allGroups[i]; - editingDefinedGroup = true; break; } } @@ -1657,7 +1655,6 @@ public class SeqPanel extends JPanel implements MouseListener, sg.setEndRes(res); sg.addSequence(sequence, false); av.setSelectionGroup(sg); - editingDefinedGroup = false; stretchGroup = sg; if (av.getConservationSelected()) @@ -1703,7 +1700,7 @@ public class SeqPanel extends JPanel implements MouseListener, // always do this - annotation has own state // but defer colourscheme update until hidden sequences are passed in boolean vischange = stretchGroup.recalcConservation(true); - needOverviewUpdate |= vischange && editingDefinedGroup; + needOverviewUpdate |= vischange && av.isSelectionDefinedGroup(); if (stretchGroup.cs != null) { stretchGroup.cs.alignmentChanged(stretchGroup, @@ -1723,7 +1720,6 @@ public class SeqPanel extends JPanel implements MouseListener, PaintRefresher.Refresh(this, av.getSequenceSetId()); ap.paintAlignment(needOverviewUpdate); needOverviewUpdate =false; - editingDefinedGroup = false; changeEndRes = false; changeStartRes = false; stretchGroup = null; @@ -1777,7 +1773,7 @@ public class SeqPanel extends JPanel implements MouseListener, if (res > (stretchGroup.getStartRes() - 1)) { stretchGroup.setEndRes(res); - needOverviewUpdate |= editingDefinedGroup; + needOverviewUpdate |= av.isSelectionDefinedGroup(); } } else if (changeStartRes) @@ -1785,7 +1781,7 @@ public class SeqPanel extends JPanel implements MouseListener, if (res < (stretchGroup.getEndRes() + 1)) { stretchGroup.setStartRes(res); - needOverviewUpdate |= editingDefinedGroup; + needOverviewUpdate |= av.isSelectionDefinedGroup(); } } @@ -1819,7 +1815,7 @@ public class SeqPanel extends JPanel implements MouseListener, if (stretchGroup.getSequences(null).contains(nextSeq)) { stretchGroup.deleteSequence(seq, false); - needOverviewUpdate |= editingDefinedGroup; + needOverviewUpdate |= av.isSelectionDefinedGroup(); } else { @@ -1829,7 +1825,7 @@ public class SeqPanel extends JPanel implements MouseListener, } stretchGroup.addSequence(nextSeq, false); - needOverviewUpdate |= editingDefinedGroup; + needOverviewUpdate |= av.isSelectionDefinedGroup(); } } diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 19ebf45..457f2c5 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -2782,5 +2782,31 @@ public abstract class AlignmentViewport implements AlignViewportI, } } + /** + * hold status of current selection group - defined on alignment or not. + */ + private boolean selectionIsDefinedGroup = false; + @Override + public boolean isSelectionDefinedGroup() + { + if (selectionGroup == null) + { + return false; + } + if (isSelectionGroupChanged(true)) + { + selectionIsDefinedGroup = false; + List gps = alignment.getGroups(); + if (gps == null || gps.size() == 0) + { + selectionIsDefinedGroup = false; + } + else + { + selectionIsDefinedGroup = gps.contains(selectionGroup); + } + } + return selectionIsDefinedGroup; + } } -- 1.7.10.2