JAL-2844 line drawing at mouse click added on top of Aptx
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Mon, 27 Nov 2017 16:20:14 +0000 (16:20 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Mon, 27 Nov 2017 16:20:14 +0000 (16:20 +0000)
src/jalview/ext/archaeopteryx/JalviewBinding.java

index f59bdd9..2331204 100644 (file)
@@ -13,6 +13,7 @@ import jalview.structure.StructureSelectionManager;
 import jalview.util.MessageManager;
 import jalview.viewmodel.AlignmentViewport;
 
+import java.awt.Graphics;
 import java.awt.event.ActionEvent;
 import java.awt.event.InputEvent;
 import java.awt.event.MouseEvent;
@@ -159,11 +160,11 @@ public final class JalviewBinding
         }
         else
         {
-          partitionTree(e);
-        
-        
+          partitionTree(e.getX());
+
       }
       
+        PaintRefresher.Refresh(treeView, parentAvport.getSequenceSetId());
       }
     });
 
@@ -221,28 +222,27 @@ public final class JalviewBinding
   /**
    * Partially refactored from TreeCanvas
    */
-  public void partitionTree(final MouseEvent e)
+  public void partitionTree(final int x)
   {
-    int x = e.getX();
-    int lineLength = treeView.getHeight();
-
     Phylogeny tree = treeView.getPhylogeny();
-    double treeHeight = tree.calculateHeight(true);
-
-
-
-    if (treeHeight != 0)
+    if (!tree.isEmpty())
     {
-      int viewWidth = treeView.getWidth();
+      double treeDepth = tree.calculateHeight(true);
+      if (treeDepth != 0)
+      {
+        Graphics g = treeView.getGraphics();
+        int panelHeight = treeView.getHeight();
+        g.drawLine(x, 0, x, panelHeight);
 
-      // treeView.validate();
 
-      // System.out.println("selection");
-      // System.out.println(x);
-      // System.out.println("-------------");
-      // System.out.println("width");
-      // System.out.println(viewWidth);
+        // int viewWidth = treeView.getWidth();
 
+        // System.out.println("selection");
+        // System.out.println(x);
+        // System.out.println("-------------");
+        // System.out.println("width");
+        // System.out.println(viewWidth);
+      }
     }
 
 
@@ -267,7 +267,7 @@ public final class JalviewBinding
         showMatchingSequence(node);
       }
 
-    PaintRefresher.Refresh(treeView, parentAvport.getSequenceSetId());
+
     }