X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FIdCanvas.java;h=6d4a5b9b589f9807aded006cf5df216865c28218;hb=c865a01627208f07db46ae7d28c06f39d83924ee;hp=c1df12d0e558e7dbc20ad5e116740d05418da495;hpb=b1081eceb6369009b51c960cb2c77c5b49546cc3;p=jalview.git diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index c1df12d..6d4a5b9 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -8,12 +8,6 @@ import jalview.datamodel.*; import jalview.analysis.*; public class IdCanvas extends JPanel { - protected Image img; - protected Graphics2D gg; - - protected int imgWidth; - protected int imgHeight; - protected AlignViewport av; public boolean paintFlag = false; @@ -29,11 +23,11 @@ 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)) { - gg.setColor(Color.gray); + gg.setColor(Color.lightGray); gg.fillRect(0,AlignmentUtil.getPixelHeight(starty,i,charHeight)+ ypos,getWidth(),charHeight); gg.setColor(Color.white); } else { @@ -48,43 +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 = (Graphics2D)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; @@ -93,8 +58,6 @@ public class IdCanvas extends JPanel int starty = av.getStartSeq(); int endy = av.getEndSeq(); - - if (av.getWrapAlignment()) { starty = starty%av.getChunkHeight(); @@ -157,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.lightGray; 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); }