fix size issue when re-sizing text with mouse wheel + ctrl
authorcmzmasek <cmzmasek@yahoo.com>
Fri, 1 Jul 2016 19:43:26 +0000 (12:43 -0700)
committercmzmasek <cmzmasek@yahoo.com>
Fri, 1 Jul 2016 19:43:26 +0000 (12:43 -0700)
forester/java/src/org/forester/archaeopteryx/ControlPanel.java
forester/java/src/org/forester/archaeopteryx/MainFrame.java
forester/java/src/org/forester/archaeopteryx/TreePanel.java

index fb0f3b3..dcb7a4a 100644 (file)
@@ -1381,6 +1381,11 @@ final class ControlPanel extends JPanel implements ActionListener {
     void displayedPhylogenyMightHaveChanged( final boolean recalc_longest_ext_node_info ) {
         if ( ( _mainpanel != null )
                 && ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
+            
+            if ( recalc_longest_ext_node_info ) {
+                _mainpanel.getCurrentTreePanel().initNodeData();
+                _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
+            }
             if ( getOptions().isShowOverview() ) {
                 _mainpanel.getCurrentTreePanel().updateOvSizes();
             }
@@ -1390,12 +1395,9 @@ final class ControlPanel extends JPanel implements ActionListener {
             _mainpanel.getCurrentTreePanel().calculateScaleDistance();
             _mainpanel.getCurrentTreePanel().calcMaxDepth();
             _mainpanel.adjustJScrollPane();
-            if ( recalc_longest_ext_node_info ) {
-                _mainpanel.getCurrentTreePanel().initNodeData();
-                _mainpanel.getCurrentTreePanel().calculateLongestExtNodeInfo();
-            }
+          
             _mainpanel.getCurrentTreePanel().repaint();
-            // _mainpanel.getCurrentTreePanel().setUpUrtFactors();
+            // _mainpanel.getCurrentTreePanel().setUpUrtFactor();
         }
     }
 
index 100bfbb..4cf0ac6 100644 (file)
@@ -885,6 +885,11 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );\r
         fc.showDialog( this, "Select the Base Font" );\r
         getMainPanel().getTreeFontSet().setBaseFont( fc.getFont() );\r
+        getControlPanel().displayedPhylogenyMightHaveChanged( true );\r
+        getMainPanel().getCurrentTreePanel().resetPreferredSize();\r
+        getMainPanel().getCurrentTreePanel().updateOvSizes();\r
+       \r
+        repaint();\r
     }\r
 \r
     private void chooseMinimalConfidence() {\r
index 4b0bf09..e271b52 100644 (file)
@@ -420,12 +420,14 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         if ( e.isControlDown() ) {
             if ( notches < 0 ) {
                 getTreeFontSet().increaseFontSize();
-                getControlPanel().displayedPhylogenyMightHaveChanged( true );
             }
             else {
                 getTreeFontSet().decreaseFontSize( 1, false );
-                getControlPanel().displayedPhylogenyMightHaveChanged( true );
             }
+            getControlPanel().displayedPhylogenyMightHaveChanged( true );
+            resetPreferredSize();
+            updateOvSizes();
+            repaint();
         }
         else if ( e.isShiftDown() ) {
             if ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
@@ -714,6 +716,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 nodeTaxonomyDataAsSB( _ext_node_with_longest_txt_info.getNodeData().getTaxonomy(), sb );
             }
         }
+       
         return getFontMetricsForLargeDefaultFont().stringWidth( sb.toString() );
     }
 
@@ -4424,11 +4427,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
             return;
         }
-        int max_length = ForesterUtil.roundToInt( ( getSize().getWidth() - 2 * MOVE )
+        int max_possible_length = ForesterUtil.roundToInt( ( getSize().getWidth() - 2 * MOVE )
                                                   * AptxConstants.EXT_NODE_INFO_LENGTH_MAX_RATIO );
-        if ( max_length < 40 ) {
-            max_length = 40;
-        }
+        if ( max_possible_length < 20 ) {
+             max_possible_length = 20;
+         }
         int longest = 30;
         int longest_txt = 0;
         _longest_domain = 0;
@@ -4489,8 +4492,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 // FIXME
                 sum += RenderableMsaSequence.DEFAULT_WIDTH + 30;
             }
-            if ( sum >= max_length ) {
-                _longest_ext_node_info = max_length;
+            if ( sum >= max_possible_length ) {
+                _longest_ext_node_info = max_possible_length;
                 // return; //FIXME why?
             }
             if ( sum > longest ) {
@@ -4498,12 +4501,12 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             }
         }
         _ext_node_with_longest_txt_info = longest_txt_node;
-        if ( longest >= max_length ) {
-            _longest_ext_node_info = max_length;
-        }
-        else {
-            _longest_ext_node_info = longest;
-        }
+         if ( longest >= max_possible_length ) {
+            _longest_ext_node_info = max_possible_length;
+         }
+         else {
+           _longest_ext_node_info = longest;
+         }
         _length_of_longest_text = calcLengthOfLongestText();
     }