JAL-2035 improvement to add binding to multiple model
[jalview.git] / src / ext / edu / ucsf / rbvi / strucviz2 / ChimeraModel.java
index 0700565..7da7a48 100644 (file)
@@ -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<ChimeraStructuralObject> getChildren()
   {
     return new ArrayList<ChimeraStructuralObject>(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;
+  }
 }