From: amwaterhouse Date: Mon, 18 Apr 2005 16:04:37 +0000 (+0000) Subject: wrap alignment box paints correctly X-Git-Tag: Release_2_0~385 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=15c8bff8dcc1505bb06697a9532a71f9d30ee429;p=jalview.git wrap alignment box paints correctly --- diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 9b59309..83e3a6d 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -1,6 +1,7 @@ package jalview.gui; import java.awt.*; +import java.awt.image.*; import javax.swing.*; import jalview.datamodel.*; import jalview.analysis.*; @@ -9,7 +10,7 @@ import jalview.analysis.*; public class SeqCanvas extends JPanel { FeatureRenderer fr; - Image img; + BufferedImage img; Graphics2D gg; int imgWidth; int imgHeight; @@ -77,7 +78,7 @@ public class SeqCanvas extends JPanel } if(value!=-1) { - int x = fm.stringWidth("000") - fm.stringWidth(value+""); + int x = LABEL_WEST - fm.stringWidth(value+""); g.drawString(value + "", x, ypos + i*av.charHeight - av.charHeight/5); } } @@ -191,7 +192,7 @@ public void fastPaint(int horizontal, int vertical) imgWidth -= imgWidth%av.charWidth; imgHeight-= imgHeight%av.charHeight; - img = createImage(imgWidth,imgHeight); + img = new BufferedImage(imgWidth,imgHeight,BufferedImage.TYPE_INT_RGB); gg = (Graphics2D)img.getGraphics(); gg.setFont(av.getFont()); gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); @@ -215,16 +216,19 @@ public void fastPaint(int horizontal, int vertical) } + int LABEL_WEST, LABEL_EAST; public int getWrappedCanvasWidth(int cwidth) { FontMetrics fm = getFontMetrics(av.getFont()); - int LABEL_EAST = 0; + LABEL_EAST = 0; + LABEL_WEST = 0; + if(av.scaleRightWrapped) LABEL_EAST = fm.stringWidth( av.alignment.getWidth()+"000" ); - int LABEL_WEST = 0; + if(av.scaleLeftWrapped) - LABEL_WEST = fm.stringWidth( av.alignment.getWidth()+"0" ); + LABEL_WEST = fm.stringWidth( av.alignment.getWidth()+"" ); return (cwidth - LABEL_EAST -LABEL_WEST)/av.charWidth; } @@ -240,7 +244,8 @@ public void fastPaint(int horizontal, int vertical) LABEL_EAST = fm.stringWidth( al.getWidth()+"000" ); int LABEL_WEST = 0; if(av.scaleLeftWrapped) - LABEL_WEST = fm.stringWidth( al.getWidth()+"0" ); + LABEL_WEST = fm.stringWidth(al.getWidth()+"0"); + int cWidth = (canvasWidth - LABEL_EAST -LABEL_WEST)/av.charWidth; int cHeight = (av.getAlignment().getHeight() + 2)*av.charHeight; @@ -249,7 +254,7 @@ public void fastPaint(int horizontal, int vertical) int ypos = 2*av.charHeight; - while (ypos <= canvasHeight) + while (ypos <= canvasHeight && startRes starty && y1 < av.getEndSeq()) - { - fillBackground(g, - Color.red, - (x1-startx)*charWidth, - offset + AlignmentUtil.getPixelHeight(starty,y1,av.getCharHeight()), - (x2-x1+1)*charWidth, - offset + AlignmentUtil.getPixelHeight(y1,y2,av.getCharHeight())); - }*/ - SequenceI nextSeq; /// First draw the sequences @@ -365,15 +345,6 @@ public void fastPaint(int horizontal, int vertical) sy = offset + AlignmentUtil.getPixelHeight(starty, i, av.charHeight); ex = (group.getEndRes() + 1 - group.getStartRes()) * av.charWidth -1; - if (av.getWrapAlignment()) - { - if (sx < 0) - sx = 0; - - if (ex > getWidth()) - ex = getWrappedCanvasWidth(getWidth()) * av.charWidth; - } - if (sx < getWidth() && ex > 0 && group.sequences.contains(av.alignment.getSequenceAt(i)))