messed up
authorcmzmasek <cmzmasek@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Thu, 10 Jan 2013 19:25:17 +0000 (19:25 +0000)
committercmzmasek <cmzmasek@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Thu, 10 Jan 2013 19:25:17 +0000 (19:25 +0000)
forester/java/src/org/forester/archaeopteryx/TreeFontSet.java
forester/java/src/org/forester/archaeopteryx/TreePanel.java

index d21e0b8..fcf350b 100644 (file)
@@ -64,7 +64,8 @@ public final class TreeFontSet {
     int                         _small_max_ascent     = 0;
     private final int           _min;
     private final int           _max;
-
+    private boolean _decreased_size_by_system = false;
+    
     TreeFontSet( final MainPanel owner ) {
         _owner = owner;
         _min = _owner.getConfiguration().getMinBaseFontSize();
@@ -78,9 +79,11 @@ public final class TreeFontSet {
 
     public Font getSmallFontSystem() {
         return _small_font_system;
+    
     }
 
-    void decreaseFontSize( final int min ) {
+    void decreaseFontSize( final int min, final boolean decreased_size_by_system ) {
+        setDecreasedSizeBySystem( decreased_size_by_system );
         if ( _large_font.getSize() >= min ) {
             _small_font = _small_font.deriveFont( _small_font.getSize() - FONT_SIZE_CHANGE_STEP );
             _large_font = _large_font.deriveFont( _large_font.getSize() - FONT_SIZE_CHANGE_STEP );
@@ -89,6 +92,11 @@ public final class TreeFontSet {
             setupFontMetrics();
         }
     }
+    
+    
+    
+   
+    
 
     Font getBaseFont() {
         return _base_font;
@@ -123,6 +131,7 @@ public final class TreeFontSet {
     }
 
     void largeFonts() {
+        setDecreasedSizeBySystem( false );
         _small_font = _small_font.deriveFont( 12f );
         _large_font = _large_font.deriveFont( 14f );
         _small_italic_font = _small_italic_font.deriveFont( 12f );
@@ -131,6 +140,7 @@ public final class TreeFontSet {
     }
 
     void mediumFonts() {
+        setDecreasedSizeBySystem( false );
         _small_font = _small_font.deriveFont( 8f );
         _large_font = _large_font.deriveFont( 10f );
         _small_italic_font = _small_italic_font.deriveFont( 8f );
@@ -148,6 +158,7 @@ public final class TreeFontSet {
     }
 
     void smallFonts() {
+        setDecreasedSizeBySystem( false );
         _small_font = _small_font.deriveFont( SMALL_FONTS_BASE - 1 );
         _large_font = _large_font.deriveFont( SMALL_FONTS_BASE );
         _small_italic_font = _small_italic_font.deriveFont( SMALL_FONTS_BASE - 1 );
@@ -156,6 +167,7 @@ public final class TreeFontSet {
     }
 
     void superTinyFonts() {
+        setDecreasedSizeBySystem( false );
         _small_font = _small_font.deriveFont( 2f );
         _large_font = _large_font.deriveFont( 3f );
         _small_italic_font = _small_italic_font.deriveFont( 2f );
@@ -164,6 +176,7 @@ public final class TreeFontSet {
     }
 
     void tinyFonts() {
+        setDecreasedSizeBySystem( false );
         _small_font = _small_font.deriveFont( 5f );
         _large_font = _large_font.deriveFont( 6f );
         _small_italic_font = _small_italic_font.deriveFont( 5f );
@@ -202,4 +215,12 @@ public final class TreeFontSet {
         _small_max_descent = _fm_small.getMaxDescent();
         _small_max_ascent = _fm_small.getMaxAscent() + 1;
     }
+
+    boolean isDecreasedSizeBySystem() {
+        return _decreased_size_by_system;
+    }
+
+    private void setDecreasedSizeBySystem( final boolean decreased_size_by_system ) {
+        _decreased_size_by_system = decreased_size_by_system;
+    }
 }
index 1a4fef3..bfc9f05 100644 (file)
@@ -404,7 +404,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 getControlPanel().displayedPhylogenyMightHaveChanged( true );
             }
             else {
-                getTreeFontSet().decreaseFontSize( 1 );
+                getTreeFontSet().decreaseFontSize( 1, false );
                 getControlPanel().displayedPhylogenyMightHaveChanged( true );
             }
         }
@@ -525,7 +525,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             if ( recalc_longest_ext_node_info ) {
                 calculateLongestExtNodeInfo();
                 while ( ( getLongestExtNodeInfo() > ( x * 0.67 ) ) && ( getTreeFontSet().getLargeFont().getSize() > 2 ) ) {
-                    getMainPanel().getTreeFontSet().decreaseFontSize( getConfiguration().getMinBaseFontSize() );
+                    getMainPanel().getTreeFontSet().decreaseFontSize( getConfiguration().getMinBaseFontSize(), true );
+
+                    
                     calculateLongestExtNodeInfo();
                 }
             }
@@ -581,11 +583,12 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 if ( dynamic_hiding_factor > 1 ) {
                     while ( dynamic_hiding_factor > 1
                             && getTreeFontSet()._fm_large.getHeight() > TreeFontSet.SMALL_FONTS_BASE ) {
-                        getTreeFontSet().decreaseFontSize( 1 );
+                        getTreeFontSet().decreaseFontSize( 1, true );
+                        
                         dynamic_hiding_factor = calcDynamicHidingFactor();
                     }
                 }
-                else {
+                else if ( getTreeFontSet().isDecreasedSizeBySystem() ) {
                     while ( dynamic_hiding_factor < 1 && getTreeFontSet()._fm_large.getHeight() < 12 ) {
                         getTreeFontSet().increaseFontSize();
                         dynamic_hiding_factor = calcDynamicHidingFactor();
@@ -2981,7 +2984,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( true );
             }
             else if ( ( e.getKeyCode() == KeyEvent.VK_SUBTRACT ) || ( e.getKeyCode() == KeyEvent.VK_MINUS ) ) {
-                getMainPanel().getTreeFontSet().decreaseFontSize( 1 );
+                getMainPanel().getTreeFontSet().decreaseFontSize( 1, false );
+
+                
                 getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( true );
             }
             else if ( plusPressed( e.getKeyCode() ) ) {