Attribute Table Lens
When using an AbstractTableLens to create a table lens, if the program also wants to supply the visual attributes, it has to implement the methods that return those attributes. While this is fairly simple to do, it is tedious when the only thing you need to do is set the values of a few attributes.
To make ad hoc settings of table attributes easier, the InetSoft package provides a table decorator class, AttributeTableLens. The AttributeTableLens is a wrapper that can be wrapped around other table lens objects. In addition to implementing the TableLens interface methods, it also provides methods for setting the attributes.
The AttributeTableLens is the base class for all table adapter classes, such as the Swing JTable adapter and JDBC table adapter. It is also the base class for all table style classes. Whenever you are working with any table adapters or styles you can easily override the table attributes by using the convenient API of AttributeTableLens.
The attributes returned from an AttributeTableLens may come from either the original table lens object or from the value explicitly set by users. The attribute setting methods provided by the AttributeTableLens roughly correspond to the attribute access methods defined in the TableLens interface, but with slightly different signatures.
We will not cover all methods in the AttributeTableLens since there is a large number of them. In the following code snippets, we will show some of the more commonly used methods to modify the behavior of tables.
A feature provided by the AttributeTableLens is the ability to associate a presenter or format object with a column. If we do not want to associate a presenter/format with a type in the entire report, we can set the associated presenter/format of a particular column in a table:
JTableLens table = new JTableLens(jTable1);
table.setFormat(5, NumberFormat.getCurrencyInstance());
table.setPresenter(4, new BooleanPresenter());