import jalview.fts.api.FTSDataColumnI;
import java.util.Collection;
+import java.util.Map;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
{
return String.class;
}
- return cols[columnIndex - colOffset].getDataColumnClass();
+ return cols[columnIndex - colOffset].getDataType()
+ .getDataTypeClass();
}
};
tableModel.addColumn("Ref Sequence"); // Create sequence column header if
// exists in the request
}
- for (FTSDataColumnI field : request
- .getWantedFields())
+ for (FTSDataColumnI field : request.getWantedFields())
{
tableModel.addColumn(field.getName()); // Create sequence column header if
// exists in the request
}
public static void configureTableColumn(JTable tbl_summary,
- Collection<FTSDataColumnI> wantedFields)
+ Collection<FTSDataColumnI> wantedFields,
+ Map<String, Integer> columnPrefs)
{
- try
- {
- // wait for table model initialisation to complete
- Thread.sleep(1200);
- } catch (InterruptedException e1)
- {
- e1.printStackTrace();
- }
for (FTSDataColumnI wantedField : wantedFields)
{
try
{
- tbl_summary.getColumn(wantedField.getName()).setMinWidth(
- wantedField.getMinWidth());
- tbl_summary.getColumn(wantedField.getName()).setMaxWidth(
- wantedField.getMaxWidth());
- tbl_summary.getColumn(wantedField.getName()).setPreferredWidth(
- wantedField.getPreferredWidth());
+ tbl_summary.getColumn(wantedField.getName())
+ .setMinWidth(wantedField.getMinWidth());
+ tbl_summary.getColumn(wantedField.getName())
+ .setMaxWidth(wantedField.getMaxWidth());
+ int prefedWidth = columnPrefs.get(wantedField.getName()) == null
+ ? wantedField.getPreferredWidth()
+ : columnPrefs.get(wantedField.getName());
+ tbl_summary.getColumn(wantedField.getName())
+ .setPreferredWidth(prefedWidth);
} catch (Exception e)
{
e.printStackTrace();
}
+ if (wantedField.getDataType().getDataTypeClass() == Double.class)
+ {
+ DecimalFormatTableCellRenderer dfr = new DecimalFormatTableCellRenderer(
+ wantedField.getDataType().isFormtted(),
+ wantedField.getDataType().getSignificantFigures());
+ tbl_summary.getColumn(wantedField.getName()).setCellRenderer(dfr);
+ }
+ else if (wantedField.getDataType()
+ .getDataTypeClass() == Integer.class)
+ {
+ DecimalFormatTableCellRenderer dfr = new DecimalFormatTableCellRenderer(
+ wantedField.getDataType().isFormtted(),
+ wantedField.getDataType().getSignificantFigures());
+ tbl_summary.getColumn(wantedField.getName()).setCellRenderer(dfr);
+ }
}
}
-
}