Revert "JAL-2799 all tabs now get mouse listeners and Jalview switches tree view"
authorJim Procter <j.procter@dundee.ac.uk>
Thu, 2 Jun 2022 16:31:52 +0000 (17:31 +0100)
committerJim Procter <j.procter@dundee.ac.uk>
Thu, 2 Jun 2022 16:31:52 +0000 (17:31 +0100)
This reverts commit 62f2ed464010270830afcfe954647a51dfb5114b.

src/jalview/ext/archaeopteryx/JalviewBinding.java

index 7a0668d..dae01f1 100644 (file)
@@ -39,11 +39,9 @@ import org.forester.phylogeny.PhylogenyNode;
 public final class JalviewBinding
         implements ExternalTreeViewerBindingI<PhylogenyNode>
 {
-  private final MainFrame aptxFrame;
+  private org.forester.archaeopteryx.TreePanel treeView;
 
-  private org.forester.archaeopteryx.TreePanel currentTreeView;
-
-  private final AlignmentViewport parentAvport;
+  private AlignmentViewport parentAvport;
 
   private JTabbedPane treeTabs;
 
@@ -74,30 +72,19 @@ public final class JalviewBinding
           final Map<PhylogenyNode, SequenceI> nodesMappedToAlign)
   {
     // deal with/prohibit null values here as that will cause problems
-    aptxFrame = archaeopteryx;
     parentAvport = jalviewAlignmentViewport;
     sequencesBoundToNodes = alignMappedToNodes;
     nodesBoundToSequences = nodesMappedToAlign;
 
-    treeTabs = aptxFrame.getMainPanel().getTabbedPane();
+    treeView = archaeopteryx.getMainPanel().getCurrentTreePanel();
+    treeTabs = archaeopteryx.getMainPanel().getTabbedPane();
     ssm = parentAvport.getStructureSelectionManager();
 
     // archaeopteryx.getMainPanel().getControlPanel().setColorBranches(true);
     
     ssm.addSelectionListener(this);
-
-    int tabCount = treeTabs.getTabCount();
-
-    for (int i = 0; i < tabCount; i++)
-    {
-      // roundabout way to select each tree because getComponentAt(i) requires
-      // casting to TreePanel which doesn't work
-      treeTabs.setSelectedIndex(i);
-      currentTreeView = aptxFrame.getMainPanel().getCurrentTreePanel();
-      currentTreeView.addMouseListener(this);
-      PaintRefresher.Register(currentTreeView,
-              parentAvport.getSequenceSetId());
-    }
+    treeView.addMouseListener(this);
+    PaintRefresher.Register(treeView, parentAvport.getSequenceSetId());
 
 
     treeTabs.addChangeListener(new ChangeListener()
@@ -119,9 +106,9 @@ public final class JalviewBinding
            */
           public void run()
           {
-            currentTreeView = aptxFrame.getMainPanel()
-                    .getCurrentTreePanel();
             parentAvport.sendSelection();
+            // PaintRefresher.Refresh(treeView,
+            // parentAvport.getSequenceSetId());
 
           }
         });
@@ -148,16 +135,13 @@ public final class JalviewBinding
        */
       public void run()
       {
-
-        final PhylogenyNode node = currentTreeView.findNode(e.getX(),
-                e.getY());
+        final PhylogenyNode node = treeView.findNode(e.getX(), e.getY());
         if (node != null)
         {
           if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) // clear previous
           // selection if shift
           // IS NOT pressed
           {
-
             parentAvport.setSelectionGroup(null);
 
           }
@@ -205,7 +189,7 @@ public final class JalviewBinding
     if (source == parentAvport) // check if source is alignment from where the
     // tree originates
     {
-      currentTreeView.setFoundNodes0(
+      treeView.setFoundNodes0(
               new HashSet<Long>(seqsel.getSequences().size()));
 
       for (SequenceI selectedSequence : seqsel.getSequences())
@@ -213,11 +197,11 @@ public final class JalviewBinding
         PhylogenyNode matchingNode = sequencesBoundToNodes.get(selectedSequence);
         if (matchingNode != null)
         {
-          currentTreeView.getFoundNodes0().add(matchingNode.getId());
+          treeView.getFoundNodes0().add(matchingNode.getId());
         }
 
       }
-      aptxFrame.repaint();
+      treeView.repaint();
 
     }
 
@@ -230,16 +214,16 @@ public final class JalviewBinding
   public void partitionTree(final MouseEvent e)
   {
     int x = e.getX();
-    int lineLength = currentTreeView.getHeight();
+    int lineLength = treeView.getHeight();
 
-    Phylogeny tree = currentTreeView.getPhylogeny();
+    Phylogeny tree = treeView.getPhylogeny();
     double treeHeight = tree.calculateHeight(true);
 
 
 
     if (treeHeight != 0)
     {
-      int viewWidth = currentTreeView.getWidth();
+      int viewWidth = treeView.getWidth();
 
       // treeView.validate();
 
@@ -283,7 +267,7 @@ public final class JalviewBinding
     if (matchingSequence != null)
     {
       long nodeId = nodeToMatch.getId();
-      addOrRemoveInSet(currentTreeView.getFoundNodes0(), nodeId);
+      addOrRemoveInSet(treeView.getFoundNodes0(), nodeId);
       treeSelectionChanged(matchingSequence);
       parentAvport.sendSelection();
 
@@ -305,7 +289,7 @@ public final class JalviewBinding
       if (matchingSequence != null)
       {
         long nodeId = childNode.getId();
-        addOrRemoveInSet(currentTreeView.getFoundNodes0(), nodeId);
+        addOrRemoveInSet(treeView.getFoundNodes0(), nodeId);
 
         treeSelectionChanged(matchingSequence);
 
@@ -440,13 +424,11 @@ public final class JalviewBinding
     return parentAvport;
   }
 
-  public org.forester.archaeopteryx.TreePanel getTreeView()
+  public void setParentAvport(final AlignmentViewport parentAvport)
   {
-    return currentTreeView;
+    this.parentAvport = parentAvport;
   }
-
 }
 
 
 
-