f22813b352b771518a0a112460deb3b9deaef0d8
[jalviewjs.git] / site / swingjs / j2s / javax / swing / text / LabelView.js
1 Clazz.declarePackage ("javax.swing.text");
2 Clazz.load (["javax.swing.text.GlyphView", "$.TabableView"], "javax.swing.text.LabelView", ["java.awt.Toolkit", "javax.swing.text.StateInvariantError", "$.StyleConstants", "$.StyledDocument"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.font = null;
5 this.fg = null;
6 this.bg = null;
7 this.underline = false;
8 this.strike = false;
9 this.superscript = false;
10 this.subscript = false;
11 Clazz.instantialize (this, arguments);
12 }, javax.swing.text, "LabelView", javax.swing.text.GlyphView, javax.swing.text.TabableView);
13 Clazz.defineMethod (c$, "sync", 
14 function () {
15 if (this.font == null) {
16 this.setPropertiesFromAttributes ();
17 }});
18 Clazz.defineMethod (c$, "setUnderline", 
19 function (u) {
20 this.underline = u;
21 }, "~B");
22 Clazz.defineMethod (c$, "setStrikeThrough", 
23 function (s) {
24 this.strike = s;
25 }, "~B");
26 Clazz.defineMethod (c$, "setSuperscript", 
27 function (s) {
28 this.superscript = s;
29 }, "~B");
30 Clazz.defineMethod (c$, "setSubscript", 
31 function (s) {
32 this.subscript = s;
33 }, "~B");
34 Clazz.defineMethod (c$, "setBackground", 
35 function (bg) {
36 this.bg = bg;
37 }, "java.awt.Color");
38 Clazz.defineMethod (c$, "setPropertiesFromAttributes", 
39 function () {
40 var attr = this.getAttributes ();
41 if (attr != null) {
42 var d = this.getDocument ();
43 if (Clazz.instanceOf (d, javax.swing.text.StyledDocument)) {
44 var doc = d;
45 this.font = doc.getFont (attr);
46 this.fg = doc.getForeground (attr);
47 if (attr.isDefined (javax.swing.text.StyleConstants.Background)) {
48 this.bg = doc.getBackground (attr);
49 } else {
50 this.bg = null;
51 }this.setUnderline (javax.swing.text.StyleConstants.isUnderline (attr));
52 this.setStrikeThrough (javax.swing.text.StyleConstants.isStrikeThrough (attr));
53 this.setSuperscript (javax.swing.text.StyleConstants.isSuperscript (attr));
54 this.setSubscript (javax.swing.text.StyleConstants.isSubscript (attr));
55 } else {
56 throw  new javax.swing.text.StateInvariantError ("LabelView needs StyledDocument");
57 }}});
58 Clazz.defineMethod (c$, "getFontMetrics", 
59 function () {
60 this.sync ();
61 var c = this.getContainer ();
62 return (c != null) ? c.getFontMetrics (this.font) : java.awt.Toolkit.getDefaultToolkit ().getFontMetrics (this.font);
63 });
64 Clazz.overrideMethod (c$, "getBackground", 
65 function () {
66 this.sync ();
67 return this.bg;
68 });
69 Clazz.overrideMethod (c$, "getForeground", 
70 function () {
71 this.sync ();
72 return this.fg;
73 });
74 Clazz.overrideMethod (c$, "getFont", 
75 function () {
76 this.sync ();
77 return this.font;
78 });
79 Clazz.overrideMethod (c$, "isUnderline", 
80 function () {
81 this.sync ();
82 return this.underline;
83 });
84 Clazz.overrideMethod (c$, "isStrikeThrough", 
85 function () {
86 this.sync ();
87 return this.strike;
88 });
89 Clazz.overrideMethod (c$, "isSubscript", 
90 function () {
91 this.sync ();
92 return this.subscript;
93 });
94 Clazz.overrideMethod (c$, "isSuperscript", 
95 function () {
96 this.sync ();
97 return this.superscript;
98 });
99 Clazz.defineMethod (c$, "changedUpdate", 
100 function (e, a, f) {
101 this.font = null;
102 Clazz.superCall (this, javax.swing.text.LabelView, "changedUpdate", [e, a, f]);
103 }, "javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory");
104 });