Cleaned up some code that is relevant to the bug I'm looking into. I need to
instrument it. Functionally, this change is a no-op. I just don't want to confuse refactoring with the actual bug fix.
This commit is contained in:
parent
00961b633f
commit
be632e1874
2 changed files with 37 additions and 49 deletions
|
@ -939,8 +939,8 @@ public class TibTextUtils implements THDLWylieConstants {
|
||||||
* @return the Extended Wylie/ACIP corresponding to these glyphs (with
|
* @return the Extended Wylie/ACIP corresponding to these glyphs (with
|
||||||
* font size info), or null */
|
* font size info), or null */
|
||||||
public static TranslitList getTranslit(boolean EWTSNotACIP,
|
public static TranslitList getTranslit(boolean EWTSNotACIP,
|
||||||
SizedDuffCode[] dcs,
|
SizedDuffCode[] dcs,
|
||||||
boolean noSuch[]) {
|
boolean noSuch[]) {
|
||||||
StringBuffer warnings = (debug ? new StringBuffer() : null);
|
StringBuffer warnings = (debug ? new StringBuffer() : null);
|
||||||
TranslitList ans
|
TranslitList ans
|
||||||
= getTranslitImplementation(EWTSNotACIP, dcs, noSuch, warnings);
|
= getTranslitImplementation(EWTSNotACIP, dcs, noSuch, warnings);
|
||||||
|
|
|
@ -344,10 +344,9 @@ public class TibetanDocument extends DefaultStyledDocument {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a portion of the document into Extended Wylie.
|
* Does not modify the document. Returns the EWTS transliteration for
|
||||||
* If the document consists of both Tibetan and
|
* the given portion of the document. Basically ignores non-TMW
|
||||||
* non-Tibetan fonts, however, the conversion stops
|
* characters.
|
||||||
* at the first non-Tibetan font.
|
|
||||||
* @param begin the beginning of the region to convert
|
* @param begin the beginning of the region to convert
|
||||||
* @param end the end of the region to convert
|
* @param end the end of the region to convert
|
||||||
* @param noSuchWylie an array which will not be touched if this is
|
* @param noSuchWylie an array which will not be touched if this is
|
||||||
|
@ -360,9 +359,9 @@ public class TibetanDocument extends DefaultStyledDocument {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a portion of the document into ACIP. If the document
|
* Does not modify the document. Returns the ACIP transliteration for
|
||||||
* consists of both Tibetan and non-Tibetan fonts, however, the
|
* the given portion of the document. Basically ignores non-TMW
|
||||||
* conversion stops at the first non-Tibetan font.
|
* characters.
|
||||||
* @param begin the beginning of the region to convert
|
* @param begin the beginning of the region to convert
|
||||||
* @param end the end of the region to convert
|
* @param end the end of the region to convert
|
||||||
* @param noSuchACIP an array which will not be touched if this is
|
* @param noSuchACIP an array which will not be touched if this is
|
||||||
|
@ -373,68 +372,56 @@ public class TibetanDocument extends DefaultStyledDocument {
|
||||||
return getTranslit(false, begin, end, noSuchACIP);
|
return getTranslit(false, begin, end, noSuchACIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTranslit(boolean EWTSNotACIP, int begin, int end, boolean noSuch[]) {
|
private String getTranslit(boolean EWTSNotACIP, int begin, int end,
|
||||||
AttributeSet attr;
|
boolean noSuch[]) {
|
||||||
String fontName;
|
|
||||||
int fontNum;
|
|
||||||
char ch;
|
|
||||||
|
|
||||||
if (begin >= end)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
java.util.List dcs = new ArrayList();
|
|
||||||
int i = begin;
|
|
||||||
TranslitList translitBuffer = new TranslitList();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while (i < end) {
|
TranslitList translitBuffer = new TranslitList();
|
||||||
attr = getCharacterElement(i).getAttributes();
|
java.util.List dcs = new ArrayList();
|
||||||
fontName = StyleConstants.getFontFamily(attr);
|
for (int i = begin; i < end; i++) {
|
||||||
int fsz
|
char ch = getText(i,1).charAt(0);
|
||||||
= ((Integer)attr.getAttribute(StyleConstants.FontSize)).intValue();
|
int fontNum;
|
||||||
|
|
||||||
ch = getText(i,1).charAt(0);
|
|
||||||
|
|
||||||
//current character is formatting
|
//current character is formatting
|
||||||
if (ch == '\n' || ch == '\t') {
|
if (ch == '\n' || ch == '\t') {
|
||||||
if (dcs.size() > 0) {
|
if (dcs.size() > 0) {
|
||||||
SizedDuffCode[] dc_array
|
translitBuffer.append(TibTextUtils.getTranslit(EWTSNotACIP,
|
||||||
= (SizedDuffCode[])dcs.toArray(new SizedDuffCode[0]);
|
(SizedDuffCode[])dcs.toArray(new SizedDuffCode[0]),
|
||||||
translitBuffer.append(TibTextUtils.getTranslit(EWTSNotACIP, dc_array, noSuch));
|
noSuch));
|
||||||
dcs.clear();
|
dcs.clear();
|
||||||
}
|
}
|
||||||
translitBuffer.append(ch, fsz);
|
translitBuffer.append(ch, 12);
|
||||||
}
|
}
|
||||||
//current character isn't TMW
|
//current character isn't TMW
|
||||||
else if ((0 == (fontNum = TibetanMachineWeb.getTMWFontNumber(fontName)))) {
|
else if ((0 == (fontNum
|
||||||
|
= TibetanMachineWeb.getTMWFontNumber(StyleConstants.getFontFamily(getCharacterElement(i).getAttributes()))))) {
|
||||||
if (dcs.size() > 0) {
|
if (dcs.size() > 0) {
|
||||||
SizedDuffCode[] dc_array
|
translitBuffer.append(TibTextUtils.getTranslit(EWTSNotACIP,
|
||||||
= (SizedDuffCode[])dcs.toArray(new SizedDuffCode[0]);
|
(SizedDuffCode[])dcs.toArray(new SizedDuffCode[0]),
|
||||||
translitBuffer.append(TibTextUtils.getTranslit(EWTSNotACIP, dc_array, noSuch));
|
noSuch));
|
||||||
dcs.clear();
|
dcs.clear();
|
||||||
}
|
}
|
||||||
|
// The current character is sort of nonexistent --
|
||||||
|
// it doesn't go into translitBuffer.
|
||||||
}
|
}
|
||||||
//current character is convertable
|
//current character is convertable
|
||||||
else {
|
else {
|
||||||
dcs.add(new SizedDuffCode(new DuffCode(fontNum, ch), fsz));
|
dcs.add(new SizedDuffCode(new DuffCode(fontNum, ch), 12));
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
if (dcs.size() > 0) {
|
if (dcs.size() > 0) {
|
||||||
SizedDuffCode[] dc_array
|
|
||||||
= (SizedDuffCode[])dcs.toArray(new SizedDuffCode[0]);
|
|
||||||
translitBuffer.append(TibTextUtils.getTranslit(EWTSNotACIP,
|
translitBuffer.append(TibTextUtils.getTranslit(EWTSNotACIP,
|
||||||
dc_array,
|
(SizedDuffCode[])dcs.toArray(new SizedDuffCode[0]),
|
||||||
noSuch));
|
noSuch));
|
||||||
|
// we'd clear dcs but we're done.
|
||||||
}
|
}
|
||||||
return translitBuffer.getString();
|
String ans = translitBuffer.getString();
|
||||||
}
|
ThdlDebug.verify(begin < end // SPEED_FIXME: make this an assertion
|
||||||
catch (BadLocationException ble) {
|
|| "".equals(ans));
|
||||||
|
return ans;
|
||||||
|
} catch (BadLocationException ble) {
|
||||||
ble.printStackTrace();
|
ble.printStackTrace();
|
||||||
ThdlDebug.noteIffyCode();
|
ThdlDebug.noteIffyCode();
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Prints to standard output a list of all the indices of
|
/** Prints to standard output a list of all the indices of
|
||||||
|
@ -1186,7 +1173,8 @@ public class TibetanDocument extends DefaultStyledDocument {
|
||||||
return toTranslit(true, start, end, numAttemptedReplacements);
|
return toTranslit(true, start, end, numAttemptedReplacements);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DLC DOC just like {@link #toWylie(int,int,long[])}
|
// DLC DOC just like {@link #toWylie(int,int,long[])} but uses
|
||||||
|
// ACIP instead of EWTS
|
||||||
public boolean toACIP(int start, int end,
|
public boolean toACIP(int start, int end,
|
||||||
long numAttemptedReplacements[]) {
|
long numAttemptedReplacements[]) {
|
||||||
return toTranslit(false, start, end, numAttemptedReplacements);
|
return toTranslit(false, start, end, numAttemptedReplacements);
|
||||||
|
|
Loading…
Reference in a new issue