GFXMapping.java
6.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.gfx;
public class GFXMapping {
private final IndexSet moChars;
private final IndexSet moGlyphs;
public GFXMapping() {
this.moChars = new IndexSet();
this.moGlyphs = new IndexSet();
}
public GFXMapping(GFXMapping oSource) {
this.moChars = new IndexSet(oSource.moChars);
this.moGlyphs = new IndexSet(oSource.moGlyphs);
}
public GFXMapping(int nCharIndex, int nGlyphIndex, int nCharLength, int nGlyphLength) {
this.moChars = new IndexSet(nCharIndex, nCharLength);
this.moGlyphs = new IndexSet(nGlyphIndex, nGlyphLength);
}
public GFXMapping(int nCharIndex, int nGlyphIndex, int nCharLength) {
this(nCharIndex, nGlyphIndex, nCharLength, 1);
}
public GFXMapping(int nCharIndex, int nGlyphIndex) {
this(nCharIndex, nGlyphIndex, 1, 1);
}
public void addCharIndex(int nCharIndex) {
this.moChars.add(nCharIndex);
}
public int getCharCount() {
return this.moChars.getCount();
}
public int getCharIndex(int nIndex) {
return this.moChars.get(nIndex);
}
public int getLowestCharIndex() {
return this.moChars.getLowest();
}
public int getHighestCharIndex() {
return this.moChars.getHighest();
}
public void addGlyphIndex(int nGlyphIndex) {
this.moGlyphs.add(nGlyphIndex);
}
public int getGlyphCount() {
return this.moGlyphs.getCount();
}
public int getGlyphIndex(int nIndex) {
return this.moGlyphs.get(nIndex);
}
public int getLowestGlyphIndex() {
return this.moGlyphs.getLowest();
}
public int getHighestGlyphIndex() {
return this.moGlyphs.getHighest();
}
public void copyFrom(GFXMapping oSource) {
if (this != oSource) {
this.moChars.copyFrom(oSource.moChars);
this.moGlyphs.copyFrom(oSource.moGlyphs);
}
}
int getCount(boolean bGlyph) {
return bGlyph ? this.getGlyphCount() : this.getCharCount();
}
int getIndex(boolean bGlyph, int nIndex) {
return bGlyph ? this.getGlyphIndex(nIndex) : this.getCharIndex(nIndex);
}
int getLowestIndex(boolean bGlyph) {
return bGlyph ? this.getLowestGlyphIndex() : this.getLowestCharIndex();
}
int getHighestIndex(boolean bGlyph) {
return bGlyph ? this.getHighestGlyphIndex() : this.getHighestCharIndex();
}
private static class IndexSet {
private int mnStart;
private int mnLength;
private int[] mpoIndexes;
IndexSet() {
}
IndexSet(IndexSet oSource) {
this.copyFrom(oSource);
}
IndexSet(int nIndex, int nLength) {
this.mnStart = nIndex;
this.mnLength = nLength;
}
void add(int nIndex) {
if (this.mpoIndexes == null) {
int nStart;
int nLimit;
if ((nLimit = (nStart = this.mnStart--) + this.mnLength) == nStart) {
this.mnStart = nIndex;
this.mnLength = 1;
} else if (nIndex + 1 != nStart) {
if (nIndex == nLimit) {
++this.mnLength;
} else if (nIndex < nStart || nIndex >= nLimit) {
this.forceArray();
}
}
}
if (this.mpoIndexes != null) {
int currentLength = this.mpoIndexes.length;
if (this.mnLength >= currentLength) {
int[] newIndexes = new int[currentLength * 2];
for (int i = 0; i < this.mnLength; ++i) {
newIndexes[i] = this.mpoIndexes[i];
}
this.mpoIndexes = newIndexes;
}
this.mpoIndexes[this.mnLength] = nIndex;
++this.mnLength;
}
}
int getCount() {
return this.mnLength;
}
int get(int nIndex) {
return this.mpoIndexes == null ? this.mnStart + nIndex : this.mpoIndexes[nIndex];
}
int getLowest() {
return this.mpoIndexes == null ? this.mnStart : this.searchLowest();
}
int getHighest() {
return this.mpoIndexes == null ? this.mnStart + this.mnLength - 1 : this.searchHighest();
}
void copyFrom(IndexSet oSource) {
if (this != oSource) {
this.mnLength = oSource.mnLength;
if (oSource.mpoIndexes == null) {
this.mpoIndexes = null;
this.mnStart = oSource.mnStart;
} else {
if (this.mpoIndexes == null || this.mpoIndexes.length < oSource.mnLength) {
this.mpoIndexes = new int[oSource.mpoIndexes.length];
}
for (int i = 0; i < oSource.mnLength; ++i) {
this.mpoIndexes[i] = oSource.mpoIndexes[i];
}
}
}
}
private int searchLowest() {
assert (this.mpoIndexes != null);
int nReturn = Integer.MAX_VALUE;
for (int i = 0; i < this.mnLength; ++i) {
int nIndex = this.mpoIndexes[i];
if (nIndex >= nReturn) continue;
nReturn = nIndex;
}
return nReturn;
}
private int searchHighest() {
assert (this.mpoIndexes != null);
int nReturn = 0;
for (int i = 0; i < this.mnLength; ++i) {
int nIndex = this.mpoIndexes[i];
if (nIndex <= nReturn) continue;
nReturn = nIndex;
}
return nReturn;
}
private void forceArray() {
int size;
assert (this.mpoIndexes == null);
for (size = 4; size < this.mnLength; size *= 2) {
}
this.mpoIndexes = new int[size];
for (int i = 0; i < this.mnLength; ++i) {
this.mpoIndexes[i] = this.mnStart + i;
}
}
}
}