JAL-2438 removed (non-functional) lastSeq, lastSequenceFeatures
[jalview.git] / src / jalview / renderer / seqfeatures / FeatureRenderer.java
index f826a88..72ac2c8 100644 (file)
@@ -37,12 +37,6 @@ public class FeatureRenderer extends FeatureRendererModel
   private static final AlphaComposite NO_TRANSPARENCY = AlphaComposite
           .getInstance(AlphaComposite.SRC_OVER, 1.0f);
 
-  protected SequenceI lastSeq;
-
-  private volatile SequenceFeature[] lastSequenceFeatures;
-
-  int sfSize;
-
   /**
    * Constructor given a viewport
    * 
@@ -210,12 +204,7 @@ public class FeatureRenderer extends FeatureRendererModel
   }
 
   /**
-   * This is used by Structure Viewers and the Overview Window to get the
-   * feature colour of the rendered sequence
-   * 
-   * @param seq
-   * @param column
-   * @return
+   * {@inheritDoc}
    */
   @Override
   public Color findFeatureColour(SequenceI seq, int column, Graphics g)
@@ -226,33 +215,13 @@ public class FeatureRenderer extends FeatureRendererModel
     }
 
     SequenceFeature[] sequenceFeatures = seq.getSequenceFeatures();
-    if (seq != lastSeq)
-    {
-      lastSeq = seq;
-      lastSequenceFeatures = sequenceFeatures;
-      if (lastSequenceFeatures != null)
-      {
-        sfSize = lastSequenceFeatures.length;
-      }
-    }
-    else
-    {
-      if (lastSequenceFeatures != sequenceFeatures)
-      {
-        lastSequenceFeatures = sequenceFeatures;
-        if (lastSequenceFeatures != null)
-        {
-          sfSize = lastSequenceFeatures.length;
-        }
-      }
-    }
 
-    if (lastSequenceFeatures == null || sfSize == 0)
+    if (sequenceFeatures == null || sequenceFeatures.length == 0)
     {
       return null;
     }
 
-    if (Comparison.isGap(lastSeq.getCharAt(column)))
+    if (Comparison.isGap(seq.getCharAt(column)))
     {
       return Color.white;
     }
@@ -260,26 +229,35 @@ public class FeatureRenderer extends FeatureRendererModel
     Color renderedColour = null;
     if (transparency == 1.0f)
     {
+      /*
+       * simple case - just find the topmost rendered visible feature colour
+       */
       renderedColour = findFeatureColour(seq, seq.findPosition(column));
     }
     else
     {
-      renderedColour = drawSequence(g, lastSeq, column, column, 0, true);
+      /*
+       * transparency case - draw all visible features in render order to
+       * build up a composite colour on the graphics context
+       */
+      renderedColour = drawSequence(g, seq, column, column, 0, true);
     }
     return renderedColour;
   }
 
   /**
    * Draws the sequence features on the graphics context, or just determines the
-   * colour that would be drawn (if flag offscreenrender is true).
+   * colour that would be drawn (if flag colourOnly is true). Returns the last
+   * colour drawn (which may not be the effective colour if transparency
+   * applies), or null if no feature is drawn in the range given.
    * 
    * @param g
    *          the graphics context to draw on (may be null if colourOnly==true)
    * @param seq
    * @param start
-   *          start column (or sequence position in offscreenrender mode)
+   *          start column
    * @param end
-   *          end column (not used in offscreenrender mode)
+   *          end column
    * @param y1
    *          vertical offset at which to draw on the graphics
    * @param colourOnly
@@ -299,13 +277,6 @@ public class FeatureRenderer extends FeatureRendererModel
 
     updateFeatures();
 
-    if (lastSeq == null || seq != lastSeq
-            || sequenceFeatures != lastSequenceFeatures)
-    {
-      lastSeq = seq;
-      lastSequenceFeatures = sequenceFeatures;
-    }
-
     if (transparency != 1f && g != null)
     {
       Graphics2D g2 = (Graphics2D) g;
@@ -313,10 +284,10 @@ public class FeatureRenderer extends FeatureRendererModel
               transparency));
     }
 
-    int startPos = lastSeq.findPosition(start);
-    int endPos = lastSeq.findPosition(end);
+    int startPos = seq.findPosition(start);
+    int endPos = seq.findPosition(end);
 
-    sfSize = lastSequenceFeatures.length;
+    int sfSize = sequenceFeatures.length;
     Color drawnColour = null;
 
     /*
@@ -334,7 +305,7 @@ public class FeatureRenderer extends FeatureRendererModel
       // current feature to render
       for (int sfindex = 0; sfindex < sfSize; sfindex++)
       {
-        final SequenceFeature sequenceFeature = lastSequenceFeatures[sfindex];
+        final SequenceFeature sequenceFeature = sequenceFeatures[sfindex];
         if (!sequenceFeature.type.equals(type))
         {
           continue;
@@ -445,7 +416,6 @@ public class FeatureRenderer extends FeatureRendererModel
   @Override
   public void featuresAdded()
   {
-    lastSeq = null;
     findAllFeatures();
   }
 
@@ -467,7 +437,10 @@ public class FeatureRenderer extends FeatureRendererModel
       return null;
     }
   
-    // updateFeatures();
+    /*
+     * check for new feature added while processing
+     */
+    updateFeatures();
 
     /*
      * inspect features in reverse renderOrder (the last in the array is 
@@ -494,6 +467,10 @@ public class FeatureRenderer extends FeatureRendererModel
           continue;
         }
 
+        /*
+         * check the column position is within the feature range
+         * (or is one of the two contact positions for a contact feature)
+         */
         boolean featureIsAtPosition = sequenceFeature.begin <= pos
                 && sequenceFeature.end >= pos;
         if (sequenceFeature.isContactFeature())