X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdCanvas.java;h=ff3eb16fc7edd6d9d44a5564f5780c95e6b3f88b;hb=f1eef48c0073f03279b444dc297780c26d238cd8;hp=6d4a5b9b589f9807aded006cf5df216865c28218;hpb=3c6f9560473b43f3f6e338e4f0fa2405b732179e;p=jalview.git diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index 6d4a5b9..ff3eb16 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -10,7 +10,6 @@ public class IdCanvas extends JPanel { protected AlignViewport av; - public boolean paintFlag = false; protected boolean showScores = true; protected int maxIdLength = -1; @@ -23,29 +22,35 @@ public class IdCanvas extends JPanel PaintRefresher.Register(this); } - public void drawIdString(Graphics gg,SequenceI ds,int i, int starty, int ypos) { + public void drawIdString(Graphics gg,SequenceI s,int i, int starty, int ypos) { int charHeight = av.getCharHeight(); - if (av.getSelection().contains(ds)) { + + if (av.getSelectionGroup()!=null && av.getSelectionGroup().sequences.contains(s)) { gg.setColor(Color.lightGray); gg.fillRect(0,AlignmentUtil.getPixelHeight(starty,i,charHeight)+ ypos,getWidth(),charHeight); gg.setColor(Color.white); } else { - gg.setColor(ds.getColor()); + gg.setColor(s.getColor()); gg.fillRect(0,AlignmentUtil.getPixelHeight(starty,i,charHeight)+ ypos,getWidth(),charHeight); gg.setColor(Color.black); } - String string = ds.getName() + "/" + ds.getStart() + "-" + ds.getEnd(); + String string = s.getName(); + if(av.getShowFullId()) + string = s.getDisplayId(); gg.drawString(string,0,AlignmentUtil.getPixelHeight(starty,i,charHeight) + ypos + charHeight- (charHeight/5)); } public void paintComponent(Graphics gg) { - AlignmentI da = av.getAlignment(); - int charHeight = av.getCharHeight(); - gg.setFont(av.getFont()); + AlignmentI al = av.alignment; + int charHeight = av.charHeight; + Font italic = new Font(av.getFont().getName(), Font.ITALIC, av.getFont().getSize()); + + gg.setFont(italic); + //Fill in the background gg.setColor(Color.white); @@ -56,70 +61,25 @@ public class IdCanvas extends JPanel //Which ids are we printing int starty = av.getStartSeq(); - int endy = av.getEndSeq(); + int endy = av.endSeq; if (av.getWrapAlignment()) { - starty = starty%av.getChunkHeight(); - - int ypos = 0; - int rowstart = starty; - - if (starty == 0) - ypos = 2*charHeight; - else if (starty == 1) - { - starty = 0; - ypos = charHeight; - } - - endy = starty + da.getHeight(); - - if (endy > da.getHeight()) { - endy = da.getHeight(); - } - - for (int i = starty; i < endy; i++) { - SequenceI s = da.getSequenceAt(i); - drawIdString(gg,s,i,starty,ypos); - } - if (rowstart == 0) { - ypos = ypos + av.getChunkHeight(); - } else if (rowstart == 1) { - ypos = ypos + av.getChunkHeight(); - } else { - ypos = ypos + av.getChunkHeight() - rowstart*charHeight; - } - - starty = 0; - - int chunkwidth = av.getChunkWidth(); - int startx = (int)(av.getEndSeq()/chunkwidth)*chunkwidth; - int endx = startx + chunkwidth; - - - while (ypos <= getHeight() && endx < da.getWidth()) { - - for (int i = starty; i < endy; i++) { - SequenceI s = da.getSequenceAt(i); - drawIdString(gg,s,i,starty,ypos); - } - - ypos += av.getChunkHeight(); - startx += chunkwidth; - endx = startx + chunkwidth; + // Draw the rest of the panels + int chunkHeight = (al.getHeight() + 2)*av.charHeight; + int row = av.getStartRes() / av.chunkWidth ; + for(int ypos=2*av.charHeight; + ypos <= getHeight() && row*av.chunkWidth da.getWidth()) { - endx = da.getWidth(); - } - starty = 0; - - if (endy > da.getHeight()) { - endy = da.getHeight(); - } - - } } else { @@ -127,14 +87,16 @@ public class IdCanvas extends JPanel for (int i = starty; i < endy; i++) { // Selected sequence colours - if (av.getSelection().contains(da.getSequenceAt(i))) + + if (av.getSelectionGroup()!= null && av.getSelectionGroup().sequences.contains(al.getSequenceAt(i))) { + // if(av.alignment.findGroup(al.getSequenceAt(i)).getEndRes()== currentColor = Color.lightGray; currentTextColor = Color.black; } else { - currentColor = da.getSequenceAt(i).getColor(); + currentColor = al.getSequenceAt(i).getColor(); currentTextColor = Color.black; } @@ -146,41 +108,18 @@ public class IdCanvas extends JPanel charHeight); gg.setColor(currentTextColor); - String string = da.getSequenceAt(i).getDisplayId(); + String string = al.getSequenceAt(i).getName(); + if(av.getShowFullId()) + string = al.getSequenceAt(i).getDisplayId(); gg.drawString(string, 0, AlignmentUtil.getPixelHeight(starty, i, charHeight) + charHeight - (charHeight / 5)); } + + // add a border + gg.setColor(Color.white); + gg.fillRect(getWidth()-4,0,4,getHeight()); } } - - - public Dimension getLabelWidth() - { - - FontMetrics fm = this.getGraphics().getFontMetrics(av.font); - AlignmentI al = av.getAlignment(); - - int i = 0; - int idWidth = 0; - - while (i < al.getHeight() && al.getSequenceAt(i) != null) - { - SequenceI s = al.getSequenceAt(i); - String str = s.getDisplayId(); - if (fm.stringWidth(str) > idWidth) - idWidth = fm.stringWidth(str); - i++; - } - - return new Dimension(idWidth + 10,getHeight()); - } - - public Dimension getPreferredSize() - { - return getLabelWidth(); - } - - }