X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FSeqPanel.java;h=1352fe9526b1eee1aff14421126fa4504270475b;hb=d38a8b5baa757886792e4a3c5cb0b3877b25a256;hp=31bf6a48af3a14ba96afd2d99d026c0171919f19;hpb=e2745a846737920f1ec43b72d271611784503e4c;p=jalview.git diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index 31bf6a4..1352fe9 100644 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -25,8 +25,9 @@ import jalview.commands.EditCommand; import jalview.commands.EditCommand.Action; import jalview.datamodel.AlignmentI; import jalview.datamodel.ColumnSelection; +import jalview.datamodel.SearchResultMatchI; import jalview.datamodel.SearchResults; -import jalview.datamodel.SearchResults.Match; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceGroup; @@ -458,7 +459,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, * @param results * @return true if results were matched, false if not */ - private boolean setStatusMessage(SearchResults results) + private boolean setStatusMessage(SearchResultsI results) { AlignmentI al = this.av.getAlignment(); int sequenceIndex = al.findIndex(results); @@ -467,7 +468,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, return false; } SequenceI ds = al.getSequenceAt(sequenceIndex).getDatasetSequence(); - for (Match m : results.getResults()) + for (SearchResultMatchI m : results.getResults()) { SequenceI seq = m.getSequence(); if (seq.getDatasetSequence() != null) @@ -559,7 +560,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, if (features != null && features.length > 0) { - SearchResults highlight = new SearchResults(); + SearchResultsI highlight = new SearchResults(); highlight.addResult(sequence, features[0].getBegin(), features[0].getEnd()); seqCanvas.highlightSearchResults(highlight); @@ -731,7 +732,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, } @Override - public void highlightSequence(SearchResults results) + public void highlightSequence(SearchResultsI results) { if (av.isFollowHighlight()) { @@ -919,6 +920,14 @@ public class SeqPanel extends Panel implements MouseMotionListener, Tooltip tooltip; + /** + * set when the current UI interaction has resulted in a change that requires + * overview shading to be recalculated. this could be changed to something + * more expressive that indicates what actually has changed, so selective + * redraws can be applied + */ + private boolean needOverviewUpdate; // TODO: refactor to avcontroller + @Override public void mouseDragged(MouseEvent evt) { @@ -1414,41 +1423,15 @@ public class SeqPanel extends Panel implements MouseMotionListener, stretchGroup = av.getSelectionGroup(); - if (stretchGroup == null) + if (stretchGroup == null || !stretchGroup.contains(sequence, res)) { - stretchGroup = av.getAlignment().findGroup(sequence); - if (stretchGroup != null && res > stretchGroup.getStartRes() - && res < stretchGroup.getEndRes()) + stretchGroup = av.getAlignment().findGroup(sequence, res); + if (stretchGroup != null) { + // only update the current selection if the popup menu has a group to + // focus on av.setSelectionGroup(stretchGroup); } - else - { - stretchGroup = null; - } - } - - else if (!stretchGroup.getSequences(null).contains(sequence) - || stretchGroup.getStartRes() > res - || stretchGroup.getEndRes() < res) - { - stretchGroup = null; - - SequenceGroup[] allGroups = av.getAlignment().findAllGroups(sequence); - - if (allGroups != null) - { - for (int i = 0; i < allGroups.length; i++) - { - if (allGroups[i].getStartRes() <= res - && allGroups[i].getEndRes() >= res) - { - stretchGroup = allGroups[i]; - break; - } - } - } - av.setSelectionGroup(stretchGroup); } // DETECT RIGHT MOUSE BUTTON IN AWT @@ -1503,13 +1486,13 @@ public class SeqPanel extends Panel implements MouseMotionListener, if (av.getConservationSelected()) { - SliderPanel.setConservationSlider(ap, av.getGlobalColourScheme(), - "Background"); + SliderPanel.setConservationSlider(ap, av.getResidueShading(), + ap.getViewName()); } if (av.getAbovePIDThreshold()) { - SliderPanel.setPIDSliderSource(ap, av.getGlobalColourScheme(), - "Background"); + SliderPanel.setPIDSliderSource(ap, av.getResidueShading(), + ap.getViewName()); } } @@ -1521,9 +1504,11 @@ public class SeqPanel extends Panel implements MouseMotionListener, { return; } - - stretchGroup.recalcConservation(); // always do this - annotation has own - // state + // always do this - annotation has own state + // but defer colourscheme update until hidden sequences are passed in + boolean vischange = stretchGroup.recalcConservation(true); + // here we rely on stretchGroup == av.getSelection() + needOverviewUpdate |= vischange && av.isSelectionDefinedGroup(); if (stretchGroup.cs != null) { stretchGroup.cs.alignmentChanged(stretchGroup, @@ -1534,17 +1519,18 @@ public class SeqPanel extends Panel implements MouseMotionListener, SliderPanel.setConservationSlider(ap, stretchGroup.cs, stretchGroup.getName()); } - else + if (stretchGroup.cs.getThreshold() > 0) { SliderPanel.setPIDSliderSource(ap, stretchGroup.cs, stretchGroup.getName()); } } + PaintRefresher.Refresh(ap, av.getSequenceSetId()); + ap.paintAlignment(needOverviewUpdate); + needOverviewUpdate = false; changeEndRes = false; changeStartRes = false; stretchGroup = null; - PaintRefresher.Refresh(ap, av.getSequenceSetId()); - ap.paintAlignment(true); av.sendSelection(); } @@ -1596,6 +1582,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, if (res > (stretchGroup.getStartRes() - 1)) { stretchGroup.setEndRes(res); + needOverviewUpdate |= av.isSelectionDefinedGroup(); } } else if (changeStartRes) @@ -1603,6 +1590,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, if (res < (stretchGroup.getEndRes() + 1)) { stretchGroup.setStartRes(res); + needOverviewUpdate |= av.isSelectionDefinedGroup(); } } @@ -1636,6 +1624,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, if (stretchGroup.getSequences(null).contains(nextSeq)) { stretchGroup.deleteSequence(seq, false); + needOverviewUpdate |= av.isSelectionDefinedGroup(); } else { @@ -1645,6 +1634,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, } stretchGroup.addSequence(nextSeq, false); + needOverviewUpdate |= av.isSelectionDefinedGroup(); } }