X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAlignViewport.java;h=99d0794f3c9adb3cfb933b54b31f7ac131fbd7ed;hb=c42fcf7bf5cfcf51e67dd0f683edb9ab6683d157;hp=481a657501204114037cf42065ec41e75555c0a7;hpb=245ddd4612033edc65de15acb93ac9c22912a828;p=jalview.git diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index 481a657..99d0794 100755 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -56,7 +56,7 @@ public class AlignViewport boolean conservationColourSelected = false; boolean abovePIDThreshold = false; - SequenceGroup selectionGroup = new SequenceGroup(); + SequenceGroup selectionGroup; int charHeight; int charWidth; @@ -79,7 +79,11 @@ public class AlignViewport // The following vector holds the features which are // currently visible, in the correct order or rendering - Hashtable featuresDisplayed = null; + Hashtable featuresDisplayed; + + boolean hasHiddenColumns = false; + boolean hasHiddenRows = false; + boolean showHiddenMarkers = true; public Vector vconsensus; @@ -95,8 +99,11 @@ public class AlignViewport boolean ignoreGapsInConsensusCalculation = false; + jalview.bin.JalviewLite applet; + public AlignViewport(AlignmentI al, JalviewLite applet) { + this.applet = applet; setAlignment(al); this.startRes = 0; this.endRes = al.getWidth() - 1; @@ -141,14 +148,34 @@ public class AlignViewport updateConservation(); updateConsensus(); - if (applet != null && applet.getParameter("defaultColour") != null) + + if (applet != null) { - globalColourScheme = ColourSchemeProperty.getColour(alignment, - applet.getParameter("defaultColour")); - if (globalColourScheme != null) + String colour = applet.getParameter("defaultColour"); + + if(colour == null) { - globalColourScheme.setConsensus(vconsensus); + colour = applet.getParameter("userDefinedColour"); + if(colour !=null) + colour = "User Defined"; } + + if(colour != null) + { + globalColourScheme = ColourSchemeProperty.getColour(alignment, colour); + if (globalColourScheme != null) + { + globalColourScheme.setConsensus(vconsensus); + } + } + + if(applet.getParameter("userDefinedColour")!=null) + { + ((UserColourScheme)globalColourScheme).parseAppletParameter( + applet.getParameter("userDefinedColour")); + } + + } } @@ -561,30 +588,11 @@ public class AlignViewport return increment; } - public int getIndex(int y) + public void setHiddenColumns(ColumnSelection colsel) { - 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; + this.colSel = colsel; + if(colSel.getHiddenColumns()!=null) + hasHiddenColumns = true; } public ColumnSelection getColumnSelection() @@ -719,6 +727,288 @@ public class AlignViewport { return ignoreGapsInConsensusCalculation; } + public void hideSelectedColumns() + { + if (colSel.size() < 1) + return; + + colSel.hideSelectedColumns(); + setSelectionGroup(null); + + hasHiddenColumns = true; + } + + public void invertColumnSelection() + { + int column; + for (int i = 0; i < alignment.getWidth(); i++) + { + column = i; + + if (colSel.contains(column)) + colSel.removeElement(column); + else + colSel.addElement(column); + + } + } + + + public void hideColumns(int start, int end) + { + if(start==end) + colSel.hideColumns(start); + else + colSel.hideColumns(start, end); + setSelectionGroup(null); + hasHiddenColumns = true; + } + + public void hideSequence(SequenceI seq) + { + if(seq!=null) + { + alignment.getHiddenSequences().hideSequence(seq); + hasHiddenRows = true; + } + } + + public void showSequence(int index) + { + alignment.getHiddenSequences().showSequence(index); + + if(alignment.getHiddenSequences().getSize()<1) + hasHiddenRows = false; + } + + public void showColumn(int col) + { + colSel.revealHiddenColumns(col); + if(colSel.getHiddenColumns()==null) + hasHiddenColumns = false; + } + + public void showAllHiddenColumns() + { + colSel.revealAllHiddenColumns(); + hasHiddenColumns = false; + } + + public void showAllHiddenSeqs() + { + if(alignment.getHiddenSequences().getSize()>0) + { + alignment.getHiddenSequences().showAll(); + hasHiddenRows = false; + } + } + + public int adjustForHiddenSeqs(int alignmentIndex) + { + return alignment.getHiddenSequences().adjustForHiddenSeqs(alignmentIndex); + } + + /** + * This method returns the a new SequenceI [] with + * the selection sequence and start and end points adjusted + * @return String[] + */ + public SequenceI[] getSelectionAsNewSequence() + { + SequenceI[] sequences; + + if (selectionGroup == null) + sequences = alignment.getSequencesArray(); + else + sequences = selectionGroup.getSelectionAsNewSequences(alignment); + + 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