scale above, left right added
[jalview.git] / src / jalview / gui / AlignViewport.java
index 19a206d..d02eb01 100755 (executable)
@@ -22,6 +22,7 @@ public class AlignViewport
   boolean wrapAlignment=false;\r
   boolean renderGaps = true;\r
   boolean showSequenceFeatures = false;\r
+  boolean showAnnotation = true;\r
 \r
   boolean colourAppliesToAllGroups = true;\r
   ColourSchemeI globalColourScheme = null;\r
@@ -42,12 +43,15 @@ public class AlignViewport
 \r
   ColumnSelection colSel = new ColumnSelection();\r
 \r
-\r
   int threshold;\r
   int increment;\r
 \r
   NJTree currentTree = null;\r
 \r
+  boolean scaleAboveWrapped = false;\r
+  boolean scaleLeftWrapped  = true;\r
+  boolean scaleRightWrapped = true;\r
+\r
 \r
   public AlignViewport(AlignmentI al,\r
                        boolean showText,\r
@@ -83,29 +87,41 @@ public class AlignViewport
         alignment.getWidth());\r
     cons.calculate();\r
     cons.verdict(false, 100);\r
-\r
+    cons.findQuality();\r
     String sequence = cons.getConsSequence().getSequence();\r
+    float minR,minG,minB, maxR,maxG,maxB;\r
+    minR = 0.3f;\r
+    minG = 0f;\r
+    minB = 0f;\r
+    maxR = 1.0f-minR; maxG=0.9f-minG; maxB=0f-minB; // scalable range for colouring\r
+    float min = cons.qualityRange[0].floatValue();\r
+    float max = cons.qualityRange[1].floatValue();\r
+\r
     for (int i = 0; i < alignment.getWidth(); i++)\r
     {\r
-      int value = 0;\r
+      float value = 0;\r
       try\r
       {\r
-        value = Integer.parseInt(sequence.charAt(i) + "");\r
+        //value = Integer.parseInt(sequence.charAt(i) + "");\r
+        value = ((Double) cons.quality.get(i)).floatValue();\r
       }\r
       catch (Exception ex)\r
       {\r
         if (sequence.charAt(i) == '*') value = 10;\r
       }\r
-\r
+      float vprop = value-min;\r
+      vprop/=max;\r
       annotations[i] = new Annotation(sequence.charAt(i) + "",\r
-                                      "Conservation graph", ' ', value);\r
+                                      "Conservation graph", ' ', value, new Color(minR+maxR*vprop, minB+maxB*vprop, minB+maxB*vprop));\r
     }\r
 \r
     if(conservation==null)\r
     {\r
       conservation = new AlignmentAnnotation("Conservation",\r
                                              "Conservation of total alignment",\r
-                                             annotations, 0, 10, 1);\r
+                                             annotations,\r
+                                             cons.qualityRange[0].floatValue(),\r
+                                             cons.qualityRange[1].floatValue(), 1);\r
       alignment.addAnnotation(conservation);\r
     }\r
     else\r
@@ -134,7 +150,7 @@ public class AlignViewport
           maxRes = "+ ";\r
         }\r
 \r
-        mouseOver += value+"%";\r
+        mouseOver += (int)value+"%";\r
         annotations[i] = new Annotation(maxRes, mouseOver, ' ', value);\r
 \r
     }\r
@@ -421,4 +437,34 @@ public class AlignViewport
   {\r
     showFullId = b;\r
   }\r
+\r
+  public boolean getShowAnnotation()\r
+  {\r
+    return showAnnotation;\r
+  }\r
+\r
+  public void setShowAnnotation(boolean b)\r
+  {\r
+    showAnnotation = b;\r
+  }\r
+\r
+  public boolean getScaleAboveWrapped()\r
+  { return scaleAboveWrapped;}\r
+\r
+  public boolean getScaleLeftWrapped()\r
+  { return scaleLeftWrapped; }\r
+\r
+  public boolean getScaleRightWrapped()\r
+  { return scaleRightWrapped; }\r
+\r
+  public void setScaleAboveWrapped(boolean b)\r
+  { scaleAboveWrapped = b; }\r
+\r
+  public void setScaleLeftWrapped(boolean b)\r
+  { scaleLeftWrapped = b; }\r
+\r
+  public void setScaleRightWrapped(boolean b)\r
+  { scaleRightWrapped = b; }\r
+\r
+\r
 }\r