From 470b5191a045f078014ec3d5d8727e041141def2 Mon Sep 17 00:00:00 2001 From: kiramt Date: Fri, 28 Jul 2017 12:47:41 +0200 Subject: [PATCH] JAL-2587 Added sizing for annotation and positioning for box --- src/jalview/gui/OverviewCanvas.java | 51 +++++++++++++++++++++++++++++++---- src/jalview/gui/OverviewPanel.java | 12 ++++----- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/src/jalview/gui/OverviewCanvas.java b/src/jalview/gui/OverviewCanvas.java index 468deb1..14ffad6 100644 --- a/src/jalview/gui/OverviewCanvas.java +++ b/src/jalview/gui/OverviewCanvas.java @@ -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); } } diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index 6a33ba2..fe57621 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -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(); + // } } }); -- 1.7.10.2