From: jprocter Date: Thu, 29 Apr 2010 11:12:16 +0000 (+0000) Subject: new selection manipulation method X-Git-Tag: Release_2_5~20 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=c16d6b192b294503d2bd16294454cfe136426e7d new selection manipulation method --- diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index 1b3af30..1147526 100755 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -1628,4 +1628,30 @@ public class AlignViewport { return this.showConsensusHistogram; } + /** + * synthesize a column selection if none exists so it covers the given selection group. + * if wholewidth is false, no column selection is made if the selection group covers the whole alignment width. + * @param sg + * @param wholewidth + */ + public void expandColSelection(SequenceGroup sg, boolean wholewidth) + { + int sgs,sge; + if (sg!=null && (sgs=sg.getStartRes())>=0 && sg.getStartRes()<=(sge=sg.getEndRes())&& (colSel==null || colSel.getSelected()==null || colSel.getSelected().size()==0)) + { + if (!wholewidth && alignment.getWidth()==(1+sge-sgs)) + { + // do nothing + return; + } + if (colSel==null) + { + colSel = new ColumnSelection(); + } + for (int cspos = sg.getStartRes(); cspos<=sg.getEndRes(); cspos++) { + colSel.addElement(cspos); + } + } + } + } diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index fd1fa7d..f386bf3 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -2177,5 +2177,29 @@ public class AlignViewport implements SelectionSource { return this.showConsensusHistogram; } - + /** + * synthesize a column selection if none exists so it covers the given selection group. + * if wholewidth is false, no column selection is made if the selection group covers the whole alignment width. + * @param sg + * @param wholewidth + */ + public void expandColSelection(SequenceGroup sg, boolean wholewidth) + { + int sgs,sge; + if (sg!=null && (sgs=sg.getStartRes())>=0 && sg.getStartRes()<=(sge=sg.getEndRes())&& (colSel==null || colSel.getSelected()==null || colSel.getSelected().size()==0)) + { + if (!wholewidth && alignment.getWidth()==(1+sge-sgs)) + { + // do nothing + return; + } + if (colSel==null) + { + colSel = new ColumnSelection(); + } + for (int cspos = sg.getStartRes(); cspos<=sg.getEndRes(); cspos++) { + colSel.addElement(cspos); + } + } + } }