create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / gui / adaptors / Column.java
1 package net.sf.openrocket.gui.adaptors;
2
3 import javax.swing.table.TableColumnModel;
4
5 public abstract class Column {
6         private final String name;
7         
8         /**
9          * Create a new column with specified name.  Additionally, the {@link #getValueAt(int)}
10          * method must be implemented.
11          * 
12          * @param name  the caption of the column.
13          */
14         public Column(String name) {
15                 this.name = name;
16         }
17         
18         /**
19          * Return the caption of the column.
20          */
21         @Override
22         public String toString() {
23                 return name;
24         }
25         
26         /**
27          * Return the default width of the column.  This is used by the method
28          * {@link #ColumnTableModel.setColumnWidth(TableColumnModel)}.  The default width is
29          * 100, the method may be overridden to return other values relative to this value.
30          * 
31          * @return              the relative width of the column (default 100).
32          */
33         public int getDefaultWidth() {
34                 return 100;
35         }
36         
37         
38         /**
39          * Returns the exact width of this column.  If the return value is positive,
40          * both the minimum and maximum widths of this column are set to this value
41          * 
42          * @return              the absolute exact width of the column (default 0).
43          */
44         public int getExactWidth() {
45                 return 0;
46         }
47         
48         
49         /**
50          * Return the column type class.  This is necessary for example for numerical
51          * sorting of Value objects, showing booleans as checkboxes etc.
52          * 
53          * @return      the object class of this column, by default <code>Object.class</code>.
54          */
55         public Class<?> getColumnClass() {
56                 return Object.class;
57         }
58         
59         /**
60          * Return the value in this column at the specified row.
61          * 
62          * @param row   the row of the data.
63          * @return              the value at the specified position.
64          */
65         public abstract Object getValueAt(int row);
66
67         /**
68          * Set a value in the table.
69          * 
70          * Override if the cell is editable.
71          * 
72          * @param row
73          * @param value
74          */
75         public void setValueAt(int row, Object value ) {
76         }
77         
78 }