X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdCanvas.java;h=67c3dca37b3d0036ae6e73bcad7406d9f5598bc1;hb=1fdab090d852d60dfa5e859a1335579d43b5c7f4;hp=67fabf799cc3e350699318ff97252cd15f457dee;hpb=dad44a64adbed84c9bf40a49fc8fa01e9e6074f0;p=jalview.git diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index 67fabf7..67c3dca 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -1,17 +1,13 @@ package jalview.gui; import java.awt.*; +import java.awt.Graphics2D.*; + import javax.swing.*; import jalview.datamodel.*; import jalview.analysis.*; public class IdCanvas extends JPanel { - protected Image img; - protected Graphics gg; - - protected int imgWidth; - protected int imgHeight; - protected AlignViewport av; public boolean paintFlag = false; @@ -27,7 +23,7 @@ public class IdCanvas extends JPanel PaintRefresher.Register(this); } - public void drawIdString(Graphics g,SequenceI ds,int i, int starty, int ypos) { + public void drawIdString(Graphics gg,SequenceI ds,int i, int starty, int ypos) { int charHeight = av.getCharHeight(); if (av.getSelection().contains(ds)) { @@ -46,42 +42,14 @@ public class IdCanvas extends JPanel } - public void paintComponent(Graphics g) { + public void paintComponent(Graphics gg) { AlignmentI da = av.getAlignment(); int charHeight = av.getCharHeight(); - Font f = av.getFont(); - - if (img == null || - imgWidth != getWidth() || - imgHeight != getHeight() || - paintFlag == true) { - - imgWidth = getWidth(); - imgHeight = getHeight(); - - if (imgWidth <= 0 ) { - imgWidth = 700; - } - if (imgHeight <= 0 ) { - imgHeight = 500; - } - - img = createImage(imgWidth,imgHeight); - - gg = img.getGraphics(); - gg.setColor(Color.white); - gg.fillRect(0,0,imgWidth,imgHeight); - - gg.setFont(f); - - paintFlag = false; - - } - + gg.setFont(av.getFont()); //Fill in the background gg.setColor(Color.white); - gg.fillRect(0,0,imgWidth,imgHeight); + gg.fillRect(0,0,getWidth(),getHeight()); Color currentColor = Color.white; Color currentTextColor = Color.black; @@ -90,8 +58,6 @@ public class IdCanvas extends JPanel int starty = av.getStartSeq(); int endy = av.getEndSeq(); - - if (av.getWrapAlignment()) { starty = starty%av.getChunkHeight(); @@ -154,42 +120,39 @@ public class IdCanvas extends JPanel } } - } else { - - //Now draw the id strings - for (int i = starty; i < endy; i++) + } else { - // Selected sequence colours - if (av.getSelection().contains(da.getSequenceAt(i))) + //Now draw the id strings + for (int i = starty; i < endy; i++) { - currentColor = Color.gray; + // Selected sequence colours + if (av.getSelection().contains(da.getSequenceAt(i))) + { + currentColor = Color.gray; currentTextColor = Color.black; - } - else - { - currentColor = da.getSequenceAt(i).getColor(); - currentTextColor = Color.black; - } - - gg.setColor(currentColor); - + } + else + { + currentColor = da.getSequenceAt(i).getColor(); + currentTextColor = Color.black; + } + gg.setColor(currentColor); - gg.fillRect(0, - AlignmentUtil.getPixelHeight(starty,i,charHeight), + gg.fillRect(0, + AlignmentUtil.getPixelHeight(starty, i, charHeight), getWidth(), charHeight); - gg.setColor(currentTextColor); - - String string = da.getSequenceAt(i).getDisplayId(); - - gg.drawString(string,0,AlignmentUtil.getPixelHeight(starty,i,charHeight) + charHeight- (charHeight/5)); - } + gg.setColor(currentTextColor); + String string = da.getSequenceAt(i).getDisplayId(); + gg.drawString(string, 0, + AlignmentUtil.getPixelHeight(starty, i, charHeight) + + charHeight - (charHeight / 5)); + } } - g.drawImage(img,0,0,this); }