Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / text / CharacterIteratorFieldDelegate.js
1 Clazz.declarePackage ("java.text");
2 Clazz.load (["java.text.Format"], "java.text.CharacterIteratorFieldDelegate", ["java.util.ArrayList", "java.text.AttributedString"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.attributedStrings = null;
5 this.size = 0;
6 Clazz.instantialize (this, arguments);
7 }, java.text, "CharacterIteratorFieldDelegate", null, java.text.Format.FieldDelegate);
8 Clazz.makeConstructor (c$, 
9 function () {
10 this.attributedStrings =  new java.util.ArrayList ();
11 });
12 Clazz.defineMethod (c$, "formatted", 
13 function (attr, value, start, end, buffer) {
14 if (start != end) {
15 if (start < this.size) {
16 var index = this.size;
17 var asIndex = this.attributedStrings.size () - 1;
18 while (start < index) {
19 var as = this.attributedStrings.get (asIndex--);
20 var newIndex = index - as.length ();
21 var aStart = Math.max (0, start - newIndex);
22 as.addAttribute (attr, value, aStart, Math.min (end - start, as.length () - aStart) + aStart);
23 index = newIndex;
24 }
25 }if (this.size < start) {
26 this.attributedStrings.add ( new java.text.AttributedString (buffer.substring (this.size, start)));
27 this.size = start;
28 }if (this.size < end) {
29 var aStart = Math.max (start, this.size);
30 var string =  new java.text.AttributedString (buffer.substring (aStart, end));
31 string.addAttribute (attr, value);
32 this.attributedStrings.add (string);
33 this.size = end;
34 }}}, "java.text.Format.Field,~O,~N,~N,StringBuffer");
35 Clazz.defineMethod (c$, "formatted", 
36 function (fieldID, attr, value, start, end, buffer) {
37 this.formatted (attr, value, start, end, buffer);
38 }, "~N,java.text.Format.Field,~O,~N,~N,StringBuffer");
39 Clazz.defineMethod (c$, "getIterator", 
40 function (string) {
41 if (string.length > this.size) {
42 this.attributedStrings.add ( new java.text.AttributedString (string.substring (this.size)));
43 this.size = string.length;
44 }var iCount = this.attributedStrings.size ();
45 var iterators =  new Array (iCount);
46 for (var counter = 0; counter < iCount; counter++) {
47 iterators[counter] = (this.attributedStrings.get (counter)).getIterator ();
48 }
49 return  new java.text.AttributedString (iterators).getIterator ();
50 }, "~S");
51 });