X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FIdCanvas.java;h=6d4a5b9b589f9807aded006cf5df216865c28218;hb=c865a01627208f07db46ae7d28c06f39d83924ee;hp=fee86cdfbdf8df3bdbf62d453ebe232bc16910bb;hpb=8d93a0012a8372e61445046ae742830b59936ebb;p=jalview.git diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index fee86cd..6d4a5b9 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,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 { @@ -42,47 +38,18 @@ public class IdCanvas extends JPanel String string = ds.getName() + "/" + ds.getStart() + "-" + ds.getEnd(); - gg.drawString(string,0,AlignmentUtil.getPixelHeight(starty,i,charHeight) + ypos + charHeight/2); + gg.drawString(string,0,AlignmentUtil.getPixelHeight(starty,i,charHeight) + ypos + charHeight- (charHeight/5)); } - public void paintComponent(Graphics g) { + public void paintComponent(Graphics gg) { AlignmentI da = av.getAlignment(); - int charWidth = (int)av.getCharWidth(); 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; @@ -91,17 +58,17 @@ public class IdCanvas extends JPanel int starty = av.getStartSeq(); int endy = av.getEndSeq(); - - - if (av.getWrapAlignment()) { + if (av.getWrapAlignment()) + { starty = starty%av.getChunkHeight(); int ypos = 0; int rowstart = starty; - if (starty == 0) { + if (starty == 0) ypos = 2*charHeight; - } else if (starty == 1) { + else if (starty == 1) + { starty = 0; ypos = charHeight; } @@ -135,7 +102,7 @@ public class IdCanvas extends JPanel for (int i = starty; i < endy; i++) { SequenceI s = da.getSequenceAt(i); - drawIdString(gg,s,i,starty,ypos); + drawIdString(gg,s,i,starty,ypos); } ypos += av.getChunkHeight(); @@ -153,45 +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))) { - if (currentColor != Color.gray) { - currentColor = Color.gray; + //Now draw the id strings + for (int i = starty; i < endy; i++) + { + // 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; } - } - else if (da.getSequenceAt(i).getColor() != null) - { - currentColor = da.getSequenceAt(i).getColor(); - currentTextColor = Color.black; - } - gg.setColor(currentColor); + gg.setColor(currentColor); - if (currentColor != Color.BLACK) - { gg.fillRect(0, - AlignmentUtil.getPixelHeight(starty,i,charHeight), + 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); }