import java.awt.*; public class Ndraw extends Panel{ private String[] data; //the strings private Color[] datac; //the color of the strings private int[][] pos; //pos[x] contains row and col info for string int[] lpos; private int nindex; public static final int TOP=1; public static final int BOTTOM=2; public static final int NONE=0; //constructors public Ndraw(String[] data, Color[] datac, int[][] pos,int[] lpos,int NIndex){ //rowcol true: pos is row and col this.nindex=NIndex; this.data = data; this.datac = datac; this.pos = pos; this.lpos = lpos; } //changers public void setString(String[] data){ this.data = data; repaint(); } public void setColor(Color[] datac){ this.datac = datac; repaint(); } public void setRowCol(int[][] pos){ this.pos = pos; repaint(); } //display public void paint(Graphics g){ FontMetrics fm; int i; fm = g.getFontMetrics(); g.setColor(Color.black); g.drawRect(0,0,size().width-1,size().height-1); g.drawRect(2,2,size().width-5,size().height-5); for(i=0;iwidth){ width = (data[i].length()+1)*maxCharWidth(fm); } } } return width; } public int maxCharWidth(FontMetrics fm){ int i; int width = 0; if (fm.charWidth('A')>width){ width = fm.charWidth('A'); } if (fm.charWidth('T')>width){ width = fm.charWidth('T'); } if (fm.charWidth('C')>width){ width = fm.charWidth('C'); } if (fm.charWidth('G')>width){ width = fm.charWidth('G'); } if (fm.charWidth('U')>width){ width = fm.charWidth('U'); } return width+1; } }