4 import java.awt.Graphics2D.*;
\r
6 import javax.swing.*;
\r
7 import jalview.datamodel.*;
\r
8 import jalview.analysis.*;
\r
9 public class IdCanvas extends JPanel
\r
11 protected AlignViewport av;
\r
13 protected boolean showScores = true;
\r
15 protected int maxIdLength = -1;
\r
16 protected String maxIdStr = null;
\r
18 public IdCanvas(AlignViewport av)
\r
20 setLayout(new BorderLayout());
\r
22 PaintRefresher.Register(this);
\r
25 public void drawIdString(Graphics gg,SequenceI s,int i, int starty, int ypos) {
\r
26 int charHeight = av.getCharHeight();
\r
29 if (av.getSelectionGroup()!=null && av.getSelectionGroup().sequences.contains(s)) {
\r
30 gg.setColor(Color.lightGray);
\r
31 gg.fillRect(0,AlignmentUtil.getPixelHeight(starty,i,charHeight)+ ypos,getWidth(),charHeight);
\r
32 gg.setColor(Color.white);
\r
34 gg.setColor(s.getColor());
\r
35 gg.fillRect(0,AlignmentUtil.getPixelHeight(starty,i,charHeight)+ ypos,getWidth(),charHeight);
\r
36 gg.setColor(Color.black);
\r
39 String string = s.getName();
\r
40 if(av.getShowFullId())
\r
41 string = s.getDisplayId();
\r
43 gg.drawString(string,0,AlignmentUtil.getPixelHeight(starty,i,charHeight) + ypos + charHeight- (charHeight/5));
\r
47 public void paintComponent(Graphics gg) {
\r
48 AlignmentI al = av.alignment;
\r
49 int charHeight = av.charHeight;
\r
50 Font italic = new Font(av.getFont().getName(), Font.ITALIC, av.getFont().getSize());
\r
55 //Fill in the background
\r
56 gg.setColor(Color.white);
\r
57 gg.fillRect(0,0,getWidth(),getHeight());
\r
59 Color currentColor = Color.white;
\r
60 Color currentTextColor = Color.black;
\r
62 //Which ids are we printing
\r
63 int starty = av.getStartSeq();
\r
64 int endy = av.endSeq;
\r
66 if (av.getWrapAlignment())
\r
68 // Draw the rest of the panels
\r
69 int chunkHeight = (al.getHeight() + 2)*av.charHeight;
\r
70 int row = av.getStartRes() / av.chunkWidth ;
\r
71 for(int ypos=2*av.charHeight;
\r
72 ypos <= getHeight() && row*av.chunkWidth<al.getWidth();
\r
73 ypos += chunkHeight, row++ )
\r
75 for (int i = starty; i < av.alignment.getHeight(); i++)
\r
77 SequenceI s = al.getSequenceAt(i);
\r
78 drawIdString(gg, s, i, 0, ypos);
\r
86 //Now draw the id strings
\r
87 for (int i = starty; i < endy; i++)
\r
89 // Selected sequence colours
\r
91 if (av.getSelectionGroup()!= null && av.getSelectionGroup().sequences.contains(al.getSequenceAt(i)))
\r
93 // if(av.alignment.findGroup(al.getSequenceAt(i)).getEndRes()==
\r
94 currentColor = Color.lightGray;
\r
95 currentTextColor = Color.black;
\r
99 currentColor = al.getSequenceAt(i).getColor();
\r
100 currentTextColor = Color.black;
\r
103 gg.setColor(currentColor);
\r
106 AlignmentUtil.getPixelHeight(starty, i, charHeight),
\r
110 gg.setColor(currentTextColor);
\r
111 String string = al.getSequenceAt(i).getName();
\r
112 if(av.getShowFullId())
\r
113 string = al.getSequenceAt(i).getDisplayId();
\r
114 gg.drawString(string, 0,
\r
115 AlignmentUtil.getPixelHeight(starty, i, charHeight) +
\r
116 charHeight - (charHeight / 5));
\r
120 gg.setColor(Color.white);
\r
121 gg.fillRect(getWidth()-4,0,4,getHeight());
\r