1 Clazz.declarePackage ("jalview.appletgui");
2 Clazz.load (["awt2swing.Panel", "java.awt.event.ItemListener", "awt2swing.Button", "$.Checkbox", "$.Choice", "java.awt.Font"], "jalview.appletgui.FontChooser", ["awt2swing.Frame", "$.Label", "jalview.appletgui.JVDialog", "jalview.bin.JalviewLite", "jalview.util.MessageManager", "java.awt.BorderLayout", "$.Color", "$.FlowLayout", "$.Toolkit", "java.awt.event.ActionListener"], function () {
3 c$ = Clazz.decorateAsClass (function () {
7 this.scaleAsCdna = null;
13 this.oldCharWidth = 0;
14 this.oldScaleProtein = false;
15 this.lastSelected = null;
16 this.lastSelStyle = 0;
20 Clazz.instantialize (this, arguments);
21 }, jalview.appletgui, "FontChooser", awt2swing.Panel, java.awt.event.ItemListener);
22 Clazz.prepareFields (c$, function () {
23 this.fontSize = new awt2swing.Choice ();
24 this.fontStyle = new awt2swing.Choice ();
25 this.fontName = new awt2swing.Choice ();
26 this.scaleAsCdna = new awt2swing.Checkbox ();
27 this.ok = new awt2swing.Button ();
28 this.cancel = new awt2swing.Button ();
30 Clazz.makeConstructor (c$,
32 Clazz.superConstructor (this, jalview.appletgui.FontChooser, []);
36 if (Clazz.exceptionOf (e, Exception)) {
43 this.oldFont = tp.getTreeFont ();
45 }, "jalview.appletgui.TreePanel");
46 Clazz.makeConstructor (c$,
48 Clazz.superConstructor (this, jalview.appletgui.FontChooser, []);
50 this.oldFont = ap.av.getFont ();
51 this.oldCharWidth = ap.av.getViewStyle ().getCharWidth ();
52 this.oldScaleProtein = ap.av.getViewStyle ().isScaleProteinAsCdna ();
56 if (Clazz.exceptionOf (e, Exception)) {
63 }, "jalview.appletgui.AlignmentPanel");
64 Clazz.defineMethod (c$, "init",
66 var fonts = java.awt.Toolkit.getDefaultToolkit ().getFontList ();
67 for (var i = 0; i < fonts.length; i++) {
68 this.fontName.addItem (fonts[i]);
70 for (var i = 1; i < 31; i++) {
71 this.fontSize.addItem (i + "");
73 this.fontStyle.addItem ("plain");
74 this.fontStyle.addItem ("bold");
75 this.fontStyle.addItem ("italic");
76 this.fontName.select (this.oldFont.getName ());
77 this.fontSize.select (this.oldFont.getSize () + "");
78 this.fontStyle.select (new Integer (this.oldFont.getStyle ()));
79 this.frame = new awt2swing.Frame ();
80 this.frame.add (this);
81 jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("action.change_font"), 440, 115);
84 Clazz.overrideMethod (c$, "itemStateChanged",
86 var source = evt.getSource ();
87 if (source === this.fontName) {
88 this.fontName_actionPerformed ();
89 } else if (source === this.fontSize) {
90 this.fontSize_actionPerformed ();
91 } else if (source === this.fontStyle) {
92 this.fontStyle_actionPerformed ();
93 } else if (source === this.scaleAsCdna) {
94 this.scaleAsCdna_actionPerformed ();
95 }}, "java.awt.event.ItemEvent");
96 Clazz.defineMethod (c$, "ok_actionPerformed",
98 this.frame.setVisible (false);
99 if (this.ap != null) {
100 if (this.ap.getOverviewPanel () != null) {
101 this.ap.getOverviewPanel ().updateOverviewImage ();
103 Clazz.defineMethod (c$, "cancel_actionPerformed",
105 if (this.ap != null) {
106 this.ap.av.setScaleProteinAsCdna (this.oldScaleProtein);
107 if (this.ap.av.getCodingComplement () != null) {
108 this.ap.av.getCodingComplement ().setScaleProteinAsCdna (this.oldScaleProtein);
109 this.ap.alignFrame.getSplitFrame ().repaint ();
110 }this.ap.av.setFont (this.oldFont);
111 var style = this.ap.av.getViewStyle ();
112 if (style.getCharWidth () != this.oldCharWidth) {
113 style.setCharWidth (this.oldCharWidth);
114 this.ap.av.setViewStyle (style);
115 }this.ap.paintAlignment (true);
116 } else if (this.tp != null) {
117 this.tp.setTreeFont (this.oldFont);
118 this.tp.treeCanvas.repaint ();
119 }this.fontName.select (this.oldFont.getName ());
120 this.fontSize.select (this.oldFont.getSize () + "");
121 this.fontStyle.select (new Integer (this.oldFont.getStyle ()));
122 this.frame.setVisible (false);
124 Clazz.defineMethod (c$, "changeFont",
126 if (this.lastSelected == null) {
127 this.lastSelected = this.oldFont;
128 this.lastSelSize = this.oldFont.getSize ();
129 this.lastSelStyle = this.oldFont.getStyle ();
130 }var newFont = new java.awt.Font (this.fontName.getSelectedItem ().toString (), this.fontStyle.getSelectedIndex (), Integer.parseInt (this.fontSize.getSelectedItem ().toString ()));
131 var fm = this.getGraphics ().getFontMetrics (newFont);
132 var mw = fm.getStringBounds ("M", this.getGraphics ()).getWidth ();
133 var iw = fm.getStringBounds ("I", this.getGraphics ()).getWidth ();
134 if (mw < 1 || iw < 1) {
135 this.fontName.select (this.lastSelected.getName ());
136 this.fontStyle.select (new Integer (this.lastSelStyle));
137 this.fontSize.select ("" + this.lastSelSize);
138 var d = new jalview.appletgui.JVDialog (this.frame, jalview.util.MessageManager.getString ("label.invalid_font"), true, 350, 200);
139 var mp = new awt2swing.Panel ();
140 d.cancel.setVisible (false);
141 mp.setLayout ( new java.awt.FlowLayout ());
142 mp.add ( new awt2swing.Label ("Font doesn't have letters defined\nso cannot be used\nwith alignment data."));
146 }if (this.tp != null) {
147 this.tp.setTreeFont (newFont);
148 } else if (this.ap != null) {
149 this.ap.av.setFont (newFont);
150 this.ap.fontChanged ();
151 }this.lastSelected = newFont;
153 Clazz.defineMethod (c$, "fontName_actionPerformed",
159 Clazz.defineMethod (c$, "fontSize_actionPerformed",
165 Clazz.defineMethod (c$, "fontStyle_actionPerformed",
171 Clazz.defineMethod (c$, "jbInit",
173 this.setLayout ( new java.awt.BorderLayout ());
174 this.setBackground (java.awt.Color.white);
175 var fontLabel = new awt2swing.Label (jalview.util.MessageManager.getString ("label.font"));
176 fontLabel.setFont (jalview.appletgui.FontChooser.VERDANA_11PT);
177 fontLabel.setAlignment (4);
178 this.fontSize.setFont (jalview.appletgui.FontChooser.VERDANA_11PT);
179 this.fontSize.addItemListener (this);
180 this.fontStyle.setFont (jalview.appletgui.FontChooser.VERDANA_11PT);
181 this.fontStyle.addItemListener (this);
182 var sizeLabel = new awt2swing.Label (jalview.util.MessageManager.getString ("label.size"));
183 sizeLabel.setAlignment (4);
184 sizeLabel.setFont (jalview.appletgui.FontChooser.VERDANA_11PT);
185 var styleLabel = new awt2swing.Label (jalview.util.MessageManager.getString ("label.style"));
186 styleLabel.setAlignment (4);
187 styleLabel.setFont (jalview.appletgui.FontChooser.VERDANA_11PT);
188 this.fontName.setFont (jalview.appletgui.FontChooser.VERDANA_11PT);
189 this.fontName.addItemListener (this);
190 this.scaleAsCdna.setLabel (jalview.util.MessageManager.getString ("label.scale_as_cdna"));
191 this.scaleAsCdna.setFont (jalview.appletgui.FontChooser.VERDANA_11PT);
192 this.scaleAsCdna.addItemListener (this);
193 this.scaleAsCdna.setState (this.ap.av.isScaleProteinAsCdna ());
194 this.ok.setFont (jalview.appletgui.FontChooser.VERDANA_11PT);
195 this.ok.setLabel (jalview.util.MessageManager.getString ("action.ok"));
196 this.ok.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.FontChooser$1") ? 0 : jalview.appletgui.FontChooser.$FontChooser$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.FontChooser$1, this, null)));
197 this.cancel.setFont (jalview.appletgui.FontChooser.VERDANA_11PT);
198 this.cancel.setLabel (jalview.util.MessageManager.getString ("action.cancel"));
199 this.cancel.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.FontChooser$2") ? 0 : jalview.appletgui.FontChooser.$FontChooser$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.FontChooser$2, this, null)));
200 var fontPanel = new awt2swing.Panel ();
201 fontPanel.setLayout ( new java.awt.BorderLayout ());
202 var stylePanel = new awt2swing.Panel ();
203 stylePanel.setLayout ( new java.awt.BorderLayout ());
204 var sizePanel = new awt2swing.Panel ();
205 sizePanel.setLayout ( new java.awt.BorderLayout ());
206 var scalePanel = new awt2swing.Panel ();
207 scalePanel.setLayout ( new java.awt.BorderLayout ());
208 var okCancelPanel = new awt2swing.Panel ();
209 var optionsPanel = new awt2swing.Panel ();
210 fontPanel.setBackground (java.awt.Color.white);
211 stylePanel.setBackground (java.awt.Color.white);
212 sizePanel.setBackground (java.awt.Color.white);
213 okCancelPanel.setBackground (java.awt.Color.white);
214 optionsPanel.setBackground (java.awt.Color.white);
215 fontPanel.add (fontLabel, "West");
216 fontPanel.add (this.fontName, "Center");
217 stylePanel.add (styleLabel, "West");
218 stylePanel.add (this.fontStyle, "Center");
219 sizePanel.add (sizeLabel, "West");
220 sizePanel.add (this.fontSize, "Center");
221 scalePanel.add (this.scaleAsCdna, "Center");
222 okCancelPanel.add (this.ok, null);
223 okCancelPanel.add (this.cancel, null);
224 optionsPanel.add (fontPanel, null);
225 optionsPanel.add (sizePanel, null);
226 optionsPanel.add (stylePanel, null);
227 this.add (optionsPanel, "North");
228 if (this.ap.alignFrame.getSplitFrame () != null) {
229 this.add (scalePanel, "Center");
230 }this.add (okCancelPanel, "South");
231 }, $fz.isPrivate = true, $fz));
232 Clazz.defineMethod (c$, "scaleAsCdna_actionPerformed",
234 this.ap.av.setScaleProteinAsCdna (this.scaleAsCdna.getState ());
235 this.ap.av.getCodingComplement ().setScaleProteinAsCdna (this.scaleAsCdna.getState ());
236 this.ap.alignFrame.getSplitFrame ().adjustLayout ();
237 this.ap.paintAlignment (true);
238 this.ap.alignFrame.getSplitFrame ().repaint ();
240 c$.$FontChooser$1$ = function () {
242 c$ = Clazz.declareAnonymous (jalview.appletgui, "FontChooser$1", null, java.awt.event.ActionListener);
243 Clazz.overrideMethod (c$, "actionPerformed",
245 this.b$["jalview.appletgui.FontChooser"].ok_actionPerformed ();
246 }, "java.awt.event.ActionEvent");
249 c$.$FontChooser$2$ = function () {
251 c$ = Clazz.declareAnonymous (jalview.appletgui, "FontChooser$2", null, java.awt.event.ActionListener);
252 Clazz.overrideMethod (c$, "actionPerformed",
254 this.b$["jalview.appletgui.FontChooser"].cancel_actionPerformed ();
255 }, "java.awt.event.ActionEvent");
258 c$.VERDANA_11PT = c$.prototype.VERDANA_11PT = new java.awt.Font ("Verdana", 0, 11);