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 AlignViewport av; public boolean paintFlag = false; protected boolean showScores = true; protected int maxIdLength = -1; protected String maxIdStr = null; public IdCanvas(AlignViewport av) { setLayout(new BorderLayout()); this.av = av; PaintRefresher.Register(this); } 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.lightGray); gg.fillRect(0,AlignmentUtil.getPixelHeight(starty,i,charHeight)+ ypos,getWidth(),charHeight); gg.setColor(Color.white); } else { gg.setColor(ds.getColor()); gg.fillRect(0,AlignmentUtil.getPixelHeight(starty,i,charHeight)+ ypos,getWidth(),charHeight); gg.setColor(Color.black); } String string = ds.getName() + "/" + ds.getStart() + "-" + ds.getEnd(); 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()); //Fill in the background gg.setColor(Color.white); gg.fillRect(0,0,getWidth(),getHeight()); Color currentColor = Color.white; Color currentTextColor = Color.black; //Which ids are we printing int starty = av.getStartSeq(); int endy = av.endSeq; if (av.getWrapAlignment()) { // Draw the rest of the panels int chunkHeight = (da.getHeight() + 2)*av.charHeight; int row = av.getStartRes() / av.chunkWidth ; for(int ypos=2*av.charHeight; ypos <= getHeight() && row*av.chunkWidth idWidth) idWidth = fm.stringWidth(str); i++; } return new Dimension(idWidth + 10,getHeight()); } public Dimension getPreferredSize() { return getLabelWidth(); } }