X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=eb5ef20372ec2396af208c5bdd0421b179f6e58c;hb=990fd5f012601024aaeeb09e2901791d242636c4;hp=36f69a52d6f27bb235ad2999e8c676287c57dce0;hpb=95028e2485f520a9263e779ea1340d433e414072;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 36f69a5..eb5ef20 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.*; @@ -25,11 +29,7 @@ import jalview.bin.*; import jalview.datamodel.*; import jalview.schemes.*; - -import java.awt.*; - -import java.util.*; - +import jalview.structure.StructureSelectionManager; /** * DOCUMENT ME! @@ -61,6 +61,7 @@ public class AlignViewport boolean validCharWidth; int wrappedWidth; Font font; + boolean seqNameItalics; AlignmentI alignment; ColumnSelection colSel = new ColumnSelection(); int threshold; @@ -91,7 +92,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; @@ -109,6 +111,20 @@ public class AlignViewport boolean gatherViewsHere = false; + Stack historyList = new Stack(); + Stack redoList = new Stack(); + + Hashtable sequenceColours; + + int thresholdTextColour = 0; + Color textColour = Color.black; + Color textColour2 = Color.white; + + boolean rightAlignIds = false; + + Hashtable hiddenRepSequences; + + /** * Creates a new AlignViewport object. * @@ -124,13 +140,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(); } @@ -146,6 +166,8 @@ public class AlignViewport showJVSuffix = Cache.getDefault("SHOW_JVSUFFIX", true); showAnnotation = Cache.getDefault("SHOW_ANNOTATIONS", true); + rightAlignIds = Cache.getDefault("RIGHT_ALIGN_IDS", false); + autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true); padGaps = Cache.getDefault("PAD_GAPS", true); @@ -154,6 +176,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")) @@ -183,6 +207,7 @@ public class AlignViewport 11f, AlignmentAnnotation.BAR_GRAPH); conservation.hasText = true; + conservation.autoCalculated=true; if (Cache.getDefault("SHOW_CONSERVATION", true)) @@ -199,6 +224,7 @@ public class AlignViewport 11f, AlignmentAnnotation.BAR_GRAPH); quality.hasText = true; + quality.autoCalculated=true; alignment.addAnnotation(quality); } @@ -208,6 +234,7 @@ public class AlignViewport new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); consensus.hasText = true; + consensus.autoCalculated=true; if (Cache.getDefault("SHOW_IDENTITY", true)) { @@ -223,7 +250,8 @@ public class AlignViewport if (globalColourScheme instanceof UserColourScheme) { globalColourScheme = UserDefinedColours.loadDefaultColours(); - ((UserColourScheme)globalColourScheme).setThreshold(0, getIgnoreGapsConsensus()); + ( (UserColourScheme) globalColourScheme).setThreshold(0, + getIgnoreGapsConsensus()); } if (globalColourScheme != null) @@ -231,6 +259,8 @@ public class AlignViewport globalColourScheme.setConsensus(hconsensus); } } + + wrapAlignment = jalview.bin.Cache.getDefault("WRAP_ALIGNMENT", false); } @@ -250,9 +280,8 @@ public class AlignViewport return showSequenceFeatures; } - - - class ConservationThread extends Thread + class ConservationThread + extends Thread { AlignmentPanel ap; public ConservationThread(AlignmentPanel ap) @@ -264,10 +293,16 @@ public class AlignViewport { try { - while (updatingConservation) + updatingConservation = true; + + while (UPDATING_CONSERVATION) { try { + if (ap != null) + { + ap.paintAlignment(false); + } Thread.sleep(200); } catch (Exception ex) @@ -276,12 +311,14 @@ public class AlignViewport } } - updatingConservation = true; + UPDATING_CONSERVATION = true; int alWidth = alignment.getWidth(); if(alWidth<0) + { return; + } Conservation cons = new jalview.analysis.Conservation("All", jalview.schemes.ResidueProperties.propHash, 3, @@ -295,7 +332,7 @@ public class AlignViewport cons.findQuality(); } - String sequence = cons.getConsSequence().getSequence(); + char [] sequence = cons.getConsSequence().getSequence(); float minR; float minG; float minB; @@ -330,14 +367,20 @@ public class AlignViewport { float value = 0; - c = sequence.charAt(i); + 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; @@ -354,7 +397,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), @@ -387,11 +431,14 @@ public class AlignViewport } + UPDATING_CONSERVATION = false; + updatingConservation = false; + if(ap!=null) { - ap.repaint(); + ap.paintAlignment(true); } - updatingConservation = false; + } } @@ -402,9 +449,13 @@ public class AlignViewport boolean consUpdateNeeded = false; - static boolean updatingConsensus = false; + static boolean UPDATING_CONSENSUS = false; + + static boolean UPDATING_CONSERVATION = false; - static boolean updatingConservation = false; + boolean updatingConsensus = false; + + boolean updatingConservation = false; /** * DOCUMENT ME! @@ -412,7 +463,9 @@ public class AlignViewport public void updateConservation(final AlignmentPanel ap) { if (alignment.isNucleotide() || conservation==null) + { return; + } conservationThread = new ConservationThread(ap); conservationThread.start(); @@ -427,8 +480,8 @@ public class AlignViewport consensusThread.start(); } - - class ConsensusThread extends Thread + class ConsensusThread + extends Thread { AlignmentPanel ap; public ConsensusThread(AlignmentPanel ap) @@ -437,10 +490,16 @@ public class AlignViewport } public void run() { - while (updatingConsensus) + updatingConsensus = true; + while (UPDATING_CONSENSUS) { try { + if (ap != null) + { + ap.paintAlignment(false); + } + Thread.sleep(200); } catch (Exception ex) @@ -449,13 +508,16 @@ public class AlignViewport } } - updatingConsensus = true; + + UPDATING_CONSENSUS = true; try { int aWidth = alignment.getWidth(); if(aWidth<0) + { return; + } consensus.annotations = null; consensus.annotations = new Annotation[aWidth]; @@ -471,11 +533,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,16 +553,21 @@ 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) { + alignment.deleteAnnotation(consensus); + consensus = null; hconsensus = null; javax.swing.SwingUtilities.invokeLater(new Runnable() @@ -515,36 +586,49 @@ public class AlignViewport System.out.println("Consensus calculation: " + error); System.gc(); } + UPDATING_CONSENSUS = false; + updatingConsensus = false; if (ap != null) { - ap.repaint(); + ap.paintAlignment(true); } - - - updatingConsensus = false; } } /** * 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; i0) { if(selectionGroup==null) @@ -1269,15 +1407,19 @@ public class AlignViewport } if(alignment.getHiddenSequences().getSize()<1) + { hasHiddenRows = false; } + } public void showColumn(int col) { colSel.revealHiddenColumns(col); if(colSel.getHiddenColumns()==null) + { hasHiddenColumns = false; } + } public void showAllHiddenColumns() { @@ -1294,7 +1436,7 @@ public class AlignViewport selectionGroup = new SequenceGroup(); selectionGroup.setEndRes(alignment.getWidth()-1); } - Vector tmp = alignment.getHiddenSequences().showAll(); + Vector tmp = alignment.getHiddenSequences().showAll(hiddenRepSequences); for(int t=0; t