KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > console > table > TableMetaData


1 package org.sapia.console.table;
2
3
4 /**
5  * @author Yanick Duchesne
6  * 2002-03-04
7  *
8  */

9 public class TableMetaData {
10   private int _colCount;
11   private int _colWidth;
12   private int _width;
13   private ColumnMetaData[] _cols;
14
15   TableMetaData(int colCount, int width) {
16     _colCount = colCount;
17     _colWidth = width;
18     _cols = new ColumnMetaData[colCount];
19
20     for (int i = 0; i < colCount; i++) {
21       _cols[i] = new ColumnMetaData(this, width);
22     }
23
24     calcWidth();
25   }
26
27   public int getColumnCount() {
28     return _colCount;
29   }
30
31   public void setColWidth(int width) {
32     _colWidth = width;
33   }
34
35   public ColumnMetaData getColumnMetaDataAt(int index) {
36     return _cols[index];
37   }
38
39   public int getColWidth() {
40     return _colWidth;
41   }
42
43   public int getTableWidth() {
44     return _width;
45   }
46
47   void calcWidth() {
48     int width = 0;
49
50     for (int i = 0; i < _cols.length; i++) {
51       width = width + _cols[i].getWidth() + (_cols[i].getCellPadding() * 2);
52     }
53
54     _width = width;
55   }
56 }
57
Popular Tags