1 Clazz.declarePackage ("javax.swing.text");
2 Clazz.load (["javax.swing.text.View"], "javax.swing.text.IconView", ["java.lang.IllegalArgumentException", "javax.swing.text.BadLocationException", "$.Position", "$.StyleConstants"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 Clazz.instantialize (this, arguments);
6 }, javax.swing.text, "IconView", javax.swing.text.View);
7 Clazz.makeConstructor (c$,
9 Clazz.superConstructor (this, javax.swing.text.IconView, [elem]);
10 var attr = elem.getAttributes ();
11 this.c = javax.swing.text.StyleConstants.getIcon (attr);
12 }, "javax.swing.text.Element");
13 Clazz.overrideMethod (c$, "paint",
15 var alloc = a.getBounds ();
16 this.c.paintIcon (this.getContainer (), g, alloc.x, alloc.y);
17 }, "java.awt.Graphics,java.awt.Shape");
18 Clazz.overrideMethod (c$, "getPreferredSpan",
22 return this.c.getIconWidth ();
24 return this.c.getIconHeight ();
26 throw new IllegalArgumentException ("Invalid axis: " + axis);
29 Clazz.defineMethod (c$, "getAlignment",
35 return Clazz.superCall (this, javax.swing.text.IconView, "getAlignment", [axis]);
38 Clazz.defineMethod (c$, "modelToView",
39 function (pos, a, b) {
40 var p0 = this.getStartOffset ();
41 var p1 = this.getEndOffset ();
42 if ((pos >= p0) && (pos <= p1)) {
43 var r = a.getBounds ();
48 }throw new javax.swing.text.BadLocationException (pos + " not in range " + p0 + "," + p1, pos);
49 }, "~N,java.awt.Shape,javax.swing.text.Position.Bias");
50 Clazz.defineMethod (c$, "viewToModel",
51 function (x, y, a, bias) {
53 if (x < alloc.x + (Clazz.doubleToInt (alloc.width / 2))) {
54 bias[0] = javax.swing.text.Position.Bias.Forward;
55 return this.getStartOffset ();
56 }bias[0] = javax.swing.text.Position.Bias.Backward;
57 return this.getEndOffset ();
58 }, "~N,~N,java.awt.Shape,~A");