X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAlignViewport.java;h=43831a247ac8504410961eab86aff4710372c95b;hb=d0b7395c10aec7c5da5a5662fc69783ec78fae8d;hp=88a0b0f6a528dfe41ab1489bbc702df33ba02b4d;hpb=0452450533728e478ef8c893ea2cb3483c740fb3;p=jalview.git diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index 88a0b0f..43831a2 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) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2007 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,6 @@ public class AlignViewport int startSeq; int endSeq; - boolean cursorMode = false; boolean showJVSuffix = true; @@ -79,15 +78,14 @@ public class AlignViewport boolean scaleRightWrapped = true; // The following vector holds the features which are - // currently visible, in the correct order or rendering + // currently visible, in the correct order or rendering public Hashtable featuresDisplayed; boolean hasHiddenColumns = false; boolean hasHiddenRows = false; boolean showHiddenMarkers = true; - - public Hashtable [] hconsensus; + public Hashtable[] hconsensus; AlignmentAnnotation consensus; AlignmentAnnotation conservation; AlignmentAnnotation quality; @@ -96,7 +94,8 @@ public class AlignViewport public int ConsPercGaps = 25; // JBPNote : This should be a scalable property! - private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(this); + private java.beans.PropertyChangeSupport changeSupport = new java.beans. + PropertyChangeSupport(this); boolean ignoreGapsInConsensusCalculation = false; @@ -123,8 +122,10 @@ public class AlignViewport this.endSeq = al.getHeight() - 1; setFont(font); - if(System.getProperty("os.name").startsWith("Mac")) + if (System.getProperty("os.name").startsWith("Mac")) + { MAC = true; + } if (applet != null) { @@ -161,8 +162,10 @@ public class AlignViewport param = applet.getParameter("upperCase"); if (param != null) { - if(param.equalsIgnoreCase("bold")) + if (param.equalsIgnoreCase("bold")) + { upperCasebold = true; + } } } @@ -171,14 +174,16 @@ public class AlignViewport { String colour = applet.getParameter("defaultColour"); - if(colour == null) + if (colour == null) { colour = applet.getParameter("userDefinedColour"); - if(colour !=null) + if (colour != null) + { colour = "User Defined"; + } } - if(colour != null) + if (colour != null) { globalColourScheme = ColourSchemeProperty.getColour(alignment, colour); if (globalColourScheme != null) @@ -187,24 +192,24 @@ public class AlignViewport } } - if(applet.getParameter("userDefinedColour")!=null) + if (applet.getParameter("userDefinedColour") != null) { - ((UserColourScheme)globalColourScheme).parseAppletParameter( + ( (UserColourScheme) globalColourScheme).parseAppletParameter( applet.getParameter("userDefinedColour")); } - if(hconsensus==null) + if (hconsensus == null) { - if(!alignment.isNucleotide()) + if (!alignment.isNucleotide()) { conservation = new AlignmentAnnotation("Conservation", - "Conservation of total alignment less than " + - ConsPercGaps + "% gaps", - new Annotation[1], 0f, - 11f, - AlignmentAnnotation.BAR_GRAPH); + "Conservation of total alignment less than " + + ConsPercGaps + "% gaps", + new Annotation[1], 0f, + 11f, + AlignmentAnnotation.BAR_GRAPH); conservation.hasText = true; - + conservation.autoCalculated = true; if (showConservation) { @@ -220,20 +225,22 @@ public class AlignViewport 11f, AlignmentAnnotation.BAR_GRAPH); quality.hasText = true; + quality.autoCalculated = true; alignment.addAnnotation(quality); } } consensus = new AlignmentAnnotation("Consensus", "PID", - new Annotation[1], 0f, 100f, - AlignmentAnnotation.BAR_GRAPH); + new Annotation[1], 0f, 100f, + AlignmentAnnotation.BAR_GRAPH); consensus.hasText = true; + consensus.autoCalculated = true; - if (showConsensus) - { - alignment.addAnnotation(consensus); - } + if (showConsensus) + { + alignment.addAnnotation(consensus); + } } } } @@ -248,8 +255,8 @@ public class AlignViewport return showSequenceFeatures; } - - class ConservationThread extends Thread + class ConservationThread + extends Thread { AlignmentPanel ap; public ConservationThread(AlignmentPanel ap) @@ -269,7 +276,7 @@ public class AlignViewport { if (ap != null) { - ap.repaint(); + ap.paintAlignment(true); } Thread.sleep(200); } @@ -281,24 +288,25 @@ public class AlignViewport UPDATING_CONSERVATION = true; - int alWidth = alignment.getWidth(); - if(alWidth<0) + if (alWidth < 0) + { return; + } Conservation cons = new jalview.analysis.Conservation("All", jalview.schemes.ResidueProperties.propHash, 3, - alignment.getSequences(), 0, alWidth -1); + alignment.getSequences(), 0, alWidth - 1); cons.calculate(); cons.verdict(false, ConsPercGaps); - if (quality!=null) + if (quality != null) { cons.findQuality(); } - char [] sequence = cons.getConsSequence().getSequence(); + char[] sequence = cons.getConsSequence().getSequence(); float minR; float minG; float minB; @@ -321,7 +329,7 @@ public class AlignViewport conservation.annotations = new Annotation[alWidth]; - if (quality!=null) + if (quality != null) { quality.graphMax = cons.qualityRange[1].floatValue(); quality.annotations = new Annotation[alWidth]; @@ -336,11 +344,17 @@ public class AlignViewport c = sequence[i]; if (Character.isDigit(c)) + { value = (int) (c - '0'); + } else if (c == '*') + { value = 11; + } else if (c == '+') + { value = 10; + } float vprop = value - min; vprop /= max; @@ -352,16 +366,17 @@ public class AlignViewport minB + (maxB * vprop))); // Quality calc - if (quality!=null) + if (quality != null) { value = ( (Double) cons.quality.elementAt(i)).floatValue(); vprop = value - qmin; vprop /= qmax; - quality.annotations[i] = new Annotation(" ", String.valueOf(value), ' ', - value, - new Color(minR + (maxR * vprop), - minG + (maxG * vprop), - minB + (maxB * vprop))); + quality.annotations[i] = new Annotation(" ", String.valueOf(value), + ' ', + value, + new Color(minR + (maxR * vprop), + minG + (maxG * vprop), + minB + (maxB * vprop))); } } } @@ -376,15 +391,14 @@ public class AlignViewport UPDATING_CONSERVATION = false; updatingConservation = false; - if(ap!=null) + if (ap != null) { - ap.repaint(); + ap.paintAlignment(true); } } } - ConservationThread conservationThread; ConsensusThread consensusThread; @@ -404,8 +418,10 @@ public class AlignViewport */ public void updateConservation(final AlignmentPanel ap) { - if (alignment.isNucleotide() || conservation==null) + if (alignment.isNucleotide() || conservation == null) + { return; + } conservationThread = new ConservationThread(ap); conservationThread.start(); @@ -420,14 +436,15 @@ public class AlignViewport consensusThread.start(); } - - class ConsensusThread extends Thread + class ConsensusThread + extends Thread { AlignmentPanel ap; public ConsensusThread(AlignmentPanel ap) { this.ap = ap; } + public void run() { updatingConsensus = true; @@ -437,7 +454,7 @@ public class AlignViewport { if (ap != null) { - ap.repaint(); + ap.paintAlignment(true); } Thread.sleep(200); @@ -448,19 +465,19 @@ public class AlignViewport } } - UPDATING_CONSENSUS = true; try { int aWidth = alignment.getWidth(); - if(aWidth<0) + if (aWidth < 0) + { return; + } consensus.annotations = null; consensus.annotations = new Annotation[aWidth]; - hconsensus = new Hashtable[aWidth]; AAFrequency.calculate(alignment.getSequencesArray(), 0, @@ -471,11 +488,15 @@ public class AlignViewport { float value = 0; if (ignoreGapsInConsensusCalculation) + { value = ( (Float) hconsensus[i].get(AAFrequency.PID_NOGAPS)). floatValue(); + } else + { value = ( (Float) hconsensus[i].get(AAFrequency.PID_GAPS)). floatValue(); + } String maxRes = hconsensus[i].get(AAFrequency.MAXRESIDUE).toString(); String mouseOver = hconsensus[i].get(AAFrequency.MAXRESIDUE) + " "; @@ -487,12 +508,14 @@ public class AlignViewport } mouseOver += ( (int) value + "%"); - consensus.annotations[i] = new Annotation(maxRes, mouseOver, ' ', value); + consensus.annotations[i] = new Annotation(maxRes, mouseOver, ' ', + value); } - if (globalColourScheme != null) + { globalColourScheme.setConsensus(hconsensus); + } } catch (OutOfMemoryError error) @@ -509,7 +532,7 @@ public class AlignViewport if (ap != null) { - ap.repaint(); + ap.paintAlignment(true); } } } @@ -524,21 +547,32 @@ public class AlignViewport */ public SequenceI getConsensusSeq() { - if (consensus==null) + if (consensus == null) + { return null; - StringBuffer seqs=new StringBuffer(); - for (int i=0; i0) + if (alignment.getHiddenSequences().getSize() > 0) { - if(selectionGroup==null) + if (selectionGroup == null) { selectionGroup = new SequenceGroup(); - selectionGroup.setEndRes(alignment.getWidth()-1); + selectionGroup.setEndRes(alignment.getWidth() - 1); } Vector tmp = alignment.getHiddenSequences().showAll(hiddenRepSequences); - for(int t=0; t