JAL-2844 partitioning code made slightly clearer
[jalview.git] / forester / java / src / org / forester / archaeopteryx / TreePanel.java
index 3b3977d..3b69ded 100644 (file)
@@ -315,6 +315,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
     private int                           _ov_y_position                                     = 0;
     private int                           _ov_y_start                                        = 0;
     private boolean                     _partition_tree                                     = false;
+    private float                            _partition_threshold                           = 0;
     private final boolean                 _phy_has_branch_lengths;
     private Phylogeny                     _phylogeny                                         = null;
     private final Path2D.Float            _polygon                                           = new Path2D.Float();
@@ -1360,6 +1361,10 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
     final private TreeFontSet getTreeFontSet() {
         return getMainPanel().getTreeFontSet();
     }
+    
+    final public float getThreshold() {
+        return _partition_threshold;
+    }
 
     final private float getUrtFactor() {
         return _urt_factor;
@@ -5290,7 +5295,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 && ( !node.isRoot() || ( _subtree_index > 0 ) ) );
     }
 
-    final boolean isCurrentTreeIsSubtree() {
+    public final boolean isCurrentTreeIsSubtree() {
         return ( _subtree_index > 0 );
     }
 
@@ -5395,8 +5400,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 
                 _clicked_x = e.getX();
                 if (!getPhylogeny().isEmpty()) {
-                // should be calculated on each partition as the tree can theoretically
-                // change in the meantime
+
                 PhylogenyNode furthestNode = PhylogenyMethods.calculateNodeWithMaxDistanceToRoot( _phylogeny );
                 _furthest_node_x = furthestNode.getXcoord();
                 _root_x = _phylogeny.getRoot().getXcoord();
@@ -5677,6 +5681,14 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         paintCircularsLite( phy.getRoot(), phy, center_x, center_y, radius, g );
     }
 
+    public final void paintFile( final Graphics2D g,
+                                 final boolean to_pdf,
+                                 final int graphics_file_width,
+                                 final int graphics_file_height,
+                                 final int graphics_file_x,
+                                 final int graphics_file_y ) {
+        paintPhylogeny(g,to_pdf,true,graphics_file_width,graphics_file_height,graphics_file_x,graphics_file_y);
+    }
     final void paintPhylogeny( final Graphics2D g,
                                final boolean to_pdf,
                                final boolean to_graphics_file,
@@ -5684,13 +5696,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                                final int graphics_file_height,
                                final int graphics_file_x,
                                final int graphics_file_y ) {
-        if (_partition_tree) {
-//            float threshold = (_clicked_x - _root_x) / (_furthest_node_x - _root_x);
-//            drawLine( _clicked_x, 0, _clicked_x, getHeight(),g);
-            
-            _partition_tree = false;
-        }
-        
+
         if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
             return;
         }
@@ -5891,8 +5897,17 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 g.setTransform( _at );
                 paintOvRectangle( g );
             }
-        }
+
+              
+        }            
+        if (_partition_tree) {
+            g.setColor( Color.BLACK );
+            _partition_threshold = (_clicked_x - _root_x) / (_furthest_node_x - _root_x);
+           drawLine( _clicked_x, 0, _clicked_x, getHeight(),g);
+             _partition_tree = false;
+         }
     }
+    
 
     final void recalculateMaxDistanceToRoot() {
         _max_distance_to_root = PhylogenyMethods.calculateMaxDistanceToRoot( getPhylogeny() );