X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=88a6e37fab493ce38f6f9506039fd0ce4f24c705;hb=1b5ee75e7538b6229da397b28a91296e612d23e8;hp=8b929c7d4aa271a7fa6816f946df1e9a3c19c9e7;hpb=49722127cdfb9c1dc5b736733c4c5204941a4f84;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 8b929c7..88a6e37 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/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 @@ -18,6 +18,10 @@ */ package jalview.gui; +import java.util.*; + +import java.awt.*; + import jalview.analysis.*; import jalview.bin.*; @@ -26,11 +30,6 @@ import jalview.datamodel.*; import jalview.schemes.*; -import java.awt.*; - -import java.util.*; - - /** * DOCUMENT ME! * @@ -61,6 +60,7 @@ public class AlignViewport boolean validCharWidth; int wrappedWidth; Font font; + boolean seqNameItalics; AlignmentI alignment; ColumnSelection colSel = new ColumnSelection(); int threshold; @@ -91,7 +91,8 @@ public class AlignViewport public int ConsPercGaps = 25; // JBPNote : This should be a scalable property! // JBPNote Prolly only need this in the applet version. - private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(this); + private java.beans.PropertyChangeSupport changeSupport = new java.beans. + PropertyChangeSupport(this); boolean ignoreGapsInConsensusCalculation = false; @@ -138,13 +139,17 @@ public class AlignViewport * @param al AlignmentI * @param hiddenColumns ColumnSelection */ - public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns) { + public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns) + { setAlignment(al); - if (hiddenColumns!=null) { + if (hiddenColumns != null) + { this.colSel = hiddenColumns; if (hiddenColumns.getHiddenColumns() != null) + { hasHiddenColumns = true; } + } init(); } @@ -170,6 +175,8 @@ public class AlignViewport String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "") ; String fontSize = Cache.getDefault("FONT_SIZE", "10"); + seqNameItalics = Cache.getDefault("ID_ITALICS", true); + int style = 0; if (fontStyle.equals("bold")) @@ -199,7 +206,7 @@ public class AlignViewport 11f, AlignmentAnnotation.BAR_GRAPH); conservation.hasText = true; - conservation.autoCalculated = true; + conservation.autoCalculated=true; if (Cache.getDefault("SHOW_CONSERVATION", true)) @@ -216,7 +223,7 @@ public class AlignViewport 11f, AlignmentAnnotation.BAR_GRAPH); quality.hasText = true; - quality.autoCalculated = true; + quality.autoCalculated=true; alignment.addAnnotation(quality); } @@ -226,7 +233,7 @@ public class AlignViewport new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); consensus.hasText = true; - consensus.autoCalculated = true; + consensus.autoCalculated=true; if (Cache.getDefault("SHOW_IDENTITY", true)) { @@ -242,7 +249,8 @@ public class AlignViewport if (globalColourScheme instanceof UserColourScheme) { globalColourScheme = UserDefinedColours.loadDefaultColours(); - ((UserColourScheme)globalColourScheme).setThreshold(0, getIgnoreGapsConsensus()); + ( (UserColourScheme) globalColourScheme).setThreshold(0, + getIgnoreGapsConsensus()); } if (globalColourScheme != null) @@ -271,9 +279,8 @@ public class AlignViewport return showSequenceFeatures; } - - - class ConservationThread extends Thread + class ConservationThread + extends Thread { AlignmentPanel ap; public ConservationThread(AlignmentPanel ap) @@ -293,7 +300,7 @@ public class AlignViewport { if (ap != null) { - ap.repaint(); + ap.paintAlignment(true); } Thread.sleep(200); } @@ -308,7 +315,9 @@ public class AlignViewport int alWidth = alignment.getWidth(); if(alWidth<0) + { return; + } Conservation cons = new jalview.analysis.Conservation("All", jalview.schemes.ResidueProperties.propHash, 3, @@ -360,11 +369,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; @@ -381,7 +396,8 @@ public class AlignViewport value = ( (Double) cons.quality.get(i)).floatValue(); vprop = value - qmin; vprop /= qmax; - quality.annotations[i] = new Annotation(" ", String.valueOf(value), ' ', + quality.annotations[i] = new Annotation(" ", String.valueOf(value), + ' ', value, new Color(minR + (maxR * vprop), minG + (maxG * vprop), @@ -419,7 +435,7 @@ public class AlignViewport if(ap!=null) { - ap.repaint(); + ap.paintAlignment(true); } } @@ -446,7 +462,9 @@ public class AlignViewport public void updateConservation(final AlignmentPanel ap) { if (alignment.isNucleotide() || conservation==null) + { return; + } conservationThread = new ConservationThread(ap); conservationThread.start(); @@ -461,8 +479,8 @@ public class AlignViewport consensusThread.start(); } - - class ConsensusThread extends Thread + class ConsensusThread + extends Thread { AlignmentPanel ap; public ConsensusThread(AlignmentPanel ap) @@ -478,7 +496,7 @@ public class AlignViewport { if (ap != null) { - ap.repaint(); + ap.paintAlignment(true); } Thread.sleep(200); @@ -496,7 +514,9 @@ public class AlignViewport { int aWidth = alignment.getWidth(); if(aWidth<0) + { return; + } consensus.annotations = null; consensus.annotations = new Annotation[aWidth]; @@ -512,11 +532,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) + " "; @@ -528,12 +552,15 @@ 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) @@ -563,7 +590,7 @@ public class AlignViewport if (ap != null) { - ap.repaint(); + ap.paintAlignment(true); } } } @@ -571,23 +598,36 @@ public class AlignViewport * get the consensus sequence as displayed under the PID consensus annotation row. * @return consensus sequence as a new sequence object */ - public SequenceI getConsensusSeq() { + public SequenceI getConsensusSeq() + { if (consensus==null) + { updateConsensus(null); + } if (consensus==null) + { return null; + } StringBuffer seqs=new StringBuffer(); - for (int i=0; i