From be4db180ce3af04fc619f2aa92b812d2057f36aa Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 10 Aug 2006 14:57:52 +0000 Subject: [PATCH] Smoother drawing --- src/jalview/appletgui/OverviewPanel.java | 33 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 4d3dec4..54e1ac2 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -26,6 +26,7 @@ public class OverviewPanel extends Panel implements Runnable, MouseMotionListener, MouseListener { Image miniMe; + Image offscreen; AlignViewport av; AlignmentPanel ap; float scalew = 1f; @@ -252,17 +253,19 @@ public class OverviewPanel scaleh = (float) sequencesHeight / (float) fullsizeHeight; miniMe = nullFrame.createImage(width, sequencesHeight + graphHeight); + offscreen = nullFrame.createImage(width, sequencesHeight + graphHeight); Graphics mg = miniMe.getGraphics(); float sampleCol = (float) alwidth / (float) width; float sampleRow = (float) alheight / (float) sequencesHeight; - int lastcol=-1, lastrow=-1; + int lastcol=0, lastrow=0; + int xstart=0, ystart=0; Color color = Color.yellow; int row, col, sameRow = 0, sameCol = 0; jalview.datamodel.SequenceI seq; boolean hiddenRow = false; - for (row = 0; row < sequencesHeight; row++) + for (row = 0; row <= sequencesHeight; row++) { if((int)(row*sampleRow)==lastrow) { @@ -270,8 +273,6 @@ public class OverviewPanel continue; } - lastrow = (int)(row*sampleRow); - hiddenRow = false; if (av.hasHiddenRows) { @@ -291,12 +292,6 @@ public class OverviewPanel else seq = av.alignment.getSequenceAt(lastrow); - if(seq==null) - { - System.out.println(lastrow+" null"); - continue; - } - for (col = 0; col < width; col++) { if ( (int) (col * sampleCol) == lastcol && (int) (row * sampleRow) == lastrow) @@ -328,12 +323,15 @@ public class OverviewPanel mg.setColor(color); if (sameCol == 1 && sameRow == 1) - mg.drawLine(col, row, col, row); + mg.drawLine(xstart, ystart, xstart, ystart); else - mg.fillRect(col, row, col+sameCol, col+sameRow); + mg.fillRect(xstart, ystart, sameCol, sameRow); + xstart = col; sameCol = 1; } + lastrow = (int)(row*sampleRow); + ystart = row; sameRow = 1; } @@ -418,9 +416,14 @@ public class OverviewPanel public void paint(Graphics g) { + Graphics og = offscreen.getGraphics(); if (miniMe != null) { - g.drawImage(miniMe, 0, 0, this); + og.drawImage(miniMe, 0, 0, this); + og.setColor(Color.red); + og.drawRect(boxX, boxY, boxWidth, boxHeight); + og.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2); + g.drawImage(offscreen, 0,0, this); } else { @@ -431,10 +434,6 @@ public class OverviewPanel g.drawString("Recalculating", 5, sequencesHeight / 2); g.drawString("Overview.....", 5, (sequencesHeight / 2) + 20); } - - g.setColor(Color.red); - g.drawRect(boxX, boxY, boxWidth, boxHeight); - g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2); } } -- 1.7.10.2