1 package jalview.ws.uimodel;
3 import javax.swing.DefaultListModel;
5 import org.json.simple.JSONObject;
9 { "serial", "rawtypes" })
10 public class PDBSummaryListModel extends DefaultListModel
14 private String summary;
16 private JSONObject rawJson;
18 private int width = 480;
21 public PDBSummaryListModel(JSONObject doc)
24 StringBuilder summary = new StringBuilder();
25 if (doc.get("molecule_type") != null)
27 String moleculeType = doc.get("molecule_type").toString();
28 if (moleculeType.equalsIgnoreCase("protein"))
30 summary.append("<img src=\""
31 + getClass().getResource("/images/protein.png").toString()
34 if (moleculeType.equalsIgnoreCase("dna"))
36 summary.append("<img src=\""
37 + getClass().getResource("/images/dna.png").toString()
40 if (moleculeType.equalsIgnoreCase("rna"))
42 summary.append("<img src=\""
43 + getClass().getResource("/images/dna.png").toString()
46 if (moleculeType.equalsIgnoreCase("sugar"))
48 summary.append("<img src=\""
49 + getClass().getResource("/images/sugar.png").toString()
53 this.pdbId = doc.get("pdb_id").toString();
54 summary.append("PDB ID: ").append(pdbId);
57 if (doc.get("molecule_name") != null)
59 summary.append(" | Molecule Name: ").append(doc.get("molecule_name"));
61 if (doc.get("gene_name") != null)
63 summary.append(" | Gene Name: ").append(doc.get("gene_name"));
65 if (doc.get("genus") != null)
67 summary.append(" | Genus: ").append(doc.get("genus"));
69 if (doc.get("title") != null)
71 summary.append(" | Title: ").append(doc.get("title"));
73 this.summary = summary.toString();
76 public String getPdbId()
81 public void setPdbId(String pdbId)
86 public String getSummary()
91 public void setSummary(String summary)
93 this.summary = summary;
96 public JSONObject getRawJson()
101 public void setRawJson(JSONObject rawJson)
103 this.rawJson = rawJson;
106 public String toString()
108 StringBuilder html = new StringBuilder();
109 html.append("<html><div style=\"width:" + width
110 + "; word-wrap: break-word; border-bottom-style: dotted;\"> ");
111 html.append(summary);
112 html.append("</div></html>");
113 return html.toString();