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 int width = 480;
18 public PDBSummaryListModel(String pdbId, String summary)
21 this.summary = summary;
24 public PDBSummaryListModel(JSONObject doc)
26 StringBuilder summary = new StringBuilder();
27 if (doc.get("molecule_type") != null)
29 String moleculeType = doc.get("molecule_type").toString();
30 if (moleculeType.equalsIgnoreCase("protein"))
32 summary.append("<img src=\""
33 + getClass().getResource("/images/protein.png").toString()
36 if (moleculeType.equalsIgnoreCase("dna"))
38 summary.append("<img src=\""
39 + getClass().getResource("/images/dna.png").toString()
42 if (moleculeType.equalsIgnoreCase("rna"))
44 summary.append("<img src=\""
45 + getClass().getResource("/images/dna.png").toString()
48 if (moleculeType.equalsIgnoreCase("sugar"))
50 summary.append("<img src=\""
51 + getClass().getResource("/images/sugar.png").toString()
55 this.pdbId = doc.get("pdb_id").toString();
56 summary.append("PDB ID: ").append(pdbId);
59 if (doc.get("molecule_name") != null)
61 summary.append(" | Molecule Name: ").append(doc.get("molecule_name"));
63 if (doc.get("gene_name") != null)
65 summary.append(" | Gene Name: ").append(doc.get("gene_name"));
67 if (doc.get("genus") != null)
69 summary.append(" | Genus: ").append(doc.get("genus"));
71 if (doc.get("title") != null)
73 summary.append(" | Title: ").append(doc.get("title"));
75 this.summary = summary.toString();
78 public String getPdbId()
83 public void setPdbId(String pdbId)
88 public String getSummary()
93 public void setSummary(String summary)
95 this.summary = summary;
98 public String toString()
100 StringBuilder html = new StringBuilder();
101 html.append("<html><div style=\"width:" + width
102 + "; word-wrap: break-word; border-bottom-style: dotted;\"> ");
103 html.append(summary);
104 html.append("</div></html>");
105 return html.toString();