Merge branch 'develop' into spike/matrix_annot
[jalview.git] / src / jalview / datamodel / Alignment.java
index a6f2bf4..e0326c0 100755 (executable)
@@ -30,6 +30,7 @@ import jalview.util.MessageManager;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.List;
@@ -1921,4 +1922,38 @@ public class Alignment implements AlignmentI
     }
     return new int[] { startPos, endPos };
   }
+
+  Map<Object, ContactMatrixI> contactmaps = new HashMap<Object, ContactMatrixI>();
+  @Override
+  public
+  ContactListI getContactListFor(AlignmentAnnotation _aa, int column)
+  {
+    ContactMatrixI cm = contactmaps.get(_aa.annotationId);
+    if (cm == null)
+    {
+      return null;
+    }
+    return cm.getContactList(column);
+  }
+
+  @Override
+  public AlignmentAnnotation addContactList(ContactMatrixI cm)
+  {
+    Annotation _aa[] = new Annotation[getWidth()];
+    Annotation dummy = new Annotation(0.0f);
+    for (int i = 0; i < _aa.length; _aa[i++] = dummy)
+    {
+      ;
+    }
+    AlignmentAnnotation aa = new AlignmentAnnotation("Contact Matrix",
+            "Contact Matrix", _aa);
+    aa.graph = AlignmentAnnotation.CUSTOMRENDERER;
+    aa.graphMin = cm.getMin();
+    aa.graphMax = cm.getMax();
+    aa.editable = false;
+    // aa.autoCalculated = true;
+    contactmaps.put(aa.annotationId, cm);
+    addAnnotation(aa);
+    return aa;
+  }
 }