1 Clazz.declarePackage ("javax.swing.text");
\r
2 Clazz.load (["javax.swing.SwingConstants"], "javax.swing.text.View", ["java.lang.IllegalArgumentException", "java.awt.Rectangle", "javax.swing.event.DocumentEvent", "javax.swing.text.Position", "$.Utilities"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
6 Clazz.instantialize (this, arguments);
\r
7 }, javax.swing.text, "View", null, javax.swing.SwingConstants);
\r
8 Clazz.makeConstructor (c$,
\r
11 }, "javax.swing.text.Element");
\r
12 Clazz.defineMethod (c$, "getParent",
\r
16 Clazz.defineMethod (c$, "isVisible",
\r
20 Clazz.defineMethod (c$, "getMinimumSpan",
\r
22 var w = this.getResizeWeight (axis);
\r
24 return this.getPreferredSpan (axis);
\r
27 Clazz.defineMethod (c$, "getMaximumSpan",
\r
29 var w = this.getResizeWeight (axis);
\r
31 return this.getPreferredSpan (axis);
\r
34 Clazz.defineMethod (c$, "preferenceChanged",
\r
35 function (child, width, height) {
\r
36 var parent = this.getParent ();
\r
37 if (parent != null) {
\r
38 parent.preferenceChanged (this, width, height);
\r
39 }}, "javax.swing.text.View,~B,~B");
\r
40 Clazz.defineMethod (c$, "getAlignment",
\r
44 Clazz.defineMethod (c$, "setParent",
\r
46 if (parent == null) {
\r
47 for (var i = 0; i < this.getViewCount (); i++) {
\r
48 if (this.getView (i).getParent () === this) {
\r
49 this.getView (i).setParent (null);
\r
51 }this.parent = parent;
\r
52 }, "javax.swing.text.View");
\r
53 Clazz.defineMethod (c$, "getViewCount",
\r
57 Clazz.defineMethod (c$, "getView",
\r
61 Clazz.defineMethod (c$, "removeAll",
\r
63 this.replace (0, this.getViewCount (), null);
\r
65 Clazz.defineMethod (c$, "remove",
\r
67 this.replace (i, 1, null);
\r
69 Clazz.defineMethod (c$, "insert",
\r
70 function (offs, v) {
\r
71 var one = new Array (1);
\r
73 this.replace (offs, 0, one);
\r
74 }, "~N,javax.swing.text.View");
\r
75 Clazz.defineMethod (c$, "append",
\r
77 var one = new Array (1);
\r
79 this.replace (this.getViewCount (), 0, one);
\r
80 }, "javax.swing.text.View");
\r
81 Clazz.defineMethod (c$, "replace",
\r
82 function (offset, length, views) {
\r
84 Clazz.defineMethod (c$, "getViewIndex",
\r
87 }, "~N,javax.swing.text.Position.Bias");
\r
88 Clazz.defineMethod (c$, "getChildAllocation",
\r
89 function (index, a) {
\r
91 }, "~N,java.awt.Shape");
\r
92 Clazz.defineMethod (c$, "getNextVisualPositionFrom",
\r
93 function (pos, b, a, direction, biasRet) {
\r
94 biasRet[0] = javax.swing.text.Position.Bias.Forward;
\r
95 switch (direction) {
\r
100 pos = (direction == 1) ? Math.max (0, this.getEndOffset () - 1) : this.getStartOffset ();
\r
102 }var target = this.getContainer ();
\r
103 var c = (target != null) ? target.getCaret () : null;
\r
106 mcp = c.getMagicCaretPosition ();
\r
111 var loc = target.modelToView (pos);
\r
112 x = (loc == null) ? 0 : loc.x;
\r
115 }if (direction == 1) {
\r
116 pos = javax.swing.text.Utilities.getPositionAbove (target, pos, x);
\r
118 pos = javax.swing.text.Utilities.getPositionBelow (target, pos, x);
\r
122 pos = Math.max (0, this.getEndOffset () - 1);
\r
124 pos = Math.max (0, pos - 1);
\r
128 pos = this.getStartOffset ();
\r
130 pos = Math.min (pos + 1, this.getDocument ().getLength ());
\r
133 throw new IllegalArgumentException ("Bad direction: " + direction);
\r
136 }, "~N,javax.swing.text.Position.Bias,java.awt.Shape,~N,~A");
\r
137 Clazz.defineMethod (c$, "modelToView",
\r
138 function (p0, b0, p1, b1, a) {
\r
139 var s0 = this.modelToView (p0, a, b0);
\r
141 if (p1 == this.getEndOffset ()) {
\r
143 s1 = this.modelToView (p1, a, b1);
\r
145 if (Clazz.exceptionOf (ble, javax.swing.text.BadLocationException)) {
\r
152 var alloc = (Clazz.instanceOf (a, java.awt.Rectangle)) ? a : a.getBounds ();
\r
153 s1 = new java.awt.Rectangle (alloc.x + alloc.width - 1, alloc.y, 1, alloc.height);
\r
155 s1 = this.modelToView (p1, a, b1);
\r
156 }var r0 = s0.getBounds ();
\r
157 var r1 = (Clazz.instanceOf (s1, java.awt.Rectangle)) ? s1 : s1.getBounds ();
\r
158 if (r0.y != r1.y) {
\r
159 var alloc = (Clazz.instanceOf (a, java.awt.Rectangle)) ? a : a.getBounds ();
\r
161 r0.width = alloc.width;
\r
164 }, "~N,javax.swing.text.Position.Bias,~N,javax.swing.text.Position.Bias,java.awt.Shape");
\r
165 Clazz.defineMethod (c$, "insertUpdate",
\r
166 function (e, a, f) {
\r
167 if (this.getViewCount () > 0) {
\r
168 var elem = this.getElement ();
\r
169 var ec = e.getChange (elem);
\r
171 if (!this.updateChildren (ec, e, f)) {
\r
173 }}this.forwardUpdate (ec, e, a, f);
\r
174 this.updateLayout (ec, e, a);
\r
175 }}, "javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory");
\r
176 Clazz.defineMethod (c$, "removeUpdate",
\r
177 function (e, a, f) {
\r
178 if (this.getViewCount () > 0) {
\r
179 var elem = this.getElement ();
\r
180 var ec = e.getChange (elem);
\r
182 if (!this.updateChildren (ec, e, f)) {
\r
184 }}this.forwardUpdate (ec, e, a, f);
\r
185 this.updateLayout (ec, e, a);
\r
186 }}, "javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory");
\r
187 Clazz.defineMethod (c$, "changedUpdate",
\r
188 function (e, a, f) {
\r
189 if (this.getViewCount () > 0) {
\r
190 var elem = this.getElement ();
\r
191 var ec = e.getChange (elem);
\r
193 if (!this.updateChildren (ec, e, f)) {
\r
195 }}this.forwardUpdate (ec, e, a, f);
\r
196 this.updateLayout (ec, e, a);
\r
197 }}, "javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory");
\r
198 Clazz.defineMethod (c$, "getDocument",
\r
200 return this.elem.getDocument ();
\r
202 Clazz.defineMethod (c$, "getStartOffset",
\r
204 return this.elem.getStartOffset ();
\r
206 Clazz.defineMethod (c$, "getEndOffset",
\r
208 return this.elem.getEndOffset ();
\r
210 Clazz.defineMethod (c$, "getElement",
\r
214 Clazz.defineMethod (c$, "getGraphics",
\r
216 var c = this.getContainer ();
\r
217 return c.getGraphics ();
\r
219 Clazz.defineMethod (c$, "getAttributes",
\r
221 return this.elem.getAttributes ();
\r
223 Clazz.defineMethod (c$, "breakView",
\r
224 function (axis, offset, pos, len) {
\r
227 Clazz.defineMethod (c$, "createFragment",
\r
228 function (p0, p1) {
\r
231 Clazz.defineMethod (c$, "getBreakWeight",
\r
232 function (axis, pos, len) {
\r
233 if (len > this.getPreferredSpan (axis)) {
\r
237 Clazz.defineMethod (c$, "getResizeWeight",
\r
241 Clazz.defineMethod (c$, "setSize",
\r
242 function (width, height) {
\r
244 Clazz.defineMethod (c$, "getContainer",
\r
246 var v = this.getParent ();
\r
247 return (v != null) ? v.getContainer () : null;
\r
249 Clazz.defineMethod (c$, "getViewFactory",
\r
251 var v = this.getParent ();
\r
252 return (v != null) ? v.getViewFactory () : null;
\r
254 Clazz.defineMethod (c$, "getToolTipText",
\r
255 function (x, y, allocation) {
\r
256 var viewIndex = this.getViewIndex (x, y, allocation);
\r
257 if (viewIndex >= 0) {
\r
258 allocation = this.getChildAllocation (viewIndex, allocation);
\r
259 var rect = (Clazz.instanceOf (allocation, java.awt.Rectangle)) ? allocation : allocation.getBounds ();
\r
260 if (rect.contains (x, y)) {
\r
261 return this.getView (viewIndex).getToolTipText (x, y, allocation);
\r
263 }, "~N,~N,java.awt.Shape");
\r
264 Clazz.defineMethod (c$, "getViewIndex",
\r
265 function (x, y, allocation) {
\r
266 for (var counter = this.getViewCount () - 1; counter >= 0; counter--) {
\r
267 var childAllocation = this.getChildAllocation (counter, allocation);
\r
268 if (childAllocation != null) {
\r
269 var rect = (Clazz.instanceOf (childAllocation, java.awt.Rectangle)) ? childAllocation : childAllocation.getBounds ();
\r
270 if (rect.contains (x, y)) {
\r
274 }, "~N,~N,java.awt.Shape");
\r
275 Clazz.defineMethod (c$, "updateChildren",
\r
276 function (ec, e, f) {
\r
277 var removedElems = ec.getChildrenRemoved ();
\r
278 var addedElems = ec.getChildrenAdded ();
\r
280 if (addedElems != null) {
\r
281 added = new Array (addedElems.length);
\r
282 for (var i = 0; i < addedElems.length; i++) {
\r
283 added[i] = f.create (addedElems[i]);
\r
286 var index = ec.getIndex ();
\r
287 if (removedElems != null) {
\r
288 nremoved = removedElems.length;
\r
289 }this.replace (index, nremoved, added);
\r
291 }, "javax.swing.event.DocumentEvent.ElementChange,javax.swing.event.DocumentEvent,javax.swing.text.ViewFactory");
\r
292 Clazz.defineMethod (c$, "forwardUpdate",
\r
293 function (ec, e, a, f) {
\r
294 var elem = this.getElement ();
\r
295 var pos = e.getOffset ();
\r
296 var index0 = this.getViewIndex (pos, javax.swing.text.Position.Bias.Forward);
\r
297 if (index0 == -1 && e.getType () === javax.swing.event.DocumentEvent.EventType.REMOVE && pos >= this.getEndOffset ()) {
\r
298 index0 = this.getViewCount () - 1;
\r
299 }var index1 = index0;
\r
300 var v = (index0 >= 0) ? this.getView (index0) : null;
\r
302 if ((v.getStartOffset () == pos) && (pos > 0)) {
\r
303 index0 = Math.max (index0 - 1, 0);
\r
304 }}if (e.getType () !== javax.swing.event.DocumentEvent.EventType.REMOVE) {
\r
305 index1 = this.getViewIndex (pos + e.getLength (), javax.swing.text.Position.Bias.Forward);
\r
307 index1 = this.getViewCount () - 1;
\r
308 }}var hole0 = index1 + 1;
\r
310 var addedElems = (ec != null) ? ec.getChildrenAdded () : null;
\r
311 if ((addedElems != null) && (addedElems.length > 0)) {
\r
312 hole0 = ec.getIndex ();
\r
313 hole1 = hole0 + addedElems.length - 1;
\r
314 }index0 = Math.max (index0, 0);
\r
315 for (var i = index0; i <= index1; i++) {
\r
316 if (!((i >= hole0) && (i <= hole1))) {
\r
317 v = this.getView (i);
\r
319 var childAlloc = this.getChildAllocation (i, a);
\r
320 this.forwardUpdateToView (v, e, childAlloc, f);
\r
322 }, "javax.swing.event.DocumentEvent.ElementChange,javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory");
\r
323 Clazz.defineMethod (c$, "forwardUpdateToView",
\r
324 function (v, e, a, f) {
\r
325 var type = e.getType ();
\r
326 if (type === javax.swing.event.DocumentEvent.EventType.INSERT) {
\r
327 v.insertUpdate (e, a, f);
\r
328 } else if (type === javax.swing.event.DocumentEvent.EventType.REMOVE) {
\r
329 v.removeUpdate (e, a, f);
\r
331 v.changedUpdate (e, a, f);
\r
332 }}, "javax.swing.text.View,javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory");
\r
333 Clazz.defineMethod (c$, "updateLayout",
\r
334 function (ec, e, a) {
\r
335 if ((ec != null) && (a != null)) {
\r
336 this.preferenceChanged (null, true, true);
\r
337 var host = this.getContainer ();
\r
338 if (host != null) {
\r
340 }}}, "javax.swing.event.DocumentEvent.ElementChange,javax.swing.event.DocumentEvent,java.awt.Shape");
\r
341 Clazz.defineMethod (c$, "modelToView",
\r
342 function (pos, a) {
\r
343 return this.modelToView (pos, a, javax.swing.text.Position.Bias.Forward);
\r
344 }, "~N,java.awt.Shape");
\r
345 Clazz.defineMethod (c$, "viewToModel",
\r
346 function (x, y, a) {
\r
347 javax.swing.text.View.sharedBiasReturn[0] = javax.swing.text.Position.Bias.Forward;
\r
348 return this.viewToModel (x, y, a, javax.swing.text.View.sharedBiasReturn);
\r
349 }, "~N,~N,java.awt.Shape");
\r
350 Clazz.defineStatics (c$,
\r
351 "BadBreakWeight", 0,
\r
352 "GoodBreakWeight", 1000,
\r
353 "ExcellentBreakWeight", 2000,
\r
354 "ForcedBreakWeight", 3000,
\r
357 c$.sharedBiasReturn = c$.prototype.sharedBiasReturn = new Array (1);
\r