}
public void createColumns() {
// clear column groups
ColumnGroup groups[] = header.getColumnGroups();
if (groups != null) {
for (ColumnGroup group : groups) {
header.removeColumnGroup(group);
}
}
// clear the column model
while (getColumnCount() > 0) {
TableColumn col = getColumn(0);
removeColumn(col);
}
// create the "average" group
ColumnGroup averageGroup = new ColumnGroup("Average");
header.addColumnGroup(averageGroup);
JTextField editorField = new JTextField();
editorField.setFont(editFont);
DefaultCellEditor defaultEditor = new DefaultCellEditor(editorField);
ColumnSettingParameter<CommonColumnType> csPar = parameters
.getParameter(PeakListTableParameters.commonColumns);
CommonColumnType visibleCommonColumns[] = csPar.getValue();
ColumnSettingParameter<DataFileColumnType> dfPar = parameters
.getParameter(PeakListTableParameters.dataFileColumns);
DataFileColumnType visibleDataFileColumns[] = dfPar.getValue();
for (int i = 0; i < visibleCommonColumns.length; i++) {
CommonColumnType commonColumn = visibleCommonColumns[i];
int modelIndex = Arrays.asList(CommonColumnType.values()).indexOf(
commonColumn);
TableColumn newColumn = new TableColumn(modelIndex);
newColumn.setHeaderValue(commonColumn.getColumnName());
newColumn.setIdentifier(commonColumn);
switch (commonColumn) {
case AVERAGEMZ :
newColumn.setCellRenderer(mzRenderer);
break;
case AVERAGERT :
newColumn.setCellRenderer(rtRenderer);
break;
case IDENTITY :
newColumn.setCellRenderer(identityRenderer);
break;
case COMMENT :
newColumn.setCellRenderer(defaultRenderer);
newColumn.setCellEditor(defaultEditor);
break;
case PEAKSHAPE :
newColumn.setCellRenderer(peakShapeRenderer);
break;
default :
newColumn.setCellRenderer(defaultRenderer);
}
this.addColumn(newColumn);
newColumn.setPreferredWidth(csPar.getColumnWidth(modelIndex));
if ((commonColumn == CommonColumnType.AVERAGEMZ)
|| (commonColumn == CommonColumnType.AVERAGERT)) {
averageGroup.add(newColumn);
}
}
for (int i = 0; i < peakList.getNumberOfRawDataFiles(); i++) {
RawDataFile dataFile = peakList.getRawDataFile(i);
ColumnGroup fileGroup = new ColumnGroup(dataFile.getName());
header.addColumnGroup(fileGroup);
for (int j = 0; j < visibleDataFileColumns.length; j++) {
DataFileColumnType dataFileColumn = visibleDataFileColumns[j];
int dataFileColumnIndex = Arrays.asList(
DataFileColumnType.values()).indexOf(dataFileColumn);
int modelIndex = CommonColumnType.values().length
+ (i * DataFileColumnType.values().length)
+ dataFileColumnIndex;
TableColumn newColumn = new TableColumn(modelIndex);
newColumn.setHeaderValue(dataFileColumn.getColumnName());
newColumn.setIdentifier(dataFileColumn);
switch (dataFileColumn) {
case MZ :
newColumn.setCellRenderer(mzRenderer);
break;
case PEAKSHAPE :
newColumn.setCellRenderer(peakShapeRenderer);
break;
case STATUS :
newColumn.setCellRenderer(peakStatusRenderer);
break;
case RT :
newColumn.setCellRenderer(rtRenderer);
break;
case DURATION :
newColumn.setCellRenderer(rtRenderer);
break;
case HEIGHT :
newColumn.setCellRenderer(intensityRenderer);
break;
case AREA :
newColumn.setCellRenderer(intensityRenderer);
break;
default :
newColumn.setCellRenderer(defaultRenderer);
break;
}
this.addColumn(newColumn);
newColumn.setPreferredWidth(dfPar
.getColumnWidth(dataFileColumnIndex));
fileGroup.add(newColumn);
}
}
}