-package jalview.ws.uimodel;
-
-import java.util.List;
-
-import javax.swing.DefaultListModel;
-
-import org.json.simple.JSONObject;
-
-
-@SuppressWarnings(
-{ "serial", "rawtypes" })
-public class PDBSummaryListModel extends DefaultListModel
-{
- private String pdbId;
-
- private String summary;
-
- private int width = 480;
-
-
- public PDBSummaryListModel(JSONObject doc, List<PDBDocField> diplayFields)
- {
- StringBuilder summaryBuilder = new StringBuilder();
-
- for (PDBDocField field : diplayFields)
- {
- if (field.equals(PDBDocField.MOLECULE_TYPE)
- && doc.get("molecule_type") != null)
- {
- String moleculeType = doc.get("molecule_type").toString();
- if (moleculeType.equalsIgnoreCase("protein"))
- {
- summaryBuilder.append("<img src=\""
- + getClass().getResource("/images/protein.png").toString()
- + "\">");
- }
- if (moleculeType.equalsIgnoreCase("dna"))
- {
- summaryBuilder.append("<img src=\""
- + getClass().getResource("/images/dna.png").toString()
- + "\">");
- }
- if (moleculeType.equalsIgnoreCase("rna"))
- {
- summaryBuilder.append("<img src=\""
- + getClass().getResource("/images/dna.png").toString()
- + "\">");
- }
- if (moleculeType.equalsIgnoreCase("sugar"))
- {
- summaryBuilder.append("<img src=\""
- + getClass().getResource("/images/sugar.png").toString()
- + "\">");
- }
- }else if (doc.get(field.getCode()) != null)
- {
- summaryBuilder.append(field.getName()).append(": ")
- .append(doc.get(field.getCode())).append(" | ");
- }
- }
- int endIndex = summaryBuilder.lastIndexOf(" | ");
- String fSummary = summaryBuilder.toString().substring(0, endIndex);
- this.summary = fSummary.trim();
-
- }
-
- public String getPdbId()
- {
- return pdbId;
- }
-
- public void setPdbId(String pdbId)
- {
- this.pdbId = pdbId;
- }
-
- public String getSummary()
- {
- return summary;
- }
-
- public void setSummary(String summary)
- {
- this.summary = summary;
- }
-
-
- public String toString()
- {
- StringBuilder html = new StringBuilder();
- html.append("<html><div style=\"width:" + width
- + "; word-wrap: break-word; border-bottom-style: dotted;\"> ");
- html.append(summary);
- html.append("</div></html>");
- return html.toString();
- }
-
-
- public enum PDBDocField
- {
- PDB_ID("PDB Id", "pdb_id"), TITLE("Title", "title"), MOLECULE_NAME(
- "Molecule", "molecule_name"), MOLECULE_TYPE("Molecule Type",
- "molecule_type"), MOLECULE_SEQUENCE("Sequence",
- "molecule_sequence"), UNIPROT_FEATURES("Uniprot Features",
- "uniprot_features"), PFAM_ACCESSION("PFAM Accession",
- "pfam_accession"), INTERPRO_ACCESSION("InterPro Accession",
- "interpro_accession"), UNIPROT_ACCESSION("UniProt Accession",
- "uniprot_accession"), R_FACTOR("R Factor", "r_factor"), RESOLUTION(
- "Resolution", "resolution"), DATA_QUALITY("Data Quality",
- "data_quality"), OVERALL_QUALITY("Overall Quality",
- "overall_quality"), POLYMER_COUNT("Polymer Count",
- "number_of_polymers"), PROTEIN_CHAIN_COUNT(
- "Protein Chain Count", "number_of_protein_chains"), BOUND_MOLECULE_COUNT(
- "Bound Molecule Count", "number_of_bound_molecules"), POLYMER_RESIDUE_COUNT(
- "Polymer Residue Count", "number_of_polymer_residues"), UNIPROT_COVERAGE(
- "UniProt Coverage", "uniprot_coverage"), GENUS("GENUS", "genus"), GENE_NAME(
- "Gene Name", "gene_name");
-
- private String name;
-
- private String code;
-
- PDBDocField(String name, String code)
- {
- this.name = name;
- this.code = code;
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getCode()
- {
- return code;
- }
-
- public String toString()
- {
- return name;
- }
- }
-}