ACOP Table

AcopTable

Description

AcopTable is a MultipleAcopDisplayer which is inteded to show values of multi-channel arrays or spectrum arrays. The values in the table are shown in columns, where each column represent one multi channel.

The component is an extension of a JPanel which consists of a JTable. The table has adjustable number of rows and can show any number of columns.

Code examples

The following lines show an example how to use the features of the AcopTAble.

Connection to a remote property

First we will create an instance of the AcopTable object.

AcopTable table = new AcopTable();

Let's make a table which displays the names and values of a multi-channel array or spectrum. For this we will require two columns, which will be specified by two AcopTableParameters. For each of these parameters we have to define connection points. Therefore we have to create ConnectionParameters which specify this array:

ConnectionParameters connectionParameters = new ConnectionParameters("TINE", "context", "server", "device", "property", AccessMode.POLL, 1000);

These parameters describe a remote property context/server/device/property in the TINE control system. We will request a constant monitoring, therefore AccessMode.POLL was used. Polling rate is set to 1000 milliseconds, which means that value on the table will be updated every 1000 milliseconds. Now we make AcopTableParameters. First for the names of the devices.

AcopTableParameters namesParameters = new AcopTableParameters(connectionParameters, TableColumnType.NAME, "Devices");

Here we used a TableColumnType.NAME. Now we have to create parameters for the values, where we use the TableColumnType.VALUE.

AcopTableParameters valuesParameters = new AcopTableParameters(connectionParameters, TableColumnType.VALUE, "Values");

We could also display all values as bits by using TableColumnType.BIT. When making a column with names we could also use TableColumnType.STRING. However, when dealing with static names (devices names do not change in time) it is better to use the NAME type. STRING type could be used when monitoring a channel with string values. Parameters are then attached to the table. Connection is created automatically.

try {
        table.setDisplayerParameters(new AcopTableParameters[]{namesParameters, valuesParameters});
} catch (CommonException e) {
        e.printStackTrace();
} catch (PropertyVetoException e) {
        e.printStackTrace();
}

If no exception occured, table will show two columns. Une with device names and one with the remote values.

Converters

Anytime we can add additional columns displaying any channel we want. Let's say that we want to display a channel but we want the values of that channel are too large to be readable. We can use logarithmic converter and instead of x the table will show log_10(x).

ConnectionParameters cp = new ConnectionParameters("TINE", "context", "server", "device", "property", AccessMode.POLL, 1000);
LogarithmicConverter logConverter = new LogarithmicConverter(10);
AcopTableParameters atp = new AcopTableParameters(cp, TableColumnType.VALUE, logConverter, "Log(value)");
try {
        table.addDisplayerParameters(atp);
} catch (CommonException e) {
        e.printStackTrace();
} catch (PropertyVetoException e) {
        e.printStackTrace();
}

Instead of logarithmic converter we can also choose LinearConverter, MultiplierConverter, ExponentialConverter or PotentialConverter. We can also construct a chain of converter combining different mathematical operations:

try {
        LinearConverter linConverter = new LinearConverter(5,4);
        ConverterChain chain = new ConverterChain(new Converter[]{logConverter, linConverter});
        AcopTableParameters atp1 = new AcopTableParameters(cp, TableColumnType.VALUE, chain, "5 (log_10(value)) + 4");
        table.addDisplayerParameters(atp1);
} catch (PropertyVetoException e) {
        e.printStackTrace();
}

The fourth column in the table will now show 5 (log_10(x)) + 4.

Other properties

Table can show any number of rows one desires. If we are monitoring a channel which originally has 50 devices, but we are only interested in the first 10, we set the number of rows.

table.setNumberOfRows(10);

By default in runtime we can drag the columns around, allowing to rearrange the table when we want to put two separated columns together. We can decide that the user will not be allowed to do that.

table.setReorderingAllowed(false);

Some Other properties of the table can also simply be adjusted by calling the appropriate setter methods. These properties include background/foreground color etc:

table.setBackground(Color.RED);
table.setForeground(Color.GREEN);

See the complete source code used in this examples.