{
searchSummaryFields.add(PDBDocField.PDB_ID);
searchSummaryFields.add(PDBDocField.TITLE);
+ searchSummaryFields.add(PDBDocField.RESOLUTION);
structureSummaryFields.add(PDBDocField.PDB_ID);
structureSummaryFields.add(PDBDocField.TITLE);
+ structureSummaryFields.add(PDBDocField.RESOLUTION);
}
public PDBDocFieldPreferences(PreferenceSource source)
PDBFieldTableModel model = new PDBFieldTableModel(columnNames, data);
tbl_pdbDocFieldConfig.setModel(model);
- // DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
- // rightRenderer.setHorizontalAlignment(SwingConstants.LEFT);
- // tbl_pdbDocFieldConfig.getColumn("Show in structure summary")
- // .setCellRenderer(rightRenderer);
switch (source)
{
case SEARCH_SUMMARY:
case STRUCTURE_CHOOSER:
tbl_pdbDocFieldConfig.getColumnModel().getColumn(0)
- .setPreferredWidth(5);
+ .setPreferredWidth(30);
+ tbl_pdbDocFieldConfig.getColumnModel().getColumn(0).setMinWidth(20);
+ tbl_pdbDocFieldConfig.getColumnModel().getColumn(0).setMaxWidth(40);
tbl_pdbDocFieldConfig.getColumnModel().getColumn(1)
- .setPreferredWidth(195);
+ .setPreferredWidth(150);
+ tbl_pdbDocFieldConfig.getColumnModel().getColumn(1).setMinWidth(150);
tbl_pdbDocFieldConfig.getColumnModel().getColumn(2)
- .setPreferredWidth(200);
+ .setPreferredWidth(150);
+ tbl_pdbDocFieldConfig.getColumnModel().getColumn(2)
+.setMinWidth(150);
TableRowSorter<TableModel> sorter = new TableRowSorter<>(
tbl_pdbDocFieldConfig.getModel());
}
});
sorter.sort();
+
+ tbl_pdbDocFieldConfig
+ .setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
break;
case PREFERENCES:
default:
break;
}
-
}
public static Collection<PDBDocField> getSearchSummaryFields()
import jalview.datamodel.SequenceI;
import jalview.ws.dbsources.PDBRestClient.PDBDocField;
+import jalview.ws.dbsources.PDBRestClient.PDBDocField.Group;
import java.util.Collection;
import java.util.Objects;
+import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import org.json.simple.JSONObject;
public static DefaultTableModel getTableModel(PDBRestRequest request,
Collection<PDBResponseSummary> summariesList)
{
+ final PDBDocField[] cols = request.getWantedFields().toArray(
+ new PDBDocField[0]);
+ final int colOffset = request.getAssociatedSequence() == null ? 0 : 1;
DefaultTableModel tableModel = new DefaultTableModel()
{
@Override
{
return false;
}
+
+ @Override
+ public Class<?> getColumnClass(int columnIndex)
+ {
+ if (colOffset == 1 && columnIndex == 0)
+ {
+ return String.class;
+ }
+ if (cols[columnIndex - colOffset].getGroup().getName()
+ .equalsIgnoreCase(Group.QUALITY_MEASURES.getName()))
+ {
+ return Double.class;
+ }
+ return String.class;
+ }
+
};
if (request.getAssociatedSequence() != null)
{
}
else
{
- summaryRowData[colCounter++] = fieldData;
+ if (field.getGroup().getName()
+ .equals(Group.QUALITY_MEASURES.getName()))
+ {
+ try
+ {
+ if (fieldData == null || fieldData.isEmpty())
+ {
+ summaryRowData[colCounter++] = null;
+ }
+ else
+ {
+ Double value = Double.valueOf(fieldData);
+ summaryRowData[colCounter++] = value;
+ }
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ System.out.println("offending value:" + fieldData);
+ summaryRowData[colCounter++] = 0.0;
+ }
+ }else{
+ summaryRowData[colCounter++] = fieldData;
+ }
}
}
}
- public String getPdbId()
+ public Object getPdbId()
{
return pdbId;
}
return summaryRowData;
}
- public void setSummaryData(String[] summaryData)
+ public void setSummaryData(Object[] summaryData)
{
this.summaryRowData = summaryData;
}
StringBuilder summaryFieldValues = new StringBuilder();
for (Object summaryField : summaryRowData)
{
- summaryFieldValues.append(summaryField.toString()).append("\t");
+ summaryFieldValues.append(
+ summaryField == null ? " " : summaryField.toString())
+ .append("\t");
}
return summaryFieldValues.toString();
}
}
+ public static void configureTableColumn(JTable tbl_summary,
+ Collection<PDBDocField> wantedFields)
+ {
+ for (PDBDocField wantedField : wantedFields)
+ {
+ if (wantedField.equals(PDBDocField.PDB_ID))
+ {
+ tbl_summary.getColumn(wantedField.getName()).setMinWidth(40);
+ tbl_summary.getColumn(wantedField.getName()).setMaxWidth(60);
+ tbl_summary.getColumn(wantedField.getName()).setPreferredWidth(45);
+ }
+ else if (wantedField.equals(PDBDocField.TITLE))
+ {
+ tbl_summary.getColumn(wantedField.getName()).setMinWidth(300);
+ tbl_summary.getColumn(wantedField.getName()).setMaxWidth(1000);
+ tbl_summary.getColumn(wantedField.getName()).setPreferredWidth(400);
+ }
+ else if (wantedField.getGroup() == Group.QUALITY_MEASURES)
+ {
+ tbl_summary.getColumn(wantedField.getName()).setMinWidth(50);
+ tbl_summary.getColumn(wantedField.getName()).setMaxWidth(150);
+ tbl_summary.getColumn(wantedField.getName()).setPreferredWidth(85);
+ }
+ else
+ {
+ tbl_summary.getColumn(wantedField.getName()).setMinWidth(50);
+ tbl_summary.getColumn(wantedField.getName()).setMaxWidth(400);
+ tbl_summary.getColumn(wantedField.getName()).setPreferredWidth(95);
+ }
+ }
+ }
}