1 Clazz.declarePackage ("javax.swing.text");
\r
2 Clazz.load (["javax.swing.text.View"], "javax.swing.text.CompositeView", ["java.lang.IllegalArgumentException", "java.awt.Rectangle", "javax.swing.text.BadLocationException", "$.Position", "$.StyleConstants", "$.Utilities"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
4 this.children = null;
\r
10 this.childAlloc = null;
\r
11 Clazz.instantialize (this, arguments);
\r
12 }, javax.swing.text, "CompositeView", javax.swing.text.View);
\r
13 Clazz.makeConstructor (c$,
\r
15 Clazz.superConstructor (this, javax.swing.text.CompositeView, [elem]);
\r
16 this.children = new Array (1);
\r
18 this.childAlloc = new java.awt.Rectangle ();
\r
19 }, "javax.swing.text.Element");
\r
20 Clazz.defineMethod (c$, "loadChildren",
\r
24 }var e = this.getElement ();
\r
25 var n = e.getElementCount ();
\r
27 var added = new Array (n);
\r
28 for (var i = 0; i < n; i++) {
\r
29 added[i] = f.create (e.getElement (i));
\r
31 this.replace (0, 0, added);
\r
32 }}, "javax.swing.text.ViewFactory");
\r
33 Clazz.defineMethod (c$, "setParent",
\r
35 Clazz.superCall (this, javax.swing.text.CompositeView, "setParent", [parent]);
\r
36 if ((parent != null) && (this.nchildren == 0)) {
\r
37 var f = this.getViewFactory ();
\r
38 this.loadChildren (f);
\r
39 }}, "javax.swing.text.View");
\r
40 Clazz.overrideMethod (c$, "getViewCount",
\r
42 return this.nchildren;
\r
44 Clazz.overrideMethod (c$, "getView",
\r
46 return this.children[n];
\r
48 Clazz.overrideMethod (c$, "replace",
\r
49 function (offset, length, views) {
\r
50 if (views == null) {
\r
51 views = javax.swing.text.CompositeView.ZERO;
\r
52 }for (var i = offset; i < offset + length; i++) {
\r
53 if (this.children[i].getParent () === this) {
\r
54 this.children[i].setParent (null);
\r
55 }this.children[i] = null;
\r
57 var delta = views.length - length;
\r
58 var src = offset + length;
\r
59 var nmove = this.nchildren - src;
\r
60 var dest = src + delta;
\r
61 if ((this.nchildren + delta) >= this.children.length) {
\r
62 var newLength = Math.max (2 * this.children.length, this.nchildren + delta);
\r
63 var newChildren = new Array (newLength);
\r
64 System.arraycopy (this.children, 0, newChildren, 0, offset);
\r
65 System.arraycopy (views, 0, newChildren, offset, views.length);
\r
66 System.arraycopy (this.children, src, newChildren, dest, nmove);
\r
67 this.children = newChildren;
\r
69 System.arraycopy (this.children, src, this.children, dest, nmove);
\r
70 System.arraycopy (views, 0, this.children, offset, views.length);
\r
71 }this.nchildren = this.nchildren + delta;
\r
72 for (var i = 0; i < views.length; i++) {
\r
73 views[i].setParent (this);
\r
76 Clazz.overrideMethod (c$, "getChildAllocation",
\r
77 function (index, a) {
\r
78 var alloc = this.getInsideAllocation (a);
\r
79 this.childAllocation (index, alloc);
\r
81 }, "~N,java.awt.Shape");
\r
82 Clazz.defineMethod (c$, "modelToView",
\r
83 function (pos, a, b) {
\r
84 var isBackward = (b === javax.swing.text.Position.Bias.Backward);
\r
85 var testPos = (isBackward) ? Math.max (0, pos - 1) : pos;
\r
86 if (isBackward && testPos < this.getStartOffset ()) {
\r
88 }var vIndex = this.getViewIndexAtPosition (testPos);
\r
89 if ((vIndex != -1) && (vIndex < this.getViewCount ())) {
\r
90 var v = this.getView (vIndex);
\r
91 if (v != null && testPos >= v.getStartOffset () && testPos < v.getEndOffset ()) {
\r
92 var childShape = this.getChildAllocation (vIndex, a);
\r
93 if (childShape == null) {
\r
95 }var retShape = v.modelToView (pos, childShape, b);
\r
96 if (retShape == null && v.getEndOffset () == pos) {
\r
97 if (++vIndex < this.getViewCount ()) {
\r
98 v = this.getView (vIndex);
\r
99 retShape = v.modelToView (pos, this.getChildAllocation (vIndex, a), b);
\r
101 }}throw new javax.swing.text.BadLocationException ("Position not represented by view", pos);
\r
102 }, "~N,java.awt.Shape,javax.swing.text.Position.Bias");
\r
103 Clazz.defineMethod (c$, "modelToView",
\r
104 function (p0, b0, p1, b1, a) {
\r
105 if (p0 == this.getStartOffset () && p1 == this.getEndOffset ()) {
\r
107 }var alloc = this.getInsideAllocation (a);
\r
108 var r0 = new java.awt.Rectangle (alloc);
\r
109 var v0 = this.getViewAtPosition ((b0 === javax.swing.text.Position.Bias.Backward) ? Math.max (0, p0 - 1) : p0, r0);
\r
110 var r1 = new java.awt.Rectangle (alloc);
\r
111 var v1 = this.getViewAtPosition ((b1 === javax.swing.text.Position.Bias.Backward) ? Math.max (0, p1 - 1) : p1, r1);
\r
115 }return v0.modelToView (p0, b0, p1, b1, r0);
\r
116 }var viewCount = this.getViewCount ();
\r
118 while (counter < viewCount) {
\r
120 if ((v = this.getView (counter)) === v0 || v === v1) {
\r
123 var tempRect = new java.awt.Rectangle ();
\r
125 retRect = v0.modelToView (p0, b0, v0.getEndOffset (), javax.swing.text.Position.Bias.Backward, r0).getBounds ();
\r
128 retRect = v1.modelToView (v1.getStartOffset (), javax.swing.text.Position.Bias.Forward, p1, b1, r1).getBounds ();
\r
130 }while (++counter < viewCount && (v = this.getView (counter)) !== endView) {
\r
131 tempRect.setBounds (alloc);
\r
132 this.childAllocation (counter, tempRect);
\r
133 retRect.add (tempRect);
\r
135 if (endView != null) {
\r
137 if (endView === v1) {
\r
138 endShape = v1.modelToView (v1.getStartOffset (), javax.swing.text.Position.Bias.Forward, p1, b1, r1);
\r
140 endShape = v0.modelToView (p0, b0, v0.getEndOffset (), javax.swing.text.Position.Bias.Backward, r0);
\r
141 }if (Clazz.instanceOf (endShape, java.awt.Rectangle)) {
\r
142 retRect.add (endShape);
\r
144 retRect.add (endShape.getBounds ());
\r
148 throw new javax.swing.text.BadLocationException ("Position not represented by view", p0);
\r
149 }, "~N,javax.swing.text.Position.Bias,~N,javax.swing.text.Position.Bias,java.awt.Shape");
\r
150 Clazz.defineMethod (c$, "viewToModel",
\r
151 function (x, y, a, bias) {
\r
152 var alloc = this.getInsideAllocation (a);
\r
153 if (this.isBefore (Clazz.floatToInt (x), Clazz.floatToInt (y), alloc)) {
\r
156 retValue = this.getNextVisualPositionFrom (-1, javax.swing.text.Position.Bias.Forward, a, 3, bias);
\r
158 if (Clazz.exceptionOf (e$$, javax.swing.text.BadLocationException)) {
\r
162 } else if (Clazz.exceptionOf (e$$, IllegalArgumentException)) {
\r
170 if (retValue == -1) {
\r
171 retValue = this.getStartOffset ();
\r
172 bias[0] = javax.swing.text.Position.Bias.Forward;
\r
174 } else if (this.isAfter (Clazz.floatToInt (x), Clazz.floatToInt (y), alloc)) {
\r
177 retValue = this.getNextVisualPositionFrom (-1, javax.swing.text.Position.Bias.Forward, a, 7, bias);
\r
179 if (Clazz.exceptionOf (e$$, javax.swing.text.BadLocationException)) {
\r
183 } else if (Clazz.exceptionOf (e$$, IllegalArgumentException)) {
\r
191 if (retValue == -1) {
\r
192 retValue = this.getEndOffset () - 1;
\r
193 bias[0] = javax.swing.text.Position.Bias.Forward;
\r
196 var v = this.getViewAtPoint (Clazz.floatToInt (x), Clazz.floatToInt (y), alloc);
\r
198 return v.viewToModel (x, y, alloc, bias);
\r
200 }, "~N,~N,java.awt.Shape,~A");
\r
201 Clazz.overrideMethod (c$, "getNextVisualPositionFrom",
\r
202 function (pos, b, a, direction, biasRet) {
\r
203 switch (direction) {
\r
205 return this.getNextNorthSouthVisualPositionFrom (pos, b, a, direction, biasRet);
\r
207 return this.getNextNorthSouthVisualPositionFrom (pos, b, a, direction, biasRet);
\r
209 return this.getNextEastWestVisualPositionFrom (pos, b, a, direction, biasRet);
\r
211 return this.getNextEastWestVisualPositionFrom (pos, b, a, direction, biasRet);
\r
213 throw new IllegalArgumentException ("Bad direction: " + direction);
\r
215 }, "~N,javax.swing.text.Position.Bias,java.awt.Shape,~N,~A");
\r
216 Clazz.defineMethod (c$, "getViewIndex",
\r
217 function (pos, b) {
\r
218 if (b === javax.swing.text.Position.Bias.Backward) {
\r
220 }if ((pos >= this.getStartOffset ()) && (pos < this.getEndOffset ())) {
\r
221 return this.getViewIndexAtPosition (pos);
\r
223 }, "~N,javax.swing.text.Position.Bias");
\r
224 Clazz.defineMethod (c$, "getViewAtPosition",
\r
225 function (pos, a) {
\r
226 var index = this.getViewIndexAtPosition (pos);
\r
227 if ((index >= 0) && (index < this.getViewCount ())) {
\r
228 var v = this.getView (index);
\r
230 this.childAllocation (index, a);
\r
233 }, "~N,java.awt.Rectangle");
\r
234 Clazz.defineMethod (c$, "getViewIndexAtPosition",
\r
236 var elem = this.getElement ();
\r
237 return elem.getElementIndex (pos);
\r
239 Clazz.defineMethod (c$, "getInsideAllocation",
\r
243 if (Clazz.instanceOf (a, java.awt.Rectangle)) {
\r
246 alloc = a.getBounds ();
\r
247 }this.childAlloc.setBounds (alloc);
\r
248 this.childAlloc.x += this.getLeftInset ();
\r
249 this.childAlloc.y += this.getTopInset ();
\r
250 this.childAlloc.width -= this.getLeftInset () + this.getRightInset ();
\r
251 this.childAlloc.height -= this.getTopInset () + this.getBottomInset ();
\r
252 return this.childAlloc;
\r
254 }, "java.awt.Shape");
\r
255 Clazz.defineMethod (c$, "setParagraphInsets",
\r
257 this.top = Clazz.floatToShort (javax.swing.text.StyleConstants.getSpaceAbove (attr));
\r
258 this.left = Clazz.floatToShort (javax.swing.text.StyleConstants.getLeftIndent (attr));
\r
259 this.bottom = Clazz.floatToShort (javax.swing.text.StyleConstants.getSpaceBelow (attr));
\r
260 this.right = Clazz.floatToShort (javax.swing.text.StyleConstants.getRightIndent (attr));
\r
261 }, "javax.swing.text.AttributeSet");
\r
262 Clazz.defineMethod (c$, "setInsets",
\r
263 function (top, left, bottom, right) {
\r
266 this.right = right;
\r
267 this.bottom = bottom;
\r
269 Clazz.defineMethod (c$, "getLeftInset",
\r
273 Clazz.defineMethod (c$, "getRightInset",
\r
277 Clazz.defineMethod (c$, "getTopInset",
\r
281 Clazz.defineMethod (c$, "getBottomInset",
\r
283 return this.bottom;
\r
285 Clazz.defineMethod (c$, "getNextNorthSouthVisualPositionFrom",
\r
286 function (pos, b, a, direction, biasRet) {
\r
287 return javax.swing.text.Utilities.getNextVisualPositionFrom (this, pos, b, a, direction, biasRet);
\r
288 }, "~N,javax.swing.text.Position.Bias,java.awt.Shape,~N,~A");
\r
289 Clazz.defineMethod (c$, "getNextEastWestVisualPositionFrom",
\r
290 function (pos, b, a, direction, biasRet) {
\r
291 return javax.swing.text.Utilities.getNextVisualPositionFrom (this, pos, b, a, direction, biasRet);
\r
292 }, "~N,javax.swing.text.Position.Bias,java.awt.Shape,~N,~A");
\r
293 Clazz.defineMethod (c$, "flipEastAndWestAtEnds",
\r
294 function (position, bias) {
\r
296 }, "~N,javax.swing.text.Position.Bias");
\r
297 c$.ZERO = c$.prototype.ZERO = new Array (0);
\r