X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fext%2Fedu%2Fucsf%2Frbvi%2Fstrucviz2%2FChimeraChain.java;fp=src%2Fext%2Fedu%2Fucsf%2Frbvi%2Fstrucviz2%2FChimeraChain.java;h=9a29a99dd1adb3e53c582a2277b0b1c97b4aa5ab;hb=bf01811b6e0c8eb15630a73700a602f14908f6a0;hp=92193f2966b260f188af93d57587404685e1fb48;hpb=be2b1727035f39e94c4e5e320ac6011af984bcc6;p=jalview.git diff --git a/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraChain.java b/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraChain.java index 92193f2..9a29a99 100644 --- a/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraChain.java +++ b/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraChain.java @@ -44,287 +44,329 @@ import java.util.TreeMap; * */ // TODO: [Optional] Implement toAttr() method -public class ChimeraChain implements ChimeraStructuralObject { +public class ChimeraChain implements ChimeraStructuralObject +{ - /** - * The model/subModel number this chain is a part of - */ - private int modelNumber; - private int subModelNumber; + /** + * The model/subModel number this chain is a part of + */ + private int modelNumber; - /** - * A pointer to the model this chain is a part of - */ - private ChimeraModel chimeraModel; + private int subModelNumber; - /** - * The chainID (from the PDB record) - */ - private String chainId; + /** + * A pointer to the model this chain is a part of + */ + private ChimeraModel chimeraModel; - /** - * The residues that are part of this chain - */ - private TreeMap residueMap; + /** + * The chainID (from the PDB record) + */ + private String chainId; - /** - * userData to associate with this chain - */ - private Object userData; + /** + * The residues that are part of this chain + */ + private TreeMap residueMap; - /** - * Flag to indicate the selection state - */ - private boolean selected = false; + /** + * userData to associate with this chain + */ + private Object userData; - /** - * Constructor to create a new ChimeraChain - * - * @param model - * the model number this chain is part of - * @param subModel - * the subModel number this chain is part of - * @param chainId - * the chain ID for this chain - */ - public ChimeraChain(int model, int subModel, String chainId) { - this.modelNumber = model; - this.subModelNumber = subModel; - this.chainId = chainId; - residueMap = new TreeMap(); - } + /** + * Flag to indicate the selection state + */ + private boolean selected = false; - /** - * set the selected state of this chain - * - * @param selected - * a boolean to set the selected state to - */ - public void setSelected(boolean selected) { - this.selected = selected; - } + /** + * Constructor to create a new ChimeraChain + * + * @param model + * the model number this chain is part of + * @param subModel + * the subModel number this chain is part of + * @param chainId + * the chain ID for this chain + */ + public ChimeraChain(int model, int subModel, String chainId) + { + this.modelNumber = model; + this.subModelNumber = subModel; + this.chainId = chainId; + residueMap = new TreeMap(); + } - /** - * return the selected state of this chain - * - * @return the selected state - */ - public boolean isSelected() { - return selected; - } + /** + * set the selected state of this chain + * + * @param selected + * a boolean to set the selected state to + */ + public void setSelected(boolean selected) + { + this.selected = selected; + } - public boolean hasSelectedChildren() { - if (selected) { - return true; - } else { - for (ChimeraResidue residue : getResidues()) { - if (residue.isSelected()) - return true; - } - } - return false; - } + /** + * return the selected state of this chain + * + * @return the selected state + */ + public boolean isSelected() + { + return selected; + } - /** - * Return the list of selected residues - * - * @return all selected residues - */ - public List getSelectedResidues() { - List residueList = new ArrayList(); - if (selected) { - residueList.addAll(getResidues()); - } else { - for (ChimeraResidue residue : getResidues()) { - if (residue.isSelected()) - residueList.add(residue); - } - } - return residueList; - } + public boolean hasSelectedChildren() + { + if (selected) + { + return true; + } + else + { + for (ChimeraResidue residue : getResidues()) + { + if (residue.isSelected()) + return true; + } + } + return false; + } - /** - * Add a residue to the chain. - * - * @param residue - * the ChimeraResidue to add to the chain. - */ - public void addResidue(ChimeraResidue residue) { - String index = residue.getIndex(); - // Put it in our map so that we can return it in order - residueMap.put(index, residue); - } + /** + * Return the list of selected residues + * + * @return all selected residues + */ + public List getSelectedResidues() + { + List residueList = new ArrayList(); + if (selected) + { + residueList.addAll(getResidues()); + } + else + { + for (ChimeraResidue residue : getResidues()) + { + if (residue.isSelected()) + residueList.add(residue); + } + } + return residueList; + } - /** - * Return the list of residues in this chain in pdb residue order - * - * @return a Collection of residues in residue order - */ - public Collection getResidues() { - return residueMap.values(); - } + /** + * Add a residue to the chain. + * + * @param residue + * the ChimeraResidue to add to the chain. + */ + public void addResidue(ChimeraResidue residue) + { + String index = residue.getIndex(); + // Put it in our map so that we can return it in order + residueMap.put(index, residue); + } - /** - * Return the list of residues in this chain as a list - * - * @return List of residues - */ - public List getChildren() { - return new ArrayList(residueMap.values()); - } + /** + * Return the list of residues in this chain in pdb residue order + * + * @return a Collection of residues in residue order + */ + public Collection getResidues() + { + return residueMap.values(); + } - /** - * Get a specific residue - * - * @param residueIndex - * String representation of the residue index - * @return the ChimeraResidue represented by the residueIndex - */ - public ChimeraResidue getResidue(String index) { - // Integer index = new Integer(residueIndex); - if (residueMap.containsKey(index)) - return residueMap.get(index); - return null; - } + /** + * Return the list of residues in this chain as a list + * + * @return List of residues + */ + public List getChildren() + { + return new ArrayList(residueMap.values()); + } - /** - * Get a list of residues as a residue range - * - * @param residueRange - * String representation of the residue range - * @return the List of ChimeraResidues represented by the range - */ - public List getResidueRange(String residueRange) { - String[] range = residueRange.split("-", 2); - if (range[1] == null || range[1].length() == 0) { - range[1] = range[0]; - } - List resultRange = new ArrayList(); - int start = Integer.parseInt(range[0]); - int end = Integer.parseInt(range[1]); - for (int i = start; i <= end; i++) { - String index = String.valueOf(i); - if (residueMap.containsKey(index)) - resultRange.add(residueMap.get(index)); - } - return resultRange; - } + /** + * Get a specific residue + * + * @param residueIndex + * String representation of the residue index + * @return the ChimeraResidue represented by the residueIndex + */ + public ChimeraResidue getResidue(String index) + { + // Integer index = new Integer(residueIndex); + if (residueMap.containsKey(index)) + return residueMap.get(index); + return null; + } - /** - * Get the ID for this chain - * - * @return String value of the chainId - */ - public String getChainId() { - return chainId; - } + /** + * Get a list of residues as a residue range + * + * @param residueRange + * String representation of the residue range + * @return the List of ChimeraResidues represented by the range + */ + public List getResidueRange(String residueRange) + { + String[] range = residueRange.split("-", 2); + if (range[1] == null || range[1].length() == 0) + { + range[1] = range[0]; + } + List resultRange = new ArrayList(); + int start = Integer.parseInt(range[0]); + int end = Integer.parseInt(range[1]); + for (int i = start; i <= end; i++) + { + String index = String.valueOf(i); + if (residueMap.containsKey(index)) + resultRange.add(residueMap.get(index)); + } + return resultRange; + } - /** - * Get the model number for this chain - * - * @return the model number - */ - public int getModelNumber() { - return modelNumber; - } + /** + * Get the ID for this chain + * + * @return String value of the chainId + */ + public String getChainId() + { + return chainId; + } - /** - * Get the sub-model number for this chain - * - * @return the sub-model number - */ - public int getSubModelNumber() { - return subModelNumber; - } + /** + * Get the model number for this chain + * + * @return the model number + */ + public int getModelNumber() + { + return modelNumber; + } - /** - * Return a string representation of this chain as follows: Chain chainId - * (residue_count residues) - * - * @return String representation of chain - */ - public String displayName() { - if (chainId.equals("_")) { - return ("Chain (no ID) (" + getResidueCount() + " residues)"); - } else { - return ("Chain " + chainId + " (" + getResidueCount() + " residues)"); - } - } + /** + * Get the sub-model number for this chain + * + * @return the sub-model number + */ + public int getSubModelNumber() + { + return subModelNumber; + } - /** - * Return a string representation of this chain as follows: Node xxx [Model yyyy Chain - * chainId] - * - * @return String representation of chain - */ - public String toString() { - String displayName = chimeraModel.getModelName(); - if (displayName.length() > 14) - displayName = displayName.substring(0, 13) + "..."; - if (chainId.equals("_")) { - return (displayName + " Chain (no ID) (" + getResidueCount() + " residues)"); - } else { - return (displayName + " Chain " + chainId + " (" + getResidueCount() + " residues)"); - } - } + /** + * Return a string representation of this chain as follows: Chain + * chainId (residue_count residues) + * + * @return String representation of chain + */ + public String displayName() + { + if (chainId.equals("_")) + { + return ("Chain (no ID) (" + getResidueCount() + " residues)"); + } + else + { + return ("Chain " + chainId + " (" + getResidueCount() + " residues)"); + } + } - /** - * Return the Chimera specification for this chain - * - * @return Chimera specification - */ - public String toSpec() { - if (chainId.equals("_")) { - return ("#" + modelNumber + "." + subModelNumber + ":."); - } else { - return ("#" + modelNumber + "." + subModelNumber + ":." + chainId); - } - } + /** + * Return a string representation of this chain as follows: Node xxx [Model + * yyyy Chain chainId] + * + * @return String representation of chain + */ + public String toString() + { + String displayName = chimeraModel.getModelName(); + if (displayName.length() > 14) + displayName = displayName.substring(0, 13) + "..."; + if (chainId.equals("_")) + { + return (displayName + " Chain (no ID) (" + getResidueCount() + " residues)"); + } + else + { + return (displayName + " Chain " + chainId + " (" + getResidueCount() + " residues)"); + } + } - /** - * Return the number of residues in this chain - * - * @return integer number of residues - */ - public int getResidueCount() { - return residueMap.size(); - } + /** + * Return the Chimera specification for this chain + * + * @return Chimera specification + */ + public String toSpec() + { + if (chainId.equals("_")) + { + return ("#" + modelNumber + "." + subModelNumber + ":."); + } + else + { + return ("#" + modelNumber + "." + subModelNumber + ":." + chainId); + } + } - /** - * Set the ChimeraModel for this chain - * - * @param model - * ChimeraModel to associate with this chain - */ - public void setChimeraModel(ChimeraModel model) { - this.chimeraModel = model; - } + /** + * Return the number of residues in this chain + * + * @return integer number of residues + */ + public int getResidueCount() + { + return residueMap.size(); + } - /** - * Get the ChimeraModel for this chain - * - * @return ChimeraModel associated with this chain - */ - public ChimeraModel getChimeraModel() { - return chimeraModel; - } + /** + * Set the ChimeraModel for this chain + * + * @param model + * ChimeraModel to associate with this chain + */ + public void setChimeraModel(ChimeraModel model) + { + this.chimeraModel = model; + } - /** - * Get the user data for this Chain - * - * @return user data - */ - public Object getUserData() { - return userData; - } + /** + * Get the ChimeraModel for this chain + * + * @return ChimeraModel associated with this chain + */ + public ChimeraModel getChimeraModel() + { + return chimeraModel; + } - /** - * Set the user data for this Chain - * - * @param data - * the user data to associate with this chain - */ - public void setUserData(Object data) { - this.userData = data; - } + /** + * Get the user data for this Chain + * + * @return user data + */ + public Object getUserData() + { + return userData; + } + + /** + * Set the user data for this Chain + * + * @param data + * the user data to associate with this chain + */ + public void setUserData(Object data) + { + this.userData = data; + } }