package lawyer; import java.awt.*; import java.awt.event.*; /** *
This Frame displays the data from the statistics section of a lesson. * It automatically displays itself when it is created.
* * @author David Danks * @version 0.9; July 24, 1998 * @see LessonManager */ public class DataTableFrame extends Frame { /** @serial */ public String[][] data; /** @serial */ public String[] labels; /** @serial */ public String[] attrib; /** @serial */ private int xMax; /** @serial */ private int yMax; /** @serial */ private int height; /** @serial */ private int drop; /** @serial */ private int tableX; /** @serial */ private int tableY; /** @serial */ private int[] maxColWidth; /** @serial */ private FontMetrics fm; private static final int MARGIN = 10; /** * Constructor for the DataTableFrame. * * @param dat A two-dimensional String array of the actual data. The * format is String[row][column]. * @param dataLabels A one-dimensional String array of the row and column * tags. It is assumed that the first half of the * array will be column labels, and the second half will * be row names, withnull
Strings in
* between, if necessary.
* @param attrib A one-dimensional String array of the reference for the
* data, of the form String[line_of_text].
* @param font The font to display the text in.
*/
public DataTableFrame(String dat[][], String dataLabels[], String attrib[],
Font font) {
super("Data Table");
this.data = dat;
this.labels = dataLabels;
this.attrib = attrib;
fm = this.getFontMetrics(font);
// determine the size of the table
height = fm.getHeight() + 10;
drop = height - fm.getDescent();
maxColWidth = new int[data[0].length+1];
for (int i=0; i<(labels.length / 2); i++) {
if (labels[i] == null) break;
else {
maxColWidth[0] = Math.max(maxColWidth[0],
fm.stringWidth(labels[i]) + 5); }
}
for (int i=0; i