JAL-2435 copy font changes across split screen
[jalview.git] / src / jalview / gui / FontChooser.java
index 8220aea..b03d7a5 100755 (executable)
@@ -31,7 +31,6 @@ import java.awt.geom.Rectangle2D;
 
 import javax.swing.JInternalFrame;
 import javax.swing.JLayeredPane;
-import javax.swing.JOptionPane;
 
 /**
  * DOCUMENT ME!
@@ -103,14 +102,16 @@ public class FontChooser extends GFontChooser
 
     /*
      * Enable 'scale protein as cDNA' in a SplitFrame view. The selection is
-     * stored in the ViewStyle of both dna and protein Viewport
+     * stored in the ViewStyle of both dna and protein Viewport. Also enable
+     * checkbox for copy font changes to other half of split frame.
      */
-    scaleAsCdna.setEnabled(false);
-    if (ap.av.getCodingComplement() != null)
+    boolean inSplitFrame = ap.av.getCodingComplement() != null;
+    if (inSplitFrame)
     {
-      scaleAsCdna.setEnabled(true);
       scaleAsCdna.setVisible(true);
       scaleAsCdna.setSelected(ap.av.isScaleProteinAsCdna());
+      fontAsCdna.setVisible(true);
+      fontAsCdna.setSelected(true);
     }
 
     if (tp != null)
@@ -122,7 +123,7 @@ public class FontChooser extends GFontChooser
     else
     {
       Desktop.addInternalFrame(frame,
-              MessageManager.getString("action.change_font"), 380, 200,
+              MessageManager.getString("action.change_font"), 380, 220,
               false);
     }
 
@@ -204,10 +205,10 @@ public class FontChooser extends GFontChooser
       ap.av.setFont(oldFont, true);
       ap.av.setScaleProteinAsCdna(oldProteinScale);
       ap.paintAlignment(true);
-      if (scaleAsCdna.isEnabled())
+      if (scaleAsCdna.isVisible() && scaleAsCdna.isEnabled())
       {
-        ap.av.setScaleProteinAsCdna(oldProteinScale);
         ap.av.getCodingComplement().setScaleProteinAsCdna(oldProteinScale);
+        ap.av.getCodingComplement().setFont(oldFont, true);
       }
     }
     else if (tp != null)
@@ -287,6 +288,17 @@ public class FontChooser extends GFontChooser
     {
       ap.av.setFont(newFont, true);
       ap.fontChanged();
+
+      /*
+       * and change font in other half of split frame if any
+       */
+      if (fontAsCdna.isEnabled() && fontAsCdna.isSelected())
+      {
+        ap.av.getCodingComplement().setFont(newFont, true);
+        SplitFrame splitFrame = (SplitFrame) ap.alignFrame
+                .getSplitViewContainer();
+        splitFrame.repaint();
+      }
     }
 
     monospaced.setSelected(mw == iw);
@@ -381,7 +393,5 @@ public class FontChooser extends GFontChooser
             .getSplitViewContainer();
     splitFrame.adjustLayout();
     splitFrame.repaint();
-    // ap.paintAlignment(true);
-    // TODO would like to repaint
   }
 }