JAL-2587 Added sizing for annotation and positioning for box
authorkiramt <k.mourao@dundee.ac.uk>
Fri, 28 Jul 2017 10:47:41 +0000 (12:47 +0200)
committerkiramt <k.mourao@dundee.ac.uk>
Fri, 28 Jul 2017 10:47:41 +0000 (12:47 +0200)
src/jalview/gui/OverviewCanvas.java
src/jalview/gui/OverviewPanel.java

index 468deb1..14ffad6 100644 (file)
@@ -180,15 +180,56 @@ public class OverviewCanvas extends JComponent
     }
     else if (lastMiniMe != null)
     {
-      g.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this);
-      /* if (lastMiniMe != miniMe)
+      if ((getWidth() > 0) && (getHeight() > 0)
+              && ((getWidth() != od.getWidth())
+                      || (getHeight() != od.getHeight())))
       {
-        g.setColor(TRANS_GREY);
-        g.fillRect(0, 0, getWidth(), getHeight());
-      }*/
+        // scale the alignment and annotation separately *** if there is
+        // annotation ***
+        if (od.getGraphHeight() > 0)
+        {
+          BufferedImage topImage = lastMiniMe.getSubimage(0, 0,
+                  od.getWidth(), od.getSequencesHeight());
+          BufferedImage bottomImage = lastMiniMe.getSubimage(0,
+                  od.getSequencesHeight(), od.getWidth(),
+                  od.getGraphHeight());
+
+          od.setWidth(getWidth());
+          od.setHeight(getHeight());
+
+          // stick the images back together so lastMiniMe is consistent in the
+          // event
+          // of a repaint
+          lastMiniMe = new BufferedImage(od.getWidth(), od.getHeight(),
+                  BufferedImage.TYPE_INT_RGB);
+          Graphics lg = lastMiniMe.getGraphics();
+          lg.drawImage(topImage, 0, 0, od.getWidth(),
+                  od.getSequencesHeight(), null);
+          lg.drawImage(bottomImage, 0, od.getSequencesHeight(),
+                  od.getWidth(), od.getGraphHeight(), this);
+          lg.dispose();
+        }
+
+        g.drawImage(lastMiniMe, 0, 0, od.getWidth(), od.getHeight(), null);
+      }
+      else
+      {
+        g.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this);
+        if (lastMiniMe != miniMe)
+        {
+          g.setColor(TRANS_GREY);
+          g.fillRect(0, 0, getWidth(), getHeight());
+        }
+      }
+
     }
 
     g.setColor(Color.red);
+
+
+    od.setBoxPosition(av.getAlignment().getHiddenSequences(),
+            av.getAlignment().getHiddenColumns());
+
     od.drawBox(g);
   }
 }
index 6a33ba2..fe57621 100755 (executable)
@@ -93,7 +93,7 @@ public class OverviewPanel extends JPanel implements Runnable,
       @Override
       public void componentResized(ComponentEvent evt)
       {
-        if ((getWidth() != od.getWidth())
+        /*        if ((getWidth() != od.getWidth())
                 || (getHeight() != (od.getHeight())))
         {
           if ((getWidth() > 0) && (getHeight() > 0))
@@ -101,13 +101,13 @@ public class OverviewPanel extends JPanel implements Runnable,
             od.setWidth(getWidth());
             od.setHeight(getHeight());
           }
-
-          setBoxPosition();
+        
+        
           setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
-
-
+        */
           updateOverviewImage();
-        }
+          // setBoxPosition();
+        // }
       }
     });