/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
package jalview.fts.core;
+import jalview.datamodel.SequenceI;
import jalview.fts.api.FTSData;
import jalview.fts.api.FTSDataColumnI;
import java.util.Collection;
+import java.util.Map;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
/**
- * Represents the response model produced by the PDBRestClient upon successful
- * execution of a given request
+ * Represents the response model generated by the FTSRestClient upon successful
+ * execution of a given FTS request
*
* @author tcnofoegbu
*
* on the request parameters
*
* @param request
- * the PDBRestRequest object which holds useful information for
+ * the FTSRestRequest object which holds useful information for
* creating a table model
* @param summariesList
* the summary list which contains the data for populating the
{
if (colOffset == 1 && columnIndex == 0)
{
- return String.class;
+ return SequenceI.class;
}
- if (cols[columnIndex - colOffset].getGroup().getName()
- .equalsIgnoreCase("Quality Measures"))
- {
- return Double.class;
- }
- return String.class;
+ 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);
+ }
}
}
-
}