X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=dd3f980abe33efb7555d277bca01e3c69eba48a3;hb=1402060fb2ca7b2639ef98da3e22766d01149b16;hp=e8f34d8a320ae0a5924cbe6f0c025b446312586b;hpb=efc31b4a8d5cee63555586804a2b79c06bdb5a14;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index e8f34d8..dd3f980 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -58,7 +58,7 @@ public class AlignViewport ColourSchemeI globalColourScheme = null; boolean conservationColourSelected = false; boolean abovePIDThreshold = false; - SequenceGroup selectionGroup = new SequenceGroup(); + SequenceGroup selectionGroup; int charHeight; int charWidth; int chunkWidth; @@ -85,6 +85,8 @@ public class AlignViewport // JBPNote Prolly only need this in the applet version. private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(this); + boolean ignoreGapsInConsensusCalculation = false; + /** * Creates a new AlignViewport object. * @@ -106,52 +108,48 @@ public class AlignViewport */ public void updateFromPreferences() { - showFullId = Preferences.showFullId; - showAnnotation = Preferences.showAnnotation; - showConservation = Preferences.showConservation; - showQuality = Preferences.showQuality; - showIdentity = Preferences.showIdentity; - showFullId = Preferences.showFullId; + showFullId = Cache.getDefault("SHOW_FULL_ID", true); + showAnnotation = Cache.getDefault("SHOW_ANNOTATIONS", true); + showConservation = Cache.getDefault("SHOW_CONSERVATION", true); - String fontName = Preferences.fontName; - String fontStyle = Preferences.fontStyle; - String fontSize = Cache.getProperty("FONT_SIZE"); + showQuality = Cache.getDefault("SHOW_QUALITY", true); + showIdentity = Cache.getDefault("SHOW_IDENTITY", true); - if ((fontName != null) && (fontStyle != null) && (fontSize != null)) - { - int style = 0; + String fontName = Cache.getDefault("FONT_NAME", "SansSerif"); + String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "") ; + String fontSize = Cache.getDefault("FONT_SIZE", "10"); - if (fontStyle.equals("bold")) - { - style = 1; - } - else if (fontStyle.equals("italic")) - { - style = 2; - } + int style = 0; + + if (fontStyle.equals("bold")) + { + style = 1; + } + else if (fontStyle.equals("italic")) + { + style = 2; + } + + setFont(new Font(fontName, style, Integer.parseInt(fontSize))); - setFont(new Font(fontName, style, Integer.parseInt(fontSize))); - } - else - { - setFont(font); - } - alignment.setGapCharacter(Preferences.gapSymbol); + alignment.setGapCharacter( Cache.getDefault("GAP_SYMBOL", "-").charAt(0) ); + // We must set conservation and consensus before setting colour, // as Blosum and Clustal require this to be done updateConservation(); updateConsensus(); - if (Preferences.defaultColour != null) + if (jalview.bin.Cache.getProperty("DEFAULT_COLOUR") != null) { - globalColourScheme = ColourSchemeProperty.getColour(alignment, - Preferences.defaultColour); + globalColourScheme = ColourSchemeProperty.getColour(alignment, + jalview.bin.Cache.getProperty("DEFAULT_COLOUR")); if (globalColourScheme instanceof UserColourScheme) { globalColourScheme = UserDefinedColours.loadDefaultColours(); + ((UserColourScheme)globalColourScheme).setThreshold(0, getIgnoreGapsConsensus()); } if (globalColourScheme != null) @@ -161,6 +159,8 @@ public class AlignViewport } } + + /** * DOCUMENT ME! * @@ -307,18 +307,19 @@ public class AlignViewport { hash = (Hashtable) vconsensus.elementAt(i); - float value = Float.parseFloat(hash.get("maxCount").toString()); - value /= Float.parseFloat(hash.get("size").toString()); - - value *= 100; + float value = 0; + if(ignoreGapsInConsensusCalculation) + value = ((Float)hash.get("pid_nogaps")).floatValue(); + else + value = ((Float)hash.get("pid_gaps")).floatValue(); - String maxRes = hash.get("maxResidue") + " "; - String mouseOver = hash.get("maxResidue") + " "; + String maxRes = hash.get("maxResidue").toString(); + String mouseOver = hash.get("maxResidue")+" "; - if (maxRes.length() > 2) + if (maxRes.length() > 1) { mouseOver = "[" + maxRes + "] "; - maxRes = "+ "; + maxRes = "+"; } mouseOver += ((int) value + "%"); @@ -339,6 +340,9 @@ public class AlignViewport { consensus.annotations = annotations; } + + if(globalColourScheme!=null) + globalColourScheme.setConsensus(vconsensus); } /** @@ -531,10 +535,9 @@ public class AlignViewport { font = f; - javax.swing.JFrame temp = new javax.swing.JFrame(); - temp.addNotify(); + Container c = new Container(); - java.awt.FontMetrics fm = temp.getGraphics().getFontMetrics(font); + java.awt.FontMetrics fm = c.getFontMetrics(font); setCharHeight(fm.getHeight()); setCharWidth(fm.charWidth('M')); } @@ -999,7 +1002,7 @@ public class AlignViewport } /** - * DOCUMENT ME! + * Property change listener for changes in alignment * * @param listener DOCUMENT ME! */ @@ -1021,7 +1024,7 @@ public class AlignViewport } /** - * DOCUMENT ME! + * Property change listener for changes in alignment * * @param prop DOCUMENT ME! * @param oldvalue DOCUMENT ME! @@ -1031,4 +1034,23 @@ public class AlignViewport { changeSupport.firePropertyChange(prop, oldvalue, newvalue); } + + public void setIgnoreGapsConsensus(boolean b) + { + ignoreGapsInConsensusCalculation = b; + updateConsensus(); + if(globalColourScheme!=null && globalColourScheme instanceof ResidueColourScheme) + { + ((ResidueColourScheme) globalColourScheme).setThreshold( + ((ResidueColourScheme) globalColourScheme).getThreshold(), ignoreGapsInConsensusCalculation); + + + } + + } + + public boolean getIgnoreGapsConsensus() + { + return ignoreGapsInConsensusCalculation; + } }