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 g) {
\r
48 Graphics2D gg = (Graphics2D)g;
\r
49 gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
\r
50 AlignmentI al = av.alignment;
\r
51 int charHeight = av.charHeight;
\r
52 Font italic = new Font(av.getFont().getName(), Font.ITALIC, av.getFont().getSize());
\r
57 //Fill in the background
\r
58 gg.setColor(Color.white);
\r
59 gg.fillRect(0,0,getWidth(),getHeight());
\r
61 Color currentColor = Color.white;
\r
62 Color currentTextColor = Color.black;
\r
64 //Which ids are we printing
\r
65 int starty = av.getStartSeq();
\r
66 int endy = av.endSeq;
\r
68 if (av.getWrapAlignment())
\r
70 // Draw the rest of the panels
\r
71 int chunkHeight = (al.getHeight() + 2)*av.charHeight;
\r
72 int row = av.getStartRes() / av.chunkWidth ;
\r
73 for(int ypos=2*av.charHeight;
\r
74 ypos <= getHeight() && row*av.chunkWidth<al.getWidth();
\r
75 ypos += chunkHeight, row++ )
\r
77 for (int i = starty; i < av.alignment.getHeight(); i++)
\r
79 SequenceI s = al.getSequenceAt(i);
\r
80 drawIdString(gg, s, i, 0, ypos);
\r
88 //Now draw the id strings
\r
89 for (int i = starty; i < endy; i++)
\r
91 // Selected sequence colours
\r
93 if (av.getSelectionGroup()!= null && av.getSelectionGroup().sequences.contains(al.getSequenceAt(i)))
\r
95 // if(av.alignment.findGroup(al.getSequenceAt(i)).getEndRes()==
\r
96 currentColor = Color.lightGray;
\r
97 currentTextColor = Color.black;
\r
101 currentColor = al.getSequenceAt(i).getColor();
\r
102 currentTextColor = Color.black;
\r
105 gg.setColor(currentColor);
\r
108 AlignmentUtil.getPixelHeight(starty, i, charHeight),
\r
112 gg.setColor(currentTextColor);
\r
113 String string = al.getSequenceAt(i).getName();
\r
114 if(av.getShowFullId())
\r
115 string = al.getSequenceAt(i).getDisplayId();
\r
116 gg.drawString(string, 0,
\r
117 AlignmentUtil.getPixelHeight(starty, i, charHeight) +
\r
118 charHeight - (charHeight / 5));
\r
122 gg.setColor(Color.white);
\r
123 gg.fillRect(getWidth()-4,0,4,getHeight());
\r