X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fws%2Fuimodel%2FPDBSummaryListModel.java;fp=src%2Fjalview%2Fws%2Fuimodel%2FPDBSummaryListModel.java;h=ef93aeded140fc6e7849627dc49547b57e9e09ba;hb=e4da162f3c4eb461c40f7b97794cd77d3b1e2407;hp=0000000000000000000000000000000000000000;hpb=b13f521553582ef2fbfd7815ae25e23284babdea;p=jalview.git diff --git a/src/jalview/ws/uimodel/PDBSummaryListModel.java b/src/jalview/ws/uimodel/PDBSummaryListModel.java new file mode 100644 index 0000000..ef93aed --- /dev/null +++ b/src/jalview/ws/uimodel/PDBSummaryListModel.java @@ -0,0 +1,108 @@ +package jalview.ws.uimodel; + +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(String pdbId, String summary) + { + this.pdbId = pdbId; + this.summary = summary; + } + + public PDBSummaryListModel(JSONObject doc) + { + StringBuilder summary = new StringBuilder(); + if (doc.get("molecule_type") != null) + { + String moleculeType = doc.get("molecule_type").toString(); + if (moleculeType.equalsIgnoreCase("protein")) + { + summary.append(""); + } + if (moleculeType.equalsIgnoreCase("dna")) + { + summary.append(""); + } + if (moleculeType.equalsIgnoreCase("rna")) + { + summary.append(""); + } + if (moleculeType.equalsIgnoreCase("sugar")) + { + summary.append(""); + } + } + this.pdbId = doc.get("pdb_id").toString(); + summary.append("PDB ID: ").append(pdbId); + + + if (doc.get("molecule_name") != null) + { + summary.append(" | Molecule Name: ").append(doc.get("molecule_name")); + } + if (doc.get("gene_name") != null) + { + summary.append(" | Gene Name: ").append(doc.get("gene_name")); + } + if (doc.get("genus") != null) + { + summary.append(" | Genus: ").append(doc.get("genus")); + } + if (doc.get("title") != null) + { + summary.append(" | Title: ").append(doc.get("title")); + } + this.summary = summary.toString(); + } + + 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.append(summary); + html.append("
"); + return html.toString(); + } + +}