+/*
+ * 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
#
+/*
+ * 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.
+ */
+
uniprot_data_columns
#
_group.id
_data_column.is_shown_by_default
_data_column.is_searchable
Uniprot Id;id;String;g3;80;150;85;true;true
-Entry Name;entry name|name;String;g3;100;150;105;true;true
-Protein names;protein names|protein name;String;g3;300;1500;500;true;true
+Entry Name;entry name|mnemonic;String;g3;100;150;105;true;true
+Protein names;protein names|name;String;g3;300;1500;500;true;true
Gene Names;genes|gene;String;g3;100;1000;145;true;true
Organism;organism;String;g3;100;1000;200;true;true
-Organism ID;organism-id;int;g3;60;100;80;false;true
-Proteomes;proteome;String;g3;50;1000;95;false;true
-Taxonomic lineage (ALL);lineage(ALL);String;g3;50;400;95;false;false
-Virus hosts;virus hosts;String;g3;50;1000;95;false;true
-Fragment;fragment;String;g7;50;1000;95;false;true
-Gene encoded by;encodedon;String;g7;50;1000;95;false;true
+Organism ID;organism-id;int;g3;60;100;80;false;false
+Proteomes;proteome;String;g3;50;1000;95;false;false
+Taxonomic lineage (ALL);lineage(ALL)|taxonomy;String;g3;50;400;95;false;false
+Virus hosts;virus hosts|host;String;g3;50;1000;95;false;true
+Fragment;fragment;String;g7;50;1000;95;false;false
+Gene encoded by;encodedon;String;g7;50;1000;95;false;false
Alternative products (isoforms);comment(ALTERNATIVE PRODUCTS);String;g7;50;1000;95;false;false
Erroneous gene model prediction;comment(ERRONEOUS GENE MODEL PREDICTION);String;g7;50;1000;95;false;false
Erroneous initiation;comment(ERRONEOUS INITIATION);String;g7;50;1000;95;false;false
RNA editing;comment(RNA EDITING);String;g7;50;1000;95;false;false
Sequence caution;comment(SEQUENCE CAUTION);String;g7;50;1000;95;false;false
Status;reviewed;String;g6;50;100;95;true;true
-Length;length;int;g7;50;100;65;true;true
+Length;length;int|T|0;g7;50;100;65;true;true
Mass;mass;String;g7;50;100;80;false;true
-Sequence;sequence;String;g7;50;1000;95;false;true
+Sequence;sequence;String;g7;50;1000;95;false;false
Alternative sequence;feature(ALTERNATIVE SEQUENCE);String;g7;50;1000;95;false;false
Natural variant;feature(NATURAL VARIANT);String;g7;50;1000;95;false;false
Non-adjacent residues;feature(NON ADJACENT RESIDUES);String;g7;50;1000;95;false;false
Metal binding;feature(METAL BINDING);String;g8;50;1000;95;false;false
Nucleotide binding;feature(NP BIND);String;g8;50;1000;95;false;false
Site;feature(SITE);String;g8;50;1000;95;false;false
-Annotation;annotation score;String;g6;50;1000;95;false;true
-Features;features;String;g6;50;1000;95;false;true
+Annotation;annotation score;String;g6;50;1000;95;false;false
+Features;features;String;g6;50;1000;95;false;false
Caution;comment(CAUTION);String;g6;50;1000;95;false;false
Miscellaneous [CC];comment(GENERAL);String;g6;50;1000;95;false;false
-Keywords;keywords;String;g6;50;1000;95;false;true
+Keywords;keywords|keyword;String;g6;50;1000;95;false;true
Protein existence;existence;String;g6;50;1000;95;false;true
ALL;Search All;String;g7;50;1000;95;false;true;
Subunit structure [CC];comment(SUBUNIT);String;g9;50;1000;95;false;false
-Interacts with;interactor;String;g9;50;1000;95;false;true
+Interacts with;interactor;String;g9;50;1000;95;false;false
Developmental stage;comment(DEVELOPMENTAL STAGE);String;g10;50;1000;95;false;false
Induction;comment(INDUCTION);String;g10;50;1000;95;false;false
Tissue specificity;comment(TISSUE SPECIFICITY);String;g10;50;1000;95;false;false
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);
+ }
}
}
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
+import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
protected HashSet<String> paginatorCart = new HashSet<String>();
+ protected static final DecimalFormat totalNumberformatter = new DecimalFormat(
+ "###,###");
+
private JTable tbl_summary = new JTable()
{
private boolean inLayout;
if (isPaginationEnabled() && resultSetCount > 0)
{
updateSearchFrameTitle(defaultFTSFrameTitle + " - " + result
- + " " + (offSet + 1) + " to "
- + (offSet + resultSetCount) + " of "
- + totalResultSetCount
+ + " "
+ + totalNumberformatter.format((Number) (offSet + 1))
+ + " to "
+ + totalNumberformatter
+ .format((Number) (offSet + resultSetCount))
+ + " of "
+ + totalNumberformatter
+ .format((Number) totalResultSetCount)
+ " " + " (" + (endTime - startTime) + " milli secs)");
}
else
{
try
{
- summaryRowData[colCounter++] = (field.getDataColumnClass() == Integer.class) ? Integer
+ summaryRowData[colCounter++] = (field.getDataType()
+ .getDataTypeClass() == Integer.class) ? Integer
.valueOf(fieldData)
- : (field.getDataColumnClass() == Double.class) ? Double
+ : (field.getDataType()
+ .getDataTypeClass() == Double.class) ? Double
.valueOf(fieldData)
- : fieldData;
+ : sanitiseData(fieldData);
} catch (Exception e)
{
e.printStackTrace();
};
}
+ private static String sanitiseData(String data)
+ {
+ String cleanData = data.replaceAll("\\[\"", "").replaceAll("\\]\"", "")
+ .replaceAll("\\[", "").replaceAll("\\]", "")
+ .replaceAll("\",\"", ", ").replaceAll("\"", "");
+ return cleanData;
+ }
+
@Override
public String getColumnDataConfigFileName()
{
String query = uniportRestRequest.getFieldToSearchBy()
.equalsIgnoreCase("Search All") ? uniportRestRequest
+ .getSearchTerm()
+ + " or mnemonic:"
+ + uniportRestRequest
.getSearchTerm() : uniportRestRequest.getFieldToSearchBy()
+ ":" + uniportRestRequest.getSearchTerm();
{
try
{
- summaryRowData[colCounter++] = (field.getDataColumnClass() == Integer.class) ? Integer
+ summaryRowData[colCounter++] = (field.getDataType()
+ .getDataTypeClass() == Integer.class) ? Integer
.valueOf(fieldData)
- : (field.getDataColumnClass() == Double.class) ? Double
+ : (field.getDataType()
+ .getDataTypeClass() == Double.class) ? Double
.valueOf(fieldData) : fieldData;
} catch (Exception e)
{
if (isPaginationEnabled() && resultSetCount > 0)
{
updateSearchFrameTitle(defaultFTSFrameTitle + " - " + result
- + " " + (offSet + 1) + " to "
- + (offSet + resultSetCount) + " of "
- + totalResultSetCount
+ + " "
+ + totalNumberformatter.format((Number) (offSet + 1))
+ + " to "
+ + totalNumberformatter
+ .format((Number) (offSet + resultSetCount))
+ + " of "
+ + totalNumberformatter
+ .format((Number) totalResultSetCount)
+ " " + " (" + (endTime - startTime) + " milli secs)");
}
else
String actual = ftsRestClient
.getDataColumnsFieldsAsCommaDelimitedString(wantedFields);
Assert.assertEquals(actual,
- "id,entry name,protein names,genes,organism,length,reviewed");
+ "id,entry name,protein names,genes,organism,reviewed,length");
}
public void getDefaultResponsePageSize()
{
int defaultResSize = ftsRestClient.getDefaultResponsePageSize();
- Assert.assertEquals(defaultResSize, 100);
+ Assert.assertEquals(defaultResSize, 500);
}
@Test(groups = { "Functional" })
FTSDataColumnI foundDataCol = ftsRestClient
.getDataColumnByNameOrCode("Protein names");
Assert.assertNotNull(foundDataCol);
- Assert.assertEquals(foundDataCol.getDataColumnClass(), String.class);
+ Assert.assertEquals(foundDataCol.getDataType().getDataTypeClass(),
+ String.class);
foundDataCol = ftsRestClient.getDataColumnByNameOrCode("length");
Assert.assertNotNull(foundDataCol);
- Assert.assertEquals(foundDataCol.getDataColumnClass(), Integer.class);
+ Assert.assertEquals(foundDataCol.getDataType().getDataTypeClass(),
+ Integer.class);
// foundDataCol = ftsRestClient.getDataColumnByNameOrCode("length");
// Assert.assertNotNull(foundDataCol);
// Assert.assertEquals(foundDataCol.getDataColumnClass(), Double.class);