From: tcofoegbu Date: Thu, 31 Mar 2016 11:36:25 +0000 (+0100) Subject: JAL-2035 improvement to add binding to multiple model X-Git-Tag: Release_2_10_0~275 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=86ce701110991d006f506c585e13128996a01477;p=jalview.git JAL-2035 improvement to add binding to multiple model --- diff --git a/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java b/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java index 2e5dbeb..4201f43 100644 --- a/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java +++ b/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java @@ -178,6 +178,7 @@ public class ChimeraManager { logger.info("chimera open " + modelPath); // stopListening(); + List modelList = getModelList(); List response = null; // TODO: [Optional] Handle modbase models if (type == ModelType.MODBASE_MODEL) @@ -197,16 +198,26 @@ public class ChimeraManager logger.warn("Could not open " + modelPath); return null; } - List chimeraModels = getModelList(); + + List newModelList = getModelList(); + for (ChimeraModel newModel : newModelList) + { + if (!modelList.contains(newModel)) + { + newModel.setModelName(modelName); + sendChimeraCommand( + "setattr M name " + modelName + " #" + + newModel.getModelNumber(), false); + modelList.add(newModel); + + } + } + // assign color and residues to open models - for (ChimeraModel chimeraModel : chimeraModels) + for (ChimeraModel chimeraModel : modelList) { // // patch for Jalview - set model name in Chimera // // TODO: find a variant that works for sub-models - chimeraModel.setModelName(modelName); - sendChimeraCommand( - "setattr M name " + modelName + " #" - + chimeraModel.getModelNumber(), false); // get model color Color modelColor = getModelColor(chimeraModel); if (modelColor != null) @@ -227,7 +238,7 @@ public class ChimeraManager sendChimeraCommand("focus", false); // startListening(); // see ChimeraListener - return chimeraModels; + return modelList; } /** diff --git a/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraModel.java b/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraModel.java index 0700565..7da7a48 100644 --- a/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraModel.java +++ b/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraModel.java @@ -145,6 +145,7 @@ public class ChimeraModel implements ChimeraStructuralObject * * @return ChimeraModel */ + @Override public ChimeraModel getChimeraModel() { return this; @@ -272,6 +273,7 @@ public class ChimeraModel implements ChimeraStructuralObject * * @return user data */ + @Override public Object getUserData() { return userData; @@ -283,6 +285,7 @@ public class ChimeraModel implements ChimeraStructuralObject * @param data * user data to associate with this model */ + @Override public void setUserData(Object data) { this.userData = data; @@ -293,6 +296,7 @@ public class ChimeraModel implements ChimeraStructuralObject * * @return the selected state */ + @Override public boolean isSelected() { return selected; @@ -304,6 +308,7 @@ public class ChimeraModel implements ChimeraStructuralObject * @param selected * a boolean to set the selected state to */ + @Override public void setSelected(boolean selected) { this.selected = selected; @@ -314,6 +319,7 @@ public class ChimeraModel implements ChimeraStructuralObject * * @return the chains in this model as a list */ + @Override public List getChildren() { return new ArrayList(chainMap.values()); @@ -414,6 +420,7 @@ public class ChimeraModel implements ChimeraStructuralObject /** * Checks if this model has selected children. */ + @Override public boolean hasSelectedChildren() { if (selected) @@ -458,10 +465,13 @@ public class ChimeraModel implements ChimeraStructuralObject /** * Return the Chimera specification for this model. */ + @Override public String toSpec() { if (subModelNumber == 0) + { return ("#" + modelNumber); + } return ("#" + modelNumber + "." + subModelNumber); } @@ -469,6 +479,7 @@ public class ChimeraModel implements ChimeraStructuralObject * Return a string representation for the model. Shorten if longer than 100 * characters. */ + @Override public String toString() { String modelName = ""; @@ -554,4 +565,27 @@ public class ChimeraModel implements ChimeraStructuralObject } return nodeName; } + + @Override + public boolean equals(Object otherChimeraModel) + { + if (!(otherChimeraModel instanceof ChimeraModel)) + { + return false; + } + ChimeraModel otherCM = ((ChimeraModel) otherChimeraModel); + return this.name.equals(otherCM.name) + && this.modelNumber == otherCM.modelNumber + && this.type == otherCM.type; + } + + @Override + public int hashCode() + { + int hashCode = 1; + hashCode = hashCode * 37 + this.name.hashCode(); + hashCode = hashCode * 37 + this.type.hashCode(); + hashCode = (hashCode * 37) + modelNumber; + return hashCode; + } }