X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAlignViewport.java;h=fc4638697a6fd6b9cd96f5b0391285fd4c5b708d;hb=c95df1d1e8746c6fa31b94c2bf8505f25a30c168;hp=50a90fee2685a166a53eea56aa0a2d04a6d66f58;hpb=59183747dbffe3ab6b141c5440d2f70799ae360b;p=jalview.git diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index 50a90fe..fc46386 100755 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -36,6 +36,9 @@ public class AlignViewport int startSeq; int endSeq; + + boolean cursorMode = false; + boolean showJVSuffix = true; boolean showText = true; boolean showColourText = false; @@ -47,19 +50,21 @@ public class AlignViewport boolean showConservation = true; boolean showQuality = true; boolean showConsensus = true; + boolean upperCasebold = false; boolean colourAppliesToAllGroups = true; ColourSchemeI globalColourScheme = null; boolean conservationColourSelected = false; boolean abovePIDThreshold = false; - SequenceGroup selectionGroup = new SequenceGroup(); + SequenceGroup selectionGroup; int charHeight; int charWidth; int wrappedWidth; Font font = new Font("SansSerif", Font.PLAIN, 10); + boolean validCharWidth = true; AlignmentI alignment; ColumnSelection colSel = new ColumnSelection(); @@ -73,19 +78,35 @@ public class AlignViewport boolean scaleLeftWrapped = true; boolean scaleRightWrapped = true; + // The following vector holds the features which are + // currently visible, in the correct order or rendering + public Hashtable featuresDisplayed; + + boolean hasHiddenColumns = false; + boolean hasHiddenRows = false; + boolean showHiddenMarkers = true; + + public Vector vconsensus; AlignmentAnnotation consensus; AlignmentAnnotation conservation; AlignmentAnnotation quality; + boolean autocalculateConsensus = true; + public int ConsPercGaps = 25; // JBPNote : This should be a scalable property! private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(this); boolean ignoreGapsInConsensusCalculation = false; + jalview.bin.JalviewLite applet; + + boolean MAC = false; + public AlignViewport(AlignmentI al, JalviewLite applet) { + this.applet = applet; setAlignment(al); this.startRes = 0; this.endRes = al.getWidth() - 1; @@ -93,6 +114,9 @@ public class AlignViewport this.endSeq = al.getHeight() - 1; setFont(font); + if(System.getProperty("os.name").startsWith("Mac")) + MAC = true; + if (applet != null) { String param = applet.getParameter("showFullId"); @@ -124,20 +148,48 @@ public class AlignViewport { showConsensus = Boolean.valueOf(param).booleanValue(); } + + param = applet.getParameter("upperCase"); + if (param != null) + { + if(param.equalsIgnoreCase("bold")) + upperCasebold = true; + } + } // We must set conservation and consensus before setting colour, // as Blosum and Clustal require this to be done 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")); + } + + } } @@ -146,6 +198,11 @@ public class AlignViewport showSequenceFeatures = b; } + public boolean getShowSequenceFeatures() + { + return showSequenceFeatures; + } + public void updateConservation() { @@ -309,7 +366,32 @@ public class AlignViewport globalColourScheme.setConsensus(vconsensus); } - + /** + * get the consensus sequence as displayed under the PID consensus annotation row. + * @return consensus sequence as a new sequence object + */ + /** + * get the consensus sequence as displayed under the PID consensus annotation row. + * @return consensus sequence as a new sequence object + */ + public SequenceI getConsensusSeq() { + if (consensus==null) + updateConsensus(); + if (consensus==null) + return null; + StringBuffer seqs=new StringBuffer(); + for (int i=0; i= y1 && y <= y2) - { - return i; - } - y1 = y2; - } - else - { - return -1; - } - } - return -1; + this.colSel = colsel; + if(colSel.getHiddenColumns()!=null) + hasHiddenColumns = true; } public ColumnSelection getColumnSelection() @@ -698,6 +768,307 @@ 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); + + hasHiddenColumns = true; + } + + public void hideAllSelectedSeqs() + { + if (selectionGroup == null) + return; + + SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment); + + hideSequence(seqs); + + setSelectionGroup(null); + } + + public void hideSequence(SequenceI [] seq) + { + if(seq!=null) + { + for (int i = 0; i < seq.length; i++) + alignment.getHiddenSequences().hideSequence(seq[i]); + + hasHiddenRows = true; + firePropertyChange("alignment", null, alignment.getSequences()); + } + } + + 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) + { + if(selectionGroup==null) + { + selectionGroup = new SequenceGroup(); + selectionGroup.setEndRes(alignment.getWidth()-1); + } + Vector tmp = alignment.getHiddenSequences().showAll(); + for(int t=0; t