X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=fde4d90e18bbf9f5c2b1e09f3aac7850c817c9a6;hb=3596077c79b7aa2051b9aaa978481004b513101c;hp=a101fcf4db6647881971e931ac849460706b02ff;hpb=1ef53c6e1e8f030bce0933c2154a7af3773b496a;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index a101fcf..fde4d90 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -121,6 +121,20 @@ public class AlignViewport setAlignment(al); init(); } + /** + * Create a new AlignViewport with hidden regions + * @param al AlignmentI + * @param hiddenColumns ColumnSelection + */ + public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns) { + setAlignment(al); + if (hiddenColumns!=null) { + this.colSel = hiddenColumns; + if (hiddenColumns.getHiddenColumns() != null) + hasHiddenColumns = true; + } + init(); + } void init() { @@ -873,41 +887,6 @@ public class AlignViewport return increment; } - /** - * DOCUMENT ME! - * - * @param y DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public int getIndex(int y) - { - int y1 = 0; - int starty = getStartSeq(); - int endy = getEndSeq(); - - for (int i = starty; i <= endy; i++) - { - if ((i < alignment.getHeight()) && - (alignment.getSequenceAt(i) != null)) - { - int y2 = y1 + getCharHeight(); - - if ((y >= y1) && (y <= y2)) - { - return i; - } - - y1 = y2; - } - else - { - return -1; - } - } - - return -1; - } /** * DOCUMENT ME! @@ -1123,15 +1102,12 @@ public class AlignViewport public void hideSelectedColumns() { - if (colSel.selected.size() < 1) + if (colSel.size() < 1) return; - while (colSel.selected.size() > 0) - { - int column = ( (Integer) colSel.selected.firstElement()).intValue(); - colSel.hideColumns(column); - } + colSel.hideSelectedColumns(); setSelectionGroup(null); + hasHiddenColumns = true; } @@ -1139,14 +1115,9 @@ public class AlignViewport public void hideColumns(int start, int end) { if(start==end) - end++; - - for(int i=start; i0) @@ -1199,22 +1183,114 @@ public class AlignViewport return sequences; } + /** + * This method returns the visible alignment as text, as + * seen on the GUI, ie if columns are hidden they will not + * be returned in the result. + * Use this for calculating trees, PCA, redundancy etc on views + * which contain hidden columns. + * @return String[] + */ + public jalview.datamodel.CigarArray getViewAsCigars(boolean selectedRegionOnly) + { + CigarArray selection=null; + SequenceI [] seqs= null; + int i, iSize; + int start = 0, end = 0; + if(selectedRegionOnly && selectionGroup!=null) + { + iSize = selectionGroup.getSize(false); + seqs = selectionGroup.getSequencesInOrder(alignment); + start = selectionGroup.getStartRes(); + end = selectionGroup.getEndRes(); // inclusive for start and end in SeqCigar constructor + } + else + { + iSize = alignment.getHeight(); + seqs = alignment.getSequencesArray(); + end = alignment.getWidth()-1; + } + SeqCigar[] selseqs = new SeqCigar[iSize]; + for(i=0; i