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