JAL-2587 First working effort
authorkiramt <k.mourao@dundee.ac.uk>
Fri, 4 Aug 2017 13:28:43 +0000 (14:28 +0100)
committerkiramt <k.mourao@dundee.ac.uk>
Fri, 4 Aug 2017 13:28:43 +0000 (14:28 +0100)
src/jalview/gui/OverviewCanvas.java

index 3bd365e..8f8cff7 100644 (file)
@@ -198,6 +198,7 @@ public class OverviewCanvas extends JComponent
     {
       updaterunning = false;
       lastMiniMe = miniMe;
+      alpha = 1f;
       timer.start();
     }
   }
@@ -226,8 +227,6 @@ public class OverviewCanvas extends JComponent
               && ((getWidth() != od.getWidth())
                       || (getHeight() != od.getHeight())))
       {
-        resize = true;
-
         // scale the alignment and annotation separately *** if there is
         // annotation ***
         if (od.getGraphHeight() > 0)
@@ -269,32 +268,32 @@ public class OverviewCanvas extends JComponent
       }
       else
       {
-
-        if (lastMiniMe != miniMe && !resize)
-        {
-          g.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this);
-          g.setColor(TRANS_GREY);
-          g.fillRect(0, 0, getWidth(), getHeight());
-        }
-        else if (veryLastMiniMe != null)
+        if (alpha != 0) // this is a timer triggered dissolve
         {
           Graphics2D g2d = (Graphics2D) g.create();
           
-          g2d.setComposite(AlphaComposite.SrcOver.derive(alpha));
+          // draw the original image
           g2d.drawImage(veryLastMiniMe, 0, 0, getWidth(), getHeight(),
                   this);
 
+          // draw the new image on top with varying degrees of transparency
           g2d.setComposite(AlphaComposite.SrcOver.derive(1f - alpha));
           g2d.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this);
 
           g2d.dispose();
         }
+        else if (lastMiniMe != miniMe)
+        {
+          g.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this);
+          g.setColor(TRANS_GREY);
+          g.fillRect(0, 0, getWidth(), getHeight());
+        }
         else
         {
-          // fall back if everything goes wrong somehow
+          // fall back to normal behaviour
           g.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this);
         }
-        resize = false;
+
       }
 
     }