+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+
pdb_data_columns
#
_group.id
g1;Quality Measures;1
g2;Cross References;2
g3;Names & Taxonomy;3
-g4;Procedures & Softwares;4
+g4;Procedures & Software;4
g5;Date Of;5
g6;Miscellenous;6
#
_data_column.name
_data_column.code
_data_column.group_id
-_data_column.data_type
+_data_column.data_type | _data_column.isFormated | _data_column.significantDigit
_data_column.min_col_width
_data_column.max_col_width
_data_column.preferred_col_width
UniProt Accession;uniprot_accession;String;g2;50;400;95;false;false
UniProt Coverage;uniprot_coverage;String;g6;50;400;95;false;false
Uniprot Features;uniprot_features;String;g6;50;400;95;false;false
-R Factor;r_factor;Double;g1;50;150;85;false;false
-Resolution;resolution;Double;g1;50;150;85;true;false
-Data Quality;data_quality;Double;g1;50;150;85;false;false
-Overall Quality;overall_quality;Double;g1;50;150;85;false;false
+R Factor;r_factor;Double|T|3;g1;50;150;85;false;false
+Experimental Method;experimental_method;String;g4;50;400;105;true;false
+Resolution;resolution;Double|T|3;g1;50;150;85;true;false
+Data Quality;data_quality;Double|T|2;g1;50;150;85;false;false
+Overall Quality;overall_quality;Double|T|1;g1;50;150;85;false;false
Number of Polymers;number_of_polymers;int;g6;50;400;95;false;false
Number of Protein Chains;number_of_protein_chains;int;g6;50;400;95;false;false
Number of Bound Molecule;number_of_bound_molecules;int;g6;50;400;95;false;false
Number of Polymer Residue;number_of_polymer_residues;int;g6;50;400;95;false;false
GENUS;genus;String;g3;50;400;95;false;true
Gene Name;gene_name;String;g3;50;400;95;false;true
-Experimental Method;experimental_method;String;g4;50;400;95;false;false
GO Id;go_id;String;g2;50;400;95;false;false
Assembly Id;assembly_id;String;g2;50;400;95;false;false
Assembly Form;assembly_form;String;g6;50;400;95;false;false
Interacting Molecules;interacting_molecules;String;g6;50;400;95;false;false
Pubmed Id;pubmed_id;int;g2;50;400;95;false;false
Status;status;String;g6;50;400;95;false;false
-Model Quality;model_quality;Double;g1;50;150;85;false;false
-Pivot Resolution;pivot_resolution;Double;g1;50;150;85;false;false
+Model Quality;model_quality;Double|T|2;g1;50;150;85;false;false
+Pivot Resolution;pivot_resolution;Double|T|3;g1;50;150;85;false;false
Data reduction software;data_reduction_software;String;g4;50;400;95;false;false
Max observed residues;max_observed_residues;String;g6;50;400;95;false;false
Organism scientific name;organism_scientific_name;String;g3;50;400;95;false;false
Citation Title;citation_title;String;g6;50;400;95;false;false
Structure Solution Software;structure_solution_software;String;g4;50;400;95;false;false
Entry Entity;entry_entity;String;g6;50;400;95;false;false
-R Free;r_free;Double;g1;50;150;85;false;false
+R Free;r_free;Double|T|3;g1;50;150;85;false;false
Number of Polymer Entities;number_of_polymer_entities;int;g6;50;400;95;false;false
Number of Bound Entities;number_of_bound_entities;int;g6;50;400;95;false;false
Crystallisation Reservoir;crystallisation_reservoir;String;g6;50;400;95;false;false
Entity Id; entity_id;String;g2;50;400;95;false;false
Beam Source Name;beam_source_name;String;g3;50;400;95;false;false
Processing Site;processing_site;String;g6;50;400;95;false;false
-Entity Weight;entity_weight;Double;g6;50;400;95;false;false
-Version;_version_;String;g6;50;400;95;false;false
+Entity Weight;entity_weight;Double|T|0;g6;50;400;95;false;false
+Version;_version_;Double|F|0;g6;50;400;95;false;false
ALL;text;String;g6;50;400;95;false;true
#
public boolean isVisibleByDefault();
/**
- * Returns the data column's data type class
+ * Returns the data column's FTS data column group
*
- * @return the Class for the data column's data type
+ * @return the FTSDataColumnGroupI for the column
*/
- public Class getDataColumnClass();
+ public FTSDataColumnGroupI getGroup();
/**
- * Returns the data colum's FTS data column group
+ * Returns the data columns data type POJO
*
- * @return the FTSDataColumnGroupI for the column
+ * @return the DataTypeI for the column
*/
- public FTSDataColumnGroupI getGroup();
+ public DataTypeI getDataType();
/**
* This interface provides a model for the dynamic data column group
*/
public int getSortOrder();
}
+
+ public interface DataTypeI
+ {
+ /**
+ * Returns the data column's data type class
+ *
+ * @return the Class for the data column's data type
+ */
+ public Class getDataTypeClass();
+
+ /**
+ * Checks if the numeric data column's data will be formated
+ *
+ * @return true means the numeric data column shall be formatted
+ */
+ public boolean isFormtted();
+
+ /**
+ * Returns the number of significant figure to be used for the numeric value
+ * formatting
+ *
+ * @return the number of significant figures
+ */
+ public int getSignificantFigures();
+ }
}
--- /dev/null
+package jalview.fts.core;
+
+import java.awt.Component;
+import java.text.DecimalFormat;
+
+import javax.swing.JLabel;
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableCellRenderer;
+
+/**
+ * The class to handle the formatting of the double values for JTable cells.
+ */
+public class DecimalFormatTableCellRenderer extends
+ DefaultTableCellRenderer
+{
+ private DecimalFormat formatter;
+
+ public DecimalFormatTableCellRenderer(boolean isFormated,
+ int significantFigures)
+ {
+ String integerFormater = isFormated ? "###,##0" : "0";
+ String fractionFormater = isFormated ? "###,##0." : "0.";
+ if (significantFigures > 0)
+ {
+ StringBuilder significantFigureBuilder = new StringBuilder();
+ for (int x = 1; x <= significantFigures; ++x)
+ {
+ significantFigureBuilder.append("0");
+ }
+ formatter = new DecimalFormat(fractionFormater
+ + significantFigureBuilder.toString());
+ }
+ else
+ {
+ formatter = new DecimalFormat(integerFormater);
+ }
+ super.setHorizontalAlignment(JLabel.RIGHT);
+ }
+
+ public DecimalFormatTableCellRenderer()
+ {
+ super.setHorizontalAlignment(JLabel.RIGHT);
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table,
+ Object value, boolean isSelected, boolean hasFocus, int row,
+ int column)
+ {
+ if (value == null)
+ {
+ return null;
+ }
+
+ value = formatter.format(value);
+
+ return super.getTableCellRendererComponent(table, value, isSelected,
+ hasFocus, row, column);
+ }
+}
\ No newline at end of file
}
@Override
- public Class<?> getDataColumnClass()
+ public DataTypeI getDataType()
{
- String classString = lineData[2];
- classString = classString.toUpperCase();
- switch (classString)
+ final String[] dataTypeString = lineData[2].split("\\|");
+ final String classString = dataTypeString[0].toUpperCase();
+
+ return new DataTypeI()
{
- case "INT":
- case "INTEGER":
- return Integer.class;
- case "DOUBLE":
- return Double.class;
- case "STRING":
- default:
- return String.class;
- }
+
+ @Override
+ public boolean isFormtted()
+ {
+ if (dataTypeString.length > 1
+ && dataTypeString[1] != null)
+ {
+ switch (dataTypeString[1].toUpperCase())
+ {
+ case "T":
+ case "TRUE":
+ return true;
+ case "F":
+ case "False":
+ default:
+ return false;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int getSignificantFigures()
+ {
+ if (dataTypeString.length > 2
+ && dataTypeString[2] != null)
+ {
+ return Integer.valueOf(dataTypeString[2]);
+ }
+ return 0;
+ }
+
+ @Override
+ public Class getDataTypeClass()
+ {
+ switch (classString)
+ {
+ case "INT":
+ case "INTEGER":
+ return Integer.class;
+ case "DOUBLE":
+ return Double.class;
+ case "STRING":
+ default:
+ return String.class;
+ }
+ }
+ };
+
}
@Override
&& this.getGroup().equals(that.getGroup());
}
+
};
dataColumns.add(dataCol);
{
return String.class;
}
- return cols[columnIndex - colOffset].getDataColumnClass();
+ return cols[columnIndex - colOffset].getDataType()
+ .getDataTypeClass();
}
};
{
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);
+ }
}
}