X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSeqCanvas.java;h=30a8090e4ff2cd76f9b537dff0b84e359d47447e;hb=e7ed63f1ea56432246a6ed1553f0fe56d26f56ea;hp=9b593093b7e4176cf2e2caa427c09245a3cba84d;hpb=1a6fbadeec90e7524075ed6e37bbe4b7bba97a94;p=jalview.git diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 9b59309..30a8090 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -1,15 +1,16 @@ package jalview.gui; import java.awt.*; +import java.awt.image.*; import javax.swing.*; import jalview.datamodel.*; import jalview.analysis.*; -public class SeqCanvas extends JPanel +public class SeqCanvas extends JComponent { 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); } } @@ -121,7 +122,7 @@ public void fastPaint(int horizontal, int vertical) gg.copyArea(0, 0, imgWidth, imgHeight, -horizontal * av.charWidth, -vertical * av.charHeight); - int sr = av.startRes, er = av.endRes + 1, ss = av.startSeq, es = av.endSeq, + int sr = av.startRes, er = av.endRes, ss = av.startSeq, es = av.endSeq, transX = 0, transY = 0; if (horizontal > 0) // scrollbar pulled right, image to the left { @@ -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; @@ -248,8 +253,7 @@ public void fastPaint(int horizontal, int vertical) int endx = startRes+cWidth-1; 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 +356,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)))