X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAlignViewport.java;h=87753f4de3bbaf9545745da284c6a7c0d58ad79f;hb=f4fd7b0e74572c8fddbfe9e3e55bc624f8ba0c6a;hp=209f9394768709490deaa61ff0246d009e50acb6;hpb=ee53965807b83bf93a21cbc341cee9a9e005b2cb;p=jalview.git diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index 209f939..87753f4 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,7 +36,10 @@ public class AlignViewport int startSeq; int endSeq; - boolean showFullId = true; + + boolean cursorMode = false; + + boolean showJVSuffix = true; boolean showText = true; boolean showColourText = false; boolean showBoxes = true; @@ -53,13 +56,14 @@ public class AlignViewport 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 +77,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 + 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,12 +113,15 @@ 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"); if (param != null) { - showFullId = Boolean.valueOf(param).booleanValue(); + showJVSuffix = Boolean.valueOf(param).booleanValue(); } param = applet.getParameter("showAnnotation"); @@ -130,14 +153,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) + { + 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) { - globalColourScheme.setConsensus(vconsensus); + ((UserColourScheme)globalColourScheme).parseAppletParameter( + applet.getParameter("userDefinedColour")); } + + } } @@ -146,6 +189,11 @@ public class AlignViewport showSequenceFeatures = b; } + public boolean getShowSequenceFeatures() + { + return showSequenceFeatures; + } + public void updateConservation() { @@ -221,7 +269,7 @@ public class AlignViewport annotations, 0f, // cons.qualityRange[0].floatValue(), 11f, // cons.qualityRange[1].floatValue() - 1); + AlignmentAnnotation.BAR_GRAPH); if (showConservation) { alignment.addAnnotation(conservation); @@ -231,7 +279,7 @@ public class AlignViewport qannotations, cons.qualityRange[0].floatValue(), cons.qualityRange[1].floatValue(), - 1); + AlignmentAnnotation.BAR_GRAPH); if (showQuality) { alignment.addAnnotation(quality); @@ -294,7 +342,7 @@ public class AlignViewport if (consensus == null) { consensus = new AlignmentAnnotation("Consensus", - "PID", annotations, 0f, 100f, 1); + "PID", annotations, 0f, 100f, AlignmentAnnotation.BAR_GRAPH); if (showConsensus) { alignment.addAnnotation(consensus); @@ -309,7 +357,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() @@ -596,14 +650,14 @@ public class AlignViewport return colourAppliesToAllGroups; } - public boolean getShowFullId() + public boolean getShowJVSuffix() { - return showFullId; + return showJVSuffix; } - public void setShowFullId(boolean b) + public void setShowJVSuffix(boolean b) { - showFullId = b; + showJVSuffix = b; } public boolean getShowAnnotation() @@ -698,6 +752,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