JAL-1807 Bob's first commit -- Applet loaded; needs image
[jalview.git] / src / jalview / schemes / AnnotationColourGradient.java
index b0822ca..e65d5f5 100755 (executable)
@@ -246,110 +246,82 @@ public class AnnotationColourGradient extends FollowerColourScheme
     return Color.red;
   }
 
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param n
-   *          DOCUMENT ME!
-   * @param j
-   *          DOCUMENT ME!
-   * 
-   * @return DOCUMENT ME!
-   */
-  @Override
-  public Color findColour(char c, int j, SequenceI seq)
-  {
-    Color currentColour = Color.white;
-    AlignmentAnnotation annotation = (seqAssociated && seqannot!=null ? seqannot.get(seq)
-            : this.annotation);
-    if (annotation == null)
-    {
-      return currentColour;
-    }
-    if ((threshold == 0) || aboveThreshold(c, j))
-    {
-      if (annotation.annotations != null
-              && j < annotation.annotations.length
-              && annotation.annotations[j] != null
-              && !Comparison.isGap(c))
-      {
-        Annotation aj = annotation.annotations[j];
-        // 'use original colours' => colourScheme != null
-        // -> look up colour to be used
-        // predefined colours => preconfigured shading
-        // -> only use original colours reference if thresholding enabled &
-        // minmax exists
-        // annotation.hasIcons => null or black colours replaced with glyph
-        // colours
-        // -> reuse original colours if present
-        // -> if thresholding enabled then return colour on non-whitespace glyph
-
-        if (aboveAnnotationThreshold == NO_THRESHOLD
-                || (annotationThreshold != null && (aboveAnnotationThreshold == ABOVE_THRESHOLD ? aj.value >= annotationThreshold.value
-                        : aj.value <= annotationThreshold.value)))
-        {
-          if (predefinedColours && aj.colour != null
-                  && !aj.colour.equals(Color.black))
-          {
-            currentColour = aj.colour;
-          }
-          else if (annotation.hasIcons
-                  && annotation.graph == AlignmentAnnotation.NO_GRAPH)
-          {
-            if (aj.secondaryStructure > ' ' && aj.secondaryStructure != '.'
-                    && aj.secondaryStructure != '-')
-            {
-              if (colourScheme != null)
-              {
-                currentColour = colourScheme.findColour(c, j, seq);
-              }
-              else
-              {
-                if (annotation.isRNA())
-                {
-                  currentColour = ColourSchemeProperty.rnaHelices[(int) aj.value];
-                }
-                else
-                {
-                  currentColour = annotation.annotations[j].secondaryStructure == 'H' ? AnnotationRenderer.HELIX_COLOUR
-                          : annotation.annotations[j].secondaryStructure == 'E' ? AnnotationRenderer.SHEET_COLOUR
-                                  : AnnotationRenderer.STEM_COLOUR;
-                }
-              }
-            }
-            else
-            {
-              //
-              return Color.white;
-            }
-          }
-          else if (noGradient)
-          {
-            if (colourScheme != null)
-            {
-              currentColour = colourScheme.findColour(c, j, seq);
-            }
-            else
-            {
-              if (aj.colour != null)
-              {
-                currentColour = aj.colour;
-              }
-            }
-          }
-          else
-          {
-            currentColour = shadeCalculation(annotation, j);
-          }
-        }
-        if (conservationColouring)
-        {
-          currentColour = applyConservation(currentColour, j);
-        }
-      }
-    }
-    return currentColour;
-  }
+       /**
+        * DOCUMENT ME!
+        * 
+        * @param n
+        *          DOCUMENT ME!
+        * @param j
+        *          DOCUMENT ME!
+        * 
+        * @return DOCUMENT ME!
+        */
+       @Override
+       public Color findColour(char c, int j, SequenceI seq) {
+               Color currentColour = Color.white;
+               AlignmentAnnotation annotation = (seqAssociated && seqannot != null ? seqannot
+                               .get(seq) : this.annotation);
+               if (annotation == null) {
+                       return currentColour;
+               }
+               if ((threshold == 0) || aboveThreshold(c, j)) {
+                       if (annotation.annotations != null && j < annotation.annotations.length
+                                       && annotation.annotations[j] != null && !Comparison.isGap(c)) {
+                               Annotation aj = annotation.annotations[j];
+                               // 'use original colours' => colourScheme != null
+                               // -> look up colour to be used
+                               // predefined colours => preconfigured shading
+                               // -> only use original colours reference if thresholding enabled &
+                               // minmax exists
+                               // annotation.hasIcons => null or black colours replaced with glyph
+                               // colours
+                               // -> reuse original colours if present
+                               // -> if thresholding enabled then return colour on non-whitespace glyph
+
+                               if (aboveAnnotationThreshold == NO_THRESHOLD
+                                               || (annotationThreshold != null && (aboveAnnotationThreshold == ABOVE_THRESHOLD ? aj.value >= annotationThreshold.value
+                                                               : aj.value <= annotationThreshold.value))) {
+                                       if (predefinedColours && aj.colour != null
+                                                       && !aj.colour.equals(Color.black)) {
+                                               currentColour = aj.colour;
+                                       } else if (annotation.hasIcons
+                                                       && annotation.graph == AlignmentAnnotation.NO_GRAPH) {
+                                               if (aj.secondaryStructure > ' ' && aj.secondaryStructure != '.'
+                                                               && aj.secondaryStructure != '-') {
+                                                       if (colourScheme != null) {
+                                                               currentColour = colourScheme.findColour(c, j, seq);
+                                                       } else {
+                                                               if (annotation.isRNA()) {
+                                                                       currentColour = ColourSchemeProperty.rnaHelices[(int) aj.value];
+                                                               } else {
+                                                                       currentColour = annotation.annotations[j].secondaryStructure == 'H' ? AnnotationRenderer.HELIX_COLOUR
+                                                                                       : annotation.annotations[j].secondaryStructure == 'E' ? AnnotationRenderer.SHEET_COLOUR
+                                                                                                       : AnnotationRenderer.STEM_COLOUR;
+                                                               }
+                                                       }
+                                               } else {
+                                                       //
+                                                       return Color.white;
+                                               }
+                                       } else if (noGradient) {
+                                               if (colourScheme != null) {
+                                                       currentColour = colourScheme.findColour(c, j, seq);
+                                               } else {
+                                                       if (aj.colour != null) {
+                                                               currentColour = aj.colour;
+                                                       }
+                                               }
+                                       } else {
+                                               currentColour = shadeCalculation(annotation, j);
+                                       }
+                               }
+                               if (conservationColouring) {
+                                       currentColour = applyConservation(currentColour, j);
+                               }
+                       }
+               }
+               return currentColour;
+       }
 
   private Color shadeCalculation(AlignmentAnnotation annotation, int j)
   {