JAL-1953 first pass of adding javadoc, some methods renamed
[jalview.git] / src / jalview / ext / archaeopteryx / JalviewBinding.java
index 9296583..f0c2866 100644 (file)
@@ -116,6 +116,7 @@ public final class JalviewBinding
     treeView = archaeopteryx.getTreePanel();
     ssm = parentAvport.getStructureSelectionManager();
     
+    aptxFrame.setViewBinding(this);
     ssm.addSelectionListener(this);
     treeView.addMouseListener(this);
     treeView.registerWithPaintRefresher(
@@ -174,22 +175,21 @@ public final class JalviewBinding
 
     if (treeView.showingSubTree())
     {
-    LoadedTreeSequenceAssociation bindAptxNodes = new LoadedTreeSequenceAssociation(
-            parentAvport.getAlignment().getSequencesArray(),
+      LoadedTreeSequenceAssociation bindAptxNodes = new LoadedTreeSequenceAssociation(
+              parentAvport.getAlignment().getSequencesArray(),
               treeView.getTree());
-    bindAptxNodes.associateLeavesToSequences();
-    sequencesBoundToNodes = bindAptxNodes.getAlignmentWithNodes();
-    nodesBoundToSequences = bindAptxNodes.getNodesWithAlignment();
-    TreeViewerUtils.associateNodesWithJalviewSequences(aptxFrame, parentAvport,
-            sequencesBoundToNodes, nodesBoundToSequences);
+      bindAptxNodes.associateNodesToSequences();
+      sequencesBoundToNodes = bindAptxNodes.getAlignmentWithNodes();
+      nodesBoundToSequences = bindAptxNodes.getNodesWithAlignment();
+      TreeViewerUtils.associateNodesWithJalviewSequences(aptxFrame,
+              parentAvport, sequencesBoundToNodes, nodesBoundToSequences);
 
-
-    for (SequenceI seq : parentAvport.getAlignment().getSequencesArray())
-    {
-      if (!sequencesBoundToNodes.containsKey(seq))
+      for (SequenceI seq : parentAvport.getAlignment().getSequencesArray())
       {
-        parentAvport.hideSequence(new SequenceI[] { seq });
-      }
+        if (!sequencesBoundToNodes.containsKey(seq))
+        {
+          parentAvport.hideSequence(new SequenceI[] { seq });
+        }
       }
     }
 
@@ -336,24 +336,20 @@ public final class JalviewBinding
       rootX = tree.getRoot().getXcoord();
 
       // don't bother if 0 distance tree or clicked x lies outside of tree
-      if (furthestNodeX != rootX && !(x > furthestNodeX))
-      {
+      // if (furthestNodeX != rootX && !(x > furthestNodeX))
+
         float threshold = (x - rootX) / (furthestNodeX - rootX);
         List<TreeNodeI> foundNodes = getNodesAboveThreshold(
                 threshold,
                 tree.getRoot());
 
-      }
-      else
-      {
-        // clear previous colours?
-      }
+
     }
 
 
   }
 
-  public List<TreeNodeI> getNodesAboveThreshold(double threshold,
+  public List<TreeNodeI> getNodesAboveThreshold(float threshold,
           TreeNodeI node)
   {
 
@@ -386,7 +382,7 @@ public final class JalviewBinding
    * @return
    */
   private List<TreeNodeI> colourNodesAboveThreshold(
-          List<TreeNodeI> nodeList, double threshold,
+          List<TreeNodeI> nodeList, float threshold,
           TreeNodeI node)
   {
 
@@ -529,10 +525,7 @@ public final class JalviewBinding
 
   }
 
-  /**
-   * may or may not need an extra repaint on the alignment view (check what kira
-   * does)
-   */
+
   @Override
   public void showNodeSelectionOnAlign(final TreeNodeI node)
   {
@@ -578,8 +571,6 @@ public final class JalviewBinding
 
     for (TreeNodeI childNode : childNodes)
     {
-      // childNode.getBranchData().setBranchColor(new BranchColor(Color.BLUE));
-
       SequenceI matchingSequence = nodesBoundToSequences.get(childNode);
       if (matchingSequence != null)
       {
@@ -596,12 +587,7 @@ public final class JalviewBinding
 
   }
 
-  /**
-   * Refactored from TreeCanvas.
-   * 
-   * @param sequence
-   *          of the node selected in the tree viewer.
-   */
+
   @Override
   public void treeSelectionChanged(final SequenceI sequence)
   {
@@ -680,8 +666,6 @@ public final class JalviewBinding
   @Override
   public CommandI sortAlignmentIn(AlignmentPanel ap)
   {
-    // TODO: move to alignment view controller
-
     AlignmentViewport viewport = ap.av;
     SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
     try
@@ -741,6 +725,17 @@ public final class JalviewBinding
             .getAssociatedPanels(parentAvport.getSequenceSetId());
   }
 
+  @Override
+  public Map<SequenceI, TreeNodeI> getAlignmentWithNodes()
+  {
+    return sequencesBoundToNodes;
+  }
+
+  @Override
+  public Map<TreeNodeI, SequenceI> getNodesWithAlignment()
+  {
+    return nodesBoundToSequences;
+  }
 
 
 }