1 Clazz.declarePackage ("javax.swing.text");
\r
2 Clazz.load (["java.awt.Container", "java.beans.PropertyChangeListener", "javax.swing.text.View"], "javax.swing.text.ComponentView", ["java.lang.IllegalArgumentException", "java.awt.Dimension", "$.Rectangle", "javax.swing.SwingUtilities", "javax.swing.text.AbstractDocument", "$.BadLocationException", "$.Position", "$.StyleConstants"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
4 this.createdC = null;
\r
6 if (!Clazz.isClassDefined ("javax.swing.text.ComponentView.Invalidator")) {
\r
7 javax.swing.text.ComponentView.$ComponentView$Invalidator$ ();
\r
9 Clazz.instantialize (this, arguments);
\r
10 }, javax.swing.text, "ComponentView", javax.swing.text.View);
\r
11 Clazz.defineMethod (c$, "createComponent",
\r
13 var attr = this.getElement ().getAttributes ();
\r
14 var comp = javax.swing.text.StyleConstants.getComponent (attr);
\r
17 Clazz.defineMethod (c$, "getComponent",
\r
19 return this.createdC;
\r
21 Clazz.overrideMethod (c$, "paint",
\r
23 if (this.c != null) {
\r
24 var alloc = (Clazz.instanceOf (a, java.awt.Rectangle)) ? a : a.getBounds ();
\r
25 this.c.setBounds (alloc.x, alloc.y, alloc.width, alloc.height);
\r
26 }}, "java.awt.Graphics,java.awt.Shape");
\r
27 Clazz.overrideMethod (c$, "getPreferredSpan",
\r
29 if ((axis != 0) && (axis != 1)) {
\r
30 throw new IllegalArgumentException ("Invalid axis: " + axis);
\r
31 }if (this.c != null) {
\r
32 var size = this.c.getPreferredSize ();
\r
39 Clazz.overrideMethod (c$, "getMinimumSpan",
\r
41 if ((axis != 0) && (axis != 1)) {
\r
42 throw new IllegalArgumentException ("Invalid axis: " + axis);
\r
43 }if (this.c != null) {
\r
44 var size = this.c.getMinimumSize ();
\r
51 Clazz.overrideMethod (c$, "getMaximumSpan",
\r
53 if ((axis != 0) && (axis != 1)) {
\r
54 throw new IllegalArgumentException ("Invalid axis: " + axis);
\r
55 }if (this.c != null) {
\r
56 var size = this.c.getMaximumSize ();
\r
63 Clazz.defineMethod (c$, "getAlignment",
\r
65 if (this.c != null) {
\r
68 return this.c.getAlignmentX ();
\r
70 return this.c.getAlignmentY ();
\r
72 }return Clazz.superCall (this, javax.swing.text.ComponentView, "getAlignment", [axis]);
\r
74 Clazz.defineMethod (c$, "setParent",
\r
76 Clazz.superCall (this, javax.swing.text.ComponentView, "setParent", [p]);
\r
77 if (javax.swing.SwingUtilities.isEventDispatchThread ()) {
\r
78 this.setComponentParent ();
\r
80 var callSetComponentParent = ((Clazz.isClassDefined ("javax.swing.text.ComponentView$1") ? 0 : javax.swing.text.ComponentView.$ComponentView$1$ ()), Clazz.innerTypeInstance (javax.swing.text.ComponentView$1, this, null));
\r
81 javax.swing.SwingUtilities.invokeLater (callSetComponentParent);
\r
82 }}, "javax.swing.text.View");
\r
83 Clazz.defineMethod (c$, "setComponentParent",
\r
85 var p = this.getParent ();
\r
87 var parent = this.getContainer ();
\r
88 if (parent != null) {
\r
89 if (this.c == null) {
\r
90 var comp = this.createComponent ();
\r
92 this.createdC = comp;
\r
93 this.c = Clazz.innerTypeInstance (javax.swing.text.ComponentView.Invalidator, this, null, comp);
\r
94 }}if (this.c != null) {
\r
95 if (this.c.getParent () == null) {
\r
96 parent.add (this.c, this);
\r
97 parent.addPropertyChangeListener ("enabled", this.c);
\r
99 if (this.c != null) {
\r
100 var parent = this.c.getParent ();
\r
101 if (parent != null) {
\r
102 parent.remove (this.c);
\r
103 parent.removePropertyChangeListener ("enabled", this.c);
\r
105 Clazz.defineMethod (c$, "modelToView",
\r
106 function (pos, a, b) {
\r
107 var p0 = this.getStartOffset ();
\r
108 var p1 = this.getEndOffset ();
\r
109 if ((pos >= p0) && (pos <= p1)) {
\r
110 var r = a.getBounds ();
\r
115 }throw new javax.swing.text.BadLocationException (pos + " not in range " + p0 + "," + p1, pos);
\r
116 }, "~N,java.awt.Shape,javax.swing.text.Position.Bias");
\r
117 Clazz.defineMethod (c$, "viewToModel",
\r
118 function (x, y, a, bias) {
\r
120 if (x < alloc.x + (Clazz.doubleToInt (alloc.width / 2))) {
\r
121 bias[0] = javax.swing.text.Position.Bias.Forward;
\r
122 return this.getStartOffset ();
\r
123 }bias[0] = javax.swing.text.Position.Bias.Backward;
\r
124 return this.getEndOffset ();
\r
125 }, "~N,~N,java.awt.Shape,~A");
\r
126 c$.$ComponentView$Invalidator$ = function () {
\r
127 Clazz.pu$h(self.c$);
\r
128 c$ = Clazz.decorateAsClass (function () {
\r
129 Clazz.prepareCallback (this, arguments);
\r
135 Clazz.instantialize (this, arguments);
\r
136 }, javax.swing.text.ComponentView, "Invalidator", java.awt.Container, java.beans.PropertyChangeListener);
\r
137 Clazz.makeConstructor (c$,
\r
139 Clazz.superConstructor (this, javax.swing.text.ComponentView.Invalidator, []);
\r
140 this.setLayout (null);
\r
142 this.cacheChildSizes ();
\r
143 }, "java.awt.Component");
\r
144 Clazz.defineMethod (c$, "invalidate",
\r
146 Clazz.superCall (this, javax.swing.text.ComponentView.Invalidator, "invalidate", []);
\r
147 if (this.getParent () != null) {
\r
148 this.b$["javax.swing.text.ComponentView"].preferenceChanged (null, true, true);
\r
150 Clazz.overrideMethod (c$, "doLayout",
\r
152 this.cacheChildSizes ();
\r
154 Clazz.defineMethod (c$, "setBounds",
\r
155 function (a, b, c, d) {
\r
156 Clazz.superCall (this, javax.swing.text.ComponentView.Invalidator, "setBounds", [a, b, c, d]);
\r
157 if (this.getComponentCount () > 0) {
\r
158 this.getComponent (0).setSize (c, d);
\r
159 }this.cacheChildSizes ();
\r
161 Clazz.defineMethod (c$, "validateIfNecessary",
\r
163 if (!this.isValid ()) {
\r
166 Clazz.defineMethod (c$, "cacheChildSizes",
\r
168 if (this.getComponentCount () > 0) {
\r
169 var a = this.getComponent (0);
\r
170 this.min = a.getMinimumSize ();
\r
171 this.pref = a.getPreferredSize ();
\r
172 this.max = a.getMaximumSize ();
\r
173 this.yalign = a.getAlignmentY ();
\r
174 this.xalign = a.getAlignmentX ();
\r
176 this.min = this.pref = this.max = new java.awt.Dimension (0, 0);
\r
178 Clazz.defineMethod (c$, "setVisible",
\r
180 Clazz.superCall (this, javax.swing.text.ComponentView.Invalidator, "setVisible", [a]);
\r
181 if (this.getComponentCount () > 0) {
\r
182 this.getComponent (0).setVisible (a);
\r
184 Clazz.overrideMethod (c$, "isShowing",
\r
188 Clazz.overrideMethod (c$, "getMinimumSize",
\r
190 this.validateIfNecessary ();
\r
193 Clazz.overrideMethod (c$, "getPreferredSize",
\r
195 this.validateIfNecessary ();
\r
198 Clazz.overrideMethod (c$, "getMaximumSize",
\r
200 this.validateIfNecessary ();
\r
203 Clazz.overrideMethod (c$, "getAlignmentX",
\r
205 this.validateIfNecessary ();
\r
206 return this.xalign;
\r
208 Clazz.overrideMethod (c$, "getAlignmentY",
\r
210 this.validateIfNecessary ();
\r
211 return this.yalign;
\r
213 Clazz.overrideMethod (c$, "propertyChange",
\r
215 var b = a.getNewValue ();
\r
216 if (this.getComponentCount () > 0) {
\r
217 this.getComponent (0).setEnabled ((b).booleanValue ());
\r
218 }}, "java.beans.PropertyChangeEvent");
\r
221 c$.$ComponentView$1$ = function () {
\r
222 Clazz.pu$h(self.c$);
\r
223 c$ = Clazz.declareAnonymous (javax.swing.text, "ComponentView$1", null, Runnable);
\r
224 Clazz.overrideMethod (c$, "run",
\r
226 var doc = this.b$["javax.swing.text.ComponentView"].getDocument ();
\r
228 if (Clazz.instanceOf (doc, javax.swing.text.AbstractDocument)) {
\r
230 }this.b$["javax.swing.text.ComponentView"].setComponentParent ();
\r
231 var host = this.b$["javax.swing.text.ComponentView"].getContainer ();
\r
232 if (host != null) {
\r
233 this.b$["javax.swing.text.ComponentView"].preferenceChanged (null, true, true);
\r
236 if (Clazz.instanceOf (doc, javax.swing.text.AbstractDocument)) {
\r
237 (doc).readUnlock ();
\r