X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FFontChooser.java;h=853d4aaf73ac1cb023cc1fd3df73f73537fe3564;hb=e63fbac40aee31b0563c07a349f46d9dad37f46a;hp=80ac189eaf1f0c4263b427e11223feea1b8ea5bf;hpb=106a3890f956e2aa7780b2985f4326655912a558;p=jalview.git diff --git a/src/jalview/gui/FontChooser.java b/src/jalview/gui/FontChooser.java index 80ac189..853d4aa 100755 --- a/src/jalview/gui/FontChooser.java +++ b/src/jalview/gui/FontChooser.java @@ -20,10 +20,6 @@ */ package jalview.gui; -import jalview.bin.Cache; -import jalview.jbgui.GFontChooser; -import jalview.util.MessageManager; - import java.awt.Font; import java.awt.FontMetrics; import java.awt.geom.Rectangle2D; @@ -31,6 +27,10 @@ import java.awt.geom.Rectangle2D; import javax.swing.JInternalFrame; import javax.swing.JLayeredPane; +import jalview.bin.Cache; +import jalview.jbgui.GFontChooser; +import jalview.util.MessageManager; + /** * DOCUMENT ME! * @@ -43,6 +43,8 @@ public class FontChooser extends GFontChooser TreePanel tp; + CutAndPasteTransfer cap; + /* * The font on opening the dialog (to be restored on Cancel) */ @@ -87,7 +89,7 @@ public class FontChooser extends GFontChooser public FontChooser(TreePanel treePanel) { this.tp = treePanel; - ap = treePanel.treeCanvas.ap; + ap = treePanel.getTreeCanvas().getAssociatedPanel(); oldFont = treePanel.getTreeFont(); defaultButton.setVisible(false); smoothFont.setEnabled(false); @@ -109,32 +111,47 @@ public class FontChooser extends GFontChooser init(); } + /** + * Creates a new FontChooser for a CutAndPasteTransfer + * @param cap + */ + public FontChooser(CutAndPasteTransfer cap) + { + oldFont = new Font("Monospaced", Font.PLAIN, 12); + this.cap = cap; + init(); + } + void init() { frame = new JInternalFrame(); + frame.setFrameIcon(null); frame.setContentPane(this); - smoothFont.setSelected(ap.av.antiAlias); - - /* - * Enable 'scale protein as cDNA' in a SplitFrame view. The selection is - * stored in the ViewStyle of both dna and protein Viewport. Also enable - * checkbox for copy font changes to other half of split frame. - */ - boolean inSplitFrame = ap.av.getCodingComplement() != null; - if (inSplitFrame) + if (!isCapFont()) { - oldComplementFont = ((AlignViewport) ap.av.getCodingComplement()) - .getFont(); - oldComplementSmooth = ((AlignViewport) ap.av - .getCodingComplement()).antiAlias; - scaleAsCdna.setVisible(true); - scaleAsCdna.setSelected(ap.av.isScaleProteinAsCdna()); - fontAsCdna.setVisible(true); - fontAsCdna.setSelected(ap.av.isProteinFontAsCdna()); + smoothFont.setSelected(ap.av.antiAlias); + + /* + * Enable 'scale protein as cDNA' in a SplitFrame view. The selection is + * stored in the ViewStyle of both dna and protein Viewport. Also enable + * checkbox for copy font changes to other half of split frame. + */ + boolean inSplitFrame = ap.av.getCodingComplement() != null; + if (inSplitFrame) + { + oldComplementFont = ((AlignViewport) ap.av.getCodingComplement()) + .getFont(); + oldComplementSmooth = ((AlignViewport) ap.av + .getCodingComplement()).antiAlias; + scaleAsCdna.setVisible(true); + scaleAsCdna.setSelected(ap.av.isScaleProteinAsCdna()); + fontAsCdna.setVisible(true); + fontAsCdna.setSelected(ap.av.isProteinFontAsCdna()); + } } - if (tp != null) + if (isTreeFont()) { Desktop.addInternalFrame(frame, MessageManager.getString("action.change_font_tree_panel"), @@ -229,13 +246,17 @@ public class FontChooser extends GFontChooser @Override protected void cancel_actionPerformed() { - if (ap != null) + if (isTreeFont()) + { + tp.setTreeFont(oldFont); + } + else if (ap != null) { ap.av.setFont(oldFont, true); ap.av.setScaleProteinAsCdna(oldProteinScale); ap.av.setProteinFontAsCdna(oldMirrorFont); ap.av.antiAlias = oldSmoothFont; - ap.paintAlignment(true, false); + ap.fontChanged(); if (scaleAsCdna.isVisible() && scaleAsCdna.isEnabled()) { @@ -250,10 +271,6 @@ public class FontChooser extends GFontChooser splitFrame.repaint(); } } - else if (tp != null) - { - tp.setTreeFont(oldFont); - } try { @@ -263,6 +280,15 @@ public class FontChooser extends GFontChooser } } + private boolean isTreeFont() + { + return tp != null; + } + + private boolean isCapFont() + { + return cap != null; + } /** * DOCUMENT ME! */ @@ -317,7 +343,7 @@ public class FontChooser extends GFontChooser } return; } - if (tp != null) + if (isTreeFont()) { tp.setTreeFont(newFont); } @@ -344,6 +370,10 @@ public class FontChooser extends GFontChooser splitFrame.repaint(); } } + else if (isCapFont()) + { + cap.setFont(newFont); + } monospaced.setSelected(mw == iw);