Thread: [FOray-commit] SF.net SVN: foray: [10343] trunk/foray (Page 23)
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2008-02-23 20:08:03
|
Revision: 10343
http://foray.svn.sourceforge.net/foray/?rev=10343&view=rev
Author: victormote
Date: 2008-02-23 12:07:41 -0800 (Sat, 23 Feb 2008)
Log Message:
-----------
Adjust new test, and plug it in to the testing framework.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java
trunk/foray/foray-app/src/javatest/org/foray/app/area/TestVertical.java
trunk/foray/resource/test/fo/vertical-001.fo
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java 2008-02-23 20:06:10 UTC (rev 10342)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java 2008-02-23 20:07:41 UTC (rev 10343)
@@ -32,6 +32,7 @@
import org.foray.app.area.TestBorder;
import org.foray.app.area.TestGraphicArea;
import org.foray.app.area.TestMetadata;
+import org.foray.app.area.TestVertical;
import org.foray.app.fo.TestFont;
import org.foray.app.fo.TestGraphic;
import org.foray.app.fo.TestInvalidXml;
@@ -62,6 +63,7 @@
testSuite.addTestSuite(TestBlock.class);
testSuite.addTestSuite(TestMetadata.class);
testSuite.addTestSuite(TestGraphicArea.class);
+ testSuite.addTestSuite(TestVertical.class);
return testSuite;
}
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/area/TestVertical.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/TestVertical.java 2008-02-23 20:06:10 UTC (rev 10342)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/TestVertical.java 2008-02-23 20:07:41 UTC (rev 10343)
@@ -34,8 +34,11 @@
import org.foray.area.LineArea;
import org.foray.area.NormalBlockArea;
import org.foray.area.NormalFlowRA;
+import org.foray.area.TextArea;
import org.foray.core.FOrayException;
+import org.axsl.font.FontUse;
+
/**
* Tests of various vertical positioning concepts at the Area Tree level.
*/
@@ -55,6 +58,9 @@
AreaNode node = firstNormalFlowArea.getChildAt(0);
assertTrue(node instanceof NormalBlockArea);
final NormalBlockArea blockArea = (NormalBlockArea) node;
+ final FontUse font = blockArea.getPrimaryFont();
+ assertEquals("Courier", font.getFont().getPostscriptName());
+ assertEquals(12000, blockArea.traitFontSize());
/* The first child of the block area is a line-area. */
node = blockArea.getChildAt(0);
@@ -68,8 +74,18 @@
final InlineArea inlineArea = (InlineArea) node;
final int inlineY = inlineArea.baselineY();
- final int expectedInlineY = lineY - 20;
+ /* The current algorithm for computing the "super" baseline shift for the Base14-Courier
+ * font is 2/3 of the font's ascender, which, per the AFM file is 629. */
+ final int adjustment = Math.round(629 * 12 * 2 / 3);
+ final int expectedInlineY = lineY + adjustment;
assertEquals(expectedInlineY, inlineY);
+
+ /* The first child of the inline-area is a text area. */
+ node = inlineArea.getChildAt(0);
+ assertTrue(node instanceof TextArea);
+ final TextArea textArea = (TextArea) node;
+ final int inlineYTextArea = textArea.baselineY();
+ assertEquals(expectedInlineY, inlineYTextArea);
}
}
Modified: trunk/foray/resource/test/fo/vertical-001.fo
===================================================================
--- trunk/foray/resource/test/fo/vertical-001.fo 2008-02-23 20:06:10 UTC (rev 10342)
+++ trunk/foray/resource/test/fo/vertical-001.fo 2008-02-23 20:07:41 UTC (rev 10343)
@@ -22,7 +22,7 @@
<fo:flow flow-name="xsl-region-body">
-<fo:block font-family="Courier" font-size="12pt">At the end of this sentence is a footnote
+<fo:block font-family="Base14-Courier" font-size="12pt">At the end of this sentence is a footnote
citation.<fo:inline font-size="60%" vertical-align="super">7</fo:inline></fo:block>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-02-28 16:56:35
|
Revision: 10372
http://foray.svn.sourceforge.net/foray/?rev=10372&view=rev
Author: victormote
Date: 2008-02-28 08:56:32 -0800 (Thu, 28 Feb 2008)
Log Message:
-----------
1. Clean up more checkstyle issues.
2. Start breaking out checkstyle suppressions that are semi-permanent.
Modified Paths:
--------------
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/PatternGenerator.java
trunk/foray/scripts/checkstyle-suppressions.xml
Modified: trunk/foray/foray-hyphen/src/java/org/foray/hyphen/PatternGenerator.java
===================================================================
--- trunk/foray/foray-hyphen/src/java/org/foray/hyphen/PatternGenerator.java 2008-02-28 16:39:06 UTC (rev 10371)
+++ trunk/foray/foray-hyphen/src/java/org/foray/hyphen/PatternGenerator.java 2008-02-28 16:56:32 UTC (rev 10372)
@@ -488,7 +488,7 @@
for (int j = 0; j <= PatternGenerator.LAST_ASCII_CODE; j++) {
xext[j] = ' ';
}
- xext[PatternGenerator.EDGE_OF_WORD]= '.';
+ xext[PatternGenerator.EDGE_OF_WORD] = '.';
/* Initialize the xdig array. */
for (char j = 0; j < xdig.length; j++) {
@@ -498,9 +498,9 @@
}
/* Initialize the xhyf array. */
- xhyf[PatternGenerator.ERR_HYF]= '.';
- xhyf[PatternGenerator.IS_HYF]= '-';
- xhyf[PatternGenerator.FOUND_HYF]= '*';
+ xhyf[PatternGenerator.ERR_HYF] = '.';
+ xhyf[PatternGenerator.IS_HYF] = '-';
+ xhyf[PatternGenerator.FOUND_HYF] = '*';
}
/**
@@ -663,7 +663,7 @@
if (s > TRIE_SIZE - NUM_ASCII_CODES) {
overflow("pattern trie nodes", TRIE_SIZE);
}
- while (triebmax<s) {
+ while (triebmax < s) {
triebmax ++;
trietaken[triebmax] = false;
triec[triebmax + LAST_ASCII_CODE] = MIN_PACKED;
@@ -683,7 +683,7 @@
*/
void unpack(int s) {
this.qmax = 1;
- for(char c = this.cmin; c <= cmax; c++) {
+ for (char c = this.cmin; c <= cmax; c++) {
/* Search for transitions belonging to this state. */
int t = s + c;
if (so(triec[t]) == c) {
@@ -710,7 +710,7 @@
opcount = opcount + 1;
if (opcount == MAX_OPS) {
System.err.printf("%s%ld%s%s\n", "PATGEN capacity exceeded, sorry [",
- (long)MAX_OPS, " outputs" , "]." );
+ (long) MAX_OPS, " outputs" , "]." );
System.exit(1);
}
ops[h].val = v;
@@ -768,7 +768,7 @@
qmax = 1;
while (i < patlen) {
i = i + 1;
- trieqc[1]= pat[i];
+ trieqc[1] = pat[i];
t = firstfit();
triel[s] = t;
s = t + pat[i];
@@ -816,10 +816,10 @@
if (b > trieckmax - 256) {
if (trieckmax == TRIEC_SIZE) {
System.err.printf("%s%ld%s%s\n", "PATGEN capacity exceeded, sorry [" ,
- (long)TRIEC_SIZE, " count trie nodes" , "]." );
+ (long) TRIEC_SIZE, " count trie nodes" , "]." );
System.exit(1);
}
- System.out.printf("%ld%s", (long)trieckmax / 1024 , "K ");
+ System.out.printf("%ld%s", (long) trieckmax / 1024 , "K ");
if (trieckmax > TRIEC_SIZE - 4096) {
trieckmax = TRIEC_SIZE;
} else {
@@ -828,8 +828,8 @@
}
while (triecbmax < b) {
triecbmax = triecbmax + 1;
- triectaken[triecbmax]= false;
- triecc[triecbmax + 255]= 0;
+ triectaken[triecbmax] = false;
+ triecc[triecbmax + 255] = 0;
triecl[triecbmax + 255] = triecbmax + 256;
triecr[triecbmax + 256] = triecbmax + 255;
}
@@ -854,15 +854,15 @@
if (q <= for_end) {
do {
a = b + trieqc[q];
- triecl[triecr[a]]= triecl[a];
- triecr[triecl[a]]= triecr[a];
- triecc[a]= trieqc[q];
- triecl[a]= trieql[q];
- triecr[a]= trieqr[q];
+ triecl[triecr[a]] = triecl[a];
+ triecr[triecl[a]] = triecr[a];
+ triecc[a] = trieqc[q];
+ triecl[a] = trieql[q];
+ triecr[a] = trieqr[q];
if (a > triecmax) {
triecmax = a;
}
- } while ( q++ < for_end);
+ } while (q++ < for_end);
}
triectaken[b] = true;
return b;
@@ -911,16 +911,16 @@
if (triecc[a] == 0 ) {
triecl[triecr[a]] = triecl[a];
triecr[triecl[a]] = triecr[a];
- triecc[a]= word[spos];
- triecl[a]= 0;
- triecr[a]= 0;
+ triecc[a] = word[spos];
+ triecl[a] = 0;
+ triecr[a] = 0;
if (a > triecmax)
triecmax = a;
} else {
unpackc(a - word[spos]);
- trieqc[qmax]= word[spos];
- trieql[qmax]= 0;
- trieqr[qmax]= 0;
+ trieqc[qmax] = word[spos];
+ trieql[qmax] = 0;
+ trieqr[qmax] = 0;
a = firstcfit();
triecl[b] = a;
a = a + word [spos];
@@ -1101,7 +1101,7 @@
} else {
n1 = 0;
output.printf("%s%ld%s\n", "Specify 1<=left_hyphen_min,right_hyphen_min<=",
- (long)MAX_DOT - 1, " !");
+ (long) MAX_DOT - 1, " !");
}
} while (! (n1 > 0));
}
@@ -1176,7 +1176,7 @@
} while (! ( bufptr == MAX_BUF_LEN));
output.printf("%c\n", ' ');
System.err.printf("%s%ld%s%s\n",
- "PATGEN capacity exceeded, sorry [" , (long)256,
+ "PATGEN capacity exceeded, sorry [" , (long) 256,
" letters" , "].");
System.exit(1);
}
@@ -1271,8 +1271,8 @@
}
}
translate.close();
- output.printf("%s%ld%s%ld%s%ld%s\n", "left_hyphen_min = ", (long)lefthyphenmin,
- ", right_hyphen_min = ", (long)righthyphenmin , ", " , (long)imax - 1 , " letters");
+ output.printf("%s%ld%s%ld%s%ld%s\n", "left_hyphen_min = ", (long) lefthyphenmin,
+ ", right_hyphen_min = ", (long) righthyphenmin, ", ", (long) imax - 1, " letters");
cmax = imax;
}
@@ -1304,13 +1304,13 @@
if ( triecmax == TRIEC_SIZE ) {
System.err.printf("%s%ld%s%s\n",
"PATGEN capacity exceeded, sorry [",
- (long)TRIEC_SIZE, " count trie nodes" , "].");
+ (long) TRIEC_SIZE, " count trie nodes" , "].");
System.exit(1);
}
triecmax = triecmax + 1;
triecl[l] = triecmax;
l = triecmax;
- triecc[l]= pat[j];
+ triecc[l] = pat[j];
} while (j++ < for_end2);
}
triecl[l] = 0;
@@ -1356,7 +1356,7 @@
badcount = 0;
moretocome = false;
traversecounttrie(1, 1);
- output.printf("%ld%s%ld%s", (long)goodpatcount, " good and ", (long)badpatcount,
+ output.printf("%ld%s%ld%s", (long) goodpatcount, " good and ", (long) badpatcount,
" bad patterns added");
levelpatterncount = levelpatterncount + goodpatcount;
if (moretocome) {
@@ -1364,7 +1364,7 @@
} else {
output.printf("%c\n", ' ');
}
- output.printf("%s%ld%s%ld%s", "finding ", (long)goodcount, " good and ", (long)badcount,
+ output.printf("%s%ld%s%ld%s", "finding ", (long) goodcount, " good and ", (long) badcount,
" bad hyphens");
if (goodpatcount > 0) {
output.print(", efficiency = "
@@ -1373,8 +1373,8 @@
} else {
output.printf("%c\n", ' ');
}
- output.printf("%s%ld%s%s%ld%s%ld%s\n", "pattern trie has ", (long)triecount, " nodes, ",
- "trie_max = ", (long)triemax, ", ", (long)opcount, " outputs");
+ output.printf("%s%ld%s%s%ld%s%ld%s\n", "pattern trie has ", (long) triecount, " nodes, ",
+ "trie_max = ", (long) triemax, ", ", (long) opcount, " outputs");
}
int deletepatterns(int s) {
@@ -1446,8 +1446,8 @@
}
} while (h++ < for_end);
}
- output.printf("%ld%s%ld%s\n", (long)oldtriecount - triecount, " nodes and " ,
- (long)oldopcount - opcount, " outputs deleted");
+ output.printf("%ld%s%ld%s\n", (long) oldtriecount - triecount, " nodes and " ,
+ (long) oldopcount - opcount, " outputs deleted");
qmaxthresh = 7;
}
@@ -1497,15 +1497,16 @@
l = triecl [l ];
}
patout.write(xext[pat[d]]);
- if ( hval [d ]> 0 )
+ if (hval[d] > 0)
patout.write(xdig[hval[d]]);
}
while (d++ < for_end3);
}
patout.write('\n');
}
- if ( triel [t ]> 0 )
+ if (triel[t] > 0 ) {
outputpatterns(triel[t], patlen + 1);
+ }
}
} while (c++ < for_end);
}
@@ -1534,7 +1535,7 @@
readln(dictionary);
while (bufptr < MAX_BUF_LEN) {
bufptr = bufptr + 1;
- buf [bufptr ]= ' ';
+ buf[bufptr] = ' ';
}
}
word[1] = 1;
@@ -1569,7 +1570,7 @@
} while (! (bufptr == MAX_BUF_LEN));
output.printf("%c\n", ' ');
System.err.printf("%s%s%ld%s\n", "PATGEN capacity exceeded, sorry [",
- "word length=", (long)MAX_LEN, "].");
+ "word length=", (long) MAX_LEN, "].");
System.exit(1);
}
word[wlen] = xint[c];
@@ -1587,7 +1588,7 @@
} while (! (bufptr == MAX_BUF_LEN));
output.printf("%c\n", ' ');
System.err.printf("%s%s%ld%s\n", "PATGEN capacity exceeded, sorry [",
- "word length=", (long)MAX_LEN, "]." );
+ "word length=", (long) MAX_LEN, "]." );
System.exit(1);
}
t = 1;
@@ -1786,7 +1787,7 @@
/* TODO: Next line is not quite right. The original C code depended on "fname". Does this
* open a different dictionary file? */
dictionary.reset();
- xclass['.']= 5;
+ xclass['.'] = 5;
xclass[xhyf[1]] = 2;
xint[xhyf[1]] = 0;
xclass[xhyf[2]] = 2;
@@ -1816,8 +1817,8 @@
}
if (procesp) {
initcounttrie();
- output.printf("%s%ld%s%ld\n", "processing dictionary with pat_len = ", (long)patlen,
- ", pat_dot = ", (long)patdot);
+ output.printf("%s%ld%s%ld\n", "processing dictionary with pat_len = ", (long) patlen,
+ ", pat_dot = ", (long) patdot);
}
if (hyphp) {
filnam = "pattmp. ".toCharArray();
@@ -1844,19 +1845,22 @@
}
dictionary.close();
output.printf("%c\n", ' ');
- output.printf("%ld%s%ld%s%ld%s\n", (long)goodcount, " good, ", (long)badcount, " bad, ",
- (long)misscount, " missed");
+ output.printf("%ld%s%ld%s%ld%s\n", (long) goodcount, " good, ", (long) badcount, " bad, ",
+ (long) misscount, " missed");
if ((goodcount + misscount) > 0) {
- output.print((100 * goodcount / ((double) (goodcount + misscount))));
+ output.print((WKConstants.PERCENT_CONVERSION * goodcount
+ / ((double) (goodcount + misscount))));
output.print(" %, ");
- output.print((100 * badcount / ((double) (goodcount + misscount))));
+ output.print((WKConstants.PERCENT_CONVERSION * badcount
+ / ((double) (goodcount + misscount))));
output.print(" %, ");
- output.print((100 * misscount / ((double) (goodcount + misscount))));
+ output.print((WKConstants.PERCENT_CONVERSION * misscount
+ / ((double) (goodcount + misscount))));
output.printf("%s\n", " %");
}
if (procesp) {
- output.printf("%ld%s%ld%s%s%ld\n", (long)patcount, " patterns, ", (long)trieccount,
- " nodes in count trie, ", "triec_max = ", (long)triecmax);
+ output.printf("%ld%s%ld%s%s%ld\n", (long) patcount, " patterns, ", (long) trieccount,
+ " nodes in count trie, ", "triec_max = ", (long) triecmax);
}
if (hyphp) {
pattmp.close();
@@ -1932,7 +1936,7 @@
break;
case 4: {
patlen = patlen + 1;
- hval[patlen]= 0;
+ hval[patlen] = 0;
t = 1;
lab30: while (true) {
t = triel[t] + xord[c];
@@ -2002,9 +2006,9 @@
}
}
patterns.close();
- output.printf("%ld%s\n", (long)levelpatterncount , " patterns read in");
- output.printf("%s%ld%s%s%ld%s%ld%s\n", "pattern trie has ", (long)triecount, " nodes, ",
- "trie_max = ", (long)triemax, ", ", (long)opcount, " outputs");
+ output.printf("%ld%s\n", (long) levelpatterncount , " patterns read in");
+ output.printf("%s%ld%s%s%ld%s%ld%s\n", "pattern trie has ", (long) triecount, " nodes, ",
+ "trie_max = ", (long) triemax, ", ", (long) opcount, " outputs");
}
void mainbody() throws IOException {
@@ -2029,7 +2033,7 @@
} else {
this.n1 = 0;
output.printf("%s%ld%s\n", "Specify 1<=hyph_start,hyph_finish<=",
- (long)MAX_VAL - 1, " !");
+ (long) MAX_VAL - 1, " !");
}
} while (! (n1 > 0));
hyphlevel = maxpat;
@@ -2043,7 +2047,7 @@
if (hyphlevel > hyphstart) {
output.printf("%c\n", ' ');
} else if (hyphstart <= maxpat) {
- output.printf("%s%ld%s\n", "Largest hyphenation value ", (long)maxpat,
+ output.printf("%s%ld%s\n", "Largest hyphenation value ", (long) maxpat,
" in patterns should be less than hyph_start");
}
do {
@@ -2057,7 +2061,7 @@
} else {
n1 = 0;
output.printf("%s%ld%s\n", "Specify 1<=pat_start<=pat_finish<=",
- (long)MAX_DOT, " !" );
+ (long) MAX_DOT, " !" );
}
} while (! (n1 > 0));
do {
@@ -2079,7 +2083,7 @@
for_end2 = MAX_DOT;
if (k <= for_end2) {
do {
- morethislevel [k ]= true;
+ morethislevel[k] = true;
} while (k++ < for_end2);
}
int for_end3;
@@ -2113,8 +2117,8 @@
} while (j++ < for_end3);
}
deletebadpatterns();
- output.printf("%s%ld%s%ld\n", "total of ", (long)levelpatterncount,
- " patterns at hyph_level ", (long)hyphlevel);
+ output.printf("%s%ld%s%ld\n", "total of ", (long) levelpatterncount,
+ " patterns at hyph_level ", (long) hyphlevel);
} while (i++ < for_end);
}
findletters(triel[1], 1);
Modified: trunk/foray/scripts/checkstyle-suppressions.xml
===================================================================
--- trunk/foray/scripts/checkstyle-suppressions.xml 2008-02-28 16:39:06 UTC (rev 10371)
+++ trunk/foray/scripts/checkstyle-suppressions.xml 2008-02-28 16:56:32 UTC (rev 10372)
@@ -13,8 +13,9 @@
<suppress checks="MagicNumber"
files="src.javatest.*"/>
- <!-- Temporarily suppress all javadoc warnings for the Pattern Generator
+ <!-- Temporarily suppress some javadoc warnings for the Pattern Generator
class. -->
+ <suppress checks="MagicNumber*" files="src.java.org.foray.hyphen.PatternGenerator.*"/>
<suppress checks=".*" files="src.java.org.foray.hyphen.PatternGenerator.*"/>
</suppressions>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-02-28 18:45:54
|
Revision: 10378
http://foray.svn.sourceforge.net/foray/?rev=10378&view=rev
Author: victormote
Date: 2008-02-28 10:44:31 -0800 (Thu, 28 Feb 2008)
Log Message:
-----------
Clean up remaining checkstyle issues (except for the semi-permanent exceptions).
Modified Paths:
--------------
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/PatternGenerator.java
trunk/foray/scripts/checkstyle-suppressions.xml
Modified: trunk/foray/foray-hyphen/src/java/org/foray/hyphen/PatternGenerator.java
===================================================================
--- trunk/foray/foray-hyphen/src/java/org/foray/hyphen/PatternGenerator.java 2008-02-28 18:24:30 UTC (rev 10377)
+++ trunk/foray/foray-hyphen/src/java/org/foray/hyphen/PatternGenerator.java 2008-02-28 18:44:31 UTC (rev 10378)
@@ -205,105 +205,106 @@
/* Start of struct definitions from TeX code. */
private class Opword {
- int dot;
- int val;
- int op;
+ private int dot;
+ private int val;
+ private int op;
}
/* End of struct definitions from TeX code. */
/* Start of Variables from TeX code. */
- int patstart;
- int patfinish;
- int hyphstart;
- int hyphfinish;
- int goodwt;
- int badwt;
- int thresh;
+ private int patstart;
+ private int patfinish;
+ private int hyphstart;
+ private int hyphfinish;
+ private int goodwt;
+ private int badwt;
+ private int thresh;
/** Specifies conversion of input characters. */
- char[] xord = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ private char[] xord = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
/** Specifies conversion of output characters. */
- char[] xchr = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
- char[] xclass = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
- char[] xint = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
- char[] xdig = new char[DIGITS_SIZE];
- char[] xext = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
- char[] xhyf = new char[HYPH_SIZE];
- char cmax;
- char[] triec = new char[TRIE_SIZE + 1];
- int[] triel = new int[TRIE_SIZE + 1];
- int[] trier = new int[TRIE_SIZE + 1];
- boolean[] trietaken = new boolean[TRIE_SIZE + 1];
- char[] triecc = new char[TRIEC_SIZE + 1];
- int[] triecl = new int[TRIEC_SIZE + 1];
- int[] triecr = new int[TRIEC_SIZE + 1];
- boolean[] triectaken = new boolean[TRIEC_SIZE + 1];
- Opword[] ops = new Opword[MAX_OPS + 1];
- char[] trieqc = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
- int[] trieql = new int[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
- int[] trieqr = new int[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
- char qmax;
- char qmaxthresh;
- int triemax;
- int triebmax;
- int triecount;
- int opcount;
- char[] pat = new char[MAX_DOT + 1];
- int patlen;
- int triecmax;
- int triecbmax;
- int trieccount;
- int trieckmax;
- int patcount;
- InputStream dictionary;
- InputStream patterns;
- InputStream translate;
- OutputStream patout;
- PrintStream pattmp;
- String fname;
- float badfrac;
- float denom;
- float eff;
- char[] buf = new char[MAX_BUF_LEN + 1];
- int bufptr;
- char imax;
- int lefthyphenmin;
- int righthyphenmin;
- int goodpatcount;
- int badpatcount;
- int goodcount;
- int badcount;
- int misscount;
- int levelpatterncount;
- boolean moretocome;
- char[] word = new char[MAX_LEN + 1];
- char[] dots = new char[MAX_LEN + 1];
- char[] dotw = new char[MAX_LEN + 1];
- int[] hval = new int[MAX_LEN + 1];
- boolean[] nomore = new boolean[MAX_LEN + 1];
- int wlen;
- char wordwt;
- boolean wtchg;
- int hyfmin;
- int hyfmax;
- int hyflen;
- char gooddot;
- char baddot;
- int dotmin;
- int dotmax;
- int dotlen;
- boolean procesp;
- boolean hyphp;
- int patdot;
- int hyphlevel;
- char[] filnam = new char[FILENAME_SIZE];
- int maxpat;
- int n1;
- int n2;
- int n3;
- int dot1;
- boolean[] morethislevel = new boolean[MAX_DOT + 1];
+ private char[] xchr = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ private char[] xclass = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ private char[] xint = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ private char[] xdig = new char[PatternGenerator.DIGITS_SIZE];
+ private char[] xext = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ private char[] xhyf = new char[PatternGenerator.HYPH_SIZE];
+ private char cmax;
+ private char[] triec = new char[PatternGenerator.TRIE_SIZE + 1];
+ private int[] triel = new int[PatternGenerator.TRIE_SIZE + 1];
+ private int[] trier = new int[PatternGenerator.TRIE_SIZE + 1];
+ private boolean[] trietaken = new boolean[PatternGenerator.TRIE_SIZE + 1];
+ private char[] triecc = new char[PatternGenerator.TRIEC_SIZE + 1];
+ private int[] triecl = new int[PatternGenerator.TRIEC_SIZE + 1];
+ private int[] triecr = new int[PatternGenerator.TRIEC_SIZE + 1];
+ private boolean[] triectaken = new boolean[PatternGenerator.TRIEC_SIZE + 1];
+ private PatternGenerator.Opword[] ops =
+ new PatternGenerator.Opword[PatternGenerator.MAX_OPS + 1];
+ private char[] trieqc = new char[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ private int[] trieql = new int[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ private int[] trieqr = new int[WKConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ private char qmax;
+ private char qmaxthresh;
+ private int triemax;
+ private int triebmax;
+ private int triecount;
+ private int opcount;
+ private char[] pat = new char[PatternGenerator.MAX_DOT + 1];
+ private int patlen;
+ private int triecmax;
+ private int triecbmax;
+ private int trieccount;
+ private int trieckmax;
+ private int patcount;
+ private InputStream dictionary;
+ private InputStream patterns;
+ private InputStream translate;
+ private OutputStream patout;
+ private PrintStream pattmp;
+// private String fname;
+// private float badfrac;
+// private float denom;
+// private float eff;
+ private char[] buf = new char[PatternGenerator.MAX_BUF_LEN + 1];
+ private int bufptr;
+ private char imax;
+ private int lefthyphenmin;
+ private int righthyphenmin;
+ private int goodpatcount;
+ private int badpatcount;
+ private int goodcount;
+ private int badcount;
+ private int misscount;
+ private int levelpatterncount;
+ private boolean moretocome;
+ private char[] word = new char[PatternGenerator.MAX_LEN + 1];
+ private char[] dots = new char[PatternGenerator.MAX_LEN + 1];
+ private char[] dotw = new char[PatternGenerator.MAX_LEN + 1];
+ private int[] hval = new int[PatternGenerator.MAX_LEN + 1];
+ private boolean[] nomore = new boolean[PatternGenerator.MAX_LEN + 1];
+ private int wlen;
+ private char wordwt;
+ private boolean wtchg;
+ private int hyfmin;
+ private int hyfmax;
+ private int hyflen;
+ private char gooddot;
+ private char baddot;
+ private int dotmin;
+ private int dotmax;
+ private int dotlen;
+ private boolean procesp;
+ private boolean hyphp;
+ private int patdot;
+ private int hyphlevel;
+ private char[] filnam = new char[PatternGenerator.FILENAME_SIZE];
+ private int maxpat;
+ private int n1;
+ private int n2;
+ private int n3;
+ private int dot1;
+ private boolean[] morethislevel = new boolean[PatternGenerator.MAX_DOT + 1];
/* End of Variables from TeX code. */
/** The banner printed when the program starts. */
@@ -458,47 +459,47 @@
* a suitable inverse to the information in xchr. */
/* ASCII_code that should not appear. */
- char invalidCode = 0;
+ final char invalidCode = 0;
/* Ordinal index for the tab character. Tab characters seem to be
* unavoidable with files from UNIX systems. */
- char tabChar = '\t';
+ final char tabChar = '\t';
- for (int i = FIRST_TEXT_CHAR; i < LAST_TEXT_CHAR; i++) {
- xord[i] = invalidCode;
+ for (int i = PatternGenerator.FIRST_TEXT_CHAR; i < PatternGenerator.LAST_TEXT_CHAR; i++) {
+ this.xord[i] = invalidCode;
}
- for (char j = 0; j <= LAST_ASCII_CODE; j++) {
- xord[xchr[j]] = j;
+ for (char j = 0; j <= PatternGenerator.LAST_ASCII_CODE; j++) {
+ this.xord[this.xchr[j]] = j;
}
- xord[' '] = ' ';
- xord[tabChar] = ' ';
+ this.xord[' '] = ' ';
+ this.xord[tabChar] = ' ';
/* Initialize the xclass and xint arrays with default values. Both are
* modified by other initialization routines below. */
for (int i = PatternGenerator.FIRST_TEXT_CHAR; i <= PatternGenerator.LAST_TEXT_CHAR; i++) {
- xclass[i] = PatternGenerator.INVALID_CLASS;
- xint[i] = 0;
+ this.xclass[i] = PatternGenerator.INVALID_CLASS;
+ this.xint[i] = 0;
}
- xclass[' '] = PatternGenerator.SPACE_CLASS;
+ this.xclass[' '] = PatternGenerator.SPACE_CLASS;
/* Initialize the xext array. */
for (int j = 0; j <= PatternGenerator.LAST_ASCII_CODE; j++) {
- xext[j] = ' ';
+ this.xext[j] = ' ';
}
- xext[PatternGenerator.EDGE_OF_WORD] = '.';
+ this.xext[PatternGenerator.EDGE_OF_WORD] = '.';
/* Initialize the xdig array. */
- for (char j = 0; j < xdig.length; j++) {
- xdig[j] = xchr[j + '0'];
- xclass[xdig[j]] = PatternGenerator.DIGIT_CLASS;
- xint[xdig[j]] = j;
+ for (char j = 0; j < this.xdig.length; j++) {
+ this.xdig[j] = this.xchr[j + '0'];
+ this.xclass[this.xdig[j]] = PatternGenerator.DIGIT_CLASS;
+ this.xint[this.xdig[j]] = j;
}
/* Initialize the xhyf array. */
- xhyf[PatternGenerator.ERR_HYF] = '.';
- xhyf[PatternGenerator.IS_HYF] = '-';
- xhyf[PatternGenerator.FOUND_HYF] = '*';
+ this.xhyf[PatternGenerator.ERR_HYF] = '.';
+ this.xhyf[PatternGenerator.IS_HYF] = '-';
+ this.xhyf[PatternGenerator.FOUND_HYF] = '*';
}
/**
@@ -534,22 +535,22 @@
* @see "patgen.web, line 384"
*/
char getASCII(final char c) {
- char i = xord[c];
+ char i = this.xord[c];
if (i == 0) {
boolean found = false;
- while (i < LAST_ASCII_CODE) {
+ while (i < PatternGenerator.LAST_ASCII_CODE) {
i++;
- if ((xchr[i] == ' ')
+ if ((this.xchr[i] == ' ')
&& (i != ' ')) {
found = true;
break;
}
}
if (found) {
- xord [c] = i;
- xchr [i] = c;
+ this.xord [c] = i;
+ this.xchr [i] = c;
} else {
- overflow("characters", NUM_ASCII_CODES);
+ overflow("characters", PatternGenerator.NUM_ASCII_CODES);
}
}
return i;
@@ -575,28 +576,28 @@
forEnd = 255;
if (c <= forEnd) {
do {
- triec[1 + c] = c;
- triel[1 + c] = 0;
- trier[1 + c] = 0;
- trietaken[1 + c] = false;
+ this.triec[1 + c] = c;
+ this.triel[1 + c] = 0;
+ this.trier[1 + c] = 0;
+ this.trietaken[1 + c] = false;
} while (c++ < forEnd);
}
- trietaken[1] = true;
- triebmax = 1;
- triemax = 256;
- triecount = 256;
- qmaxthresh = 5;
- triel[0] = triemax + 1;
- trier[triemax + 1] = 0;
+ this.trietaken[1] = true;
+ this.triebmax = 1;
+ this.triemax = 256;
+ this.triecount = 256;
+ this.qmaxthresh = 5;
+ this.triel[0] = this.triemax + 1;
+ this.trier[this.triemax + 1] = 0;
int forEnd2;
h = 1;
forEnd2 = PatternGenerator.MAX_OPS;
if (h <= forEnd2) {
do {
- ops[h].val = 0;
+ this.ops[h].val = 0;
} while (h++ < forEnd2);
}
- opcount = 0;
+ this.opcount = 0;
}
/**
@@ -610,21 +611,21 @@
* @return The pointer to the location of the trie node.
*/
int firstfit() {
- int s = computeBaseLocation();
+ final int s = computeBaseLocation();
/* Pack it. */
- for (int q = 1; q <= qmax; q++) {
- int t = s + trieqc[q];
- triel[trier[t]] = triel[t];
+ for (int q = 1; q <= this.qmax; q++) {
+ final int t = s + this.trieqc[q];
+ this.triel[this.trier[t]] = this.triel[t];
/* Link around filled cell. */
- trier[triel[t]] = trier[t];
- triec[t] = si(trieqc[q]);
- triel[t] = trieql[q];
- trier[t] = trieqr[q];
- if (t > triemax) {
- triemax = t;
+ this.trier[this.triel[t]] = this.trier[t];
+ this.triec[t] = si(this.trieqc[q]);
+ this.triel[t] = this.trieql[q];
+ this.trier[t] = this.trieqr[q];
+ if (t > this.triemax) {
+ this.triemax = t;
}
}
- trietaken[s] = true;
+ this.trietaken[s] = true;
return s;
}
@@ -638,20 +639,20 @@
*/
int computeBaseLocation() {
int t = 0;
- if (qmax > qmaxthresh) {
- t = trier[triemax + 1];
+ if (this.qmax > this.qmaxthresh) {
+ t = this.trier[this.triemax + 1];
}
while (true) {
- t = triel[t];
+ t = this.triel[t];
/* Get next unoccupied cell. */
- int s = t - trieqc[1];
+ final int s = t - this.trieqc[1];
ensureTrieCapacity(s);
- if (triectaken[s]) {
+ if (this.triectaken[s]) {
return -1;
}
/* Check if state fits here. */
- for (int q = qmax; q >= 2; q++) {
- if (triec[s + trieqc[q]] != MIN_PACKED) {
+ for (int q = this.qmax; q >= 2; q++) {
+ if (this.triec[s + this.trieqc[q]] != PatternGenerator.MIN_PACKED) {
return -1;
}
}
@@ -665,17 +666,18 @@
* @see "patgen.web, line 754"
*/
void ensureTrieCapacity(final int s) {
- if (s > TRIE_SIZE - NUM_ASCII_CODES) {
- overflow("pattern trie nodes", TRIE_SIZE);
+ if (s > PatternGenerator.TRIE_SIZE - PatternGenerator.NUM_ASCII_CODES) {
+ overflow("pattern trie nodes", PatternGenerator.TRIE_SIZE);
}
- while (triebmax < s) {
- triebmax ++;
- trietaken[triebmax] = false;
- triec[triebmax + LAST_ASCII_CODE] = MIN_PACKED;
- triel[triebmax + LAST_ASCII_CODE] = triebmax
- + NUM_ASCII_CODES;
- trier[triebmax + NUM_ASCII_CODES] = triebmax
- + LAST_ASCII_CODE;
+ while (this.triebmax < s) {
+ this.triebmax ++;
+ this.trietaken[this.triebmax] = false;
+ this.triec[this.triebmax + PatternGenerator.LAST_ASCII_CODE] =
+ PatternGenerator.MIN_PACKED;
+ this.triel[this.triebmax + PatternGenerator.LAST_ASCII_CODE] =
+ this.triebmax + PatternGenerator.NUM_ASCII_CODES;
+ this.trier[this.triebmax + PatternGenerator.NUM_ASCII_CODES] =
+ this.triebmax + PatternGenerator.LAST_ASCII_CODE;
}
}
@@ -688,98 +690,98 @@
*/
void unpack(final int s) {
this.qmax = 1;
- for (char c = EDGE_OF_WORD; c <= cmax; c++) {
+ for (char c = PatternGenerator.EDGE_OF_WORD; c <= this.cmax; c++) {
/* Search for transitions belonging to this state. */
- int t = s + c;
- if (so(triec[t]) == c) {
+ final int t = s + c;
+ if (so(this.triec[t]) == c) {
/* Found one. */
- trieqc[qmax] = c;
- trieql[qmax] = triel[t];
- trieqr[qmax] = trier[t];
- qmax ++;
+ this.trieqc[this.qmax] = c;
+ this.trieql[this.qmax] = this.triel[t];
+ this.trieqr[this.qmax] = this.trier[t];
+ this.qmax ++;
/* Now free trie node. */
- trier[triel[0]] = t;
- triel[t] = triel[0];
- triel[0] = t;
- trier[t] = 0;
- triec[t] = MIN_PACKED;
+ this.trier[this.triel[0]] = t;
+ this.triel[t] = this.triel[0];
+ this.triel[0] = t;
+ this.trier[t] = 0;
+ this.triec[t] = PatternGenerator.MIN_PACKED;
}
}
- trietaken[s] = false;
+ this.trietaken[s] = false;
}
int znewtrieop(final int v, final int d, final int n) {
- int h = ((n + 313 * d + 361 * v) % MAX_OPS) + 1;
+ int h = ((n + 313 * d + 361 * v) % PatternGenerator.MAX_OPS) + 1;
while (true) {
- if (ops[h].val == 0) {
- opcount = opcount + 1;
- if (opcount == MAX_OPS) {
+ if (this.ops[h].val == 0) {
+ this.opcount = this.opcount + 1;
+ if (this.opcount == PatternGenerator.MAX_OPS) {
System.err.printf("%s%ld%s%s\n", "PATGEN capacity exceeded, sorry [",
- (long) MAX_OPS, " outputs" , "]." );
+ (long) PatternGenerator.MAX_OPS, " outputs" , "].");
System.exit(1);
}
- ops[h].val = v;
- ops[h].dot = d;
- ops[h].op = n;
+ this.ops[h].val = v;
+ this.ops[h].dot = d;
+ this.ops[h].op = n;
return h;
}
- if ((ops[h].val == v )
- && (ops[h].dot == d)
- && (ops[h].op == n)) {
+ if ((this.ops[h].val == v)
+ && (this.ops[h].dot == d)
+ && (this.ops[h].op == n)) {
return h;
}
if (h > 1) {
h--;
} else {
- h = MAX_OPS;
+ h = PatternGenerator.MAX_OPS;
}
}
}
void insertpattern(final int val, final int dot) {
int i = 1;
- int s = 1 + pat[i];
- int t = triel[s];
+ int s = 1 + this.pat[i];
+ int t = this.triel[s];
while ((t > 0)
- && (i < patlen)) {
+ && (i < this.patlen)) {
i = i + 1;
- t = t + pat [i];
- if (triec[t] != pat[i]) {
- if (triec[t] == 0) {
- triel[trier[t]] = triel[t];
- trier[triel[t]] = trier[t];
- triec[t] = pat[i];
- triel[t] = 0;
- trier[t] = 0;
- if (t > triemax) {
- triemax = t;
+ t = t + this.pat [i];
+ if (this.triec[t] != this.pat[i]) {
+ if (this.triec[t] == 0) {
+ this.triel[this.trier[t]] = this.triel[t];
+ this.trier[this.triel[t]] = this.trier[t];
+ this.triec[t] = this.pat[i];
+ this.triel[t] = 0;
+ this.trier[t] = 0;
+ if (t > this.triemax) {
+ this.triemax = t;
}
} else {
- unpack(t - pat[i]);
- trieqc[qmax] = pat[i];
- trieql[qmax] = 0;
- trieqr[qmax] = 0;
+ unpack(t - this.pat[i]);
+ this.trieqc[this.qmax] = this.pat[i];
+ this.trieql[this.qmax] = 0;
+ this.trieqr[this.qmax] = 0;
t = firstfit();
- triel[s] = t;
- t = t + pat[i];
+ this.triel[s] = t;
+ t = t + this.pat[i];
}
- triecount = triecount + 1;
+ this.triecount = this.triecount + 1;
}
s = t;
- t = triel[s];
+ t = this.triel[s];
}
- trieql[1] = 0;
- trieqr[1] = 0;
- qmax = 1;
- while (i < patlen) {
+ this.trieql[1] = 0;
+ this.trieqr[1] = 0;
+ this.qmax = 1;
+ while (i < this.patlen) {
i = i + 1;
- trieqc[1] = pat[i];
+ this.trieqc[1] = this.pat[i];
t = firstfit();
- triel[s] = t;
- s = t + pat[i];
- triecount = triecount + 1;
+ this.triel[s] = t;
+ s = t + this.pat[i];
+ this.triecount = this.triecount + 1;
}
- trier[s] = znewtrieop(val, dot, trier[s]);
+ this.trier[s] = znewtrieop(val, dot, this.trier[s]);
}
void initcounttrie() {
@@ -790,64 +792,64 @@
forEnd = 255;
if (c <= forEnd) {
do {
- triecc[1 + c] = c;
- triecl[1 + c] = 0;
- triecr[1 + c] = 0;
- triectaken[1 + c] = false;
+ this.triecc[1 + c] = c;
+ this.triecl[1 + c] = 0;
+ this.triecr[1 + c] = 0;
+ this.triectaken[1 + c] = false;
} while (c++ < forEnd);
}
}
- triectaken[1] = true;
- triecbmax = 1;
- triecmax = 256;
- trieccount = 256;
- trieckmax = 4096;
- triecl[0] = triecmax + 1;
- triecr[triecmax + 1] = 0;
- patcount = 0;
+ this.triectaken[1] = true;
+ this.triecbmax = 1;
+ this.triecmax = 256;
+ this.trieccount = 256;
+ this.trieckmax = 4096;
+ this.triecl[0] = this.triecmax + 1;
+ this.triecr[this.triecmax + 1] = 0;
+ this.patcount = 0;
}
int firstcfit() {
int a;
int b;
char q;
- if (qmax > 3) {
- a = triecr[triecmax + 1];
+ if (this.qmax > 3) {
+ a = this.triecr[this.triecmax + 1];
} else {
a = 0;
}
lab41: while (true) {
- a = triecl[a];
- b = a - trieqc[1];
- if (b > trieckmax - 256) {
- if (trieckmax == TRIEC_SIZE) {
+ a = this.triecl[a];
+ b = a - this.trieqc[1];
+ if (b > this.trieckmax - 256) {
+ if (this.trieckmax == PatternGenerator.TRIEC_SIZE) {
System.err.printf("%s%ld%s%s\n", "PATGEN capacity exceeded, sorry [" ,
- (long) TRIEC_SIZE, " count trie nodes" , "]." );
+ (long) PatternGenerator.TRIEC_SIZE, " count trie nodes" , "].");
System.exit(1);
}
- System.out.printf("%ld%s", (long) trieckmax / 1024 , "K ");
- if (trieckmax > TRIEC_SIZE - 4096) {
- trieckmax = TRIEC_SIZE;
+ System.out.printf("%ld%s", (long) this.trieckmax / 1024 , "K ");
+ if (this.trieckmax > PatternGenerator.TRIEC_SIZE - 4096) {
+ this.trieckmax = PatternGenerator.TRIEC_SIZE;
} else {
- trieckmax = trieckmax + 4096;
+ this.trieckmax = this.trieckmax + 4096;
}
}
- while (triecbmax < b) {
- triecbmax = triecbmax + 1;
- triectaken[triecbmax] = false;
- triecc[triecbmax + 255] = 0;
- triecl[triecbmax + 255] = triecbmax + 256;
- triecr[triecbmax + 256] = triecbmax + 255;
+ while (this.triecbmax < b) {
+ this.triecbmax = this.triecbmax + 1;
+ this.triectaken[this.triecbmax] = false;
+ this.triecc[this.triecbmax + 255] = 0;
+ this.triecl[this.triecbmax + 255] = this.triecbmax + 256;
+ this.triecr[this.triecbmax + 256] = this.triecbmax + 255;
}
- if (triectaken[b]) {
+ if (this.triectaken[b]) {
continue lab41;
}
int forEnd;
- q = qmax;
+ q = this.qmax;
forEnd = 2;
if (q >= forEnd) {
do {
- if (triecc[b + trieqc[q]] != 0) {
+ if (this.triecc[b + this.trieqc[q]] != 0) {
continue lab41;
}
} while (q-- > forEnd);
@@ -856,99 +858,99 @@
}
int forEnd;
q = 1;
- forEnd = qmax;
+ forEnd = this.qmax;
if (q <= forEnd) {
do {
- a = b + trieqc[q];
- triecl[triecr[a]] = triecl[a];
- triecr[triecl[a]] = triecr[a];
- triecc[a] = trieqc[q];
- triecl[a] = trieql[q];
- triecr[a] = trieqr[q];
- if (a > triecmax) {
- triecmax = a;
+ a = b + this.trieqc[q];
+ this.triecl[this.triecr[a]] = this.triecl[a];
+ this.triecr[this.triecl[a]] = this.triecr[a];
+ this.triecc[a] = this.trieqc[q];
+ this.triecl[a] = this.trieql[q];
+ this.triecr[a] = this.trieqr[q];
+ if (a > this.triecmax) {
+ this.triecmax = a;
}
} while (q++ < forEnd);
}
- triectaken[b] = true;
+ this.triectaken[b] = true;
return b;
}
void unpackc(final int b) {
char c;
int a;
- qmax = 1;
+ this.qmax = 1;
int forEnd;
c = 1;
- forEnd = cmax;
+ forEnd = this.cmax;
if (c <= forEnd) {
do {
a = b + c;
- if (triecc[a] == c) {
- trieqc[qmax] = c;
- trieql[qmax] = triecl[a];
- trieqr[qmax] = triecr[a];
- qmax ++;
- triecr[triecl[0]] = a;
- triecl[a] = triecl[0];
- triecl[0] = a;
- triecr[a] = 0;
- triecc[a] = 0;
+ if (this.triecc[a] == c) {
+ this.trieqc[this.qmax] = c;
+ this.trieql[this.qmax] = this.triecl[a];
+ this.trieqr[this.qmax] = this.triecr[a];
+ this.qmax ++;
+ this.triecr[this.triecl[0]] = a;
+ this.triecl[a] = this.triecl[0];
+ this.triecl[0] = a;
+ this.triecr[a] = 0;
+ this.triecc[a] = 0;
}
} while (c++ < forEnd);
}
- triectaken[b] = false;
+ this.triectaken[b] = false;
}
int insertcpat(final int fpos) {
int spos;
int a;
int b;
- spos = fpos - patlen;
+ spos = fpos - this.patlen;
spos = spos + 1;
- b = 1 + word[spos];
- a = triecl[b];
+ b = 1 + this.word[spos];
+ a = this.triecl[b];
while ((a > 0)
&& (spos < fpos)) {
spos = spos + 1;
- a = a + word[spos];
- if (triecc[a] != word[spos]) {
- if (triecc[a] == 0 ) {
- triecl[triecr[a]] = triecl[a];
- triecr[triecl[a]] = triecr[a];
- triecc[a] = word[spos];
- triecl[a] = 0;
- triecr[a] = 0;
- if (a > triecmax) {
- triecmax = a;
+ a = a + this.word[spos];
+ if (this.triecc[a] != this.word[spos]) {
+ if (this.triecc[a] == 0) {
+ this.triecl[this.triecr[a]] = this.triecl[a];
+ this.triecr[this.triecl[a]] = this.triecr[a];
+ this.triecc[a] = this.word[spos];
+ this.triecl[a] = 0;
+ this.triecr[a] = 0;
+ if (a > this.triecmax) {
+ this.triecmax = a;
}
} else {
- unpackc(a - word[spos]);
- trieqc[qmax] = word[spos];
- trieql[qmax] = 0;
- trieqr[qmax] = 0;
+ unpackc(a - this.word[spos]);
+ this.trieqc[this.qmax] = this.word[spos];
+ this.trieql[this.qmax] = 0;
+ this.trieqr[this.qmax] = 0;
a = firstcfit();
- triecl[b] = a;
- a = a + word [spos];
+ this.triecl[b] = a;
+ a = a + this.word [spos];
}
- trieccount = trieccount + 1;
+ this.trieccount = this.trieccount + 1;
}
b = a;
- a = triecl[a];
+ a = this.triecl[a];
}
- trieql[1] = 0;
- trieqr[1] = 0;
- qmax = 1;
+ this.trieql[1] = 0;
+ this.trieqr[1] = 0;
+ this.qmax = 1;
while (spos < fpos) {
spos = spos + 1;
- trieqc[1] = word[spos];
+ this.trieqc[1] = this.word[spos];
a = firstcfit();
- triecl[b] = a;
- b = a + word[spos];
- trieccount = trieccount + 1;
+ this.triecl[b] = a;
+ b = a + this.word[spos];
+ this.trieccount = this.trieccount + 1;
}
- patcount = patcount + 1;
+ this.patcount ...
[truncated message content] |
|
From: <vic...@us...> - 2008-03-01 02:15:33
|
Revision: 10399
http://foray.svn.sourceforge.net/foray/?rev=10399&view=rev
Author: victormote
Date: 2008-02-29 18:15:39 -0800 (Fri, 29 Feb 2008)
Log Message:
-----------
Allow any CharSequence to be added to the TernaryTree.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/StringUtil.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/TernaryTree.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/StringUtil.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/StringUtil.java 2008-02-29 23:48:46 UTC (rev 10398)
+++ trunk/foray/foray-common/src/java/org/foray/common/StringUtil.java 2008-03-01 02:15:39 UTC (rev 10399)
@@ -305,6 +305,45 @@
}
/**
+ * Copies characters from a CharSequence string into a destination char[].
+ * This mimics the logic from {@link String#getChars(int, int, char[], int)}.
+ *
+ * <p>The first character to be copied is at index <code>srcBegin</code>;
+ * the last character to be copied is at index <code>srcEnd-1</code>
+ * (thus the total number of characters to be copied is
+ * <code>srcEnd-srcBegin</code>). The characters are copied into the
+ * subarray of <code>dst</code> starting at index <code>dstBegin</code>
+ * and ending at index:
+ * <p><blockquote><pre>
+ * dstbegin + (srcEnd-srcBegin) - 1
+ * </pre></blockquote>
+ *
+ * @param source The CharSequence from which the chars will be copied.
+ * @param srcBegin Index of the first character in the CharSequence to copy.
+ * @param srcEnd Index after the last character in the CharSequence to copy.
+ * @param dst The destination array.
+ * @param dstBegin The start offset in the destination array.
+ *
+ * @see String#getChars(int, int, char[], int)
+ */
+ public static void toChars(final CharSequence source, final int srcBegin, final int srcEnd,
+ final char dst[], final int dstBegin) {
+ if (srcBegin < 0) {
+ throw new StringIndexOutOfBoundsException(srcBegin);
+ }
+ if (srcEnd > source.length()) {
+ throw new StringIndexOutOfBoundsException(srcEnd);
+ }
+ if (srcBegin > srcEnd) {
+ throw new StringIndexOutOfBoundsException(srcEnd - srcBegin);
+ }
+ for (int i = srcBegin; i < srcEnd; i++) {
+ final int dstIndex = dstBegin + i - srcBegin;
+ dst[dstIndex] = source.charAt(i);
+ }
+ }
+
+ /**
* Compares two Strings for equality, returning the index to the first
* different character.
* @param string1 The first String being compared.
Modified: trunk/foray/foray-hyphen/src/java/org/foray/hyphen/TernaryTree.java
===================================================================
--- trunk/foray/foray-hyphen/src/java/org/foray/hyphen/TernaryTree.java 2008-02-29 23:48:46 UTC (rev 10398)
+++ trunk/foray/foray-hyphen/src/java/org/foray/hyphen/TernaryTree.java 2008-03-01 02:15:39 UTC (rev 10399)
@@ -167,9 +167,9 @@
* @param key The key to be added.
* @param value The value.
*/
- public void insert(final String key, final char value) {
+ public void insert(final CharSequence key, final char value) {
final char strkey[] = new char[key.length() + 1];
- key.getChars(0, key.length(), strkey, 0);
+ StringUtil.toChars(key, 0, key.length(), strkey, 0);
strkey[key.length()] = 0;
this.insert(strkey, 0, value);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-03-03 15:14:47
|
Revision: 10411
http://foray.svn.sourceforge.net/foray/?rev=10411&view=rev
Author: victormote
Date: 2008-03-03 07:14:53 -0800 (Mon, 03 Mar 2008)
Log Message:
-----------
Attach Xerces source code to the library jar file for Eclipse.
Modified Paths:
--------------
trunk/foray/foray-app/.classpath
trunk/foray/foray-core/.classpath
trunk/foray/foray-font/.classpath
trunk/foray/foray-hyphen/.classpath
trunk/foray/foray-pretty/.classpath
Modified: trunk/foray/foray-app/.classpath
===================================================================
--- trunk/foray/foray-app/.classpath 2008-03-02 19:13:07 UTC (rev 10410)
+++ trunk/foray/foray-app/.classpath 2008-03-03 15:14:53 UTC (rev 10411)
@@ -32,7 +32,7 @@
<classpathentry kind="lib" path="/FOray Lib/resolver.jar"/>
<classpathentry kind="lib" path="/FOray Lib/servlet-2.2.jar"/>
<classpathentry kind="lib" path="/FOray Lib/xalan-2.4.1.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/xercesImpl-2.7.1.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/xercesImpl-2.7.1.jar" sourcepath="/FOray Lib-Build/xerces/Xerces-J-src.2.7.1.zip"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslSpeech"/>
<classpathentry combineaccessrules="false" kind="src" path="/FOraySpeech"/>
Modified: trunk/foray/foray-core/.classpath
===================================================================
--- trunk/foray/foray-core/.classpath 2008-03-02 19:13:07 UTC (rev 10410)
+++ trunk/foray/foray-core/.classpath 2008-03-03 15:14:53 UTC (rev 10411)
@@ -13,7 +13,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/axslOutput"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslCommon"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslHyphen"/>
- <classpathentry kind="lib" path="/FOray Lib/xercesImpl-2.7.1.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/xercesImpl-2.7.1.jar" sourcepath="/FOray Lib-Build/xerces/Xerces-J-src.2.7.1.zip"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslSpeech"/>
<classpathentry kind="output" path="build/eclipse"/>
Modified: trunk/foray/foray-font/.classpath
===================================================================
--- trunk/foray/foray-font/.classpath 2008-03-02 19:13:07 UTC (rev 10410)
+++ trunk/foray/foray-font/.classpath 2008-03-03 15:14:53 UTC (rev 10411)
@@ -11,7 +11,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/FOrayPretty"/>
<classpathentry kind="lib" path="/FOray Lib/commons-io-1.2.jar" sourcepath="/FOray Lib-Build/commons-io/commons-io-1.2-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/foray-font-0.3-rsrc.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/xercesImpl-2.7.1.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/xercesImpl-2.7.1.jar" sourcepath="/FOray Lib-Build/xerces/Xerces-J-src.2.7.1.zip"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib-Build/ant/ant.jar"/>
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit-4.4.jar" sourcepath="/FOray Lib-Build/junit/junit-4.4-src.jar"/>
Modified: trunk/foray/foray-hyphen/.classpath
===================================================================
--- trunk/foray/foray-hyphen/.classpath 2008-03-02 19:13:07 UTC (rev 10410)
+++ trunk/foray/foray-hyphen/.classpath 2008-03-03 15:14:53 UTC (rev 10411)
@@ -5,7 +5,7 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/FOrayCommon"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslHyphen"/>
- <classpathentry kind="lib" path="/FOray Lib/xercesImpl-2.7.1.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/xercesImpl-2.7.1.jar" sourcepath="/FOray Lib-Build/xerces/Xerces-J-src.2.7.1.zip"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslCommon"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/icu4j_3_4_3.jar"/>
Modified: trunk/foray/foray-pretty/.classpath
===================================================================
--- trunk/foray/foray-pretty/.classpath 2008-03-02 19:13:07 UTC (rev 10410)
+++ trunk/foray/foray-pretty/.classpath 2008-03-03 15:14:53 UTC (rev 10411)
@@ -5,7 +5,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/FOrayCommon"/>
<classpathentry kind="lib" path="/FOray Lib/resolver.jar"/>
<classpathentry kind="lib" path="/FOray Lib/stax-api-1.0.1.jar" sourcepath="/FOray Lib-Build/stax/stax-src-1.2.0.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/xercesImpl-2.7.1.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/xercesImpl-2.7.1.jar" sourcepath="/FOray Lib-Build/xerces/Xerces-J-src.2.7.1.zip"/>
<classpathentry kind="lib" path="/FOray Lib/stax-1.2.0.jar" sourcepath="/FOray Lib-Build/stax/stax-src-1.2.0.zip"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-03-12 18:33:34
|
Revision: 10424
http://foray.svn.sourceforge.net/foray/?rev=10424&view=rev
Author: victormote
Date: 2008-03-12 11:33:36 -0700 (Wed, 12 Mar 2008)
Log Message:
-----------
Move ByteVector and CharVector classes to Common so that they can be more widely used.
Modified Paths:
--------------
trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/HyphenationTree.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/TernaryTree.java
trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/TestFOrayHyphen.java
Added Paths:
-----------
trunk/foray/foray-common/src/java/org/foray/common/ByteVector.java
trunk/foray/foray-common/src/java/org/foray/common/CharVector.java
trunk/foray/foray-common/src/javatest/org/foray/common/TestCharVector.java
Removed Paths:
-------------
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/ByteVector.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/CharVector.java
trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/TestCharVector.java
Copied: trunk/foray/foray-common/src/java/org/foray/common/ByteVector.java (from rev 10096, trunk/foray/foray-hyphen/src/java/org/foray/hyphen/ByteVector.java)
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/ByteVector.java (rev 0)
+++ trunk/foray/foray-common/src/java/org/foray/common/ByteVector.java 2008-03-12 18:33:36 UTC (rev 10424)
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+/*
+ * Known Contributors:
+ * Carlos Villegas <ca...@un...> (Original author)
+ */
+
+package org.foray.common;
+
+import java.io.Serializable;
+
+/**
+ * A vector of bytes.
+ */
+public class ByteVector implements Serializable {
+
+ /** Constant needed for serialization. */
+ static final long serialVersionUID = 977379027446677063L;
+
+ /** Default Capacity increment size. */
+ private static final int DEFAULT_BLOCK_SIZE = 2048;
+
+ /** Capacity increment size. */
+ private int blockSize = ByteVector.DEFAULT_BLOCK_SIZE;
+
+ /** The encapsulated array. */
+ private byte[] backingArray;
+
+ /** Index to to the next free item in {@link #backingArray}. */
+ private int nextIndex;
+
+ /**
+ * No-argument constructor.
+ */
+ public ByteVector() {
+ this(ByteVector.DEFAULT_BLOCK_SIZE);
+ }
+
+ /**
+ * Constructor.
+ * @param capacity The initial capacity, in bytes, of the new vector.
+ */
+ public ByteVector(final int capacity) {
+ if (capacity > 0) {
+ this.blockSize = capacity;
+ } else {
+ this.blockSize = ByteVector.DEFAULT_BLOCK_SIZE;
+ }
+ this.backingArray = new byte[this.blockSize];
+ this.nextIndex = 0;
+ }
+
+ /**
+ * Returns the number of items in the vector.
+ * @return The number of items in the vector.
+ */
+ public int length() {
+ return this.nextIndex;
+ }
+
+ /**
+ * Returns the current capacity of the vector.
+ * @return The currect capacity of the vector.
+ */
+ public int capacity() {
+ return this.backingArray.length;
+ }
+
+ /**
+ * Place an item in the vector at a specific index.
+ * @param index The 0-based index into the vector.
+ * @param val The byte value to be placed in the vector.
+ */
+ public void put(final int index, final byte val) {
+ this.backingArray[index] = val;
+ }
+
+ /**
+ * Retrieve a value from a specific index in the vector.
+ * @param index The 0-based index whose value should be returned.
+ * @return The value at <code>index</code>.
+ */
+ public byte get(final int index) {
+ return this.backingArray[index];
+ }
+
+ /**
+ * Allocates or uses a specified number of elements (bytes).
+ * If needed, this method automatically increases the vector's capacity.
+ * @param size The number of elements (bytes) to be allocated.
+ * @return The index to the beginning of the allocated elements (bytes).
+ */
+ public int alloc(final int size) {
+ final int index = this.nextIndex;
+ if (this.nextIndex + size >= this.backingArray.length) {
+ final byte[] newArray = new byte[this.backingArray.length
+ + this.blockSize];
+ System.arraycopy(this.backingArray, 0, newArray, 0,
+ this.backingArray.length);
+ this.backingArray = newArray;
+ }
+ this.nextIndex += size;
+ return index;
+ }
+
+ /**
+ * Sets the capacity of this vector equal to its size, to that there is no
+ * unused capacity.
+ */
+ public void trimToSize() {
+ if (this.nextIndex < this.backingArray.length) {
+ final byte[] aux = new byte[this.nextIndex];
+ System.arraycopy(this.backingArray, 0, aux, 0, this.nextIndex);
+ this.backingArray = aux;
+ }
+ }
+
+}
Copied: trunk/foray/foray-common/src/java/org/foray/common/CharVector.java (from rev 10406, trunk/foray/foray-hyphen/src/java/org/foray/hyphen/CharVector.java)
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/CharVector.java (rev 0)
+++ trunk/foray/foray-common/src/java/org/foray/common/CharVector.java 2008-03-12 18:33:36 UTC (rev 10424)
@@ -0,0 +1,396 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+/*
+ * Known Contributors:
+ * Carlos Villegas <ca...@un...> (Original author)
+ */
+package org.foray.common;
+
+
+import java.io.Serializable;
+
+/**
+ * A vector of chars.
+ * The main advantages of using this class instead of a plain char[] are:
+ * <ul>
+ * <li>Implementation of the CharSequence interface.</li>
+ * <li>Automatic resizing as needed, similar to the way Java Collections classes work.</li>
+ * <li>Numerous methods useful for storage, retrieval, and comparison of null-terminated char
+ * sequences in the array.</li>
+ * </ul>
+ */
+public class CharVector implements Cloneable, Serializable, CharSequence {
+
+ /** Constant used for serialization. */
+ private static final long serialVersionUID = 234670840738701586L;
+
+ /** Default Capacity increment size. */
+ private static final int DEFAULT_BLOCK_SIZE = 2048;
+
+ /** Capacity increment size. */
+ private int blockSize;
+
+ /** The encapsulated array. */
+ private char[] backingArray;
+
+ /** Points to the next free item. */
+ private int nextIndex;
+
+ /**
+ * No-argument constructor.
+ */
+ public CharVector() {
+ this(CharVector.DEFAULT_BLOCK_SIZE);
+ }
+
+ /**
+ * Constructor.
+ * @param capacity The initial capacity, in chars, of the new vector.
+ */
+ public CharVector(final int capacity) {
+ if (capacity > 0) {
+ this.blockSize = capacity;
+ } else {
+ this.blockSize = CharVector.DEFAULT_BLOCK_SIZE;
+ }
+ this.backingArray = new char[this.blockSize];
+ this.nextIndex = 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object clone() {
+ final CharVector clone = new CharVector();
+ clone.backingArray = new char[this.nextIndex];
+ System.arraycopy(this.backingArray, 0, clone.backingArray, 0,
+ this.nextIndex);
+ clone.nextIndex = this.nextIndex;
+ return clone;
+ }
+
+ /**
+ * Returns the number of items in the vector.
+ * @return The number of items in the vector.
+ */
+ public int length() {
+ return this.nextIndex;
+ }
+
+ /**
+ * Returns the current capacity of the vector.
+ * @return The currect capacity of the vector.
+ */
+ public int capacity() {
+ return this.backingArray.length;
+ }
+
+ /**
+ * Place an item in the vector at a specific index.
+ * @param index The 0-based index into the vector.
+ * @param val The char value to be placed in the vector.
+ */
+ public void put(final int index, final char val) {
+ if (index >= this.length()) {
+ throw new IndexOutOfBoundsException("Index exceeds length of vector.");
+ }
+ this.backingArray[index] = val;
+ }
+
+ /**
+ * Adds an array, or part of an array, to the end of this vector.
+ * @param source The array which should be added to this vector.
+ * @param start The 0-based index into <code>source</code> that marks the first character
+ * to be added to this vector.
+ * @param size The number of elements from <code>source</code> that should be copied to this
+ * vector.
+ * @return The index to the first char that was added.
+ */
+ public int add(final char[] source, final int start, final int size) {
+ final int startingTargetIndex = (char) alloc(size);
+ int targetIndex = startingTargetIndex;
+ for (int i = start; i < start + size; i++) {
+ this.put(targetIndex, source[i]);
+ targetIndex ++;
+ }
+ return startingTargetIndex;
+ }
+
+ /**
+ * Adds a {@link CharSequence}, or part of one, to the end of this vector.
+ * @param source The item which should be added to this vector.
+ * @param start The 0-based index into <code>source</code> that marks the first character
+ * to be added to this vector.
+ * @param size The number of elements from <code>source</code> that should be copied to this
+ * vector.
+ * @return The index to the first char that was added.
+ */
+ public int add(final CharSequence source, final int start, final int size) {
+ final int startingTargetIndex = (char) alloc(size);
+ int targetIndex = startingTargetIndex;
+ for (int i = start; i < start + size; i++) {
+ this.put(targetIndex, source.charAt(i));
+ targetIndex ++;
+ }
+ return startingTargetIndex;
+ }
+
+ /**
+ * Adds a {@link CharSequence} to the end of this vector.
+ * @param source The item which should be added to this vector.
+ * @return The index to the first char that was added.
+ */
+ public int add(final CharSequence source) {
+ return add(source, 0, source.length());
+ }
+
+ /**
+ * Adds an array, or part of an array, containing a null-terminated string, to the end of this
+ * vector.
+ * @param source The array which should be added to this vector.
+ * @param start The 0-based index into <code>source</code> that marks the first character
+ * to be added to this vector.
+ * @return The index to the first char that was added.
+ */
+ public int addNullTerminated(final char[] source, final int start) {
+ final int size = StringUtil.nullTerminatedLength(source, start);
+ return add(source, start, size);
+ }
+
+ /**
+ * Adds an array, or part of an array, containing a null-terminated string, to the end of this
+ * vector.
+ * @param source The array which should be added to this vector.
+ * @param start The 0-based index into <code>source</code> that marks the first character
+ * to be added to this vector.
+ * @return The index to the first char that was added.
+ */
+ public int addNullTerminated(final CharVector source, final int start) {
+ final int size = StringUtil.nullTerminatedLength(source.backingArray, start);
+ return add(source.backingArray, start, size);
+ }
+
+ /**
+ * Adds a char to the end of this vector.
+ * @param source The char to be added to this vector.
+ * @return The index to the char that was added.
+ */
+ public int add(final char source) {
+ final int startingIndex = (char) alloc(1);
+ this.backingArray[startingIndex] = source;
+ return startingIndex;
+ }
+
+ /**
+ * Retrieve a value from a specific index in the vector.
+ * @param index The 0-based index whose value should be returned.
+ * @return The value at <code>index</code>.
+ */
+ public char get(final int index) {
+ return this.backingArray[index];
+ }
+
+ /**
+ * Returns the size of the null-terminated String starting at a specific location.
+ * @param start The index to the first character of the String.
+ * @return The number of elements in the array starting with (and including) <code>start</code>
+ * through (but not including) the first null terminator found.
+ */
+ public int getNullTerminatedLength(final int start) {
+ return StringUtil.nullTerminatedLength(this.backingArray, start);
+ }
+
+ /**
+ * Compares a null-terminated string in this vector with another one.
+ * @param startThis The index into this vector indicating the first char in it to be tested.
+ * @param stringComp The second array to be tested.
+ * @param startComp The index into <code>arrayB</code> indicating the first
+ * char in it to be tested.
+ * @return Zero if the content of the two arrays (from their start values to
+ * the null-termination) are equal. A positive value indicates that the string in this vector
+ * has a greater numeric value. A negative value indicates that the string in the comparison
+ * array has a greater numeric value.
+ */
+ public int compareNullTerminated(final int startThis, final char[] stringComp,
+ final int startComp) {
+ int indexA = startThis;
+ int indexB = startComp;
+ while (true) {
+ if (indexA >= this.length()
+ || this.backingArray[indexA] == StringUtil.NULL_TERMINATOR) {
+ /* We are at the end of this. */
+ if (indexB >= stringComp.length) {
+ /* We are also at the end of the comparison string. The strings are equal. */
+ return 0;
+ }
+ if (stringComp[indexB] == StringUtil.NULL_TERMINATOR) {
+ /* The comparison string is null-terminated here. The strings are equal. */
+ return 0;
+ }
+ /* The strings are not equal. The comparison string is longer and therefore
+ * greater. */
+ return - stringComp[indexB];
+ }
+ if (indexB >= stringComp.length
+ || stringComp[indexB] == StringUtil.NULL_TERMINATOR) {
+ /* We are at the end of the comparison string. We have already tested above and
+ * know that we are not at the end of this. */
+ if (this.charAt(indexA) == StringUtil.NULL_TERMINATOR) {
+ /* This string is null-terminated here. The strings are equal. */
+ return 0;
+ }
+ /* The strings are not equal. This is longer than the comparison string and is
+ * therefore greater. */
+ return this.charAt(indexA);
+ }
+ if (this.backingArray[indexA] != stringComp[indexB]) {
+ /* The two strings are not equal. */
+ return this.backingArray[indexA] - stringComp[indexB];
+ }
+ indexA ++;
+ indexB ++;
+ }
+ }
+
+ /**
+ * Compares a null-terminated string in this vector with another one.
+ * @param startThis The index into this vector indicating the first char in it to be tested.
+ * @param stringComp The second array to be tested.
+ * @param startComp The index into <code>arrayB</code> indicating the first
+ * char in it to be tested.
+ * @return Zero if the content of the two arrays (from their start values to
+ * the null-termination) are equal. A positive value indicates that the string in this vector
+ * has a greater numeric value. A negative value indicates that the string in the comparison
+ * array has a greater numeric value.
+ */
+ public int compareNullTerminated(final int startThis, final CharSequence stringComp,
+ final int startComp) {
+ int indexA = startThis;
+ int indexB = startComp;
+ while (true) {
+ if (indexA >= this.length()
+ || this.backingArray[indexA] == StringUtil.NULL_TERMINATOR) {
+ /* We are at the end of this. */
+ if (indexB >= stringComp.length()) {
+ /* We are also at the end of the comparison string. The strings are equal. */
+ return 0;
+ }
+ if (stringComp.charAt(indexB) == StringUtil.NULL_TERMINATOR) {
+ /* The comparison string is null-terminated here. The strings are equal. */
+ return 0;
+ }
+ /* The strings are not equal. The comparison string is longer and therefore
+ * greater. */
+ return - stringComp.charAt(indexB);
+ }
+ if (indexB >= stringComp.length()
+ || stringComp.charAt(indexB) == StringUtil.NULL_TERMINATOR) {
+ /* We are at the end of the comparison string. We have already tested above and
+ * know that we are not at the end of this. */
+ if (this.charAt(indexA) == StringUtil.NULL_TERMINATOR) {
+ /* This string is null-terminated here. The strings are equal. */
+ return 0;
+ }
+ /* The strings are not equal. This is longer than the comparison string and is
+ * therefore greater. */
+ return this.charAt(indexA);
+ }
+ if (this.backingArray[indexA] != stringComp.charAt(indexB)) {
+ /* The two strings are not equal. */
+ return this.backingArray[indexA] - stringComp.charAt(indexB);
+ }
+ indexA ++;
+ indexB ++;
+ }
+ }
+
+ /**
+ * Allocates or uses a specified number of elements (chars).
+ * If needed, this method automatically increases the vector's capacity.
+ * @param size The number of elements (chars) to be allocated.
+ * @return The index to the beginning of the allocated elements (chars).
+ */
+ public int alloc(final int size) {
+ final int index = this.nextIndex;
+ if (this.nextIndex + size >= this.backingArray.length) {
+ final char[] newArray = new char[this.backingArray.length
+ + this.blockSize];
+ System.arraycopy(this.backingArray, 0, newArray, 0,
+ this.backingArray.length);
+ this.backingArray = newArray;
+ }
+ this.nextIndex += size;
+ return index;
+ }
+
+ /**
+ * Sets the capacity of this vector equal to its size, to that there is no
+ * unused capacity.
+ */
+ public void trimToSize() {
+ if (this.nextIndex < this.backingArray.length) {
+ final char[] aux = new char[this.nextIndex];
+ System.arraycopy(this.backingArray, 0, aux, 0, this.nextIndex);
+ this.backingArray = aux;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ * Overrides method in {@link Object} to properly conform to the {@link CharSequence} interface.
+ */
+ @Override
+ public String toString() {
+ return new String(this.backingArray);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public CharSequence subSequence(final int start, final int end) {
+ if (start < 0
+ || end < 0
+ || end > length()
+ || start > end) {
+ throw new IndexOutOfBoundsException("Illegal sub-sequence bounds.");
+ }
+ final int subSize = end - start;
+ final CharVector subVector = new CharVector(subSize);
+ subVector.add(this.backingArray, start, subSize);
+ return subVector;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public char charAt(final int index) {
+ return this.backingArray[index];
+ }
+
+}
Copied: trunk/foray/foray-common/src/javatest/org/foray/common/TestCharVector.java (from rev 10392, trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/TestCharVector.java)
===================================================================
--- trunk/foray/foray-common/src/javatest/org/foray/common/TestCharVector.java (rev 0)
+++ trunk/foray/foray-common/src/javatest/org/foray/common/TestCharVector.java 2008-03-12 18:33:36 UTC (rev 10424)
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2008 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.common;
+
+import junit.framework.TestCase;
+
+/**
+ * JUnit test class for the class {@link CharVector}.
+ */
+public class TestCharVector extends TestCase {
+
+ /**
+ * Creates and returns a standard CharVector instance suitable for testing.
+ * @return A CharVector instance suitable for testing.
+ */
+ private CharVector getTestVector() {
+ final CharVector testVector = new CharVector();
+ testVector.add("firstWord");
+ assertEquals(9, testVector.length());
+ testVector.add(StringUtil.NULL_TERMINATOR);
+ assertEquals(10, testVector.length());
+ testVector.add("secondWord".toCharArray(), 0, 10);
+ assertEquals(20, testVector.length());
+ testVector.add(StringUtil.NULL_TERMINATOR);
+ assertEquals(21, testVector.length());
+ testVector.add("thirdWord");
+ /* Leave off the trailing null terminator, to allows tests that will treat the end of the
+ * array as the terminator. */
+ assertEquals(30, testVector.length());
+ return testVector;
+ }
+
+ /**
+ * Tests of {@link CharVector#compareNullTerminated(int, CharSequence, int)}.
+ */
+ public void testCompareNullTerminated() {
+ final CharVector testVector = this.getTestVector();
+
+ int comparison = testVector.compareNullTerminated(0, "firstWord", 0);
+ assertEquals(0, comparison);
+ comparison = testVector.compareNullTerminated(0, "firstWor", 0);
+ assertTrue(comparison > 0);
+ comparison = testVector.compareNullTerminated(0, "firstWord2", 0);
+ assertTrue(comparison < 0);
+
+ comparison = testVector.compareNullTerminated(10, "secondWord" + StringUtil.NULL_TERMINATOR
+ + "something", 0);
+ assertEquals(0, comparison);
+ comparison = testVector.compareNullTerminated(10, "secondWor" + StringUtil.NULL_TERMINATOR
+ + "d something", 0);
+ assertTrue(comparison > 0);
+ comparison = testVector.compareNullTerminated(10, "secondWord2" + StringUtil.NULL_TERMINATOR
+ + "something", 0);
+ assertTrue(comparison < 0);
+ }
+
+}
Modified: trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java
===================================================================
--- trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java 2008-03-11 17:40:56 UTC (rev 10423)
+++ trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java 2008-03-12 18:33:36 UTC (rev 10424)
@@ -70,7 +70,10 @@
*/
public static Test suite() {
final TestSuite testSuite = new TestSuite();
+
+ testSuite.addTestSuite(TestCharVector.class);
testSuite.addTestSuite(TestUnicodeChar.class);
+
return testSuite;
}
Deleted: trunk/foray/foray-hyphen/src/java/org/foray/hyphen/ByteVector.java
===================================================================
--- trunk/foray/foray-hyphen/src/java/org/foray/hyphen/ByteVector.java 2008-03-11 17:40:56 UTC (rev 10423)
+++ trunk/foray/foray-hyphen/src/java/org/foray/hyphen/ByteVector.java 2008-03-12 18:33:36 UTC (rev 10424)
@@ -1,144 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-/*
- * Known Contributors:
- * Carlos Villegas <ca...@un...> (Original author)
- */
-
-package org.foray.hyphen;
-
-import java.io.Serializable;
-
-/**
- * A vector of bytes.
- */
-public class ByteVector implements Serializable {
-
- /** Constant needed for serialization. */
- static final long serialVersionUID = 977379027446677063L;
-
- /** Default Capacity increment size. */
- private static final int DEFAULT_BLOCK_SIZE = 2048;
-
- /** Capacity increment size. */
- private int blockSize = ByteVector.DEFAULT_BLOCK_SIZE;
-
- /** The encapsulated array. */
- private byte[] backingArray;
-
- /** Index to to the next free item in {@link #backingArray}. */
- private int nextIndex;
-
- /**
- * No-argument constructor.
- */
- public ByteVector() {
- this(ByteVector.DEFAULT_BLOCK_SIZE);
- }
-
- /**
- * Constructor.
- * @param capacity The initial capacity, in bytes, of the new vector.
- */
- public ByteVector(final int capacity) {
- if (capacity > 0) {
- this.blockSize = capacity;
- } else {
- this.blockSize = ByteVector.DEFAULT_BLOCK_SIZE;
- }
- this.backingArray = new byte[this.blockSize];
- this.nextIndex = 0;
- }
-
- /**
- * Returns the number of items in the vector.
- * @return The number of items in the vector.
- */
- public int length() {
- return this.nextIndex;
- }
-
- /**
- * Returns the current capacity of the vector.
- * @return The currect capacity of the vector.
- */
- public int capacity() {
- return this.backingArray.length;
- }
-
- /**
- * Place an item in the vector at a specific index.
- * @param index The 0-based index into the vector.
- * @param val The byte value to be placed in the vector.
- */
- public void put(final int index, final byte val) {
- this.backingArray[index] = val;
- }
-
- /**
- * Retrieve a value from a specific index in the vector.
- * @param index The 0-based index whose value should be returned.
- * @return The value at <code>index</code>.
- */
- public byte get(final int index) {
- return this.backingArray[index];
- }
-
- /**
- * Allocates or uses a specified number of elements (bytes).
- * If needed, this method automatically increases the vector's capacity.
- * @param size The number of elements (bytes) to be allocated.
- * @return The index to the beginning of the allocated elements (bytes).
- */
- public int alloc(final int size) {
- final int index = this.nextIndex;
- if (this.nextIndex + size >= this.backingArray.length) {
- final byte[] newArray = new byte[this.backingArray.length
- + this.blockSize];
- System.arraycopy(this.backingArray, 0, newArray, 0,
- ...
[truncated message content] |
|
From: <vic...@us...> - 2008-03-12 18:52:41
|
Revision: 10426
http://foray.svn.sourceforge.net/foray/?rev=10426&view=rev
Author: victormote
Date: 2008-03-12 11:52:46 -0700 (Wed, 12 Mar 2008)
Log Message:
-----------
Reserialize the hyphenation patterns to use the new path for CharVector.
Modified Paths:
--------------
trunk/foray/foray-app/.classpath
Added Paths:
-----------
trunk/foray/lib/foray-hyphen-0.4-rsrc.jar
Removed Paths:
-------------
trunk/foray/lib/foray-hyphen-0.3-rsrc.jar
Modified: trunk/foray/foray-app/.classpath
===================================================================
--- trunk/foray/foray-app/.classpath 2008-03-12 18:36:49 UTC (rev 10425)
+++ trunk/foray/foray-app/.classpath 2008-03-12 18:52:46 UTC (rev 10426)
@@ -36,8 +36,8 @@
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslSpeech"/>
<classpathentry combineaccessrules="false" kind="src" path="/FOraySpeech"/>
- <classpathentry kind="lib" path="/FOray Lib/foray-hyphen-0.3-rsrc.jar"/>
<classpathentry kind="lib" path="/FOray Lib-Build/ant/ant.jar"/>
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit-4.4.jar" sourcepath="/FOray Lib-Build/junit/junit-4.4-src.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/foray-hyphen-0.4-rsrc.jar"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Deleted: trunk/foray/lib/foray-hyphen-0.3-rsrc.jar
===================================================================
(Binary files differ)
Added: trunk/foray/lib/foray-hyphen-0.4-rsrc.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/foray-hyphen-0.4-rsrc.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-03-14 16:20:58
|
Revision: 10434
http://foray.svn.sourceforge.net/foray/?rev=10434&view=rev
Author: victormote
Date: 2008-03-14 09:20:40 -0700 (Fri, 14 Mar 2008)
Log Message:
-----------
Conform to axsl changes returning CharSequence instead of char[] for text items.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java
trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/FOLineText.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/axsl/obj/Metadata.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTitle.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Character.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/CharacterSequence4a.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageNumber.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageNumberCitation.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageNumberCitationLast.java
trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FOTextPL.java
trunk/foray/foray-text/src/java/org/foray/text/line/EagerLineBreaker.java
trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java 2008-03-13 23:03:38 UTC (rev 10433)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java 2008-03-14 16:20:40 UTC (rev 10434)
@@ -122,7 +122,7 @@
final OrderedTreeNode otn = iterator.next();
if (otn instanceof TextArea) {
final TextArea textArea = (TextArea) otn;
- final char[] text = textArea.getRawText();
+ final CharSequence text = textArea.getRawText();
builder.append(text);
}
}
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2008-03-13 23:03:38 UTC (rev 10433)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2008-03-14 16:20:40 UTC (rev 10434)
@@ -972,7 +972,7 @@
}
/* If the final text will be empty, don't create the TextArea. */
- final char[] rawText = foText.getAreaTreeText(context);
+ final CharSequence rawText = foText.getAreaTreeText(context);
final boolean isFirstItemOnline = parentArea.getChildren().size() == 0;
final int ignoreAtStart = TextArea.ignoreAtStart(rawText, startOffset,
sizeInChars, isFirstItemOnline,
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2008-03-13 23:03:38 UTC (rev 10433)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2008-03-14 16:20:40 UTC (rev 10434)
@@ -277,7 +277,7 @@
* @return The text to be used in the output document.
*/
public char[] getText() {
- final char[] rawText = this.getTextContent().getAreaTreeText(this);
+ final CharSequence rawText = this.getTextContent().getAreaTreeText(this);
// Count of whitespace that should be ignored at start of array.
final int ignoreAtStart = ignoreAtStart(rawText, this.backingOffset,
this.backingSize, this.isFirstChildOfParent(),
@@ -297,9 +297,9 @@
discretionaryHyphenSize = Character.charCount(hyphenChar);
}
arraySize += discretionaryHyphenSize;
- final char[] returnChars = new char[arraySize];
- System.arraycopy(rawText, this.backingOffset + ignoreAtStart,
- returnChars, 0, returnChars.length);
+ final int start = this.backingOffset + ignoreAtStart;
+ final CharSequence returnSequence = rawText.subSequence(start, start + arraySize);
+ final char[] returnChars = returnSequence.toString().toCharArray();
if (this.hasDiscretionaryHyphen) {
if (discretionaryHyphenSize == 1) {
returnChars[returnChars.length - discretionaryHyphenSize]
@@ -341,12 +341,9 @@
* adjustments.
* @return The raw text from the FO Tree.
*/
- public char[] getRawText() {
- final char[] areaTreeText = this.getTextContent().getAreaTreeText(this);
- final char[] returnArray = new char[this.backingSize];
- System.arraycopy(areaTreeText, this.backingOffset, returnArray, 0,
- returnArray.length);
- return returnArray;
+ public CharSequence getRawText() {
+ final CharSequence foText = this.getTextContent().getAreaTreeText(this);
+ return foText.subSequence(this.backingOffset, this.backingOffset + this.backingSize);
}
/**
@@ -432,7 +429,7 @@
* @param whiteSpaceTreatment The white-space treatment value.
* @return The number of characters that should be ignored.
*/
- public static int ignoreAtStart(final char[] chars, final int start,
+ public static int ignoreAtStart(final CharSequence chars, final int start,
final int size, final boolean firstItemOnLine,
final WhiteSpaceTreatment whiteSpaceTreatment) {
// Only eat leading whitespaces if this is the first item on the line.
@@ -455,7 +452,7 @@
*/
int count = 0;
for (int i = start; i < start + size; i++) {
- final char c = chars[i];
+ final char c = chars.charAt(i);
if (! XMLCharacter.isXMLWhitespace(c)
|| c == WKConstants.LINEFEED) {
return count;
@@ -476,7 +473,7 @@
* @param whiteSpaceTreatment The white-space treatment value.
* @return The number of characters that should be ignored.
*/
- public static int ignoreAtEnd(final char[] chars, final int start,
+ public static int ignoreAtEnd(final CharSequence chars, final int start,
final int size, final boolean lastItemOnLine,
final WhiteSpaceTreatment whiteSpaceTreatment) {
// Only eat trailing whitespaces if this is the last item on the line.
@@ -499,7 +496,7 @@
*/
int count = 0;
for (int i = start + size - 1; i >= start; i--) {
- final char c = chars[i];
+ final char c = chars.charAt(i);
if (! XMLCharacter.isXMLWhitespace(c)
|| c == WKConstants.LINEFEED) {
return count;
@@ -619,15 +616,15 @@
* @return True iff this text-area ends with a linefeed.
*/
public boolean endsWithLinefeed() {
- final char[] rawText = this.getTextContent().getAreaTreeText(this);
+ final CharSequence rawText = this.getTextContent().getAreaTreeText(this);
if (rawText == null) {
return false;
}
- if (rawText.length < 1) {
+ if (rawText.length() < 1) {
return false;
}
- final int lastCharIndex = rawText.length - 1;
- if (rawText[lastCharIndex] == WKConstants.LINEFEED) {
+ final int lastCharIndex = rawText.length() - 1;
+ if (rawText.charAt(lastCharIndex) == WKConstants.LINEFEED) {
return true;
}
return false;
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/FOLineText.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/FOLineText.java 2008-03-13 23:03:38 UTC (rev 10433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FOLineText.java 2008-03-14 16:20:40 UTC (rev 10434)
@@ -61,14 +61,14 @@
/**
* {@inheritDoc}
*/
- public char[] inlineText() {
+ public CharSequence inlineText() {
return this.realLineText.inlineText(this.context);
}
/**
* {@inheritDoc}
*/
- public char[] inlineText(final FoContext context) {
+ public CharSequence inlineText(final FoContext context) {
return this.realLineText.inlineText(context);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java 2008-03-13 23:03:38 UTC (rev 10433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java 2008-03-14 16:20:40 UTC (rev 10434)
@@ -29,6 +29,7 @@
package org.foray.fotree;
import org.foray.common.AbstractOrderedTreeNode;
+import org.foray.common.CharVector;
import org.foray.common.FontUtil;
import org.foray.common.OrderedTreeNode;
import org.foray.common.UnicodeChar;
@@ -415,10 +416,10 @@
protected static final List<FObj> EMPTY_CHILD_LIST =
Collections.emptyList();
- /** Static array containing one space, to be used for obtaining a font
+ /** Static CharSequence containing one space, to be used for obtaining a font
* for the page-citation-* objects. */
- protected static final char[] PAGE_CITATION_TEXT_SEGMENT =
- new char[] { ' ' };
+ protected static final CharSequence PAGE_CITATION_TEXT_SEGMENT = new CharVector(
+ new char[] { ' ' });
/** The path to the document from which this object was parsed, if any. */
private String systemId;
@@ -4007,7 +4008,7 @@
final FoContext context) {
org.axsl.font.FontUse resolvedFont = null;
try {
- final char[] firstTextSegment = this.firstTextSegment();
+ final CharSequence firstTextSegment = this.firstTextSegment();
int firstChar = UnicodeChar.firstPrintable(firstTextSegment);
if (firstChar == WKConstants.INVALID_UNICODE_CHARACTER) {
/* There are no printable characters in the first text segment,
@@ -4121,7 +4122,7 @@
* Returns the underlying text of the first descendant text item.
* @return The underlying text of the first descendant text item.
*/
- public char[] firstTextSegment() {
+ public CharSequence firstTextSegment() {
final LineText firstLineText = firstLineText();
if (firstLineText == null) {
return null;
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/axsl/obj/Metadata.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/axsl/obj/Metadata.java 2008-03-13 23:03:38 UTC (rev 10433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/axsl/obj/Metadata.java 2008-03-14 16:20:40 UTC (rev 10434)
@@ -175,7 +175,7 @@
/* Existence and casting verified at validateDescendants(). */
final CharacterSequence4a text =
(CharacterSequence4a) this.getChildAt(0);
- return new String(text.getAreaTreeText(null));
+ return text.getAreaTreeText(null).toString();
}
/**
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTitle.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTitle.java 2008-03-13 23:03:38 UTC (rev 10433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTitle.java 2008-03-14 16:20:40 UTC (rev 10434)
@@ -246,8 +246,8 @@
return WKConstants.EMPTY_STRING;
}
final CharacterSequence4a child = this.getChildAt(0);
- final char[] text = child.getAreaTreeText(null);
- return new String(text);
+ final CharSequence text = child.getAreaTreeText(null);
+ return text.toString();
}
/**
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Character.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Character.java 2008-03-13 23:03:38 UTC (rev 10433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Character.java 2008-03-14 16:20:40 UTC (rev 10434)
@@ -139,7 +139,7 @@
/**
* {@inheritDoc}
*/
- public char[] getAreaTreeText(final FoContext context) {
+ public CharSequence getAreaTreeText(final FoContext context) {
final CharacterSequence4a text =
(CharacterSequence4a) this.getChildren().get(0);
return text.getAreaTreeText(context);
@@ -198,14 +198,14 @@
/**
* {@inheritDoc}
*/
- public char[] inlineText() {
+ public CharSequence inlineText() {
return this.inlineText(null);
}
/**
* {@inheritDoc}
*/
- public char[] inlineText(final FoContext context) {
+ public CharSequence inlineText(final FoContext context) {
return getAreaTreeText(context);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/CharacterSequence4a.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/CharacterSequence4a.java 2008-03-13 23:03:38 UTC (rev 10433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/CharacterSequence4a.java 2008-03-14 16:20:40 UTC (rev 10434)
@@ -28,6 +28,7 @@
package org.foray.fotree.fo.obj;
+import org.foray.common.CharVector;
import org.foray.common.WKConstants;
import org.foray.common.XMLCharacter;
import org.foray.fotree.FObj;
@@ -93,7 +94,7 @@
private FObj parent;
/** The raw text content. */
- private char[] ca;
+ private CharVector ca;
/** The current status of the filtering of this text item. */
private byte filterStatus = CharacterSequence4a.FILTER_RAW;
@@ -119,7 +120,7 @@
public CharacterSequence4a(final FObj parent, final char[] chars) {
super(parent);
this.parent = parent;
- this.ca = chars;
+ this.ca = new CharVector(chars);
filterContent();
}
@@ -170,8 +171,8 @@
* @return True iff all of the text in this item is whitespace.
*/
public boolean isAllWhiteSpace() {
- for (int i = 0; i < this.ca.length; i++) {
- final char ch = this.ca[i];
+ for (int i = 0; i < this.ca.length(); i++) {
+ final char ch = this.ca.charAt(i);
if ((ch == ' ')
|| (ch == '\n')
|| (ch == '\r')
@@ -198,7 +199,7 @@
*
* @return The text that should appear in the refined FO tree.
*/
- public char[] getRefinedText(final FoContext context) {
+ public CharVector getRefinedText(final FoContext context) {
/* TODO: This needs to come from effectiveParent, with context. */
final FObj effectiveParent = this.getParent();
if (this.filterStatus >= CharacterSequence4a.FILTER_REFINED_FO_TREE) {
@@ -206,14 +207,14 @@
return this.ca;
}
- final char[] charArray = getPreTextTransformText(context);
+ final CharVector charArray = getPreTextTransformText(context);
// Now handle text-transform.
final TextTransform textTransform = effectiveParent.traitTextTransform(
context);
if (textTransform != TextTransform.NONE) {
- for (int i = 0; i < charArray.length; i++) {
- charArray[i] = applyTextTransform(context, charArray, i,
- textTransform);
+ for (int i = 0; i < charArray.length(); i++) {
+ charArray.put(i, applyTextTransform(context, charArray, i,
+ textTransform));
}
}
@@ -242,7 +243,7 @@
* @return The text that should appear in the refined FO tree, except that
* text-transform is not applied.
*/
- private char[] getPreTextTransformText(final FoContext context) {
+ private CharVector getPreTextTransformText(final FoContext context) {
final FObj effectiveParent = this.effectiveParent(context);
if (this.filterStatus >= CharacterSequence4a.FILTER_PRE_TRANSFORM) {
/* The stored text has already been filtered. Just return it. */
@@ -250,7 +251,7 @@
}
/* Must handle white-space-treatment first. */
- char[] workArray = applyWhiteSpaceTreatment(this.ca,
+ CharVector workArray = applyWhiteSpaceTreatment(this.ca,
effectiveParent.traitWhiteSpaceTreatment(context));
// Now handle linefeed-treatment.
@@ -275,9 +276,9 @@
* @return The transformed char.
*/
private char applyTextTransform(final FoContext context,
- final char[] charArray, final int index,
+ final CharSequence charArray, final int index,
final TextTransform textTransform) {
- final char c = charArray[index];
+ final char c = charArray.charAt(index);
switch (textTransform) {
/* This method not be entered if value is NONE. */
case UPPERCASE:
@@ -305,7 +306,7 @@
*/
return c;
}
- return charArray[index];
+ return charArray.charAt(index);
}
/**
@@ -326,7 +327,7 @@
* word.
*/
private boolean isStartOfWord(final FoContext context,
- final char[] charArray, final int index) {
+ final CharSequence charArray, final int index) {
final char prevChar = getRelativeCharInBlock(context, charArray,
index, -1);
/* All we are really concerned about here is of what type prevChar
@@ -464,26 +465,26 @@
* the offset points to an area outside of the block.
*/
private char getRelativeCharInBlock(final FoContext context,
- final char[] charArray, final int index, final int offset) {
+ final CharSequence charArray, final int index, final int offset) {
// The easy case is where the desired character is in the same FOText
final int desiredIndex = index + offset;
- if (desiredIndex >= 0 && desiredIndex < charArray.length) {
- return this.ca[desiredIndex];
+ if (desiredIndex >= 0 && desiredIndex < charArray.length()) {
+ return this.ca.charAt(desiredIndex);
}
int remainingOffset = 0;
if (offset > 0) {
// Look in subsequent text items.
- remainingOffset = offset - (charArray.length - 1 - index);
+ remainingOffset = offset - (charArray.length() - 1 - index);
CharacterSequence4a nextFOText =
this.getNextContiguousTextInBlock();
while (nextFOText != null) {
- final char[] nextText =
+ final CharVector nextText =
nextFOText.getPreTextTransformText(context);
- if (nextText.length >= remainingOffset) {
- return nextText[remainingOffset - 1];
+ if (nextText.length() >= remainingOffset) {
+ return nextText.charAt(remainingOffset - 1);
}
- remainingOffset -= nextText.length;
+ remainingOffset -= nextText.length();
nextFOText = nextFOText.getNextContiguousTextInBlock();
}
return 0x0000;
@@ -493,11 +494,11 @@
CharacterSequence4a prevFOText =
this.getPreviousContiguousTextInBlock();
while (prevFOText != null) {
- final char[] prevText = prevFOText.getPreTextTransformText(context);
- if (prevText.length >= Math.abs(remainingOffset)) {
- return prevText[prevText.length + remainingOffset];
+ final CharVector prevText = prevFOText.getPreTextTransformText(context);
+ if (prevText.length() >= Math.abs(remainingOffset)) {
+ return prevText.charAt(prevText.length() + remainingOffset);
}
- remainingOffset += prevText.length;
+ remainingOffset += prevText.length();
prevFOText = prevFOText.getPreviousContiguousTextInBlock();
}
return 0x0000;
@@ -517,7 +518,7 @@
* issues.
* @return The text that should appear in the area tree.
*/
- public char[] getAreaTreeText(final FoContext context) {
+ public CharSequence getAreaTreeText(final FoContext context) {
final FObj effectiveParent = this.getParent();
if (this.filterStatus >= CharacterSequence4a.FILTER_AREA_TREE) {
/* The stored text has already been filtered. Just return it. */
@@ -525,7 +526,7 @@
}
// Start with the refined FO Tree text
- char[] returnArray = getRefinedText(context);
+ CharVector returnArray = getRefinedText(context);
// Apply white-space-collapse.
final boolean whiteSpaceCollapse =
effectiveParent.traitWhiteSpaceCollapse(context);
@@ -541,14 +542,14 @@
/**
* {@inheritDoc}
*/
- public char[] inlineText() {
+ public CharSequence inlineText() {
return this.inlineText(null);
}
/**
* {@inheritDoc}
*/
- public char[] inlineText(final FoContext context) {
+ public CharSequence inlineText(final FoContext context) {
return getAreaTreeText(context);
}
@@ -808,9 +809,9 @@
* Note that {@link #DISCARD_CHAR} is not a valid Unicode codepoint, and
* should therefore never be in the input.
*/
- public static char applyWhiteSpaceTreatment(final char[] charArray,
+ public static char applyWhiteSpaceTreatment(final CharSequence charArray,
final int index, final WhiteSpaceTreatment whiteSpaceTreatment) {
- final char c = charArray[index];
+ final char c = charArray.charAt(index);
if (! XMLCharacter.isXMLWhitespace(c)) {
/* If it is not whitespace, it cannot be changed. */
return c;
@@ -828,10 +829,10 @@
}
case IGNORE_IF_BEFORE_LINEFEED: {
// If last element, no change needed.
- if (index == charArray.length - 1) {
+ if (index == charArray.length() - 1) {
return c;
}
- if (charArray[index + 1] != WKConstants.LINEFEED) {
+ if (charArray.charAt(index + 1) != WKConstants.LINEFEED) {
return c;
}
return CharacterSequence4a.DISCARD_CHAR;
@@ -841,7 +842,7 @@
if (index == 0) {
return c;
}
- if (charArray[index - 1] != WKConstants.LINEFEED) {
+ if (charArray.charAt(index - 1) != WKConstants.LINEFEED) {
return c;
}
return CharacterSequence4a.DISCARD_CHAR;
@@ -853,22 +854,22 @@
default: {
// If first element, only check next.
if (index == 0) {
- if (index < charArray.length - 1
- && charArray[index + 1] == WKConstants.LINEFEED) {
+ if (index < charArray.length() - 1
+ && charArray.charAt(index + 1) == WKConstants.LINEFEED) {
return CharacterSequence4a.DISCARD_CHAR;
}
return c;
}
// If last element, only check previous
- if (index >= charArray.length - 1) {
- if (charArray[index - 1] == WKConstants.LINEFEED) {
+ if (index >= charArray.length() - 1) {
+ if (charArray.charAt(index - 1) == WKConstants.LINEFEED) {
return CharacterSequence4a.DISCARD_CHAR;
}
return c;
}
// Otherwise, check both
- if (charArray[index - 1] == WKConstants.LINEFEED
- || charArray[index + 1] == WKConstants.LINEFEED) {
+ if (charArray.charAt(index - 1) == WKConstants.LINEFEED
+ || charArray.charAt(index + 1) == WKConstants.LINEFEED) {
return CharacterSequence4a.DISCARD_CHAR;
}
return c;
@@ -890,7 +891,7 @@
* white-space-treatment, <code>charArray</code> is returned.
* Otherwise, a new char array with the result is returned.
*/
- public static char[] applyWhiteSpaceTreatment(final char[] charArray,
+ public static CharVector applyWhiteSpaceTreatment(final CharVector charArray,
final WhiteSpaceTreatment inputWhiteSpaceTreatment) {
WhiteSpaceTreatment whiteSpaceTreatment = inputWhiteSpaceTreatment;
switch (whiteSpaceTreatment) {
@@ -912,8 +913,8 @@
int discardElements = 0;
int changeElements = 0;
- for (int i = 0; i < charArray.length; i++) {
- final char c = charArray[i];
+ for (int i = 0; i < charArray.length(); i++) {
+ final char c = charArray.charAt(i);
final char conversionChar = applyWhiteSpaceTreatment(charArray, i,
whiteSpaceTreatment);
if (conversionChar == CharacterSequence4a.DISCARD_CHAR) {
@@ -929,10 +930,10 @@
/* We now know that changes of some sort must be made. Create a new
* array in which to put the results. */
- final char[] returnArray = new char[charArray.length - discardElements];
+ final char[] returnArray = new char[charArray.length() - discardElements];
discardElements = 0;
- for (int i = 0; i < charArray.length; i++) {
+ for (int i = 0; i < charArray.length(); i++) {
final char conversionChar = applyWhiteSpaceTreatment(charArray,
i, whiteSpaceTreatment);
if (conversionChar == CharacterSequence4a.DISCARD_CHAR) {
@@ -941,7 +942,7 @@
returnArray[i - discardElements] = conversionChar;
}
}
- return returnArray;
+ return new CharVector(returnArray);
}
/**
@@ -987,7 +988,7 @@
* <code>charArray</code> is returned. Otherwise, a new char array with the
* result is returned.
*/
- public static char[] applyLinefeedTreatment(final char[] charArray,
+ public static CharVector applyLinefeedTreatment(final CharVector charArray,
final LinefeedTreatment inputLinefeedTreatment) {
LinefeedTreatment linefeedTreatment = inputLinefeedTreatment;
switch (linefeedTreatment) {
@@ -1009,8 +1010,8 @@
int discardElements = 0;
int changeElements = 0;
- for (int i = 0; i < charArray.length; i++) {
- final char c = charArray[i];
+ for (int i = 0; i < charArray.length(); i++) {
+ final char c = charArray.charAt(i);
if (c == WKConstants.LINEFEED) {
if (linefeedTreatment == LinefeedTreatment.IGNORE) {
discardElements ++;
@@ -1026,10 +1027,10 @@
/* We now know that changes of some sort must be made. Create a new
* array in which to put the results. */
- final char[] returnArray = new char[charArray.length - discardElements];
+ final char[] returnArray = new char[charArray.length() - discardElements];
discardElements = 0;
- for (int i = 0; i < charArray.length; i++) {
- final char c = charArray[i];
+ for (int i = 0; i < charArray.length(); i++) {
+ final char c = charArray.charAt(i);
if (c == WKConstants.LINEFEED) {
final char conversionChar = applyLinefeedTreatment(c,
linefeedTreatment);
@@ -1042,7 +1043,7 @@
returnArray[i - discardElements] = c;
}
}
- return returnArray;
+ return new CharVector(returnArray);
}
/**
@@ -1057,9 +1058,9 @@
* if the next character is a line-feed.
* If neither of these is true, returns the original character.
*/
- public static char applyWhiteSpaceCollapse(final char[] charArray,
+ public static char applyWhiteSpaceCollapse(final CharSequence charArray,
final int index) {
- final char c = charArray[index];
+ final char c = charArray.charAt(index);
if (! XMLCharacter.isXMLWhitespace(c)) {
/* If it is not whitespace, nothing should change. */
return c;
@@ -1069,11 +1070,11 @@
return c;
}
if (index != 0 && XMLCharacter.isXMLWhitespace(
- charArray[index - 1])) {
+ charArray.charAt(index - 1))) {
return CharacterSequence4a.DISCARD_CHAR;
}
- if (index < charArray.length - 1
- && charArray[index + 1] == WKConstants.LINEFEED) {
+ if (index < charArray.length() - 1
+ && charArray.charAt(index + 1) == WKConstants.LINEFEED) {
return CharacterSequence4a.DISCARD_CHAR;
}
return c;
@@ -1091,14 +1092,14 @@
* white-space-collapse, <code>charArray</code> is returned.
* Otherwise, a new char array with the result is returned.
*/
- public static char[] applyWhiteSpaceCollapse(final char[] charArray,
+ public static CharVector applyWhiteSpaceCollapse(final CharVector charArray,
final boolean whiteSpaceCollapse) {
if (! whiteSpaceCollapse) {
return charArray;
}
int discardElements = 0;
- for (int i = 0; i < charArray.length; i++) {
+ for (int i = 0; i < charArray.length(); i++) {
final char convertChar = applyWhiteSpaceCollapse(charArray, i);
if (convertChar == CharacterSequence4a.DISCARD_CHAR) {
discardElements ++;
@@ -1111,9 +1112,9 @@
/* We now know that changes of some sort must be made. Create a new
* array in which to put the results. */
- final char[] returnArray = new char[charArray.length - discardElements];
+ final char[] returnArray = new char[charArray.length() - ...
[truncated message content] |
|
From: <vic...@us...> - 2008-03-14 16:54:39
|
Revision: 10435
http://foray.svn.sourceforge.net/foray/?rev=10435&view=rev
Author: victormote
Date: 2008-03-14 09:54:45 -0700 (Fri, 14 Mar 2008)
Log Message:
-----------
Conform to axsl changes returning CharSequence instead of char[] for text items.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/java/org/foray/area/LeaderArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationLastArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/ScalingValueCitationArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java
trunk/foray/foray-common/src/java/org/foray/common/XMLCharacter.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java
trunk/foray/foray-render/src/java/org/foray/render/PrintRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/Renderer.java
trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/LeaderArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/LeaderArea.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/LeaderArea.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -28,6 +28,8 @@
package org.foray.area;
+import org.foray.common.CharVector;
+
import org.axsl.area.AreaTreeException;
import org.axsl.common.value.LeaderAlignment;
import org.axsl.common.value.LeaderPattern;
@@ -322,14 +324,14 @@
/**
* {@inheritDoc}
*/
- public char[] getText() {
+ public CharSequence getText() {
return this.dotLeaderText();
}
/**
* {@inheritDoc}
*/
- public char[] dotLeaderText() {
+ public CharSequence dotLeaderText() {
/* Note that we are not concerned here with optimizing the size of the
* leader itself. That needs to be done prior to rendering. */
final int qtyCycles = qtyDotLeaderCycles();
@@ -345,7 +347,7 @@
leaderText[i] = ' ';
}
}
- return leaderText;
+ return new CharVector(leaderText);
}
/**
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberArea.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberArea.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -125,10 +125,10 @@
/**
* {@inheritDoc}
*/
- public char[] getText() {
+ public CharSequence getText() {
final String text = getPage().getFormattedNumber();
setProgressionDimension(getWordWidth(text));
- return text.toCharArray();
+ return text;
}
/**
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationArea.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationArea.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -132,7 +132,7 @@
/**
* {@inheritDoc}
*/
- public char[] getText() {
+ public CharSequence getText() {
final Area area = getAreaTree().firstNormalAreaReturned(traitRefId());
String text = null;
if (area == null) {
@@ -141,7 +141,7 @@
text = area.getPage().getFormattedNumber();
}
setProgressionDimension(getWordWidth(text));
- return text.toCharArray();
+ return text;
}
/**
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationLastArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationLastArea.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationLastArea.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -133,7 +133,7 @@
/**
* {@inheritDoc}
*/
- public char[] getText() {
+ public CharSequence getText() {
final Area area = getAreaTree().firstNormalAreaReturned(traitRefId());
String text = null;
if (area == null) {
@@ -142,7 +142,7 @@
text = area.getPage().getFormattedNumber();
}
setProgressionDimension(getWordWidth(text));
- return text.toCharArray();
+ return text;
}
/**
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/ScalingValueCitationArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/ScalingValueCitationArea.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/ScalingValueCitationArea.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -133,10 +133,10 @@
/**
* {@inheritDoc}
*/
- public char[] getText() {
+ public CharSequence getText() {
final String text = getPage().getFormattedNumber();
setProgressionDimension(getWordWidth(text));
- return text.toCharArray();
+ return text;
}
/**
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -28,6 +28,7 @@
package org.foray.area;
+import org.foray.common.CharVector;
import org.foray.common.WKConstants;
import org.foray.common.XMLCharacter;
@@ -276,7 +277,7 @@
*
* @return The text to be used in the output document.
*/
- public char[] getText() {
+ public CharSequence getText() {
final CharSequence rawText = this.getTextContent().getAreaTreeText(this);
// Count of whitespace that should be ignored at start of array.
final int ignoreAtStart = ignoreAtStart(rawText, this.backingOffset,
@@ -288,7 +289,7 @@
traitWhiteSpaceTreatment());
if (ignoreAtStart + ignoreAtEnd >= this.backingSize) {
// In case it was all whitespace, which shouldn't happen
- return new char[0];
+ return WKConstants.EMPTY_STRING;
}
int arraySize = this.backingSize - ignoreAtStart - ignoreAtEnd;
final int hyphenChar = this.traitHyphenationCharacter();
@@ -320,7 +321,7 @@
returnChars[i] = java.lang.Character.toUpperCase(c);
}
}
- return returnChars;
+ return new CharVector(returnChars);
}
/**
@@ -568,9 +569,9 @@
*/
public int countSpaces() {
int spaceCount = 0;
- final char[] text = this.getText();
- for (int i = 0; i < text.length; i++) {
- if (wordSpacingApplies(text[i])) {
+ final CharSequence text = this.getText();
+ for (int i = 0; i < text.length(); i++) {
+ if (wordSpacingApplies(text.charAt(i))) {
spaceCount ++;
}
}
@@ -606,7 +607,7 @@
* letter-spacing may need to be turned off for spaces with specific
* widths, like the 1/3 em space, etc. */
int letterCount = 0;
- letterCount += this.getText().length;
+ letterCount += this.getText().length();
letterCount -= this.countSpaces();
return letterCount;
}
@@ -680,9 +681,9 @@
*/
private int recomputeProgressionDimension() {
int pd = 0;
- final char[] text = getText();
- for (int i = 0; i < getText().length; i++) {
- final char c = text[i];
+ final CharSequence text = getText();
+ for (int i = 0; i < getText().length(); i++) {
+ final char c = text.charAt(i);
final boolean lastCharOnLine = false;
pd += charWidth(c, lastCharOnLine);
}
Modified: trunk/foray/foray-common/src/java/org/foray/common/XMLCharacter.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/XMLCharacter.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-common/src/java/org/foray/common/XMLCharacter.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -665,13 +665,13 @@
* @param rawText The raw text which should be expanded.
* @return The text containing the expanded entities.
*/
- public static char[] expandEntityReferences(final char[] rawText) {
+ public static CharSequence expandEntityReferences(final CharSequence rawText) {
if (rawText == null) {
return null;
}
boolean changesNeeded = false;
- for (int i = 0; i < rawText.length && ! changesNeeded; i++) {
- final char c = rawText[i];
+ for (int i = 0; i < rawText.length() && ! changesNeeded; i++) {
+ final char c = rawText.charAt(i);
if (XMLCharacter.isEntityReference(c)) {
changesNeeded = true;
}
@@ -679,7 +679,7 @@
if (! changesNeeded) {
return rawText;
}
- final StringBuilder buffer = new StringBuilder(new String(rawText));
+ final StringBuilder buffer = new StringBuilder(rawText);
for (int i = 0; i < buffer.length(); i++) {
final char c = buffer.charAt(i);
if (XMLCharacter.isEntityReference(c)) {
@@ -689,7 +689,7 @@
i += expanded.length() - 1;
}
}
- return buffer.toString().toCharArray();
+ return buffer.toString();
}
}
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -111,7 +111,7 @@
/**
* {@inheritDoc}
*/
- public synchronized void drawText(final String text, final boolean kern) {
+ public synchronized void drawText(final CharSequence text, final boolean kern) {
if (text.length() < 1) {
return;
}
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -89,7 +89,7 @@
* @return The String that should actually be written into the PDF to show
* the input text.
*/
- public static String textToPdf(final String theString,
+ public static String textToPdf(final CharSequence theString,
final FontUse fontUse, final boolean kerningActive) {
final Font font = fontUse.getFont();
final StringBuilder buffer = new StringBuilder();
Modified: trunk/foray/foray-render/src/java/org/foray/render/PrintRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/PrintRenderer.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-render/src/java/org/foray/render/PrintRenderer.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -193,7 +193,7 @@
return;
}
if (area.traitLeaderPattern() == LeaderPattern.DOTS) {
- final char[] text = area.dotLeaderText();
+ final CharSequence text = area.dotLeaderText();
if (text == null) {
return;
}
@@ -242,7 +242,7 @@
* {@inheritDoc}
*/
public void render(final TextArea area) {
- final char[] text = area.getText();
+ final CharSequence text = area.getText();
renderGenericSpace(area);
renderTextSegment(area, text);
}
Modified: trunk/foray/foray-render/src/java/org/foray/render/Renderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/Renderer.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-render/src/java/org/foray/render/Renderer.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -481,7 +481,7 @@
* @param text The text content to be rendered.
*/
public abstract void renderTextSegment(TextArea area,
- char[] text);
+ CharSequence text);
/**
* {@inheritDoc}
Modified: trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -568,7 +568,7 @@
* {@inheritDoc}
*/
public void renderTextSegment(final TextArea area,
- final char[] text) {
+ final CharSequence text) {
final FontUse font = area.getPrimaryFont();
final int size = area.traitFontSize();
@@ -592,7 +592,7 @@
final int rx = area.crOriginX();
final int bl = area.crOriginY();
- final String s = String.copyValueOf(text);
+ final String s = text.toString();
final Color oldColor = this.graphics.getColor();
final java.awt.Font oldFont = this.graphics.getFont();
Modified: trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -675,7 +675,7 @@
* {@inheritDoc}
*/
public void renderTextSegment(final TextArea area,
- final char[] text) {
+ final CharSequence text) {
/* TODO: Implement this. */
// Font font = area.getResolvedFont();
Modified: trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -328,8 +328,8 @@
* {@inheritDoc}
*/
public void renderTextSegment(final TextArea area,
- final char[] text) {
- if (text == null || text.length < 1) {
+ final CharSequence text) {
+ if (text == null || text.length() < 1) {
return;
}
@@ -351,7 +351,7 @@
final FontUse primaryFont = area.getPrimaryFont();
FontUse currentFont = primaryFont;
int startIndex = 0;
- for (int i = 0; i < text.length; i++) {
+ for (int i = 0; i < text.length(); i++) {
final int codePoint = Character.codePointAt(text, i);
if (Character.isSupplementaryCodePoint(codePoint)) {
i++;
@@ -369,9 +369,9 @@
currentFont = newFont;
}
}
- if (startIndex < text.length) {
+ if (startIndex < text.length()) {
paintText(area, currentFont, text, startIndex,
- text.length - startIndex, area.kern());
+ text.length() - startIndex, area.kern());
}
}
@@ -428,7 +428,7 @@
* @param kern Indicates whether the text should be kerned.
*/
private void paintText(final TextArea area, final FontUse fontUse,
- final char[] text, final int startIndex, final int size,
+ final CharSequence text, final int startIndex, final int size,
final boolean kern) {
if (size < 1) {
return;
@@ -436,7 +436,7 @@
getContentStream().setFont(fontUse, toPoints(area.traitFontSize()));
/* Paint the text. */
- final String textToWrite = new String(text, startIndex, size);
+ final CharSequence textToWrite = text.subSequence(startIndex, startIndex + size);
getContentStream().drawText(textToWrite, kern);
}
Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -868,8 +868,8 @@
* {@inheritDoc}
*/
public void renderTextSegment(final TextArea area,
- final char[] text) {
- if (text == null || text.length < 1) {
+ final CharSequence text) {
+ if (text == null || text.length() < 1) {
return;
}
final FontUse fontUse = area.getPrimaryFont();
@@ -878,7 +878,7 @@
useColor(area.traitColor());
write(moveTo(area));
StringBuilder sb = new StringBuilder();
- final String s = new String(text);
+ final String s = text.toString();
final int l = s.length();
for (int i = 0; i < l; i++) {
Modified: trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -440,7 +440,7 @@
* {@inheritDoc}
*/
public void renderTextSegment(final TextArea area,
- final char[] text) {
+ final CharSequence text) {
/* TODO: Implement this. */
// char ch;
Modified: trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -516,7 +516,7 @@
* {@inheritDoc}
*/
public void renderTextSegment(final TextArea area,
- final char[] text) {
+ final CharSequence text) {
/* TODO: Implement this. */
// int rx = this.currentXPosition;
Modified: trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java 2008-03-14 16:20:40 UTC (rev 10434)
+++ trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java 2008-03-14 16:54:45 UTC (rev 10435)
@@ -362,7 +362,7 @@
* {@inheritDoc}
*/
public void renderTextSegment(final TextArea area,
- final char[] text) {
+ final CharSequence text) {
/* TODO: Implement this. */
}
@@ -426,10 +426,9 @@
outputAttribute(fontBuffer, "size", area.traitFontSize());
this.writeEmptyElement("font", fontBuffer);
}
- final char[] rawText = area.getText();
- final char[] cookedText = XMLCharacter.expandEntityReferences(rawText);
- final String content = new String(cookedText);
- renderContent(content);
+ final CharSequence rawText = area.getText();
+ final CharSequence cookedText = XMLCharacter.expandEntityReferences(rawText);
+ renderContent(cookedText);
writeEndTag(area);
}
@@ -437,10 +436,10 @@
* Render the content part of an area.
* @param content The content to be rendered.
*/
- protected void renderContent(final String content) {
+ protected void renderContent(final CharSequence content) {
writeIndent();
this.writer.write("<content>");
- this.writer.write(content);
+ this.writer.write(content.toString());
this.writer.write("</content>\n");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-03-14 17:25:13
|
Revision: 10436
http://foray.svn.sourceforge.net/foray/?rev=10436&view=rev
Author: victormote
Date: 2008-03-14 10:25:20 -0700 (Fri, 14 Mar 2008)
Log Message:
-----------
Conform to axsl changes taking or returning CharSequence instead of String for text items.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/java/org/foray/area/PageCollection.java
trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationLastArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/PageRA.java
trunk/foray/foray-areatree/src/java/org/foray/area/ScalingValueCitationArea.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPageLabel.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFTextString.java
trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageCollection.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/PageCollection.java 2008-03-14 16:54:45 UTC (rev 10435)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/PageCollection.java 2008-03-14 17:25:20 UTC (rev 10436)
@@ -223,7 +223,7 @@
this.children.add(newPage);
final int newPageNumber = getCurrentPageNumber();
newPage.setNumber(newPageNumber);
- final String formattedPageNumber = pageSeq.formatPageNumber(
+ final CharSequence formattedPageNumber = pageSeq.formatPageNumber(
newPageNumber);
newPage.setFormattedNumber(formattedPageNumber);
if (!isBlank) {
@@ -463,7 +463,7 @@
/**
* {@inheritDoc}
*/
- public String getPageNumberPrefix() {
+ public CharSequence getPageNumberPrefix() {
final FolioPrefix prefix = this.traitGeneratedBy().getFolioPrefix();
if (prefix == null) {
return WKConstants.EMPTY_STRING;
@@ -474,7 +474,7 @@
/**
* {@inheritDoc}
*/
- public String getPageNumberSuffix() {
+ public CharSequence getPageNumberSuffix() {
final FolioSuffix suffix = this.traitGeneratedBy().getFolioSuffix();
if (suffix == null) {
return WKConstants.EMPTY_STRING;
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberArea.java 2008-03-14 16:54:45 UTC (rev 10435)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberArea.java 2008-03-14 17:25:20 UTC (rev 10436)
@@ -126,7 +126,7 @@
* {@inheritDoc}
*/
public CharSequence getText() {
- final String text = getPage().getFormattedNumber();
+ final CharSequence text = getPage().getFormattedNumber();
setProgressionDimension(getWordWidth(text));
return text;
}
@@ -282,7 +282,7 @@
* @param word The word whose width should be computed.
* @return The width of the word, in millipoints.
*/
- public int getWordWidth(final String word) {
+ public int getWordWidth(final CharSequence word) {
final FontUse fontUse = getPrimaryFont();
final Font font = fontUse.getFont();
fontUse.registerCharsUsed(word);
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationArea.java 2008-03-14 16:54:45 UTC (rev 10435)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationArea.java 2008-03-14 17:25:20 UTC (rev 10436)
@@ -134,7 +134,7 @@
*/
public CharSequence getText() {
final Area area = getAreaTree().firstNormalAreaReturned(traitRefId());
- String text = null;
+ CharSequence text = null;
if (area == null) {
text = "???";
} else {
@@ -311,7 +311,7 @@
* @param word The word whose width should be computed.
* @return The width of the word, in millipoints.
*/
- public int getWordWidth(final String word) {
+ public int getWordWidth(final CharSequence word) {
final FontUse fontUse = getPrimaryFont();
final Font font = fontUse.getFont();
fontUse.registerCharsUsed(word);
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationLastArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationLastArea.java 2008-03-14 16:54:45 UTC (rev 10435)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationLastArea.java 2008-03-14 17:25:20 UTC (rev 10436)
@@ -135,7 +135,7 @@
*/
public CharSequence getText() {
final Area area = getAreaTree().firstNormalAreaReturned(traitRefId());
- String text = null;
+ CharSequence text = null;
if (area == null) {
text = "???";
} else {
@@ -312,7 +312,7 @@
* @param word The word whose width should be computed.
* @return The width of the word, in millipoints.
*/
- public int getWordWidth(final String word) {
+ public int getWordWidth(final CharSequence word) {
final FontUse fontUse = getPrimaryFont();
final Font font = fontUse.getFont();
fontUse.registerCharsUsed(word);
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageRA.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/PageRA.java 2008-03-14 16:54:45 UTC (rev 10435)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/PageRA.java 2008-03-14 17:25:20 UTC (rev 10436)
@@ -91,7 +91,7 @@
private int pageNumber = 0;
/** The formatted page number for this page. */
- private String formattedPageNumber;
+ private CharSequence formattedPageNumber;
/** The list of markers found on this page. */
private List<Marker> markers = new ArrayList<Marker>();
@@ -162,14 +162,14 @@
* Sets the formatted page number for this page.
* @param number The new formatted page number.
*/
- public void setFormattedNumber(final String number) {
+ public void setFormattedNumber(final CharSequence number) {
this.formattedPageNumber = number;
}
/**
* {@inheritDoc}
*/
- public String getFormattedNumber() {
+ public CharSequence getFormattedNumber() {
return this.formattedPageNumber;
}
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/ScalingValueCitationArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/ScalingValueCitationArea.java 2008-03-14 16:54:45 UTC (rev 10435)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/ScalingValueCitationArea.java 2008-03-14 17:25:20 UTC (rev 10436)
@@ -134,7 +134,7 @@
* {@inheritDoc}
*/
public CharSequence getText() {
- final String text = getPage().getFormattedNumber();
+ final CharSequence text = getPage().getFormattedNumber();
setProgressionDimension(getWordWidth(text));
return text;
}
@@ -294,7 +294,7 @@
* @param word The word whose width should be computed.
* @return The width of the word, in millipoints.
*/
- public int getWordWidth(final String word) {
+ public int getWordWidth(final CharSequence word) {
final FontUse fontUse = getPrimaryFont();
final Font font = fontUse.getFont();
fontUse.registerCharsUsed(word);
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java 2008-03-14 16:54:45 UTC (rev 10435)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java 2008-03-14 17:25:20 UTC (rev 10436)
@@ -768,7 +768,7 @@
* {@inheritDoc}
*/
public void addPageLabelRange(final int startingPageIndex,
- final PdfPageLabelStyle labelStyle, final String labelPrefix,
+ final PdfPageLabelStyle labelStyle, final CharSequence labelPrefix,
final int startingPageNumber) {
final PDFPageLabel newPageLabel = new PDFPageLabel(this, labelStyle,
labelPrefix, startingPageNumber);
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPageLabel.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPageLabel.java 2008-03-14 16:54:45 UTC (rev 10435)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPageLabel.java 2008-03-14 17:25:20 UTC (rev 10436)
@@ -62,7 +62,7 @@
* sequentially from this value.
*/
public PDFPageLabel(final PDFDocument doc, final PdfPageLabelStyle style,
- final String labelPrefix, final int startingNumber) {
+ final CharSequence labelPrefix, final int startingNumber) {
super(doc);
this.style = style;
if (labelPrefix != null
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFTextString.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFTextString.java 2008-03-14 16:54:45 UTC (rev 10435)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFTextString.java 2008-03-14 17:25:20 UTC (rev 10436)
@@ -48,14 +48,14 @@
<< WKConstants.SHIFT_1_BYTE;
/** The encapsulated String. */
- private String theString;
+ private CharSequence theString;
/**
* Constructor.
* @param doc The parent PDF document.
* @param string The encapsulated String.
*/
- public PDFTextString(final PDFDocument doc, final String string) {
+ public PDFTextString(final PDFDocument doc, final CharSequence string) {
super(doc);
this.theString = string;
}
@@ -113,7 +113,7 @@
* @return The converted String, or null if unicodeString contains one or
* more chars that cannot be converted to PDFDocEncoding.
*/
- public static String unicodeToPDFDocEncoding(final String unicodeString) {
+ public static String unicodeToPDFDocEncoding(final CharSequence unicodeString) {
final StringBuilder pdfDocString = new StringBuilder(unicodeString);
for (int i = 0; i < unicodeString.length(); i++) {
final char unicodeChar = unicodeString.charAt(i);
Modified: trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java 2008-03-14 16:54:45 UTC (rev 10435)
+++ trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java 2008-03-14 17:25:20 UTC (rev 10436)
@@ -676,7 +676,7 @@
* @param attributeValue The value of the attribute.
*/
public void outputAttribute(final StringBuilder buffer,
- final String attributeName, final String attributeValue) {
+ final String attributeName, final CharSequence attributeValue) {
buffer.append(" " + attributeName + "=");
buffer.append(XMLRenderer.DOUBLE_QUOTE);
buffer.append(attributeValue);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-03-14 18:03:35
|
Revision: 10437
http://foray.svn.sourceforge.net/foray/?rev=10437&view=rev
Author: victormote
Date: 2008-03-14 11:03:40 -0700 (Fri, 14 Mar 2008)
Log Message:
-----------
Conform to axsl changes taking or returning CharSequence instead of String for text items.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/CharacterOutputStream.java
trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/CharacterOutputStream.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/CharacterOutputStream.java 2008-03-14 17:25:20 UTC (rev 10436)
+++ trunk/foray/foray-common/src/java/org/foray/common/CharacterOutputStream.java 2008-03-14 18:03:40 UTC (rev 10437)
@@ -59,8 +59,8 @@
* @param cmd The text to be written to the output stream.
* @throws IOException For I/O errors during the write.
*/
- public void write(final String cmd) throws IOException {
- write(cmd.getBytes("US-ASCII"));
+ public void write(final CharSequence cmd) throws IOException {
+ write(cmd.toString().getBytes("US-ASCII"));
write('\n');
}
@@ -69,8 +69,8 @@
* @param cmd The text to be written to the output stream.
* @throws IOException For I/O errors during the write.
*/
- public void writeRaw(final String cmd) throws IOException {
- write(cmd.getBytes("US-ASCII"));
+ public void writeRaw(final CharSequence cmd) throws IOException {
+ write(cmd.toString().getBytes("US-ASCII"));
}
/**
Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2008-03-14 17:25:20 UTC (rev 10436)
+++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2008-03-14 18:03:40 UTC (rev 10437)
@@ -246,7 +246,7 @@
* Write out a command (with no linefeed appended).
* @param cmd The PostScript command to write.
*/
- protected void writeRaw(final String cmd) {
+ protected void writeRaw(final CharSequence cmd) {
try {
this.out.writeRaw(cmd);
} catch (final IOException e) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-03-15 17:19:38
|
Revision: 10439
http://foray.svn.sourceforge.net/foray/?rev=10439&view=rev
Author: victormote
Date: 2008-03-15 10:19:44 -0700 (Sat, 15 Mar 2008)
Log Message:
-----------
Add test of the nesting of inline elements.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java
Added Paths:
-----------
trunk/foray/foray-app/src/javatest/org/foray/app/area/TestInline.java
trunk/foray/resource/test/fo/inline-001.fo
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java 2008-03-15 16:09:28 UTC (rev 10438)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java 2008-03-15 17:19:44 UTC (rev 10439)
@@ -31,6 +31,7 @@
import org.foray.app.area.TestBlock;
import org.foray.app.area.TestBorder;
import org.foray.app.area.TestGraphicArea;
+import org.foray.app.area.TestInline;
import org.foray.app.area.TestMetadata;
import org.foray.app.area.TestVertical;
import org.foray.app.fo.TestFont;
@@ -61,6 +62,7 @@
/* Now the Area Tree tests. */
testSuite.addTestSuite(TestBorder.class);
testSuite.addTestSuite(TestBlock.class);
+ testSuite.addTestSuite(TestInline.class);
testSuite.addTestSuite(TestMetadata.class);
testSuite.addTestSuite(TestGraphicArea.class);
testSuite.addTestSuite(TestVertical.class);
Added: trunk/foray/foray-app/src/javatest/org/foray/app/area/TestInline.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/TestInline.java (rev 0)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/TestInline.java 2008-03-15 17:19:44 UTC (rev 10439)
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2008 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.app.area;
+
+import org.foray.area.AreaNode;
+import org.foray.area.AreaTree;
+import org.foray.area.InlineArea;
+import org.foray.area.LineArea;
+import org.foray.area.NormalBlockArea;
+import org.foray.area.NormalFlowRA;
+import org.foray.area.TextArea;
+import org.foray.core.FOrayException;
+
+/**
+ * Tests of various block-related concepts at the Area Tree level.
+ */
+public class TestInline extends AbstractAreaTreeTest {
+
+ /**
+ * Test of fo/inline-001.fo. This test simply makes sure that the nesting of the various areas
+ * created is correct.
+ * Also does some basic testing of a text area's ability to return its text.
+ * @throws FOrayException For errors creating the FO Tree or Area Tree.
+ */
+ public void testInline001() throws FOrayException {
+ final AreaTreeCreator creator = AreaTreeCreator.getInstance();
+ final AreaTree areaTree = creator.buildAreaTree(
+ "fo/inline-001.fo");
+ final NormalFlowRA firstNormalFlowArea = this.getFirstNormalFlowArea(
+ areaTree);
+ assertEquals(1, firstNormalFlowArea.getChildCount());
+
+ /* The block area. */
+ AreaNode node = firstNormalFlowArea.getChildAt(0);
+ assertTrue(node instanceof NormalBlockArea);
+ final NormalBlockArea blockArea = (NormalBlockArea) node;
+ assertEquals(1, blockArea.getChildCount());
+
+ /* The only child of the block area is a line area. */
+ node = blockArea.getChildAt(0);
+ assertTrue(node instanceof LineArea);
+ final LineArea lineArea = (LineArea) node;
+ assertEquals(3, lineArea.getChildCount());
+
+ /* The first child of the line area is a text area. */
+ node = lineArea.getChildAt(0);
+ assertTrue(node instanceof TextArea);
+ final TextArea textArea1 = (TextArea) node;
+ assertEquals("Lighter(1), ", textArea1.getText().toString());
+
+ /* The second child of the line area is the outside inline area. */
+ node = lineArea.getChildAt(1);
+ assertTrue(node instanceof InlineArea);
+ final InlineArea inlineArea1 = (InlineArea) node;
+ assertEquals(3, inlineArea1.getChildCount());
+
+ /* The first child of the outside inline area is a text area. */
+ node = inlineArea1.getChildAt(0);
+ assertTrue(node instanceof TextArea);
+ final TextArea textArea2 = (TextArea) node;
+ assertEquals("Bolder(1), ", textArea2.getText().toString());
+
+ /* The second child of the outside inline area is the inside inline area. */
+ node = inlineArea1.getChildAt(1);
+ assertTrue(node instanceof InlineArea);
+ final InlineArea inlineArea2 = (InlineArea) node;
+ assertEquals(1, inlineArea2.getChildCount());
+
+ /* The first and only child of the inside inline area is a text area. */
+ node = inlineArea2.getChildAt(0);
+ assertTrue(node instanceof TextArea);
+// final TextArea textArea3 = (TextArea) node;
+// final String textArea3Text = textArea3.getText().toString();
+// assertEquals("Lighter(2), ", textArea3Text);
+
+ /* The third child of the outside inline area is another text area. */
+ node = inlineArea1.getChildAt(2);
+ assertTrue(node instanceof TextArea);
+// final TextArea textArea4 = (TextArea) node;
+// assertEquals("Bolder(2), ", textArea4.getText().toString());
+
+ /* The third child of the line area is another text area. */
+ node = lineArea.getChildAt(2);
+ assertTrue(node instanceof TextArea);
+ final TextArea textArea5 = (TextArea) node;
+ assertEquals("Lighter(3).", textArea5.getText().toString());
+
+ }
+
+}
Property changes on: trunk/foray/foray-app/src/javatest/org/foray/app/area/TestInline.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Added: trunk/foray/resource/test/fo/inline-001.fo
===================================================================
--- trunk/foray/resource/test/fo/inline-001.fo (rev 0)
+++ trunk/foray/resource/test/fo/inline-001.fo 2008-03-15 17:19:44 UTC (rev 10439)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+This fo file contains one block. That block contains one inline, which in turn contains one inline.
+The purpose of the document is to demonstrate whether nesting of inline areas works properly.
+-->
+
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+<fo:layout-master-set>
+ <!-- layout for the first page -->
+ <fo:simple-page-master master-name="simple"
+ margin-top="1in"
+ margin-bottom="1in"
+ margin-left="1in"
+ margin-right="1in">
+ <fo:region-body/>
+ </fo:simple-page-master>
+</fo:layout-master-set>
+
+<fo:page-sequence master-reference="simple">
+<fo:flow flow-name="xsl-region-body">
+
+
+ <fo:block font-family="sans-serif">Lighter(1), <fo:inline font-weight="bolder">Bolder(1),
+<fo:inline font-weight="lighter">Lighter(2), </fo:inline>Bolder(2), </fo:inline>Lighter(3).</fo:block>
+
+
+</fo:flow>
+</fo:page-sequence>
+</fo:root>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-03-15 17:39:38
|
Revision: 10440
http://foray.svn.sourceforge.net/foray/?rev=10440&view=rev
Author: victormote
Date: 2008-03-15 10:39:42 -0700 (Sat, 15 Mar 2008)
Log Message:
-----------
1. Add methods to test whether a given LineArea descendant is the first or last leaf node in the LineArea.
2. Use new methods to refine the ignoring of whitespace at the beginning and end of a TextArea.
3. Turns test for same on.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/area/TestInline.java
trunk/foray/foray-areatree/src/java/org/foray/area/AbstractInlineArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/area/TestInline.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/TestInline.java 2008-03-15 17:19:44 UTC (rev 10439)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/TestInline.java 2008-03-15 17:39:42 UTC (rev 10440)
@@ -95,15 +95,15 @@
/* The first and only child of the inside inline area is a text area. */
node = inlineArea2.getChildAt(0);
assertTrue(node instanceof TextArea);
-// final TextArea textArea3 = (TextArea) node;
-// final String textArea3Text = textArea3.getText().toString();
-// assertEquals("Lighter(2), ", textArea3Text);
+ final TextArea textArea3 = (TextArea) node;
+ final String textArea3Text = textArea3.getText().toString();
+ assertEquals("Lighter(2), ", textArea3Text);
/* The third child of the outside inline area is another text area. */
node = inlineArea1.getChildAt(2);
assertTrue(node instanceof TextArea);
-// final TextArea textArea4 = (TextArea) node;
-// assertEquals("Bolder(2), ", textArea4.getText().toString());
+ final TextArea textArea4 = (TextArea) node;
+ assertEquals("Bolder(2), ", textArea4.getText().toString());
/* The third child of the line area is another text area. */
node = lineArea.getChildAt(2);
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/AbstractInlineArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/AbstractInlineArea.java 2008-03-15 17:19:44 UTC (rev 10439)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/AbstractInlineArea.java 2008-03-15 17:39:42 UTC (rev 10440)
@@ -28,6 +28,8 @@
package org.foray.area;
+import org.foray.common.OrderedTreeNode;
+
import org.axsl.area.AreaTreeException;
import org.axsl.common.value.RelativeAxis;
import org.axsl.fo.Fo;
@@ -241,4 +243,24 @@
return 0;
}
+ /**
+ * Indicates whether this area is the first leaf area on the ancestor line.
+ * @return True iff this area is the first leaf area on the ancestory line.
+ */
+ public boolean isFirstLeafOnLine() {
+ final LineArea ancestorLine = this.ancestorLineArea();
+ final OrderedTreeNode firstLeaf = ancestorLine.getFirstLeaf();
+ return this == firstLeaf;
+ }
+
+ /**
+ * Indicates whether this area is the first leaf area on the ancestor line.
+ * @return True iff this area is the first leaf area on the ancestory line.
+ */
+ public boolean isLastLeafOnLine() {
+ final LineArea ancestorLine = this.ancestorLineArea();
+ final OrderedTreeNode lastLeaf = ancestorLine.getLastLeaf();
+ return this == lastLeaf;
+ }
+
}
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2008-03-15 17:19:44 UTC (rev 10439)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2008-03-15 17:39:42 UTC (rev 10440)
@@ -281,11 +281,11 @@
final CharSequence rawText = this.getTextContent().getAreaTreeText(this);
// Count of whitespace that should be ignored at start of array.
final int ignoreAtStart = ignoreAtStart(rawText, this.backingOffset,
- this.backingSize, this.isFirstChildOfParent(),
+ this.backingSize, this.isFirstLeafOnLine(),
traitWhiteSpaceTreatment());
// Count of whitespace that should be ignored at end of array.
final int ignoreAtEnd = ignoreAtEnd(rawText, this.backingOffset,
- this.backingSize, this.isLastChildOfParent(),
+ this.backingSize, this.isLastLeafOnLine(),
traitWhiteSpaceTreatment());
if (ignoreAtStart + ignoreAtEnd >= this.backingSize) {
// In case it was all whitespace, which shouldn't happen
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-03-15 20:06:47
|
Revision: 10442
http://foray.svn.sourceforge.net/foray/?rev=10442&view=rev
Author: victormote
Date: 2008-03-15 13:06:48 -0700 (Sat, 15 Mar 2008)
Log Message:
-----------
Fix bug: not all descendants of LineArea were considered for word-spacing and other adjustments.
Modified Paths:
--------------
trunk/foray/doc/web/00-release/notes-unreleased.html
trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java
Modified: trunk/foray/doc/web/00-release/notes-unreleased.html
===================================================================
--- trunk/foray/doc/web/00-release/notes-unreleased.html 2008-03-15 19:12:31 UTC (rev 10441)
+++ trunk/foray/doc/web/00-release/notes-unreleased.html 2008-03-15 20:06:48 UTC (rev 10442)
@@ -32,6 +32,9 @@
ninth page as "1 (9 of 29)".</li>
<li>MathML documents are now supported inside fo:instream-foreign-object.
Previously they were supported only within fo:external-graphic.</li>
+ <li>Bugfix: Pioneer layout was not properly nesting inline elements in the AreaTree.</li>
+ <li>Bugfix: Not all descenants of a LineArea were considered for word-spacing and other spacing
+adjustments.</li>
</ul>
<h3>Unreleased changes of interest to Developers</h3>
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2008-03-15 19:12:31 UTC (rev 10441)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2008-03-15 20:06:48 UTC (rev 10442)
@@ -327,10 +327,11 @@
if (wordSpacingCapacity == 0) {
return;
}
- for (int i = 0; i < getChildren().size(); i++) {
- final Object object = getChildren().get(i);
- if (object instanceof TextArea) {
- final TextArea text = (TextArea) object;
+ final Iterator<OrderedTreeNode> iterator = this.postOrderDescendantIterator();
+ while (iterator.hasNext()) {
+ final OrderedTreeNode descendant = iterator.next();
+ if (descendant instanceof TextArea) {
+ final TextArea text = (TextArea) descendant;
boolean prorating = false;
if (Math.abs(wordSpacingCapacity) >= Math.abs(unusedSpace)) {
prorating = true;
@@ -351,10 +352,11 @@
*/
private int computeWordSpacingCapacity(final int unusedSpace) {
int wordSpacingCapacity = 0;
- for (int i = 0; i < getChildren().size(); i++) {
- final Object object = getChildren().get(i);
- if (object instanceof TextArea) {
- final TextArea text = (TextArea) object;
+ final Iterator<OrderedTreeNode> iterator = this.postOrderDescendantIterator();
+ while (iterator.hasNext()) {
+ final OrderedTreeNode descendant = iterator.next();
+ if (descendant instanceof TextArea) {
+ final TextArea text = (TextArea) descendant;
if (unusedSpace > 0) {
wordSpacingCapacity += text.maxWordSpacingCapacity()
- text.wordSpacingUsed();
@@ -413,10 +415,11 @@
if (letterSpacingCapacity == 0) {
return;
}
- for (int i = 0; i < getChildren().size(); i++) {
- final Object object = getChildren().get(i);
- if (object instanceof TextArea) {
- final TextArea text = (TextArea) object;
+ final Iterator<OrderedTreeNode> iterator = this.postOrderDescendantIterator();
+ while (iterator.hasNext()) {
+ final OrderedTreeNode descendant = iterator.next();
+ if (descendant instanceof TextArea) {
+ final TextArea text = (TextArea) descendant;
boolean prorating = false;
if (Math.abs(letterSpacingCapacity) >= Math.abs(unusedSpace)) {
prorating = true;
@@ -437,10 +440,11 @@
*/
private int computeLetterSpacingCapacity(final int unusedSpace) {
int letterSpacingCapacity = 0;
- for (int i = 0; i < getChildren().size(); i++) {
- final Object object = getChildren().get(i);
- if (object instanceof TextArea) {
- final TextArea text = (TextArea) object;
+ final Iterator<OrderedTreeNode> iterator = this.postOrderDescendantIterator();
+ while (iterator.hasNext()) {
+ final OrderedTreeNode descendant = iterator.next();
+ if (descendant instanceof TextArea) {
+ final TextArea text = (TextArea) descendant;
if (unusedSpace > 0) {
letterSpacingCapacity += text.maxLetterSpacingCapacity()
- text.letterSpacingUsed();
@@ -615,9 +619,9 @@
}
/* "... any lines in the block ending in U+000A." */
- final Area lastChild = this.getLastAreaChild();
- if (lastChild instanceof TextArea) {
- final TextArea textArea = (TextArea) lastChild;
+ final OrderedTreeNode lastLeaf = this.getLastLeaf();
+ if (lastLeaf instanceof TextArea) {
+ final TextArea textArea = (TextArea) lastLeaf;
if (textArea.endsWithLinefeed()) {
return true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-03-15 22:03:07
|
Revision: 10444
http://foray.svn.sourceforge.net/foray/?rev=10444&view=rev
Author: victormote
Date: 2008-03-15 15:03:13 -0700 (Sat, 15 Mar 2008)
Log Message:
-----------
1. Conform to axsl changes adding a boolean for kerning to the method that computes the width of a String.
2. Add method that returns the number of units per text-space unit for the font.
3. Use new method to compute the correct kerning value for TTF fonts.
4. Fix bug in method computing the width of a String to adjust for the font-size.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationLastArea.java
trunk/foray/foray-areatree/src/java/org/foray/area/ScalingValueCitationArea.java
trunk/foray/foray-font/src/java/org/foray/font/FOrayFont.java
trunk/foray/foray-font/src/java/org/foray/font/FSTrueTypeFont.java
trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java
trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFTextPainter.java
trunk/foray/foray-text/src/java/org/foray/text/line/LineBreaker.java
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberArea.java 2008-03-15 20:58:59 UTC (rev 10443)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberArea.java 2008-03-15 22:03:13 UTC (rev 10444)
@@ -288,7 +288,7 @@
fontUse.registerCharsUsed(word);
return font.width(word, traitFontSize(),
traitGeneratedBy().traitLetterSpacingOpt(this),
- traitGeneratedBy().traitWordSpacingOpt(this));
+ traitGeneratedBy().traitWordSpacingOpt(this), true);
}
/**
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationArea.java 2008-03-15 20:58:59 UTC (rev 10443)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationArea.java 2008-03-15 22:03:13 UTC (rev 10444)
@@ -317,7 +317,7 @@
fontUse.registerCharsUsed(word);
return font.width(word, traitFontSize(),
traitGeneratedBy().traitLetterSpacingOpt(this),
- traitGeneratedBy().traitWordSpacingOpt(this));
+ traitGeneratedBy().traitWordSpacingOpt(this), true);
}
/**
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationLastArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationLastArea.java 2008-03-15 20:58:59 UTC (rev 10443)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/PageNumberCitationLastArea.java 2008-03-15 22:03:13 UTC (rev 10444)
@@ -318,7 +318,7 @@
fontUse.registerCharsUsed(word);
return font.width(word, traitFontSize(),
traitGeneratedBy().traitLetterSpacingOpt(this),
- traitGeneratedBy().traitWordSpacingOpt(this));
+ traitGeneratedBy().traitWordSpacingOpt(this), true);
}
/**
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/ScalingValueCitationArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/ScalingValueCitationArea.java 2008-03-15 20:58:59 UTC (rev 10443)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/ScalingValueCitationArea.java 2008-03-15 22:03:13 UTC (rev 10444)
@@ -300,7 +300,7 @@
fontUse.registerCharsUsed(word);
return font.width(word, traitFontSize(),
traitGeneratedBy().traitLetterSpacingOpt(this),
- traitGeneratedBy().traitWordSpacingOpt(this));
+ traitGeneratedBy().traitWordSpacingOpt(this), true);
}
/**
Modified: trunk/foray/foray-font/src/java/org/foray/font/FOrayFont.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/FOrayFont.java 2008-03-15 20:58:59 UTC (rev 10443)
+++ trunk/foray/foray-font/src/java/org/foray/font/FOrayFont.java 2008-03-15 22:03:13 UTC (rev 10444)
@@ -27,6 +27,7 @@
*/
package org.foray.font;
+import org.foray.common.WKConstants;
import org.foray.font.charset.CharSet;
import org.foray.font.format.Kerning;
@@ -188,7 +189,7 @@
* {@inheritDoc}
*/
public int width(final CharSequence word, final int fontSize,
- final int letterSpacing, final int wordSpacing) {
+ final int letterSpacing, final int wordSpacing, final boolean kern) {
if (word == null) {
return 0;
}
@@ -202,8 +203,13 @@
width += charWidth;
}
// Add any kerning.
- if (i < word.length() - 1) {
- width += kern(word.charAt(i), word.charAt(i + 1));
+ if (kern
+ && i < word.length() - 1) {
+ final int kerning = kern(word.charAt(i), word.charAt(i + 1));
+ /* Kerning is computed in 1/1000 of a text-space unit, regardless of how the value
+ * is stored internally in the font. Therefore, we just need to adjust for the
+ * font-size. */
+ width += Math.round(kerning * fontSize / WKConstants.MILLIPOINTS_PER_POINT);
}
// Add any word-spacing
if (word.charAt(i) == ' ') {
@@ -288,7 +294,13 @@
if (getKerning() == null) {
return 0;
}
- return getKerning().kern(char1, char2);
+ final int rawKerning = getKerning().kern(char1, char2);
+ if (WKConstants.MILLIPOINTS_PER_POINT == this.getUnitsPerTextSpaceUnit()) {
+ /* Avoid the potential loss of precision. */
+ return rawKerning;
+ }
+ return Math.round(rawKerning * WKConstants.MILLIPOINTS_PER_POINT
+ / this.getUnitsPerTextSpaceUnit());
}
@@ -534,4 +546,13 @@
return shift;
}
+ /**
+ * Returns the units per text-space unit that is used in this font for internal font
+ * measurements.
+ * For PostScript Type 1 fonts, this is 1000.
+ * For TrueType fonts, it is usually 2048, but can be specified in the font itself.
+ * @return The units per text-space unit used by this font.
+ */
+ public abstract int getUnitsPerTextSpaceUnit();
+
}
Modified: trunk/foray/foray-font/src/java/org/foray/font/FSTrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/FSTrueTypeFont.java 2008-03-15 20:58:59 UTC (rev 10443)
+++ trunk/foray/foray-font/src/java/org/foray/font/FSTrueTypeFont.java 2008-03-15 22:03:13 UTC (rev 10444)
@@ -44,6 +44,9 @@
*/
public class FSTrueTypeFont extends FreeStandingFont {
+ /** Constant indicating the default units per text-space unit used by TrueType fonts. */
+ public static final int DEFAULT_UNITS_PER_TEXT_SPACE = 2048;
+
/** Constant indicating the maximum expected file size. */
private static final int EXPECTED_FILE_SIZE = 128000;
@@ -252,4 +255,12 @@
return getEstimatedOverlinePosition(fontSize);
}
+ /**
+ * {@inheritDoc}
+ */
+ public int getUnitsPerTextSpaceUnit() {
+ /* TODO: Add logic to get the actual value out of the font. */
+ return FSTrueTypeFont.DEFAULT_UNITS_PER_TEXT_SPACE;
+ }
+
}
Modified: trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java 2008-03-15 20:58:59 UTC (rev 10443)
+++ trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java 2008-03-15 22:03:13 UTC (rev 10444)
@@ -417,4 +417,12 @@
return getEstimatedOverlinePosition(fontSize);
}
+ /**
+ * {@inheritDoc}
+ */
+ public int getUnitsPerTextSpaceUnit() {
+ /* Type 1 fonts always use 1000 units per text-space unit. */
+ return WKConstants.MILLIPOINTS_PER_POINT;
+ }
+
}
Modified: trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java 2008-03-15 20:58:59 UTC (rev 10443)
+++ trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java 2008-03-15 22:03:13 UTC (rev 10444)
@@ -602,4 +602,16 @@
return org.axsl.font.Font.Complexity.COMPOSITE;
}
+ /**
+ * {@inheritDoc}
+ */
+ public int getUnitsPerTextSpaceUnit() {
+ final FreeStandingFont relatedFSFont = this.freeStandingFontManifestation();
+ if (relatedFSFont == null) {
+ /* SystemFont is usually created from a TrueType font, so use its default. */
+ return FSTrueTypeFont.DEFAULT_UNITS_PER_TEXT_SPACE;
+ }
+ return relatedFSFont.getUnitsPerTextSpaceUnit();
+ }
+
}
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFTextPainter.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFTextPainter.java 2008-03-15 20:58:59 UTC (rev 10443)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFTextPainter.java 2008-03-15 22:03:13 UTC (rev 10444)
@@ -274,7 +274,7 @@
final int letterSpacing = 0;
final int width = fontToUse.getFont().width(txt,
awtFontSize * WKConstants.MILLIPOINTS_PER_POINT,
- letterSpacing, 0);
+ letterSpacing, 0, true);
final float advance = WKConstants.millipointsToPoints(width);
float tx = 0;
if (anchor != null) {
Modified: trunk/foray/foray-text/src/java/org/foray/text/line/LineBreaker.java
===================================================================
--- trunk/foray/foray-text/src/java/org/foray/text/line/LineBreaker.java 2008-03-15 20:58:59 UTC (rev 10443)
+++ trunk/foray/foray-text/src/java/org/foray/text/line/LineBreaker.java 2008-03-15 22:03:13 UTC (rev 10444)
@@ -335,7 +335,7 @@
fontUse.registerCharsUsed(word);
return font.width(word,
lineText.inlineFontSize(),
- lineText.inlineLetterSpacingOptimum(), 0);
+ lineText.inlineLetterSpacingOptimum(), 0, true);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-03-18 15:37:26
|
Revision: 10445
http://foray.svn.sourceforge.net/foray/?rev=10445&view=rev
Author: victormote
Date: 2008-03-18 08:37:31 -0700 (Tue, 18 Mar 2008)
Log Message:
-----------
Apply patch from Jason Harrop, adding Panose methods to get the bold and italic Panose instances.
Modified Paths:
--------------
trunk/foray/doc/web/00-release/notes-unreleased.html
trunk/foray/foray-font/src/java/org/foray/font/format/Panose.java
Modified: trunk/foray/doc/web/00-release/notes-unreleased.html
===================================================================
--- trunk/foray/doc/web/00-release/notes-unreleased.html 2008-03-15 22:03:13 UTC (rev 10444)
+++ trunk/foray/doc/web/00-release/notes-unreleased.html 2008-03-18 15:37:31 UTC (rev 10445)
@@ -35,6 +35,9 @@
<li>Bugfix: Pioneer layout was not properly nesting inline elements in the AreaTree.</li>
<li>Bugfix: Not all descenants of a LineArea were considered for word-spacing and other spacing
adjustments.</li>
+ <li>Miscellaneous improvements to the Panose class, thanks to Jason Harrop.
+These include greatly improved Panose matching, and methods to return bold and italic Panose
+instances.</li>
</ul>
<h3>Unreleased changes of interest to Developers</h3>
Modified: trunk/foray/foray-font/src/java/org/foray/font/format/Panose.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/format/Panose.java 2008-03-15 22:03:13 UTC (rev 10444)
+++ trunk/foray/foray-font/src/java/org/foray/font/format/Panose.java 2008-03-18 15:37:31 UTC (rev 10445)
@@ -116,6 +116,43 @@
}
+ /**
+ * Constant indicating the minimum italic value for the letterform field.
+ * This is based on an analysis of the MS ClearType Collection fonts:
+ * <ul>
+ * <li>consolas [ 2 11 6 9 2 2 4 3 2 4 ] bold 6 ital 3</li>
+ * <li>consolas-bold [ 2 11 7 9 2 2 4 3 2 4 ] bold 7 ital 3</li>
+ * <li>consolas-italic [ 2 11 6 9 2 2 4 10 2 4 ] bold 6 ital 10</li>
+ * <li>consolas-bolditalic [ 2 11 7 9 2 2 4 10 2 4 ] bold 7 ital 10</li>
+ *
+ * <li>cordianew [ 2 11 3 4 2 2 2 2 2 4 ] bold 3 ital 2</li>
+ * <li>cordianew-bolditalic [ 2 11 6 4 2 2 2 9 2 4 ] bold 6 ital 9</li>
+ *
+ * <li>calibri [ 2 15 5 2 2 2 4 3 2 4 ] bold 5 ital 3</li>
+ * <li>calibri-bold [ 2 15 7 2 3 4 4 3 2 4 ] bold 7 ital 3</li>
+ * <li>calibri-bolditalic [ 2 15 7 2 3 4 4 10 2 4 ] bold 7 ital 10</li>
+ *
+ * <li>constantia [ 2 3 6 2 5 3 6 3 3 3 ] bold 6 ital 3</li>
+ * <li>constantia-bold [ 2 3 7 2 6 3 6 3 3 3 ] bold 7 ital 3 (note the 6 at index 4)</li>
+ * <li>constantia-italic [ 2 3 6 2 5 3 6 10 3 3 ] bold 6 ital 10</li>
+ *
+ * <li>candara-bold [ 2 14 7 2 3 3 3 2 2 4 ] bold 7 ital 2</li>
+ * <li>candara-italic [ 2 14 5 2 3 3 3 9 2 4 ] bold 5 ital 9</li>
+ * <li>candara-bolditalic [ 2 14 7 2 3 3 3 9 2 4 ] bold 7 ital 9</li>
+ *
+ * <li>cambria-bold [ 2 4 8 3 5 4 6 3 2 4 ] bold 8 ital 3</li>
+ * <li>cambria-italic [ 2 4 5 3 5 4 6 10 2 4 ] bold 5 ital 10</li>
+ * </ul>
+ */
+ private static final byte LETTERFORM_MIN_ITALIC = 9;
+
+ /**
+ * Constant indicating the minimum bold value for the weight field.
+ * This is based on an analysis of the MS ClearType Collection fonts, which can be found at
+ * {@link #LETTERFORM_MIN_ITALIC}.
+ */
+ private static final byte WEIGHT_MIN_BOLD = 7;
+
/** An array of weights indicating that all elements in a comparison between two PANOSE values
* shall be considered to be of the same weight. */
private static final byte[] NEUTRAL_WEIGHTS = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
@@ -131,7 +168,9 @@
* @param panoseArray The array of bytes recording the PANOSE classification.
*/
private Panose(final byte[] panoseArray) {
- this.panoseArray = panoseArray;
+ /* Clone the incoming array to protect our data from subsequent changes made to the original
+ * array. */
+ this.panoseArray = panoseArray.clone();
}
/**
@@ -282,4 +321,37 @@
return sb.toString();
}
+ /**
+ * Returns the bold version of this Panose instance.
+ * @return If this already describes a bold font, returns this. Otherwise, returns a new
+ * Panose instance that is identical to this, except describing a bold font.
+ */
+ public Panose getBold() {
+ final byte weightValue = this.getElement(Panose.Field.WEIGHT);
+ if (weightValue >= Panose.WEIGHT_MIN_BOLD) {
+ /* This Panose value is already bold. */
+ return this;
+ }
+ final byte[] newArray = this.panoseArray.clone();
+ newArray[Panose.Field.WEIGHT.getIndex()] = Panose.WEIGHT_MIN_BOLD;
+ return Panose.makeInstance(newArray);
+ }
+
+ /**
+ * Returns the italic version of this Panose instance.
+ * @return If this already describes an italic font, returns this. Otherwise, returns a new
+ * Panose instance that is identical to this, except describing an italic font.
+ */
+ public Panose getItalic() {
+ final byte letterformValue = this.getElement(Panose.Field.LETTERFORM);
+ if (letterformValue >= Panose.LETTERFORM_MIN_ITALIC) {
+ /* This Panose value is already italic. */
+ return this;
+ }
+ final byte[] newArray = this.panoseArray.clone();
+ newArray[Panose.Field.LETTERFORM.getIndex()] = Panose.LETTERFORM_MIN_ITALIC;
+ return Panose.makeInstance(newArray);
+ }
+
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-03-18 23:45:41
|
Revision: 10447
http://foray.svn.sourceforge.net/foray/?rev=10447&view=rev
Author: victormote
Date: 2008-03-18 16:45:47 -0700 (Tue, 18 Mar 2008)
Log Message:
-----------
Move the text-handling logic to a new CharSequence implementation.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java
trunk/foray/foray-common/src/java/org/foray/common/CharSequenceSubset.java
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2008-03-18 19:10:51 UTC (rev 10446)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2008-03-18 23:45:47 UTC (rev 10447)
@@ -28,7 +28,7 @@
package org.foray.area;
-import org.foray.common.CharVector;
+import org.foray.common.CharSequenceSubset;
import org.foray.common.WKConstants;
import org.foray.common.XMLCharacter;
@@ -74,23 +74,10 @@
/** The "generated-by" trait, as defined in Section 6.1.1. */
private FOLinkage generatedBy;
- /**
- * The index of the first character in the char array that is the backing
- * for the text in this object. For example, if the text in this TextSegment
- * starts at array element 5 and has a size of 14, backingOffset will be 5.
- */
- private int backingOffset;
+ /** The resolved textual content of this text area. */
+ private TextAreaCharSequence charSequence;
/**
- * The number of char elements in the backing char array that are actually
- * included in this area. For example, if the text in this TextSegment
- * starts at array element 5 and has a size of 14, backingSize will be 14.
- * The ending array element that belongs to this TextSegment is computed
- * as backingOffset + backingSize.
- */
- private int backingSize;
-
- /**
* The amount, in millipoints, of letter-spacing to be used <em>between
* each letter</em> in this text.
* area.
@@ -105,19 +92,6 @@
private int resolvedWordSpacing;
/**
- * Set this to true if the text should be followed by the hyphenation
- * character.
- */
- private boolean hasDiscretionaryHyphen = false;
-
- /**
- * Set this to true if faux small caps should be applied to this TextArea.
- * If true, all text will be converted to uppercase and a reduced font-size
- * will be applied.
- */
- private boolean hasFauxSmallCaps = false;
-
- /**
* Private Constructor.
* @param parentArea The parent area.
*/
@@ -243,12 +217,11 @@
final int backingSize, final int progressionDimensionUsed,
final boolean hasDiscretionaryHyphen,
final boolean hasFauxSmallCaps) {
- this.backingOffset = backingOffset;
- this.backingSize = backingSize;
+ final CharacterSequence generatedBy = this.traitGeneratedBy();
+ this.charSequence = new TextAreaCharSequence(generatedBy.getAreaTreeText(this),
+ backingOffset, backingSize, hasDiscretionaryHyphen, hasFauxSmallCaps);
this.resolvedLetterSpacing = this.traitLetterSpacingOpt();
this.resolvedWordSpacing = this.traitWordSpacingOpt();
- this.hasDiscretionaryHyphen = hasDiscretionaryHyphen;
- this.hasFauxSmallCaps = hasFauxSmallCaps;
setProgressionDimension(progressionDimensionUsed);
this.initializeAnteriorSpace();
this.ancestorLineArea().lineContentChanged();
@@ -278,50 +251,7 @@
* @return The text to be used in the output document.
*/
public CharSequence getText() {
- final CharSequence rawText = this.getTextContent().getAreaTreeText(this);
- // Count of whitespace that should be ignored at start of array.
- final int ignoreAtStart = ignoreAtStart(rawText, this.backingOffset,
- this.backingSize, this.isFirstLeafOnLine(),
- traitWhiteSpaceTreatment());
- // Count of whitespace that should be ignored at end of array.
- final int ignoreAtEnd = ignoreAtEnd(rawText, this.backingOffset,
- this.backingSize, this.isLastLeafOnLine(),
- traitWhiteSpaceTreatment());
- if (ignoreAtStart + ignoreAtEnd >= this.backingSize) {
- // In case it was all whitespace, which shouldn't happen
- return WKConstants.EMPTY_STRING;
- }
- int arraySize = this.backingSize - ignoreAtStart - ignoreAtEnd;
- final int hyphenChar = this.traitHyphenationCharacter();
- int discretionaryHyphenSize = 0;
- if (this.hasDiscretionaryHyphen) {
- discretionaryHyphenSize = Character.charCount(hyphenChar);
- }
- arraySize += discretionaryHyphenSize;
- final int start = this.backingOffset + ignoreAtStart;
- final CharSequence returnSequence = rawText.subSequence(start, start + arraySize);
- final char[] returnChars = returnSequence.toString().toCharArray();
- if (this.hasDiscretionaryHyphen) {
- if (discretionaryHyphenSize == 1) {
- returnChars[returnChars.length - discretionaryHyphenSize]
- = (char) this.traitHyphenationCharacter();
- } else {
- final String hyphenString = new String(
- new int[] {hyphenChar}, 0, 1);
- final char[] hyphenChars = hyphenString.toCharArray();
- System.arraycopy(hyphenChars, 0, returnChars,
- returnChars.length - hyphenChars.length,
- hyphenChars.length);
- }
- }
- /* Apply faux small-caps, if appropriate. */
- if (this.hasFauxSmallCaps) {
- for (int i = 0; i < returnChars.length; i++) {
- final char c = returnChars[i];
- returnChars[i] = java.lang.Character.toUpperCase(c);
- }
- }
- return new CharVector(returnChars);
+ return this.charSequence;
}
/**
@@ -343,8 +273,7 @@
* @return The raw text from the FO Tree.
*/
public CharSequence getRawText() {
- final CharSequence foText = this.getTextContent().getAreaTreeText(this);
- return foText.subSequence(this.backingOffset, this.backingOffset + this.backingSize);
+ return this.charSequence.getRawText();
}
/**
@@ -570,8 +499,11 @@
public int countSpaces() {
int spaceCount = 0;
final CharSequence text = this.getText();
- for (int i = 0; i < text.length(); i++) {
- if (wordSpacingApplies(text.charAt(i))) {
+ /* Cache the length to avoid recomputing it on every iteration. */
+ final int length = text.length();
+ for (int i = 0; i < length; i++) {
+ final char c = text.charAt(i);
+ if (wordSpacingApplies(c)) {
spaceCount ++;
}
}
@@ -687,7 +619,7 @@
final boolean lastCharOnLine = false;
pd += charWidth(c, lastCharOnLine);
}
- if (this.hasDiscretionaryHyphen) {
+ if (this.charSequence.hasDiscretionaryHyphen()) {
pd += charWidth(this.traitHyphenationCharacter(), true);
}
return pd;
@@ -735,7 +667,7 @@
final CharacterSequence generatedBy = this.traitGeneratedBy();
final int nominalFontSize = generatedBy.traitFontSizeActual(this,
this.getPrimaryFont().getFont());
- if (this.hasFauxSmallCaps) {
+ if (this.hasFauxSmallCaps()) {
final FontUse fontUse = getPrimaryFont();
return fontUse.smallCapsSize(nominalFontSize);
}
@@ -743,6 +675,22 @@
}
/**
+ * Indicates whether this text area has a discretionary hyphen.
+ * @return True iff this character sequence has a discretionary hyphen.
+ */
+ public boolean hasDiscretionaryHyphen() {
+ return this.charSequence.hasDiscretionaryHyphen();
+ }
+
+ /**
+ * Indicates whether this text area has faux small caps.
+ * @return True iff this character sequence has faux small caps.
+ */
+ public boolean hasFauxSmallCaps() {
+ return this.charSequence.hasFauxSmallCaps();
+ }
+
+ /**
* {@inheritDoc}
*/
public String getAreaName() {
@@ -979,4 +927,226 @@
return traitGeneratedBy().traitColor(this);
}
+ /**
+ * Specialized {@link CharSequence} implementation representing the textual content of a
+ * TextArea.
+ */
+ private final class TextAreaCharSequence implements CharSequence {
+
+ /** Constant needed for serialization. */
+ private static final long serialVersionUID = 2632541023613463496L;
+
+ /** The wrapped sequence. */
+ private CharSequence wrappedSequence;
+
+ /** The index to the first element in {@link #wrappedSequence} that is considered to be part
+ * of this sequence. */
+ private int start;
+
+ /** The number of chars in {@link #wrappedSequence} that is considered to be part of this
+ * sequence. */
+ private int length;
+
+ /**
+ * Set this to true if the text should be followed by the hyphenation
+ * character.
+ */
+ private boolean hasDiscretionaryHyphen = false;
+
+ /**
+ * Set this to true if faux small caps should be applied to this TextArea.
+ * If true, all text will be converted to uppercase and a reduced font-size
+ * will be applied.
+ */
+ private boolean hasFauxSmallCaps = false;
+
+ /**
+ * Constructor.
+ * @param wrappedSequence The encapsulated sequence, a subset of which is the content for
+ * this sequence.
+ * @param start The index to the first element in <code>wrappedSequence</code> that is
+ * considered to be part of this sequence.
+ * @param length The number of chars in <code>wrappedSequence</code> that is considered to
+ * be part of this sequence.
+ * @param hasDiscretionaryHyphen Set this to true if the text should be
+ * followed by the hyphenation character.
+ * @param hasFauxSmallCaps Set this to true if faux small caps should be
+ * applied to this TextArea.
+ * If true, all text will be converted to uppercase and a reduced font-size
+ * will be applied.
+ */
+ private TextAreaCharSequence(final CharSequence wrappedSequence, final int start,
+ final int length, final boolean hasDiscretionaryHyphen,
+ final boolean hasFauxSmallCaps) {
+ if (start < 0
+ || length < 0
+ || start + length > wrappedSequence.length()) {
+ throw new IndexOutOfBoundsException("Illegal sub-sequence bounds.");
+ }
+ this.wrappedSequence = wrappedSequence;
+ this.start = start;
+ this.length = length;
+ this.hasDiscretionaryHyphen = hasDiscretionaryHyphen;
+ this.hasFauxSmallCaps = hasFauxSmallCaps;
+ }
+
+ /**
+ * Indicates whether this character sequence has a discretionary hyphen.
+ * @return True iff this character sequence has a discretionary hyphen.
+ */
+ public boolean hasDiscretionaryHyphen() {
+ return this.hasDiscretionaryHyphen;
+ }
+
+ /**
+ * Indicates whether this character sequence has faux small caps.
+ * @return True iff this character sequence has faux small caps.
+ */
+ public boolean hasFauxSmallCaps() {
+ return this.hasFauxSmallCaps;
+ }
+
+ /**
+ * Returns the raw text for this area. This method is used primarily for
+ * testing purposes as it just dumps the text out without any final
+ * adjustments.
+ * @return The raw text from the FO Tree.
+ */
+ public CharSequence getRawText() {
+ return new CharSequenceSubset(this.wrappedSequence, this.start, this.length);
+ }
+
+ /**
+ * Returns the number of characters at the start of the wrapped text that should be ignored.
+ * @return The number of characters at the start to be ignored.
+ */
+ private int ignoreAtStart() {
+ return TextArea.ignoreAtStart(this.wrappedSequence, this.start,
+ this.length, TextArea.this.isFirstLeafOnLine(),
+ TextArea.this.traitWhiteSpaceTreatment());
+ }
+
+ /**
+ * Returns the number of characters at the end of the wrapped text that should be ignored.
+ * @return The number of characters at the end to be ignored.
+ */
+ private int ignoreAtEnd() {
+ return TextArea.ignoreAtEnd(this.wrappedSequence, this.start,
+ this.length, TextArea.this.isLastLeafOnLine(),
+ TextArea.this.traitWhiteSpaceTreatment());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int length() {
+ int computedLength = this.getUnhyphenatedLength();
+ computedLength += this.hyphenSize();
+ return computedLength;
+ }
+
+ /**
+ * Computes the number of characters in this sequence before adding the length of any
+ * discretionary hyphens.
+ * @return The number of characters in this sequence before considering hyphenation.
+ */
+ public int getUnhyphenatedLength() {
+ int computedLength = this.length;
+ computedLength -= this.ignoreAtStart();
+ computedLength -= this.ignoreAtEnd();
+ return computedLength;
+ }
+
+ /**
+ * {@inheritDoc}
+ * Overrides method in {@link Object} to properly conform to the {@link CharSequence}
+ * interface.
+ */
+ @Override
+ public String toString() {
+ final int length = this.length();
+ final char[] newChars = new char[length];
+ for (int i = 0; i < length; i++) {
+ newChars[i] = this.charAt(i);
+ }
+ return new String(newChars);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public CharSequence subSequence(final int start, final int end) {
+ if (start < 0
+ || end < 0
+ || end > length()
+ || start > end) {
+ throw new IndexOutOfBoundsException("Illegal sub-sequence bounds.");
+ }
+ final int subSize = end - start;
+ return new CharSequenceSubset(this, start, subSize);
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p>Uses the wrapped sequence as a starting place, and adjusts the return value for the
+ * specialized aspects of this class, specifically:</p>
+ * <ul>
+ * <li>The final round of white-space-treatment changes is handled
+ * here.
+ * <li>Ligature changes and other font-driven character substitutions are
+ * handled here.
+ * <li>Faux small-caps changes are handled here.
+ * <li>Addition of hyphen characters at the end of a line is handled here.
+ * </ul>
+ *
+ * @return The text to be used in the output document.
+ */
+ public char charAt(final int index) {
+ if (index < 0) {
+ throw new IndexOutOfBoundsException("Index out of bounds: " + index);
+ }
+ final int ourIndex = index + this.start + this.ignoreAtStart();
+ final int ourEnd = this.start + this.length - this.ignoreAtEnd();
+ if (ourIndex < ourEnd) {
+ final char c = this.wrappedSequence.charAt(ourIndex);
+ /* Apply faux small-caps, if appropriate. */
+ if (this.hasFauxSmallCaps) {
+ return java.lang.Character.toUpperCase(c);
+ } else {
+ return c;
+ }
+ }
+
+ /* If it extends beyond the wrapped text, it could be asking for the hyphen. */
+ final int hyphenSize = this.hyphenSize();
+ if (ourIndex < ourEnd + hyphenSize) {
+ /* This assumes (properly for now) that the hyphen character can never be more than
+ * two chars long. */
+ if (hyphenSize == 1) {
+ return (char) TextArea.this.traitHyphenationCharacter();
+ } else {
+ final int hyphenIndex = ourIndex - ourEnd;
+ /* TODO: This is a bit ugly. Is there a better way? */
+ final int hyphenChar = TextArea.this.traitHyphenationCharacter();
+ final String hyphenString = new String(new int[] {hyphenChar}, 0, 1);
+ return hyphenString.charAt(hyphenIndex);
+ }
+ }
+ throw new IndexOutOfBoundsException("Index out of bounds: " + index);
+ }
+
+ /**
+ * Returns the number of chars needed to represent the hyphen character, if any.
+ * @return The number of chars needed to represent the hyphen character.
+ */
+ private int hyphenSize() {
+ if (! this.hasDiscretionaryHyphen) {
+ return 0;
+ }
+ final int hyphenChar = TextArea.this.traitHyphenationCharacter();
+ return Character.charCount(hyphenChar);
+ }
+
+ }
+
}
Modified: trunk/foray/foray-common/src/java/org/foray/common/CharSequenceSubset.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/CharSequenceSubset.java 2008-03-18 19:10:51 UTC (rev 10446)
+++ trunk/foray/foray-common/src/java/org/foray/common/CharSequenceSubset.java 2008-03-18 23:45:47 UTC (rev 10447)
@@ -34,7 +34,7 @@
* A wrapper around another CharSequence, providing a view of a subset of that sequence.
* Caveat: One of the weaknesses of {@link CharSequence} interface is its lack of a method
* indicating whether the instance is mutable or immutable.
- * This classes tests dimensions at construction time, but if the wrapped CharSequence changes its
+ * This class tests dimensions at construction time, but if the wrapped CharSequence changes its
* size, this class will have no way of knowing it.
*/
public class CharSequenceSubset implements Serializable, CharSequence {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-03-19 18:14:00
|
Revision: 10449
http://foray.svn.sourceforge.net/foray/?rev=10449&view=rev
Author: victormote
Date: 2008-03-19 11:14:02 -0700 (Wed, 19 Mar 2008)
Log Message:
-----------
Get the kerning included in the computation of the text line.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java
trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java 2008-03-18 23:54:30 UTC (rev 10448)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java 2008-03-19 18:14:02 UTC (rev 10449)
@@ -259,23 +259,24 @@
/* The text is "Test of Centering".
* From the Helvetica AFM file, the widths are as follows:
- * T(611) + e(556) + s(500) + t(278)
- * + space(278)
- * + o(556) + f(278)
- * + space(278)
- * + C(722) + e(556) + n(556) + t(278) + e(556) + r(333) + i(222)
- * + n(556) + g(556)
- * = 7,670.
- * If these are scaled to 12 points, the millipoints used are 7670 * 12
- * = 92,040. */
- assertEquals(92040, textArea.crIpd());
+ * T(611) + kern-T,e(-120) + e(556) + kern-e,s(0) + s(500) + kern-s,t(0) + t(278)
+ * + kern-t,space(0) + space(278) + kern-space,o(0)
+ * + o(556) + kern-o,f(0) + f(278)
+ * + kern-f,space(0) + space(278) + kern-space,C(0)
+ * + C(722) + kern-C,e(0) + e(556) + kern-e,n(0) + n(556) + kern-n,t(0) + t(278)
+ * + kern-t,e(0) + e(556) + kern-e,r(0) + r(333) + kern-r,i(15) + i(222) + kern-i,n(0)
+ * + n(556) + kern-n,g(0) + g(556)
+ * = 7,565.
+ * If these are scaled to 12 points, the millipoints used are 7565 * 12
+ * = 90,780. */
+ assertEquals(90780, textArea.crIpd());
/* The x value of the text area content rectangle should be at the x
* location of the parent line area + 1/2 of the unused area in the
* line. Total line area ipd = 468,000. Unused line area ipd =
- * 468,000 - 92,040 = 375,960. One half of the unused line area ipd =
- * 187,980. x = 72,000 + 187,980 = 259,980. */
- assertEquals(259980, textArea.crOriginX());
+ * 468,000 - 90,780 = 377,220. One half of the unused line area ipd =
+ * 188,610. x = 72,000 + 188,610 = 260,610. */
+ assertEquals(260610, textArea.crOriginX());
/* The y value of the text area content rectangle should be the same as
* the parent line area. */
@@ -326,27 +327,29 @@
/* The text is "Centered with Word Spacing".
* From the Helvetica AFM file, the widths are as follows:
- * C(722) + e(556) + n(556) + t(278) + e(556) + r(333) + e(556) + d(556)
- * + space(278)
- * + w(722) + i(222) + t(278) + h(556)
- * + space(278)
- * + W(944) + o(556) + r(333) + d(556)
- * + space(278)
- * + S(667) + p(556) + a(556) + c(500) + i(222) + n(556) + g(556)
- * = 12,727.
- * If these are scaled to 12 points, the millipoints used are 12,616
- * * 12 = 152,724.
+ * C(722) + kern-C,e(0) + e(556) + kern-e,n(0) + n(556) + kern-n,t(0) + t(278) + kern-t,e(0)
+ * + e(556) + kern-e,r(0) + r(333) + kern-r,e(0) + e(556) + kern-e,d(0) + d(556)
+ * + kern-d,space(0) + space(278) + kern-space,w(0)
+ * + w(722) + kern-w,i(0) + i(222) + kern-i,t(0) + t(278) + kern-t,h(0) + h(556)
+ * + kern-h,space(0) + space(278) + kern-space,W(-40)
+ * + W(944) + kern-W,o(-30) + o(556) + kern-o,r(0) + r(333) + kern-r,d(0) + d(556)
+ * + kern-d,space(0) + space(278) + kern-space,S(0)
+ * + S(667) + kern-S,p(0) + p(556) + kern-p,a(0) + a(556) + kern-a,c(0) + c(500)
+ * + kern-c,i(0) + i(222) + kern-i,n(0) + n(556) + kern-n,g(0) + g(556)
+ * = 12,657.
+ * If these are scaled to 12 points, the millipoints used are 12,657
+ * * 12 = 151,884.
* The extra word spacing is .3em = .3 * 12000 * 3 occurrences = 10,800.
- * Total ipd of text-area = 152,724 + 10,800 = 163,524. */
- assertEquals(163524, textArea.crIpd());
+ * Total ipd of text-area = 151,884 + 10,800 = 162,684. */
+ assertEquals(162684, textArea.crIpd());
/* The x value of the text area content rectangle should be at the x
* location of the parent line area + 1/2 of the unused area in the
* line. Total line area ipd = 468,000. Unused line area ipd =
- * 468,000 - 163,524 = 304,476. One half of the unused line area ipd =
- * 152,238.
- * x = 72,000 + 152,238 = 224,238. */
- assertEquals(224238, textArea.crOriginX());
+ * 468,000 - 162,684 = 305,316. One half of the unused line area ipd =
+ * 152,658.
+ * x = 72,000 + 152,238 = 224,658. */
+ assertEquals(224658, textArea.crOriginX());
/* The y value of the text area content rectangle should be the same as
* the parent line area. */
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2008-03-18 23:54:30 UTC (rev 10448)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2008-03-19 18:14:02 UTC (rev 10449)
@@ -222,7 +222,8 @@
backingOffset, backingSize, hasDiscretionaryHyphen, hasFauxSmallCaps);
this.resolvedLetterSpacing = this.traitLetterSpacingOpt();
this.resolvedWordSpacing = this.traitWordSpacingOpt();
- setProgressionDimension(progressionDimensionUsed);
+ final int computedPD = this.recomputeProgressionDimension();
+ setProgressionDimension(computedPD);
this.initializeAnteriorSpace();
this.ancestorLineArea().lineContentChanged();
}
@@ -600,54 +601,14 @@
* @return The new progression dimension value, in millipoints.
*/
private int recomputeProgressionDimension() {
- int pd = 0;
final CharSequence text = getText();
- for (int i = 0; i < getText().length(); i++) {
- final char c = text.charAt(i);
- final boolean lastCharOnLine = false;
- pd += charWidth(c, lastCharOnLine);
- }
- if (this.charSequence.hasDiscretionaryHyphen()) {
- pd += charWidth(this.traitHyphenationCharacter(), true);
- }
+ final Font font = this.getPrimaryFont().getFont();
+ final int pd = font.width(text, this.traitFontSize(), this.traitLetterSpacingOpt(),
+ this.traitWordSpacingOpt(), true);
return pd;
}
/**
- * Computes the width of a character, including any word-spacing or
- * letter-spacing that is related to it.
- * @param c The char whose width should be computed.
- * @param lastCharOnLine Indicates whether this is the last character on
- * the line. This is needed because neither letter-spacing nor word-spacing
- * should be applied to the last character.
- * @return The width of c plus any word-spacing or letter-spacing that is
- * related to it.
- */
- private int charWidth(final int c, final boolean lastCharOnLine) {
- FontUse fontUse = this.getPrimaryFont();
- if (! fontUse.glyphAvailable(c)) {
- fontUse = this.getSecondaryFont(c);
- }
- final Font font = fontUse.getFont();
- /* Add the width of the character itself. */
- int charWidth = font.width(c, this.traitFontSize());
- fontUse.registerCharUsed(c);
- if (lastCharOnLine) {
- /* Don't add word-space or letter-space to the last character on
- * the line. */
- return charWidth;
- }
- if (wordSpacingApplies(c)) {
- charWidth += this.resolvedWordSpacing;
- } else {
- /* We currently assume that if a word-space does not apply, then
- * a letter-space does. This may not be correct. */
- charWidth += this.resolvedLetterSpacing;
- }
- return charWidth;
- }
-
- /**
* {@inheritDoc}
* Overrides the Area method because it needs to handle faux-small-caps.
*/
@@ -663,18 +624,10 @@
}
/**
- * Indicates whether this text area has a discretionary hyphen.
- * @return True iff this character sequence has a discretionary hyphen.
- */
- public boolean hasDiscretionaryHyphen() {
- return this.charSequence.hasDiscretionaryHyphen();
- }
-
- /**
* Indicates whether this text area has faux small caps.
* @return True iff this character sequence has faux small caps.
*/
- public boolean hasFauxSmallCaps() {
+ private boolean hasFauxSmallCaps() {
return this.charSequence.hasFauxSmallCaps();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-03-19 18:58:33
|
Revision: 10450
http://foray.svn.sourceforge.net/foray/?rev=10450&view=rev
Author: victormote
Date: 2008-03-19 11:58:35 -0700 (Wed, 19 Mar 2008)
Log Message:
-----------
Rename font-related classes starting with "FOray" to instead end with "4a". This better distinguishes our classes from our modules and cleans up some naming in testing classes.
Modified Paths:
--------------
trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java
trunk/foray/foray-font/src/java/org/foray/font/FSTrueTypeFont.java
trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java
trunk/foray/foray-font/src/java/org/foray/font/FontConfigParser.java
trunk/foray/foray-font/src/java/org/foray/font/FontSelector.java
trunk/foray/foray-font/src/java/org/foray/font/FontSelectorCBC.java
trunk/foray/foray-font/src/java/org/foray/font/FontSelectorFactory.java
trunk/foray/foray-font/src/java/org/foray/font/FreeStandingFont.java
trunk/foray/foray-font/src/java/org/foray/font/RegisteredFont.java
trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontDesc.java
trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontFamily.java
trunk/foray/foray-font/src/java/org/foray/font/Subset.java
trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java
trunk/foray/foray-font/src/java/org/foray/font/output/FOrayFontOutput.java
trunk/foray/foray-font/src/java/org/foray/font/output/FOrayFontOutputFactory.java
trunk/foray/foray-font/src/java/org/foray/font/output/FOrayFontPDF.java
trunk/foray/foray-font/src/java/org/foray/font/output/FOrayFontPDFFactory.java
trunk/foray/foray-font/src/java/org/foray/font/output/FOrayFontPS.java
trunk/foray/foray-font/src/java/org/foray/font/output/FOrayFontPSFactory.java
trunk/foray/foray-font/src/javatest/org/foray/font/TestFontServer.java
Added Paths:
-----------
trunk/foray/foray-font/src/java/org/foray/font/ConsumerFont4a.java
trunk/foray/foray-font/src/java/org/foray/font/Font4a.java
trunk/foray/foray-font/src/java/org/foray/font/FontConsumer4a.java
trunk/foray/foray-font/src/java/org/foray/font/FontServer4a.java
trunk/foray/foray-font/src/java/org/foray/font/FontUse4a.java
Removed Paths:
-------------
trunk/foray/foray-font/src/java/org/foray/font/FOrayConsumerFont.java
trunk/foray/foray-font/src/java/org/foray/font/FOrayFont.java
trunk/foray/foray-font/src/java/org/foray/font/FOrayFontConsumer.java
trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java
trunk/foray/foray-font/src/java/org/foray/font/FOrayFontUse.java
Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2008-03-19 18:14:02 UTC (rev 10449)
+++ trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2008-03-19 18:58:35 UTC (rev 10450)
@@ -34,7 +34,7 @@
import org.foray.core.FOrayException;
import org.foray.core.FOraySession;
import org.foray.core.SessionConfig;
-import org.foray.font.FOrayFontServer;
+import org.foray.font.FontServer4a;
import org.foray.fotree.FOrayFOTreeServer;
import org.foray.graphic.GraphicServer4a;
import org.foray.pioneer.PioneerFactory;
@@ -134,7 +134,7 @@
public static FontServer makeFontServer(final Log logger,
final SessionConfig configuration) throws FOrayException {
final EntityResolver entityResolver = makeEntityResolver(configuration);
- final FOrayFontServer forayFontServer = new FOrayFontServer(logger);
+ final FontServer4a forayFontServer = new FontServer4a(logger);
forayFontServer.setBaseFontURL(
configuration.optionFontBaseDirectory());
forayFontServer.setBaseURL(configuration.optionBaseDirectory());
Copied: trunk/foray/foray-font/src/java/org/foray/font/ConsumerFont4a.java (from rev 9957, trunk/foray/foray-font/src/java/org/foray/font/FOrayConsumerFont.java)
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/ConsumerFont4a.java (rev 0)
+++ trunk/foray/foray-font/src/java/org/foray/font/ConsumerFont4a.java 2008-03-19 18:58:35 UTC (rev 10450)
@@ -0,0 +1,313 @@
+/*
+ * Copyright 2006 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font;
+
+import org.foray.ps.encode.EncodingStandard;
+import org.foray.ps.encode.EncodingSymbol;
+import org.foray.ps.encode.EncodingVector;
+import org.foray.ps.encode.EncodingZapfDingbats;
+
+import org.axsl.ps.Encoding;
+
+import org.apache.commons.logging.Log;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>A ConsumerFont represents a Font as used by a specific FontConsumer.
+ * The key fields are therefore a Font and a FontConsumer.
+ * The main responsibilities of this class are:</p>
+ * <ul>
+ * <li>To supply a FontUse with the proper encoding when it is requested by
+ * a FontConsumer.</li>
+ * <li>To handle subsetting.</li>
+ * </ul>
+ *
+ */
+public class ConsumerFont4a {
+
+ /** The parent Font instance. */
+ private Font4a font;
+
+ /** The parent FontConsumer instance. */
+ private FontConsumer4a consumer;
+
+ /** The Subset instance. This is null if subsetting is not being used. */;
+ private Subset subset = null;
+
+ /** List of all child FontUse instances. */
+ private List<FontUse4a> fontUses = new ArrayList<FontUse4a>(1);
+
+ /**
+ * Constructor.
+ * @param font The parent font.
+ * @param consumer The parent font consumer.
+ */
+ public ConsumerFont4a(final Font4a font,
+ final FontConsumer4a consumer) {
+ this.font = font;
+ this.consumer = consumer;
+ if (this.font.isSubsettable()) {
+ this.subset = new Subset(this);
+ }
+ }
+
+ /**
+ * Returns the parent font.
+ * @return The font.
+ */
+ public Font4a getFOrayFont() {
+ return this.font;
+ }
+
+ /**
+ * Returns the font cast as a free-standing font.
+ * @return The font cast as a free-standing font if it is one, or null
+ * otherwise.
+ */
+ public FreeStandingFont getFreeStandingFont() {
+ if (this.font instanceof FreeStandingFont) {
+ return (FreeStandingFont) this.font;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the font cast as a system font.
+ * @return The font cast as a system font if it is one, or null otherwise.
+ */
+ public SystemFont getSystemFont() {
+ if (this.font instanceof SystemFont) {
+ return (SystemFont) this.font;
+ }
+ return null;
+ }
+
+ /**
+ * Return the parent font consumer.
+ * @return The font consumer.
+ */
+ public FontConsumer4a getFontConsumer() {
+ return this.consumer;
+ }
+
+ /**
+ * Return the subset information for this font.
+ * @return The subset.
+ */
+ public Subset getSubset() {
+ return this.subset;
+ }
+
+ /**
+ * Indicates whether this font is being subsetted.
+ * @return True iff this font is being subsetted.
+ */
+ public boolean subSetting() {
+ return this.subset != null;
+ }
+
+ /**
+ * Return the logger.
+ * @return The logger.
+ */
+ public Log getLogger() {
+ return this.consumer.getLogger();
+ }
+
+ /**
+ * Return the font server.
+ * @return The font server.
+ */
+ public FontServer4a getFOrayFontServer() {
+ return this.consumer.getFontServer();
+ }
+
+ /**
+ * Optimize the information about this font in preparation for output.
+ */
+ protected void optimize() {
+ if (this.subset != null) {
+ this.subset.sortUsedGlyphs();
+ }
+ }
+
+ /**
+ * Return the collection of child font uses.
+ * @return The child font uses.
+ */
+ public List<FontUse4a> getFontUses() {
+ return this.fontUses;
+ }
+
+ /**
+ * Select a font use based on the registered font description and a Unicode
+ * code point.
+ * @param rfd The font description that should be used for the selection.
+ * @param codePoint The Unicode code point that should be encodable by the
+ * returned font use.
+ * @return The best font use.
+ */
+ public FontUse4a selectFontUse(final RegisteredFontDesc rfd,
+ final int codePoint) {
+ if (rfd == null) {
+ return null;
+ }
+ FontUse4a fontUse = null;
+ final SystemFont sf = getSystemFont();
+ /* Check existing FontUse instances. */
+ for (int i = 0; i < this.fontUses.size() && fontUse == null; i++) {
+ final FontUse4a trialFontUse = this.fontUses.get(i);
+ if (trialFontUse.getRegisteredFontDesc() != rfd) {
+ continue;
+ }
+ if (sf != null) {
+ if (! sf.glyphAvailable(codePoint)) {
+ continue;
+ }
+ } else {
+ final org.axsl.ps.Encoding encoding =
+ trialFontUse.getEncoding();
+ if (! encoding.canEncode(codePoint)) {
+ continue;
+ }
+ }
+ fontUse = trialFontUse;
+ }
+ if (fontUse != null) {
+ return fontUse;
+ }
+ /* If none already exists, create one. */
+ if (sf != null) {
+ /* We don't care about encodings for SystemFonts. */
+ fontUse = new FontUse4a(this, rfd, null);
+ } else {
+ final Encoding encoding = findEncoding(rfd, codePoint);
+ if (encoding == null) {
+ /* We can't encode this character.
+ * Return null so that the upstream font selection routines can
+ * try another font family. */
+ return null;
+ }
+ fontUse = new FontUse4a(this, rfd, encoding);
+ }
+ this.fontUses.add(fontUse);
+ return fontUse;
+ }
+
+ /**
+ * Returns the described FontUse instance, creating it if necessary.
+ * @param rfd The description for which the font use should be retrieved
+ * or created.
+ * @param encoding The encoding for which the font use should be retrieved
+ * or created.
+ * @return The selected or created font use.
+ */
+ public FontUse4a getFontUse(final RegisteredFontDesc rfd,
+ final Encoding encoding) {
+ for (int i = 0; i < this.fontUses.size(); i++) {
+ final FontUse4a fontUse = this.fontUses.get(i);
+ if (fontUse.getRegisteredFontDesc() != rfd) {
+ continue;
+ }
+ if (fontUse.getEncoding() != encoding) {
+ continue;
+ }
+ return fontUse;
+ }
+ return new FontUse4a(this, rfd, encoding);
+ }
+
+ /**
+ * Find the encoding that should be used for the seletion of a font use.
+ * @param rfd The font description.
+ * @param codePoint The Unicode code point.
+ * @return The appropriate encoding.
+ */
+ public Encoding findEncoding(final RegisteredFontDesc rfd,
+ final int codePoint) {
+ switch (this.consumer.getEncodingLatitude()) {
+ case FontConsumer4a.ENCODING_SPECIFIED_ONLY: {
+ return rfd.getEncoding();
+ }
+ case FontConsumer4a.ENCODING_INTERNAL_ONLY: {
+ return this.font.getInternalEncoding();
+ }
+ case FontConsumer4a.ENCODING_ANY: {
+ return getBestEncoding(codePoint);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Finds the best encoding to use for a given Unicode code point.
+ * @param codePoint The Unicode code point to be tested.
+ * @return The best encoding to use for the code point.
+ */
+ private Encoding getBestEncoding(final int codePoint) {
+ Encoding trialEncoding = null;
+ final Encoding internalEncoding = this.font.getInternalEncoding();
+ if (! (internalEncoding instanceof EncodingVector)) {
+ /* CMap encodings should be able to handle any character in the
+ * font's character set. */
+ return internalEncoding;
+ }
+ if (internalEncoding instanceof EncodingSymbol
+ || internalEncoding instanceof EncodingZapfDingbats) {
+ /* The specialized encodings cover their entire character set. */
+ return internalEncoding;
+ }
+ if (internalEncoding instanceof EncodingStandard) {
+ /* Try WinAnsiEncoding. */
+ trialEncoding = EncodingVector.getPredefinedEncoding(
+ "WinAnsiEncoding");
+ if (trialEncoding.canEncode(codePoint)) {
+ return trialEncoding;
+ }
+ /* Try the Central European encoding. */
+ trialEncoding = EncodingVector.getPredefinedEncoding("CEEncoding");
+ if (trialEncoding.canEncode(codePoint)) {
+ return trialEncoding;
+ }
+ /* Try the FOray catch-all encoding. */
+ trialEncoding = EncodingVector.getPredefinedEncoding(
+ "FOrayLatinExtraEncoding");
+ if (trialEncoding.canEncode(codePoint)) {
+ return trialEncoding;
+ }
+ }
+ if (internalEncoding.canEncode(codePoint)) {
+ return internalEncoding;
+ }
+ return null;
+ }
+
+}
Deleted: trunk/foray/foray-font/src/java/org/foray/font/FOrayConsumerFont.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/FOrayConsumerFont.java 2008-03-19 18:14:02 UTC (rev 10449)
+++ trunk/foray/foray-font/src/java/org/foray/font/FOrayConsumerFont.java 2008-03-19 18:58:35 UTC (rev 10450)
@@ -1,313 +0,0 @@
-/*
- * Copyright 2006 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.font;
-
-import org.foray.ps.encode.EncodingStandard;
-import org.foray.ps.encode.EncodingSymbol;
-import org.foray.ps.encode.EncodingVector;
-import org.foray.ps.encode.EncodingZapfDingbats;
-
-import org.axsl.ps.Encoding;
-
-import org.apache.commons.logging.Log;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * <p>A ConsumerFont represents a Font as used by a specific FontConsumer.
- * The key fields are therefore a Font and a FontConsumer.
- * The main responsibilities of this class are:</p>
- * <ul>
- * <li>To supply a FontUse with the proper encoding when it is requested by
- * a FontConsumer.</li>
- * <li>To handle subsetting.</li>
- * </ul>
- *
- */
-public class FOrayConsumerFont {
-
- /** The parent Font instance. */
- private FOrayFont font;
-
- /** The parent FontConsumer instance. */
- private FOrayFontConsumer consumer;
-
- /** The Subset instance. This is null if subsetting is not being used. */;
- private Subset subset = null;
-
- /** List of all child FontUse instances. */
- private List<FOrayFontUse> fontUses = new ArrayList<FOrayFontUse>(1);
-
- /**
- * Constructor.
- * @param font The parent font.
- * @param consumer The parent font consumer.
- */
- public FOrayConsumerFont(final FOrayFont font,
- final FOrayFontConsumer consumer) {
- this.font = font;
- this.consumer = consumer;
- if (this.font.isSubsettable()) {
- this.subset = new Subset(this);
- }
- }
-
- /**
- * Returns the parent font.
- * @return The font.
- */
- public FOrayFont getFOrayFont() {
- return this.font;
- }
-
- /**
- * Returns the font cast as a free-standing font.
- * @return The font cast as a free-standing font if it is one, or null
- * otherwise.
- */
- public FreeStandingFont getFreeStandingFont() {
- if (this.font instanceof FreeStandingFont) {
- return (FreeStandingFont) this.font;
- }
- return null;
- }
-
- /**
- * Returns the font cast as a system font.
- * @return The font cast as a system font if it is one, or null otherwise.
- */
- public SystemFont getSystemFont() {
- if (this.font instanceof SystemFont) {
- return (SystemFont) this.font;
- }
- return null;
- }
-
- /**
- * Return the parent font consumer.
- * @return The font consumer.
- */
- public FOrayFontConsumer getFontConsumer() {
- return this.consumer;
- }
-
- /**
- * Return the subset information for this font.
- * @return The subset.
- */
- public Subset getSubset() {
- return this.subset;
- }
-
- /**
- * Indicates whether this font is being subsetted.
- * @return True iff this font is being subsetted.
- */
- public boolean subSetting() {
- return this.subset != null;
- }
-
- /**
- * Return the logger.
- * @return The logger.
- */
- public Log getLogger() {
- return this.consumer.getLogger();
- }
-
- /**
- * Return the font server.
- * @return The font server.
- */
- public FOrayFontServer getFOrayFontServer() {
- return this.consumer.getFontServer();
- }
-
- /**
- * Optimize the information about this font in preparation for output.
- */
- protected void optimize() {
- if (this.subset != null) {
- this.subset.sortUsedGlyphs();
- }
- }
-
- /**
- * Return the collection of child font uses.
- * @return The child font uses.
- */
- public List<FOrayFontUse> getFontUses() {
- return this.fontUses;
- }
-
- /**
- * Select a font use based on the registered font description and a Unicode
- * code point.
- * @param rfd The font description that should be used for the selection.
- * @param codePoint The Unicode code point that should be encodable by the
- * returned font use.
- * @return The best font use.
- */
- public FOrayFontUse selectFontUse(final RegisteredFontDesc rfd,
- final int codePoint) {
- if (rfd == null) {
- return null;
- }
- FOrayFontUse fontUse = null;
- final SystemFont sf = getSystemFont();
- /* Check existing FontUse instances. */
- for (int i = 0; i < this.fontUses.size() && fontUse == null; i++) {
- final FOrayFontUse trialFontUse = this.fontUses.get(i);
- if (trialFontUse.getRegisteredFontDesc() != rfd) {
- continue;
- }
- if (sf != null) {
- if (! sf.glyphAvailable(codePoint)) {
- continue;
- }
- } else {
- final org.axsl.ps.Encoding encoding =
- trialFontUse.getEncoding();
- if (! encoding.canEncode(codePoint)) {
- continue;
- }
- }
- fontUse = trialFontUse;
- }
- if (fontUse != null) {
- return fontUse;
- }
- /* If none already exists, create one. */
- if (sf != null) {
- /* We don't care about encodings for SystemFonts. */
- fontUse = new FOrayFontUse(this, rfd, null);
- } else {
- final Encoding encoding = findEncoding(rfd, codePoint);
- if (encoding == null) {
- /* We can't encode this character.
- * Return null so that the upstream font selection routines can
- * try another font family. */
- return null;
- }
- fontUse = new FOrayFontUse(this, rfd, encoding);
- }
- this.fontUses.add(fontUse);
- return fontUse;
- }
-
- /**
- * Returns the described FontUse instance, creating it if necessary.
- * @param rfd The description for which the font use should be retrieved
- * or created.
- * @param encoding The encoding for which the font use should be retrieved
- * or created.
- * @return The selected or created font use.
- */
- public FOrayFontUse getFontUse(final RegisteredFontDesc rfd,
- final Encoding encoding) {
- for (int i = 0; i < this.fontUses.size(); i++) {
- final FOrayFontUse fontUse = this.fontUses.get(i);
- if (fontUse.getRegisteredFontDesc() != rfd) {
- continue;
- }
- if (fontUse.getEncoding() != encoding) {
- continue;
- }
- return fontUse;
- }
- return new FOrayFontUse(this, rfd, encoding);
- }
-
- /**
- * Find the encoding that should be used for the seletion of a font use.
- * @param rfd The font description.
- * @param codePoint The Unicode code point.
- * @return The appropriate encoding.
- */
- public Encoding findEncoding(final RegisteredFontDesc rfd,
- final int codePoint) {
- switch (this.consumer.getEncodingLatitude()) {
- case FOrayFontConsumer.ENCODING_SPECIFIED_ONLY: {
- return rfd.getEncoding();
- }
- case FOrayFontConsumer.ENCODING_INTERNAL_ONLY: {
- return this.font.getInternalEncoding();
- }
- case FOrayFontConsumer.ENCODING_ANY: {
- return getBestEncoding(codePoint);
- }
- }
- return null;
- }
-
- /**
- * Finds the best encoding to use for a given Unicode code point.
- * @param codePoint The Unicode code point to be tested.
- * @return The best encoding to use for the code point.
- */
- private Encoding getBestEncoding(final int codePoint) {
- Encoding trialEncoding = null;
- final Encoding internalEncoding = this.font.getInternalEncoding();
- if (! (internalEncoding instanceof EncodingVector)) {
- /* CMap encodings should be able to handle any character in the
- * font's character set. */
- return internalEncoding;
- }
- if (internalEncoding instanceof EncodingSymbol
- || internalEncoding instanceof EncodingZapfDingbats) {
- /* The specialized encodings cover their entire character set. */
- return internalEncoding;
- }
- if (internalEncoding instanceof EncodingStandard) {
- /* Try WinAnsiEncoding. */
- trialEncoding = EncodingVector.getPredefinedEncoding(
- "WinAnsiEncoding");
- if (trialEncoding.canEncode(codePoint)) {
- return trialEncoding;
- }
- /* Try the Central European encoding. */
- trialEncoding = EncodingVector.getPredefinedEncoding("CEEncoding");
- if (trialEncoding.canEncode(codePoint)) {
- return trialEncoding;
- }
- /* Try the FOray catch-all encoding. */
- trialEncoding = EncodingVector.getPredefinedEncoding(
- "FOrayLatinExtraEncoding");
- if (trialEncoding.canEncode(codePoint)) {
- return trialEncoding;
- }
- }
- if (internalEncoding.canEncode(codePoint)) {
- return internalEncoding;
- }
- return null;
- }
-
-}
Deleted: trunk/foray/foray-font/src/java/org/foray/font/FOrayFont.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/FOrayFont.java 2008-03-19 18:14:02 UTC (rev 10449)
+++ trunk/foray/foray-font/src/java/org/foray/font/FOrayFont.java 2008-03-19 18:58:35 UTC (rev 10450)
@@ -1,558 +0,0 @@
-/*
- * Copyright 2005 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-package org.foray.font;
-
-import org.foray.common.WKConstants;
-import org.foray.font.charset.CharSet;
-import org.foray.font.format.Kerning;
-
-import org.axsl.font.Font;
-
-import org.apache.commons.logging.Log;
-
-/**
- * An implementation of the aXSL {@link FOrayFont} interface.
- */
-public abstract class FOrayFont implements org.axsl.font.Font {
-
- /** Constant indicating the ratio between 3-per-em and em. */
- private static final int FACTOR_3_PER_EM = 3;
-
- /** Constant indicating the ratio between 4-per-em and em. */
- private static final int FACTOR_4_PER_EM = 4;
-
- /** Constant indicating the ratio between 6-per-em and em. */
- private static final int FACTOR_6_PER_EM = 6;
-
- /** Constant indicating the ratio between a thin space and em. */
- private static final int FACTOR_THIN_SPACE = 5;
-
- /** Constant indicating the ratio between a hair space and em. */
- private static final int FACTOR_HAIR_SPACE = 10;
-
- /** Constant indicating the default line-height factor. */
- private static final float DEFAULT_LINE_HEIGHT_FACTOR = 1.2F;
-
- /** Constant indicating the default strikeout position. */
- private static final float DEFAULT_STRIKEOUT_POSITION = .375F;
-
- /** Constant for the default strikout size. The computation is equal to
- * 102 / 2048, which factors come from the OpenType manual, Section "OS/2
- * table", for the definition of "yStrikeoutSize", where this ratio is
- * suggested. */
- private static final float DEFAULT_STRIKEOUT_SIZE = 0.0498046875F;
-
- /** Constant for the default underline position. */
- private static final float DEFAULT_UNDERLINE_POSITION = .10F;
-
- /** Constant for the default overline position. */
- private static final float DEFAULT_OVERLINE_POSITION = .10F;
-
- /** Constant for the default hanging baseline position. */
- private static final float DEFAULT_HANGING_BASELINE_POSITION = .3F;
-
- /** Constant used to compute subscript baseline shift amounts. */
- private static final float SUBSCRIPT_SHIFT_FACTOR = .6666666666666666667f;
-
- /** Constant used to compute superscript baseline shift amounts. */
- private static final float SUPERSCRIPT_SHIFT_FACTOR = .6666666666666666667f;
-
- /**
- * The RegisteredFont that is attached to this Font instance.
- */
- private RegisteredFont registeredFont = null;
-
- /**
- * Constructor.
- * @param rf The parent registered font.
- */
- protected FOrayFont(final RegisteredFont rf) {
- this.registeredFont = rf;
- }
-
- /**
- * {@inheritDoc}
- */
- public abstract int getAscender(int fontSize);
-
- /**
- * {@inheritDoc}
- */
- public abstract int getDescender(int fontSize);
-
- /**
- * {@inheritDoc}
- */
- public abstract int getCapHeight(int fontSize);
-
- /**
- * {@inheritDoc}
- */
- public abstract int getXHeight(int fontSize);
-
- /**
- * Return the width of one em.
- * @param fontSize The font size, in millipoints, at which the em width is
- * desired.
- * @return The width of one em at <code>fontSize</code>.
- */
- private int getEmWidth(final int fontSize) {
- return fontSize;
- }
-
- /**
- * Return the width of one en.
- * @param fontSize The font size, in millipoints, at which the en width is
- * desired.
- * @return The width of one en at <code>fontSize</code>.
- */
- private int getEnWidth(final int fontSize) {
- return Math.round(fontSize / 2);
- }
-
- /**
- * {@inheritDoc}
- */
- public abstract int width(int c, int fontSize);
-
- /**
- * {@inheritDoc}
- */
- public int widthEstimate(final int c, final int fontSize) {
- switch (c) {
- case '\u0009': // horizontal tab
- case '\n': // linefeed
- case '\r': // carriage-return
- case '\u00A0': // non-breaking space
- return width(' ', fontSize);
- ...
[truncated message content] |
|
From: <vic...@us...> - 2008-03-19 19:55:21
|
Revision: 10452
http://foray.svn.sourceforge.net/foray/?rev=10452&view=rev
Author: victormote
Date: 2008-03-19 12:55:27 -0700 (Wed, 19 Mar 2008)
Log Message:
-----------
Rename font-related classes starting with "FOray" to instead end with "4a". This better distinguishes our classes from our modules and cleans up some naming in testing classes.
Modified Paths:
--------------
trunk/foray/doc/web/00-release/notes-unreleased.html
trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java
trunk/foray/foray-app/src/javatest/org/foray/app/area/AreaTreeCreator.java
trunk/foray/foray-app/src/javatest/org/foray/app/fo/FoDocumentReader.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/FOTreeBuilder.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/Namespace.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/HyphenationTree.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/MorphHyphenation.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/util/ValidateChars.java
trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/TestFOrayHyphenationServer.java
trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/util/TestNaturalLanguage.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFXFormEps.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFXFormSvg.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PdfXFormMath.java
trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
trunk/foray/foray-text/src/java/org/foray/text/line/EagerLineBreaker.java
trunk/foray/foray-text/src/java/org/foray/text/line/LineBreaker.java
trunk/foray/foray-text/src/java/org/foray/text/line/PatientLineBreaker.java
trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java
Added Paths:
-----------
trunk/foray/foray-areatree/src/java/org/foray/area/AreaTreeFactory4a.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/FoTreeServer4a.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/HyphenBreak4a.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/Hyphenation4a.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/HyphenationServer4a.java
trunk/foray/foray-ps/src/java/org/foray/ps/BoundingBox4a.java
trunk/foray/foray-text/src/java/org/foray/text/TextServer4a.java
Removed Paths:
-------------
trunk/foray/foray-areatree/src/java/org/foray/area/FOrayAreaTreeFactory.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/FOrayFOTreeServer.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/FOrayHyphenBreak.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/FOrayHyphenation.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/FOrayHyphenationServer.java
trunk/foray/foray-ps/src/java/org/foray/ps/FOrayBoundingBox.java
trunk/foray/foray-text/src/java/org/foray/text/TextServer.java
Modified: trunk/foray/doc/web/00-release/notes-unreleased.html
===================================================================
--- trunk/foray/doc/web/00-release/notes-unreleased.html 2008-03-19 19:03:20 UTC (rev 10451)
+++ trunk/foray/doc/web/00-release/notes-unreleased.html 2008-03-19 19:55:27 UTC (rev 10452)
@@ -56,6 +56,8 @@
registered with the GraphicServer to do similar things for the supported output
formats. See GraphicServer4a.registerGraphicOutputFactory(GraphicOutputFactory
factory) for details.
+ <li>Renamed many classes that implement aXSL interfaces so that they end with "4a" instead of
+starting with "FOray".</li>
</li>
</ul>
Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2008-03-19 19:03:20 UTC (rev 10451)
+++ trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2008-03-19 19:55:27 UTC (rev 10452)
@@ -28,14 +28,14 @@
package org.foray.app;
-import org.foray.area.FOrayAreaTreeFactory;
+import org.foray.area.AreaTreeFactory4a;
import org.foray.common.Logging;
import org.foray.common.url.URLFactory;
import org.foray.core.FOrayException;
import org.foray.core.FOraySession;
import org.foray.core.SessionConfig;
import org.foray.font.FontServer4a;
-import org.foray.fotree.FOrayFOTreeServer;
+import org.foray.fotree.FoTreeServer4a;
import org.foray.graphic.GraphicServer4a;
import org.foray.pioneer.PioneerFactory;
import org.foray.speech.SpeechServer4a;
@@ -158,7 +158,7 @@
*/
public static TextServer makeTextServer(final Log logger,
final HyphenationServer hyphenServer) throws FOrayException {
- return new org.foray.text.TextServer(logger, hyphenServer);
+ return new org.foray.text.TextServer4a(logger, hyphenServer);
}
/**
@@ -171,7 +171,7 @@
final SessionConfig configuration) {
final URL hyphenationDir =
configuration.optionHyphenationBaseDirectory();
- return new org.foray.hyphen.FOrayHyphenationServer(logger,
+ return new org.foray.hyphen.HyphenationServer4a(logger,
hyphenationDir);
}
@@ -203,7 +203,7 @@
final GraphicServer graphicServer, final TextServer textServer)
throws FOrayException {
final URL[] graphicSearchPath = buildGraphicSearchPath(configuration);
- return new FOrayFOTreeServer(logger, fontServer, textServer,
+ return new FoTreeServer4a(logger, fontServer, textServer,
graphicServer, graphicSearchPath,
configuration.optionCacheGraphics());
}
@@ -233,9 +233,9 @@
* @return The newly-created AreaTreeFactory instance.
* @throws FOrayException For errors creating the server.
*/
- public static FOrayAreaTreeFactory makeAreaTreeFactory(final Log logger)
+ public static AreaTreeFactory4a makeAreaTreeFactory(final Log logger)
throws FOrayException {
- return new FOrayAreaTreeFactory(logger);
+ return new AreaTreeFactory4a(logger);
}
/**
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/area/AreaTreeCreator.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/AreaTreeCreator.java 2008-03-19 19:03:20 UTC (rev 10451)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/AreaTreeCreator.java 2008-03-19 19:55:27 UTC (rev 10452)
@@ -31,11 +31,11 @@
import org.foray.app.FOraySpecific;
import org.foray.app.fo.FoDocumentReader;
import org.foray.area.AreaTree;
-import org.foray.area.FOrayAreaTreeFactory;
+import org.foray.area.AreaTreeFactory4a;
import org.foray.area.PageCollection;
import org.foray.core.FOrayException;
import org.foray.fotree.FOTreeBuilder;
-import org.foray.fotree.FOrayFOTreeServer;
+import org.foray.fotree.FoTreeServer4a;
import org.foray.fotree.fo.obj.PageSequence;
import org.foray.fotree.fo.obj.Root;
import org.foray.pioneer.PioneerFactory;
@@ -56,7 +56,7 @@
private static AreaTreeCreator theInstance;
/** The area tree factory. */
- private FOrayAreaTreeFactory areaTreeFactory;
+ private AreaTreeFactory4a areaTreeFactory;
/** The layout factory. */
private PioneerFactory layoutFactory;
@@ -68,9 +68,9 @@
* objects.
*/
private AreaTreeCreator() throws IOException, FOrayException {
- final FOrayFOTreeServer treeServer = FoDocumentReader.getInstance()
+ final FoTreeServer4a treeServer = FoDocumentReader.getInstance()
.getTreeServer();
- final FOrayAreaTreeFactory areaTreeFactory =
+ final AreaTreeFactory4a areaTreeFactory =
FOraySpecific.makeAreaTreeFactory(treeServer.getLogger());
this.areaTreeFactory = areaTreeFactory;
final PioneerFactory layoutFactory = FOraySpecific.makeLayoutFactory(
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/fo/FoDocumentReader.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/fo/FoDocumentReader.java 2008-03-19 19:03:20 UTC (rev 10451)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/fo/FoDocumentReader.java 2008-03-19 19:55:27 UTC (rev 10452)
@@ -36,7 +36,7 @@
import org.foray.core.FOrayException;
import org.foray.core.SessionConfig;
import org.foray.fotree.FOTreeBuilder;
-import org.foray.fotree.FOrayFOTreeServer;
+import org.foray.fotree.FoTreeServer4a;
import org.axsl.font.FontConsumer;
import org.axsl.font.FontServer;
@@ -72,7 +72,7 @@
private File testDirectory;
/** The tree server. */
- private FOrayFOTreeServer treeServer;
+ private FoTreeServer4a treeServer;
/**
* Constructor.
@@ -99,7 +99,7 @@
graphicSearchPath[0] = URLFactory.createURL(testDirUrl, "fo/");
final boolean cachingGraphics = false;
- this.treeServer = new FOrayFOTreeServer(logger, fontServer, textServer,
+ this.treeServer = new FoTreeServer4a(logger, fontServer, textServer,
graphicServer, graphicSearchPath, cachingGraphics);
}
@@ -161,7 +161,7 @@
* Returns the tree server.
* @return The tree server.
*/
- public FOrayFOTreeServer getTreeServer() {
+ public FoTreeServer4a getTreeServer() {
return this.treeServer;
}
Copied: trunk/foray/foray-areatree/src/java/org/foray/area/AreaTreeFactory4a.java (from rev 10074, trunk/foray/foray-areatree/src/java/org/foray/area/FOrayAreaTreeFactory.java)
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/AreaTreeFactory4a.java (rev 0)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/AreaTreeFactory4a.java 2008-03-19 19:55:27 UTC (rev 10452)
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2005 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.area;
+
+import org.axsl.area.AreaTreeFactory;
+import org.axsl.fo.fo.Root;
+
+import org.apache.commons.logging.Log;
+
+/**
+ * The top-level object in the FOTree implementation.
+ * FOTreeServer encapsulates the FOTree at a high level of abstraction for a
+ * client application.
+ */
+public class AreaTreeFactory4a implements AreaTreeFactory {
+
+ /** The logger. */
+ private Log logger;
+
+ /**
+ * Constructor.
+ * @param logger The logger.
+ */
+ public AreaTreeFactory4a(final Log logger) {
+ this.logger = logger;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public AreaTree makeAreaTree(final Root root) {
+ final AreaTree areaTree = AreaTree.makeAreaTree(root, getLogger());
+ return areaTree;
+ }
+
+ /**
+ * Returns the logger.
+ * @return The logger.
+ */
+ public Log getLogger() {
+ return this.logger;
+ }
+
+ /**
+ * Sets the logger to be used by AreaTree instances.
+ * If a new logger is needed for each AreaTree instance created, this method
+ * should be run before running {@link #makeAreaTree(Root)}.
+ * @param logger The new logger.
+ */
+ public void setLogger(final Log logger) {
+ this.logger = logger;
+ }
+
+}
Deleted: trunk/foray/foray-areatree/src/java/org/foray/area/FOrayAreaTreeFactory.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/FOrayAreaTreeFactory.java 2008-03-19 19:03:20 UTC (rev 10451)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/FOrayAreaTreeFactory.java 2008-03-19 19:55:27 UTC (rev 10452)
@@ -1,80 +0,0 @@
-/*
- * Copyright 2005 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.area;
-
-import org.axsl.area.AreaTreeFactory;
-import org.axsl.fo.fo.Root;
-
-import org.apache.commons.logging.Log;
-
-/**
- * The top-level object in the FOTree implementation.
- * FOTreeServer encapsulates the FOTree at a high level of abstraction for a
- * client application.
- */
-public class FOrayAreaTreeFactory implements AreaTreeFactory {
-
- /** The logger. */
- private Log logger;
-
- /**
- * Constructor.
- * @param logger The logger.
- */
- public FOrayAreaTreeFactory(final Log logger) {
- this.logger = logger;
- }
-
- /**
- * {@inheritDoc}
- */
- public AreaTree makeAreaTree(final Root root) {
- final AreaTree areaTree = AreaTree.makeAreaTree(root, getLogger());
- return areaTree;
- }
-
- /**
- * Returns the logger.
- * @return The logger.
- */
- public Log getLogger() {
- return this.logger;
- }
-
- /**
- * Sets the logger to be used by AreaTree instances.
- * If a new logger is needed for each AreaTree instance created, this method
- * should be run before running {@link #makeAreaTree(Root)}.
- * @param logger The new logger.
- */
- public void setLogger(final Log logger) {
- this.logger = logger;
- }
-
-}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/FOTreeBuilder.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/FOTreeBuilder.java 2008-03-19 19:03:20 UTC (rev 10451)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FOTreeBuilder.java 2008-03-19 19:55:27 UTC (rev 10452)
@@ -85,7 +85,7 @@
private ForeignXML activeForeignXML = null;
/** The parent server. */
- private FOrayFOTreeServer server;
+ private FoTreeServer4a server;
/** The logger. */
private Log logger;
@@ -118,7 +118,7 @@
* @param server The parent server.
* @param logger The logger.
*/
- public FOTreeBuilder(final FOrayFOTreeServer server, final Log logger) {
+ public FOTreeBuilder(final FoTreeServer4a server, final Log logger) {
this.server = server;
this.logger = logger;
}
@@ -495,7 +495,7 @@
* Return the "parent" FO Tree server.
* @return The FO Tree server.
*/
- public FOrayFOTreeServer getTreeServer() {
+ public FoTreeServer4a getTreeServer() {
return this.server;
}
Deleted: trunk/foray/foray-fotree/src/java/org/foray/fotree/FOrayFOTreeServer.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/FOrayFOTreeServer.java 2008-03-19 19:03:20 UTC (rev 10451)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FOrayFOTreeServer.java 2008-03-19 19:55:27 UTC (rev 10452)
@@ -1,306 +0,0 @@
-/*
- * Copyright 2005 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.fotree;
-
-import org.foray.common.ClassService;
-import org.foray.fotree.axsl.NamespaceAxsl;
-import org.foray.fotree.fo.NamespaceFO;
-import org.foray.fotree.foray.NamespaceForay;
-import org.foray.fotree.math.MathNamespace;
-import org.foray.fotree.svg.NamespaceSVG;
-import org.foray.fotree.xml.NamespaceXML;
-
-import org.axsl.fo.FoTreeFactory;
-import org.axsl.font.FontServer;
-import org.axsl.graphic.GraphicServer;
-import org.axsl.text.TextServer;
-
-import org.apache.commons.logging.Log;
-
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * The top-level object in the FOTree implementation.
- * FOTreeServer encapsulates the FOTree at a high level of abstraction for a
- * client application.
- */
-public class FOrayFOTreeServer implements FoTreeFactory {
-
- /** The logger. */
- private Log logger;
-
- /** The font server. */
- private FontServer fontServer;
-
- /** The graphic server. */
- private GraphicServer graphicServer;
-
- /** The text server. */
- private TextServer textServer;
-
- /** The array of URLs in which graphics should be searched. */
- private URL[] graphicSearchPath;
-
- /** Indicates whether we are caching graphics for reuse. */
- private boolean cachingGraphics;
-
- /** Map whose key is a String of the namespace URI, and whose value is
- * a Namespace instance that knows how to parse items in that namespace. */
- private Map<String, Namespace> namespaceMap
- = new HashMap<String, Namespace>();
-
- /** The "FO" namespace. */
- private NamespaceFO namespaceFO;
-
- /** The namespace to use for "foray" items. */
- private NamespaceForay namespaceForay;
-
- /** The namespace to use for "axsl" items. */
- private NamespaceAxsl namespaceAxsl;
-
- /** The "SVG" namespace. */
- private NamespaceSVG namespaceSVG;
-
- /** The "MathML" namespace. */
- private MathNamespace namespaceMath;
-
- /** The "XML namespace. */
- private NamespaceXML namespaceXML;
-
- /**
- * Constructor.
- * @param logger The logger.
- * @param fontServer The font server.
- * @param textServer The text server.
- * @param graphicServer The graphic server.
- * @param graphicSearchPath The array of URLs in which graphics should be
- * searched.
- * @param cachingGraphics Indicates whether we are caching graphics for
- * reuse.
- */
- public FOrayFOTreeServer(final Log logger,
- final FontServer fontServer,
- final TextServer textServer,
- final GraphicServer graphicServer,
- final URL[] graphicSearchPath,
- final boolean cachingGraphics) {
- this.logger = logger;
- this.fontServer = fontServer;
- this.graphicServer = graphicServer;
- this.textServer = textServer;
- this.graphicSearchPath = graphicSearchPath;
- this.cachingGraphics = cachingGraphics;
- setupNamespaces();
- }
-
- /**
- * Creates and registers the standard Namespace instances and those custom
- * namespaces that are embedded.
- */
- private void setupNamespaces() {
- // Register the standard Namespaces.
- final NamespaceFO fo = new NamespaceFO();
- registerNamespace(fo);
- this.namespaceFO = fo;
- final NamespaceXML xml = new NamespaceXML();
- registerNamespace(xml);
- this.namespaceXML = xml;
- final NamespaceSVG svg = new NamespaceSVG();
- registerNamespace(svg);
- this.namespaceSVG = svg;
- final MathNamespace math = new MathNamespace();
- this.registerNamespace(math);
- this.namespaceMath = math;
- final NamespaceForay extensions = new NamespaceForay();
- registerNamespace(extensions);
- this.namespaceForay = extensions;
- final NamespaceAxsl namespaceAxsl = new NamespaceAxsl();
- registerNamespace(namespaceAxsl);
- this.namespaceAxsl = namespaceAxsl;
-
- // Register custom embedded Namespaces from available services
- final List<String> providers = ClassService.providers(
- org.foray.fotree.Namespace.class);
- if (providers != null) {
- for (String str : providers) {
- try {
- final Namespace ns = createNonstandardNamespace(str);
- registerNamespace(ns);
- } catch (final IllegalArgumentException e) { }
- }
- }
- }
-
- /**
- * Add a Namespace instance to the list of namespaces that we should be
- * able to parse.
- * @param namespace A Namespace instance to be added.
- */
- public void registerNamespace(final Namespace namespace) {
- this.namespaceMap.put(namespace.getNamespaceURI(), namespace);
- }
-
- /**
- * Returns the namespace for a given name.
- * @param namespaceURI The namespace URI for which a namespace is needed.
- * @return The namespace instance.
- */
- public Namespace getNamespace(final String namespaceURI) {
- return this.namespaceMap.get(namespaceURI);
- }
-
- /**
- * Returns the namespace used for "FO" items.
- * @return The namespace used for "FO" items.
- */
- public NamespaceFO getFONamespace() {
- return this.namespaceFO;
- }
-
- /**
- * Returns the namespace used for extension items.
- * @return The namespace used for extension items.
- */
- public NamespaceForay getForayNamespace() {
- return this.namespaceForay;
- }
-
- /**
- * Returns the namespace used for "SVG" items.
- * @return The namespace used for "SVG" items.
- */
- public NamespaceSVG getSVGNamespace() {
- return this.namespaceSVG;
- }
-
- /**
- * Returns the namespace used for "MathML" items.
- * @return The namespace used for "MathML" items.
- */
- public MathNamespace getMathNamespace() {
- return this.namespaceMath;
- }
-
- /**
- * Returns the namespace used for "XML" items.
- * @return The namespace used for "XML" items.
- */
- public NamespaceXML getXMLNamespace() {
- return this.namespaceXML;
- }
-
- /**
- * Returns the namespace used for "axsl" items.
- * @return The namespace used for "axsl" items.
- */
- public NamespaceAxsl getAxslNamespace() {
- return this.namespaceAxsl;
- }
-
- /**
- * Returns the text property name for a given PropertyType instance.
- * @param propertyType The property type whose name is needed.
- * @return The text property name.
- */
- public String getPropertyName(final PropertyType propertyType) {
- final String propertyName = propertyType.toStringUnparsed();
- for (Namespace ns : this.namespaceMap.values()) {
- if (propertyName != null
- && ! propertyName.equals("")) {
- return ns.getTypicalPrefix() + ":" + propertyName;
- }
- }
- return null;
- }
-
- /**
- * Creates a Namespace instance for the given class name.
- * @param mappingClassName The name of the Namespace subclass for which
- * an instance should be created.
- * @return The namespace instance.
- */
- public Namespace createNonstandardNamespace(final String mappingClassName) {
- try {
- return (Namespace) Class.forName(mappingClassName).newInstance();
- } catch (final ClassNotFoundException e) {
- throw new IllegalArgumentException("Could not find "
- + mappingClassName);
- } catch (final InstantiationException e) {
- throw new IllegalArgumentException("Could not instantiate "
- + mappingClassName);
- } catch (final IllegalAccessException e) {
- throw new IllegalArgumentException("Could not access "
- + mappingClassName);
- } catch (final ClassCastException e) {
- throw new IllegalArgumentException(mappingClassName
- + " is not an ElementMapping");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public FOTreeBuilder makeFoTree() {
- final FOTreeBuilder foTreeBuilder = new FOTreeBuilder(this,
- this.getLogger());
- foTreeBuilder.setGraphicServer(this.graphicServer);
- foTreeBuilder.setTextServer(this.textServer);
- foTreeBuilder.setGraphicSearchPath(this.graphicSearchPath);
- foTreeBuilder.setCachingGraphics(this.cachingGraphics);
- return foTreeBuilder;
- }
-
- /**
- * Returns the logger.
- * @return The logger.
- */
- public Log getLogger() {
- return this.logger;
- }
-
- /**
- * Returns the text server.
- * @return The text server.
- */
- public TextServer getTextServer() {
- return this.textServer;
- }
-
- /**
- * Returns the font server.
- * @return The font server.
- */
- public FontServer getFontServer() {
- return this.fontServer;
- }
-
-}
Copied: trunk/foray/foray-fotree/src/java/org/foray/fotree/FoTreeServer4a.java (from rev 10279, trunk/foray/foray-fotree/src/java/org/foray/fotree/FOrayFOTreeServer.java)
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/FoTreeServer4a.java (rev 0)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FoTreeServer4a.java 2008-03-19 19:55:27 UTC (rev 10452)
@@ -0,0 +1,306 @@
+/*
+ * Copyright 2005 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fotree;
+
+import org.foray.common.ClassService;
+import org.foray.fotree.axsl.NamespaceAxsl;
+import org.foray.fotree.fo.NamespaceFO;
+import org.foray.fotree.foray.NamespaceForay;
+import org.foray.fotree.math.MathNamespace;
+import org.foray.fotree.svg.NamespaceSVG;
+import org.foray.fotree.xml.NamespaceXML;
+
+import org.axsl.fo.FoTreeFactory;
+import org.axsl.font.FontServer;
+import org.axsl.graphic.GraphicServer;
+import org.axsl.text.TextServer;
+
+import org.apache.commons.logging.Log;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The top-level object in the FOTree implementation.
+ * FOTreeServer encapsulates the FOTree at a high level of abstraction for a
+ * client application.
+ */
+public class FoTreeServer4a implements FoTreeFactory {
+
+ /** The logger. */
+ private Log logger;
+
+ /** The font server. */
+ private FontServer fontServer;
+
+ /** The graphic server. */
+ private GraphicServer graphicServer;
+
+ /** The text server. */
+ private TextServer textServer;
+
+ /** The array of URLs in which graphics should be searched. */
+ private URL[] graphicSearchPath;
+
+ /** Indicates whether we are caching graphics for reuse. */
+ private boolean cachingGraphics;
+
+ /** Map whose key is a String of the namespace URI, and whose value is
+ * a Namespace instance that knows how to parse items in that namespace. */
+ private Map<String, Namespace> namespaceMap
+ = new HashMap<String, Namespace>();
+
+ /** The "FO" namespace. */
+ private NamespaceFO namespaceFO;
+
+ /** The namespace to use for "foray" items. */
+ private NamespaceForay namespaceForay;
+
+ /** The namespace to use for "axsl" items. */
+ private NamespaceAxsl namespaceAxsl;
+
+ /** The "SVG" namespace. */
+ private NamespaceSVG namespaceSVG;
+
+ /** The "MathML" namespace. */
+ private MathNamespace namespaceMath;
+
+ /** The "XML namespace. */
+ private NamespaceXML namespaceXML;
+
+ /**
+ * Constructor.
+ * @param logger The logger.
+ * @param fontServer The font server.
+ * @param textServer The text server.
+ * @param graphicServer The graphic server.
+ * @param graphicSearchPath The array of URLs in which graphics should be
+ * searched.
+ * @param cachingGraphics Indicates whether we are caching graphics for
+ * reuse.
+ */
+ public FoTreeServer4a(final Log logger,
+ final FontServer fontServer,
+ final TextServer textServer,
+ final GraphicServer graphicServer,
+ final URL[] g...
[truncated message content] |
|
From: <vic...@us...> - 2008-03-19 21:04:03
|
Revision: 10453
http://foray.svn.sourceforge.net/foray/?rev=10453&view=rev
Author: victormote
Date: 2008-03-19 14:04:07 -0700 (Wed, 19 Mar 2008)
Log Message:
-----------
1. Add "IllegalCatch" test to checkstyle configuration.
2. Add "Exception" to list of classes in "IllegalThrows" checkstyle test.
3. Clean up many of the violations of these rules.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/ClassService.java
trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java
trunk/foray/foray-font/src/java/org/foray/font/RegisteredFont.java
trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java
trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java
trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFilePFM.java
trunk/foray/foray-font/src/java/org/foray/font/format/TTFFont.java
trunk/foray/foray-font/src/java/org/foray/font/format/TTFReader.java
trunk/foray/foray-font/src/java/org/foray/font/format/TTFSubSetFile.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtColor.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/GIFGraphic.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/JPEGGraphic.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFANode.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PSGraphics2D.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/output/SvgJava2d.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/output/SvgPs.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/HyphenationServer4a.java
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/util/ValidateChars.java
trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/TestFOrayHyphenationServer.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java
trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java
trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java
trunk/foray/foray-ps/src/java/org/foray/ps/java2d/demo/Main.java
trunk/foray/foray-render/src/java/org/foray/render/awt/AWTPrintRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/awt/viewer/GoToPageDialog.java
trunk/foray/foray-render/src/java/org/foray/render/awt/viewer/LoadableProperties.java
trunk/foray/foray-render/src/java/org/foray/render/awt/viewer/SecureResourceBundle.java
trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
trunk/foray/scripts/checkstyle-config.xml
trunk/foray/scripts/checkstyle-suppressions.xml
Modified: trunk/foray/foray-common/src/java/org/foray/common/ClassService.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/ClassService.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-common/src/java/org/foray/common/ClassService.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -117,13 +117,13 @@
// Object obj = cl.loadClass(line).newInstance();
// stick it into our vector...
v.add(line);
- } catch (final Exception ex) {
+ } catch (final IOException ex) {
// Just try the next line
}
line = br.readLine();
}
- } catch (final Exception ex) {
+ } catch (final IOException ex) {
// Just try the next file...
}
Modified: trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java
===================================================================
--- trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -31,9 +31,9 @@
import org.foray.common.WKConstants;
import org.axsl.area.AreaTreeEvent;
+import org.axsl.area.AreaTreeException;
import org.axsl.area.AreaTreeFactory;
import org.axsl.area.AreaTreeListener;
-import org.axsl.area.AreaTreeException;
import org.axsl.fo.FoTreeEvent;
import org.axsl.fo.FoTreeListener;
import org.axsl.fo.fo.PageSequence;
@@ -51,6 +51,7 @@
import org.xml.sax.SAXException;
+import java.io.IOException;
import java.io.OutputStream;
/**
@@ -432,7 +433,7 @@
if (this.outputStream != null) {
try {
this.outputStream.close();
- } catch (final Exception e) {
+ } catch (final IOException e) {
}
}
}
Modified: trunk/foray/foray-font/src/java/org/foray/font/RegisteredFont.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/RegisteredFont.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-font/src/java/org/foray/font/RegisteredFont.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -209,7 +209,7 @@
getLogger().warn("Font " + this.configuredFontName
+ " does not allow embedding.");
}
- } catch (final Exception ex) {
+ } catch (final FontException ex) {
getLogger().error("Failed to create font object "
+ "for: "
+ this.configuredFontName);
Modified: trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -469,7 +469,7 @@
if (fontStream != null) {
try {
fontStream.close();
- } catch (final Exception ex) {
+ } catch (final IOException ex) {
}
}
}
Modified: trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -654,7 +654,7 @@
this.reader = reader;
try {
load();
- } catch (final Exception e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
Modified: trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFilePFM.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFilePFM.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFilePFM.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -161,7 +161,7 @@
this.reader = reader;
try {
load();
- } catch (final Exception e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
Modified: trunk/foray/foray-font/src/java/org/foray/font/format/TTFFont.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/format/TTFFont.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-font/src/java/org/foray/font/format/TTFFont.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -108,7 +108,7 @@
this.ttfTableDir = ttfTableDir;
this.in = getTTFFile().getReader();
readFont();
- } catch (final Exception e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
Modified: trunk/foray/foray-font/src/java/org/foray/font/format/TTFReader.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/format/TTFReader.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-font/src/java/org/foray/font/format/TTFReader.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -122,7 +122,7 @@
final TTFFont ttfFont = ttcFile.getTTFFont(fontName);
ttfFont.printStuff(this.logger);
}
- } catch (final Exception e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
Modified: trunk/foray/foray-font/src/java/org/foray/font/format/TTFSubSetFile.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/format/TTFSubSetFile.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-font/src/java/org/foray/font/format/TTFSubSetFile.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -34,6 +34,7 @@
import org.apache.commons.logging.Log;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -763,7 +764,7 @@
final byte[] buf = str.getBytes("ISO-8859-1");
System.arraycopy(buf, 0, byteArray, arrayPosition, buf.length);
length = buf.length;
- } catch (final Exception e) {
+ } catch (final UnsupportedEncodingException e) {
// This should never happen!
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtColor.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtColor.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtColor.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -635,34 +635,26 @@
float alpha = 1;
if (value.startsWith("#")) {
- try {
- if (value.length() == DtColor.RGB_SHORT_LENGTH) {
- red = DtColor.parseShortRGBColor(value,
- DtColor.SRGB_RED_COMPONENT, false);
- green = DtColor.parseShortRGBColor(value,
- DtColor.SRGB_GREEN_COMPONENT, false);
- blue = DtColor.parseShortRGBColor(value,
- DtColor.SRGB_BLUE_COMPONENT, false);
- } else if (value.length() == DtColor.RGB_LONG_LENGTH) {
- red = DtColor.parseShortRGBColor(value,
- DtColor.SRGB_RED_COMPONENT, true);
- green = DtColor.parseShortRGBColor(value,
- DtColor.SRGB_GREEN_COMPONENT, true);
- blue = DtColor.parseShortRGBColor(value,
- DtColor.SRGB_BLUE_COMPONENT, true);
- } else {
- red = 0;
- green = 0;
- blue = 0;
- throw new PropertyException("Unknown color format. Must "
- + "be #RGB or #RRGGBB");
- }
- } catch (final Exception e) {
+ if (value.length() == DtColor.RGB_SHORT_LENGTH) {
+ red = DtColor.parseShortRGBColor(value,
+ DtColor.SRGB_RED_COMPONENT, false);
+ green = DtColor.parseShortRGBColor(value,
+ DtColor.SRGB_GREEN_COMPONENT, false);
+ blue = DtColor.parseShortRGBColor(value,
+ DtColor.SRGB_BLUE_COMPONENT, false);
+ } else if (value.length() == DtColor.RGB_LONG_LENGTH) {
+ red = DtColor.parseShortRGBColor(value,
+ DtColor.SRGB_RED_COMPONENT, true);
+ green = DtColor.parseShortRGBColor(value,
+ DtColor.SRGB_GREEN_COMPONENT, true);
+ blue = DtColor.parseShortRGBColor(value,
+ DtColor.SRGB_BLUE_COMPONENT, true);
+ } else {
red = 0;
green = 0;
blue = 0;
- throw new PropertyException("Unknown color format. Must be "
- + "#RGB or #RRGGBB");
+ throw new PropertyException("Unknown color format. Must "
+ + "be #RGB or #RRGGBB");
}
} else if (value.startsWith("rgb(")) {
final int poss = value.indexOf("(");
@@ -670,52 +662,44 @@
if (poss != -1 && pose != -1) {
value = value.substring(poss + 1, pose);
final StringTokenizer st = new StringTokenizer(value, ",");
- try {
- if (st.hasMoreTokens()) {
- final String str = st.nextToken().trim();
- if (str.endsWith("%")) {
- red =
- Integer.parseInt(str.substring(0, str.length()
- - 1))
- * WKConstants.MAX_8_BIT_UNSIGNED_INT
- / WKConstants.PERCENT_CONVERSION;
- } else {
- red = Integer.parseInt(str)
- / WKConstants.MAX_8_BIT_UNSIGNED_INT;
- }
+ if (st.hasMoreTokens()) {
+ final String str = st.nextToken().trim();
+ if (str.endsWith("%")) {
+ red =
+ Integer.parseInt(str.substring(0, str.length()
+ - 1))
+ * WKConstants.MAX_8_BIT_UNSIGNED_INT
+ / WKConstants.PERCENT_CONVERSION;
+ } else {
+ red = Integer.parseInt(str)
+ / WKConstants.MAX_8_BIT_UNSIGNED_INT;
}
- if (st.hasMoreTokens()) {
- final String str = st.nextToken().trim();
- if (str.endsWith("%")) {
- green =
- Integer.parseInt(str.substring(0, str.length()
- - 1))
- * WKConstants.MAX_8_BIT_UNSIGNED_INT
- / WKConstants.PERCENT_CONVERSION;
- } else {
- green = Integer.parseInt(str)
- / WKConstants.MAX_8_BIT_UNSIGNED_INT;
- }
+ }
+ if (st.hasMoreTokens()) {
+ final String str = st.nextToken().trim();
+ if (str.endsWith("%")) {
+ green =
+ Integer.parseInt(str.substring(0, str.length()
+ - 1))
+ * WKConstants.MAX_8_BIT_UNSIGNED_INT
+ / WKConstants.PERCENT_CONVERSION;
+ } else {
+ green = Integer.parseInt(str)
+ / WKConstants.MAX_8_BIT_UNSIGNED_INT;
}
- if (st.hasMoreTokens()) {
- final String str = st.nextToken().trim();
- if (str.endsWith("%")) {
- blue =
- Integer.parseInt(str.substring(0, str.length()
- - 1))
- * WKConstants.MAX_8_BIT_UNSIGNED_INT
- / WKConstants.PERCENT_CONVERSION;
- } else {
- blue = Integer.parseInt(str)
- / WKConstants.MAX_8_BIT_UNSIGNED_INT;
- }
+ }
+ if (st.hasMoreTokens()) {
+ final String str = st.nextToken().trim();
+ if (str.endsWith("%")) {
+ blue =
+ Integer.parseInt(str.substring(0, str.length()
+ - 1))
+ * WKConstants.MAX_8_BIT_UNSIGNED_INT
+ / WKConstants.PERCENT_CONVERSION;
+ } else {
+ blue = Integer.parseInt(str)
+ / WKConstants.MAX_8_BIT_UNSIGNED_INT;
}
- } catch (final Exception e) {
- red = 0;
- green = 0;
- blue = 0;
- throw new PropertyException("Unknown colour format. Must "
- + "be #RGB or #RRGGBB");
}
}
} else if (value.startsWith("url(")) {
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/GIFGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/GIFGraphic.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/GIFGraphic.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -109,12 +109,7 @@
this.pixelHeight = consumer.getHeight();
this.pixelWidth = consumer.getWidth();
- try {
- tmpMap = consumer.getImage();
- } catch (final Exception ex) {
- throw new GraphicException("Image grabbing interrupted : "
- + ex.getMessage());
- }
+ tmpMap = consumer.getImage();
final ColorModel cm = consumer.getColorModel();
setBitDepth(BIT_DEPTH_GRAYSCALE);
@@ -124,12 +119,17 @@
} else {
this.isTransparent = false;
}
- } catch (final Exception ex) {
+ } catch (final InterruptedException ex) {
throw new GraphicException("Error while loading image "
+ getUrl().toString() + " : "
+ ex.getClass() + " - "
+ ex.getMessage());
- }
+ } catch (final IOException ex) {
+ throw new GraphicException("Error while loading image "
+ + getUrl().toString() + " : "
+ + ex.getClass() + " - "
+ + ex.getMessage());
+}
// Should take care of the ColorSpace and bitsPerPixel
final int contentSize = this.pixelWidth * this.pixelHeight
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/JPEGGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/JPEGGraphic.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/JPEGGraphic.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -215,7 +215,7 @@
% WKConstants.BITS_PER_BYTE) + WKConstants.BITS_PER_BYTE];
try {
iccStream.write(align);
- } catch (final Exception e) {
+ } catch (final IOException e) {
throw new GraphicException("\n1 Error while loading image " +
getUrl().toString() + " : " + e.getMessage());
}
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -106,7 +106,7 @@
final SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(
this.getServer().getSVGParserClassName());
this.doc = factory.createSVGDocument(getUrl().toExternalForm());
- } catch (final Exception e) {
+ } catch (final IOException e) {
getLogger().error("Could not load external SVG: "
+ e.getMessage());
}
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFANode.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFANode.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFANode.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -113,27 +113,24 @@
float y = 0;
float width = 0;
int count = 0;
- try {
- final StringTokenizer st = new StringTokenizer(nums, ",");
- while (st.hasMoreTokens()) {
- final String tok = st.nextToken();
- count++;
- switch(count) {
- case PDFANode.VIEWBOX_X_INDEX:
- x = Float.parseFloat(tok);
- break;
- case PDFANode.VIEWBOX_Y_INDEX:
- y = Float.parseFloat(tok);
- break;
- case PDFANode.VIEWBOX_WIDTH_INDEX:
- width = Float.parseFloat(tok);
- break;
- case PDFANode.VIEWBOX_HEIGHT_INDEX:
- default:
- break;
- }
+ final StringTokenizer st = new StringTokenizer(nums, ",");
+ while (st.hasMoreTokens()) {
+ final String tok = st.nextToken();
+ count++;
+ switch(count) {
+ case PDFANode.VIEWBOX_X_INDEX:
+ x = Float.parseFloat(tok);
+ break;
+ case PDFANode.VIEWBOX_Y_INDEX:
+ y = Float.parseFloat(tok);
+ break;
+ case PDFANode.VIEWBOX_WIDTH_INDEX:
+ width = Float.parseFloat(tok);
+ break;
+ case PDFANode.VIEWBOX_HEIGHT_INDEX:
+ default:
+ break;
}
- } catch (final Exception e) {
}
// these numbers need conversion to current
// svg position and scaled for the page
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PSGraphics2D.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PSGraphics2D.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PSGraphics2D.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -227,7 +227,7 @@
graphic.close();
// this.psRenderer.renderBitmap(graphic, x, -y, width, height);
this.out.write("grestore");
- } catch (final Exception e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
return true;
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/output/SvgJava2d.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/output/SvgJava2d.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/output/SvgJava2d.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -100,11 +100,7 @@
graphics.transform(at);
}
- try {
- root.paint(graphics);
- } catch (final Exception e) {
- e.printStackTrace();
- }
+ root.paint(graphics);
if (inverse != null && !inverse.isIdentity()) {
graphics.transform(inverse);
@@ -120,14 +116,7 @@
protected GraphicsNode getGraphicsNode(final SVGDocument doc) {
final BridgeContext ctx = makeBridgeContextAWT();
final GVTBuilder builder = new GVTBuilder();
- try {
- return builder.build(ctx, doc);
- } catch (final Exception e) {
- getLogger().error("svg graphic could not be built: "
- + e.getMessage());
- getLogger().error(e.getMessage());
- return null;
- }
+ return builder.build(ctx, doc);
}
/**
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/output/SvgPs.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/output/SvgPs.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/output/SvgPs.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -92,26 +92,13 @@
GVTBuilder builder = new GVTBuilder();
GraphicsNode root;
- try {
- root = builder.build(ctx, doc);
- } catch (final Exception e) {
- getLogger().error("svg graphic could not be built: "
- + e.getMessage());
- getLogger().error(e.getMessage());
- return;
- }
+ root = builder.build(ctx, doc);
ctx = null;
builder = null;
final PSGraphics2D graphics = new PSGraphics2D(false, cos);
graphics.setGraphicContext(new GraphicContext());
- try {
- root.paint(graphics);
- } catch (final Exception e) {
- getLogger().error("svg graphic could not be rendered: "
- + e.getMessage());
- getLogger().error(e.getMessage());
- }
+ root.paint(graphics);
}
/**
Modified: trunk/foray/foray-hyphen/src/java/org/foray/hyphen/HyphenationServer4a.java
===================================================================
--- trunk/foray/foray-hyphen/src/java/org/foray/hyphen/HyphenationServer4a.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-hyphen/src/java/org/foray/hyphen/HyphenationServer4a.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -48,6 +48,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
@@ -228,7 +229,13 @@
+ "/" + key
+ "." + FOrayConstants.BINARY_SERIALIZATION_EXTENSION);
}
- } catch (final Exception e) { }
+ } catch (final NoSuchMethodException e) {
+ return null;
+ } catch (final IllegalAccessException e) {
+ return null;
+ } catch (final InvocationTargetException e) {
+ return null;
+ }
if (is == null) {
is = HyphenationServer4a.class.getResourceAsStream(
@@ -258,8 +265,10 @@
}
ois = new ObjectInputStream(is);
hTree = (HyphenationTree) ois.readObject();
- } catch (final Exception e) {
- e.printStackTrace();
+ } catch (final IOException e) {
+ return null;
+ } catch (final ClassNotFoundException e) {
+ return null;
} finally {
if (ois != null) {
try {
Modified: trunk/foray/foray-hyphen/src/java/org/foray/hyphen/util/ValidateChars.java
===================================================================
--- trunk/foray/foray-hyphen/src/java/org/foray/hyphen/util/ValidateChars.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-hyphen/src/java/org/foray/hyphen/util/ValidateChars.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -414,10 +414,18 @@
inputSource, catalog, iso639);
try {
validator.start();
- } catch (final Exception e) {
- System.out.print("Error parsing input.");
+ } catch (final IOException e) {
+ System.out.print(e.getMessage());
e.printStackTrace();
System.exit(ValidateChars.STATUS_PARSING_ERROR);
+ } catch (final ParserConfigurationException e) {
+ System.out.print(e.getMessage());
+ e.printStackTrace();
+ System.exit(ValidateChars.STATUS_PARSING_ERROR);
+ } catch (final SAXException e) {
+ System.out.print(e.getMessage());
+ e.printStackTrace();
+ System.exit(ValidateChars.STATUS_PARSING_ERROR);
}
}
}
Modified: trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/TestFOrayHyphenationServer.java
===================================================================
--- trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/TestFOrayHyphenationServer.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/TestFOrayHyphenationServer.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -32,6 +32,7 @@
import org.foray.common.Logging;
import org.axsl.hyphen.AbstractTestHyphenationServer;
+import org.axsl.hyphen.HyphenationException;
import org.apache.commons.logging.Log;
@@ -48,8 +49,12 @@
/**
* {@inheritDoc}
*/
- public HyphenationServer4a makeHyphenationServer() throws IOException {
- return TestFOrayHyphenationServer.makeHyphenationServerStatic();
+ public HyphenationServer4a makeHyphenationServer() throws HyphenationException {
+ try {
+ return TestFOrayHyphenationServer.makeHyphenationServerStatic();
+ } catch (final IOException e) {
+ throw new HyphenationException(e);
+ }
}
/**
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java 2008-03-19 19:55:27 UTC (rev 10452)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java 2008-03-19 21:04:07 UTC (rev 10453)
@@ -33,6 +33,8 @@
import org.axsl.font.Font;
import org.axsl.font.FontUse;
+import java.io.UnsupportedEncodingException;
+
/**
* A ...
[truncated message content] |
|
From: <vic...@us...> - 2008-03-19 22:30:53
|
Revision: 10458
http://foray.svn.sourceforge.net/foray/?rev=10458&view=rev
Author: victormote
Date: 2008-03-19 15:30:42 -0700 (Wed, 19 Mar 2008)
Log Message:
-----------
Add names to the tests.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayAll.java
trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java
trunk/foray/foray-areatree/src/javatest/org/foray/area/TestFOrayAreaTree.java
trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java
trunk/foray/foray-font/src/javatest/org/foray/font/TestFOrayFont.java
trunk/foray/foray-fotree/src/javatest/org/foray/fotree/TestFOrayFOTree.java
trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestFOrayGraphic.java
trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/TestFOrayHyphen.java
trunk/foray/foray-ps/src/javatest/org/foray/ps/TestFOrayPS.java
trunk/foray/foray-render/src/javatest/org/foray/render/TestFOrayRender.java
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayAll.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayAll.java 2008-03-19 22:25:40 UTC (rev 10457)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayAll.java 2008-03-19 22:30:42 UTC (rev 10458)
@@ -50,7 +50,7 @@
* @return The built test suite.
*/
public static Test suite() {
- final TestSuite testSuite = new TestSuite();
+ final TestSuite testSuite = new TestSuite("All FOray Tests");
testSuite.addTest(TestFOrayCommon.suite());
testSuite.addTest(TestFOrayPS.suite());
testSuite.addTest(TestFOrayFont.suite());
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java 2008-03-19 22:25:40 UTC (rev 10457)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java 2008-03-19 22:30:42 UTC (rev 10458)
@@ -52,7 +52,7 @@
* @return The built test suite.
*/
public static Test suite() {
- final TestSuite testSuite = new TestSuite();
+ final TestSuite testSuite = new TestSuite("The FOray Application");
/* First the FO Tree tests. */
testSuite.addTestSuite(TestInvalidXml.class);
Modified: trunk/foray/foray-areatree/src/javatest/org/foray/area/TestFOrayAreaTree.java
===================================================================
--- trunk/foray/foray-areatree/src/javatest/org/foray/area/TestFOrayAreaTree.java 2008-03-19 22:25:40 UTC (rev 10457)
+++ trunk/foray/foray-areatree/src/javatest/org/foray/area/TestFOrayAreaTree.java 2008-03-19 22:30:42 UTC (rev 10458)
@@ -42,7 +42,7 @@
* @return The built test suite.
*/
public static Test suite() {
- final TestSuite testSuite = new TestSuite();
+ final TestSuite testSuite = new TestSuite("FOray Area Tree");
testSuite.addTestSuite(TestPageCollection.class);
Modified: trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java
===================================================================
--- trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java 2008-03-19 22:25:40 UTC (rev 10457)
+++ trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java 2008-03-19 22:30:42 UTC (rev 10458)
@@ -69,7 +69,7 @@
* @return The built test suite.
*/
public static Test suite() {
- final TestSuite testSuite = new TestSuite();
+ final TestSuite testSuite = new TestSuite("FOray Common");
testSuite.addTestSuite(TestCharVector.class);
testSuite.addTestSuite(TestUnicodeChar.class);
Modified: trunk/foray/foray-font/src/javatest/org/foray/font/TestFOrayFont.java
===================================================================
--- trunk/foray/foray-font/src/javatest/org/foray/font/TestFOrayFont.java 2008-03-19 22:25:40 UTC (rev 10457)
+++ trunk/foray/foray-font/src/javatest/org/foray/font/TestFOrayFont.java 2008-03-19 22:30:42 UTC (rev 10458)
@@ -42,7 +42,7 @@
* @return The built test suite.
*/
public static Test suite() {
- final TestSuite testSuite = new TestSuite();
+ final TestSuite testSuite = new TestSuite("FOray Font");
testSuite.addTestSuite(TestFontServer4a.class);
return testSuite;
}
Modified: trunk/foray/foray-fotree/src/javatest/org/foray/fotree/TestFOrayFOTree.java
===================================================================
--- trunk/foray/foray-fotree/src/javatest/org/foray/fotree/TestFOrayFOTree.java 2008-03-19 22:25:40 UTC (rev 10457)
+++ trunk/foray/foray-fotree/src/javatest/org/foray/fotree/TestFOrayFOTree.java 2008-03-19 22:30:42 UTC (rev 10458)
@@ -334,7 +334,7 @@
* @return The built test suite.
*/
public static Test suite() {
- final TestSuite testSuite = new TestSuite();
+ final TestSuite testSuite = new TestSuite("FOray Fo Tree");
/* Add tests of property value classes. */
testSuite.addTestSuite(TestDtLength.class);
Modified: trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestFOrayGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestFOrayGraphic.java 2008-03-19 22:25:40 UTC (rev 10457)
+++ trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestFOrayGraphic.java 2008-03-19 22:30:42 UTC (rev 10458)
@@ -42,7 +42,7 @@
* @return The built test suite.
*/
public static Test suite() {
- final TestSuite testSuite = new TestSuite();
+ final TestSuite testSuite = new TestSuite("FOray Graphic");
testSuite.addTestSuite(TestGraphicServer4a.class);
testSuite.addTestSuite(TestBmpGraphic.class);
Modified: trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/TestFOrayHyphen.java
===================================================================
--- trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/TestFOrayHyphen.java 2008-03-19 22:25:40 UTC (rev 10457)
+++ trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/TestFOrayHyphen.java 2008-03-19 22:30:42 UTC (rev 10458)
@@ -45,7 +45,7 @@
* @return The built test suite.
*/
public static Test suite() {
- final TestSuite testSuite = new TestSuite();
+ final TestSuite testSuite = new TestSuite("FOray Hyphen");
testSuite.addTestSuite(TestHyphenationServer4a.class);
testSuite.addTestSuite(TestTernaryTree.class);
Modified: trunk/foray/foray-ps/src/javatest/org/foray/ps/TestFOrayPS.java
===================================================================
--- trunk/foray/foray-ps/src/javatest/org/foray/ps/TestFOrayPS.java 2008-03-19 22:25:40 UTC (rev 10457)
+++ trunk/foray/foray-ps/src/javatest/org/foray/ps/TestFOrayPS.java 2008-03-19 22:30:42 UTC (rev 10458)
@@ -45,7 +45,7 @@
* @return The built test suite.
*/
public static Test suite() {
- final TestSuite testSuite = new TestSuite();
+ final TestSuite testSuite = new TestSuite("FOray PostScript");
testSuite.addTestSuite(TestAscii85EncodeFilter.class);
testSuite.addTestSuite(TestRunLengthEncodeFilter.class);
Modified: trunk/foray/foray-render/src/javatest/org/foray/render/TestFOrayRender.java
===================================================================
--- trunk/foray/foray-render/src/javatest/org/foray/render/TestFOrayRender.java 2008-03-19 22:25:40 UTC (rev 10457)
+++ trunk/foray/foray-render/src/javatest/org/foray/render/TestFOrayRender.java 2008-03-19 22:30:42 UTC (rev 10458)
@@ -42,7 +42,7 @@
* @return The built test suite.
*/
public static Test suite() {
- final TestSuite testSuite = new TestSuite();
+ final TestSuite testSuite = new TestSuite("FOray Render");
testSuite.addTestSuite(TestRenderer.class);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-03-20 01:37:33
|
Revision: 10460
http://foray.svn.sourceforge.net/foray/?rev=10460&view=rev
Author: victormote
Date: 2008-03-19 18:37:39 -0700 (Wed, 19 Mar 2008)
Log Message:
-----------
1. Rebuild hyphenation jar file.
2. Add custom deserialization to HyphenationTree, so that we know whether the instance was parsed or deserialized.
3. Add more tests of the hyphenation trees that we have.
Modified Paths:
--------------
trunk/foray/foray-hyphen/src/java/org/foray/hyphen/HyphenationTree.java
trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/TestHyphenationServer4a.java
trunk/foray/lib/foray-hyphen-0.4-rsrc.jar
Modified: trunk/foray/foray-hyphen/src/java/org/foray/hyphen/HyphenationTree.java
===================================================================
--- trunk/foray/foray-hyphen/src/java/org/foray/hyphen/HyphenationTree.java 2008-03-19 23:29:48 UTC (rev 10459)
+++ trunk/foray/foray-hyphen/src/java/org/foray/hyphen/HyphenationTree.java 2008-03-20 01:37:39 UTC (rev 10460)
@@ -42,6 +42,8 @@
import org.apache.commons.logging.Log;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import java.io.Serializable;
import java.net.URL;
import java.util.HashMap;
@@ -96,9 +98,9 @@
* is appended */
private static final int QTY_MARKER_CHARS = 3;
- /** The source of this tree. Assumed to be deserialized unless the parsing routines are
- * accessed. */
- private transient Source source = HyphenationTree.Source.RESOURCES;
+ /** The source of this tree. Used by testing routines to make sure that the serialized versions
+ * are getting used. */
+ private transient Source source;
/** The character to be interepreted as the hyphenation character for
* exceptions that are added. */
@@ -715,4 +717,16 @@
return this.source;
}
+ /**
+ * Custom deserialization routine.
+ * @param in The input stream being read.
+ * @throws IOException For standard IO errors.
+ * @throws ClassNotFoundException If the class does not exist.
+ */
+ private void readObject(final ObjectInputStream in) throws IOException,
+ ClassNotFoundException {
+ in.defaultReadObject();
+ this.source = HyphenationTree.Source.RESOURCES;
+ }
+
}
Modified: trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/TestHyphenationServer4a.java
===================================================================
--- trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/TestHyphenationServer4a.java 2008-03-19 23:29:48 UTC (rev 10459)
+++ trunk/foray/foray-hyphen/src/javatest/org/foray/hyphen/TestHyphenationServer4a.java 2008-03-20 01:37:39 UTC (rev 10460)
@@ -99,6 +99,7 @@
*/
public void testResources() throws HyphenationException {
final HyphenationServer4a server = this.getServer();
+
HyphenationTree tree = server.getHyphenationTree(Iso639.ENGLISH, Iso3166.UNITED_STATES);
assertNotNull(tree);
assertEquals(HyphenationTree.Source.RESOURCES, tree.getSource());
@@ -106,6 +107,34 @@
tree = server.getHyphenationTree(Iso639.FINNISH, null);
assertNotNull(tree);
assertEquals(HyphenationTree.Source.RESOURCES, tree.getSource());
+
+ tree = server.getHyphenationTree(Iso639.HUNGARIAN, null);
+ assertNotNull(tree);
+ assertEquals(HyphenationTree.Source.RESOURCES, tree.getSource());
+
+ tree = server.getHyphenationTree(Iso639.ITALIAN, null);
+ assertNotNull(tree);
+ assertEquals(HyphenationTree.Source.RESOURCES, tree.getSource());
+
+ tree = server.getHyphenationTree(Iso639.POLISH, null);
+ assertNotNull(tree);
+ assertEquals(HyphenationTree.Source.RESOURCES, tree.getSource());
+
+ tree = server.getHyphenationTree(Iso639.PORTUGUESE, null);
+ assertNotNull(tree);
+ assertEquals(HyphenationTree.Source.RESOURCES, tree.getSource());
+
+ tree = server.getHyphenationTree(Iso639.RUSSIAN, null);
+ assertNotNull(tree);
+ assertEquals(HyphenationTree.Source.RESOURCES, tree.getSource());
+
+ tree = server.getHyphenationTree(Iso639.SPANISH, null);
+ assertNotNull(tree);
+ assertEquals(HyphenationTree.Source.RESOURCES, tree.getSource());
+
+ /* Try one that we know we don't have. */
+ tree = server.getHyphenationTree(Iso639.KLINGON, null);
+ assertNull(tree);
}
}
Modified: trunk/foray/lib/foray-hyphen-0.4-rsrc.jar
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-03-20 02:39:38
|
Revision: 10461
http://foray.svn.sourceforge.net/foray/?rev=10461&view=rev
Author: victormote
Date: 2008-03-19 19:39:43 -0700 (Wed, 19 Mar 2008)
Log Message:
-----------
Move the font width testing from the app module to the font module.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayAll.java
trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java
trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java
trunk/foray/foray-font/src/javatest/org/foray/font/TestFOrayFont.java
trunk/foray/foray-font/src/javatest/org/foray/font/TestFontServer4a.java
Added Paths:
-----------
trunk/foray/foray-font/src/javatest/org/foray/font/TestFont4a.java
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayAll.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayAll.java 2008-03-20 01:37:39 UTC (rev 10460)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayAll.java 2008-03-20 02:39:43 UTC (rev 10461)
@@ -51,6 +51,7 @@
*/
public static Test suite() {
final TestSuite testSuite = new TestSuite("All FOray Tests");
+
testSuite.addTest(TestFOrayCommon.suite());
testSuite.addTest(TestFOrayPS.suite());
testSuite.addTest(TestFOrayFont.suite());
@@ -60,6 +61,7 @@
testSuite.addTest(TestFOrayAreaTree.suite());
testSuite.addTest(TestFOrayRender.suite());
testSuite.addTest(TestFOrayApp.suite());
+
return testSuite;
}
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java 2008-03-20 01:37:39 UTC (rev 10460)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java 2008-03-20 02:39:43 UTC (rev 10461)
@@ -38,7 +38,13 @@
import org.foray.area.SpanRA;
import org.foray.area.TextArea;
import org.foray.common.OrderedTreeNode;
+import org.foray.font.FontServer4a;
+import org.foray.font.FreeStandingFont;
+import org.foray.font.RegisteredFont;
+import org.foray.font.TestFontServer4a;
+import org.axsl.font.FontException;
+
import java.util.Iterator;
import junit.framework.TestCase;
@@ -49,6 +55,21 @@
public abstract class AbstractAreaTreeTest extends TestCase {
/**
+ * Returns the Base14-Helvetica font.
+ * @return The Base14-Helvetica font.
+ * @throws FontException For font system errors getting the font.
+ */
+ protected FreeStandingFont getHelveticaFont() throws FontException {
+ final FontServer4a fontServer = TestFontServer4a.getServer();
+ assertNotNull(fontServer);
+ final RegisteredFont rf = fontServer.getRegisteredFont("Base14-Helvetica");
+ assertNotNull(rf);
+ final FreeStandingFont fsf = rf.getFreeStandingFont();
+ assertNotNull(fsf);
+ return fsf;
+ }
+
+ /**
* Returns the first normal-flow reference area in a given area tree.
* @param areaTree The area tree being tested.
* @return The first normal-flow reference area in <code>areaTree</code>.
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java 2008-03-20 01:37:39 UTC (rev 10460)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java 2008-03-20 02:39:43 UTC (rev 10461)
@@ -36,7 +36,13 @@
import org.foray.area.PageCollection;
import org.foray.area.TextArea;
import org.foray.core.FOrayException;
+import org.foray.font.FontServer4a;
+import org.foray.font.FreeStandingFont;
+import org.foray.font.RegisteredFont;
+import org.foray.font.TestFontServer4a;
+import org.axsl.font.FontException;
+
/**
* Tests of various block-related concepts at the Area Tree level.
*/
@@ -220,9 +226,11 @@
* Test of fo/block-003.fo.
* This is a test of simple centering of a text-area on a line.
* @throws FOrayException For errors creating the FO Tree or Area Tree.
+ * @throws FontException For errors in the font system.
*/
- public void testBlock003() throws FOrayException {
+ public void testBlock003() throws FOrayException, FontException {
final AreaTreeCreator creator = AreaTreeCreator.getInstance();
+
final AreaTree areaTree = creator.buildAreaTree(
"fo/block-003.fo");
final NormalFlowRA firstNormalFlowArea = this.getFirstNormalFlowArea(
@@ -257,19 +265,10 @@
assertTrue(node instanceof TextArea);
final TextArea textArea = (TextArea) node;
- /* The text is "Test of Centering".
- * From the Helvetica AFM file, the widths are as follows:
- * T(611) + kern-T,e(-120) + e(556) + kern-e,s(0) + s(500) + kern-s,t(0) + t(278)
- * + kern-t,space(0) + space(278) + kern-space,o(0)
- * + o(556) + kern-o,f(0) + f(278)
- * + kern-f,space(0) + space(278) + kern-space,C(0)
- * + C(722) + kern-C,e(0) + e(556) + kern-e,n(0) + n(556) + kern-n,t(0) + t(278)
- * + kern-t,e(0) + e(556) + kern-e,r(0) + r(333) + kern-r,i(15) + i(222) + kern-i,n(0)
- * + n(556) + kern-n,g(0) + g(556)
- * = 7,565.
- * If these are scaled to 12 points, the millipoints used are 7565 * 12
- * = 90,780. */
- assertEquals(90780, textArea.crIpd());
+ final FreeStandingFont fsf = getHelveticaFont();
+ /* The following computation is tested in {@link TestFont4a#testWidth()}. */
+ final int textWidth = fsf.width("Test of Centering", 12000, 0, 0, true);
+ assertEquals(textWidth, textArea.crIpd());
/* The x value of the text area content rectangle should be at the x
* location of the parent line area + 1/2 of the unused area in the
@@ -288,8 +287,9 @@
* This is a test of centering of a text-area on a line, where the text-area
* has word-spacing = ".3em".
* @throws FOrayException For errors creating the FO Tree or Area Tree.
+ * @throws FontException For font system errors in obtaining the font.
*/
- public void testBlock004() throws FOrayException {
+ public void testBlock004() throws FOrayException, FontException {
final AreaTreeCreator creator = AreaTreeCreator.getInstance();
final AreaTree areaTree = creator.buildAreaTree(
"fo/block-004.fo");
@@ -325,23 +325,11 @@
assertTrue(node instanceof TextArea);
final TextArea textArea = (TextArea) node;
- /* The text is "Centered with Word Spacing".
- * From the Helvetica AFM file, the widths are as follows:
- * C(722) + kern-C,e(0) + e(556) + kern-e,n(0) + n(556) + kern-n,t(0) + t(278) + kern-t,e(0)
- * + e(556) + kern-e,r(0) + r(333) + kern-r,e(0) + e(556) + kern-e,d(0) + d(556)
- * + kern-d,space(0) + space(278) + kern-space,w(0)
- * + w(722) + kern-w,i(0) + i(222) + kern-i,t(0) + t(278) + kern-t,h(0) + h(556)
- * + kern-h,space(0) + space(278) + kern-space,W(-40)
- * + W(944) + kern-W,o(-30) + o(556) + kern-o,r(0) + r(333) + kern-r,d(0) + d(556)
- * + kern-d,space(0) + space(278) + kern-space,S(0)
- * + S(667) + kern-S,p(0) + p(556) + kern-p,a(0) + a(556) + kern-a,c(0) + c(500)
- * + kern-c,i(0) + i(222) + kern-i,n(0) + n(556) + kern-n,g(0) + g(556)
- * = 12,657.
- * If these are scaled to 12 points, the millipoints used are 12,657
- * * 12 = 151,884.
- * The extra word spacing is .3em = .3 * 12000 * 3 occurrences = 10,800.
- * Total ipd of text-area = 151,884 + 10,800 = 162,684. */
- assertEquals(162684, textArea.crIpd());
+ final FreeStandingFont fsf = getHelveticaFont();
+ /* The following computation is tested in {@link TestFont4a#testWidth()}.
+ * The extra word spacing is .3em = .3 * 12000 = 3600. */
+ final int textWidth = fsf.width("Centered with Word Spacing", 12000, 0, 3600, true);
+ assertEquals(textWidth, textArea.crIpd());
/* The x value of the text area content rectangle should be at the x
* location of the parent line area + 1/2 of the unused area in the
Modified: trunk/foray/foray-font/src/javatest/org/foray/font/TestFOrayFont.java
===================================================================
--- trunk/foray/foray-font/src/javatest/org/foray/font/TestFOrayFont.java 2008-03-20 01:37:39 UTC (rev 10460)
+++ trunk/foray/foray-font/src/javatest/org/foray/font/TestFOrayFont.java 2008-03-20 02:39:43 UTC (rev 10461)
@@ -43,7 +43,10 @@
*/
public static Test suite() {
final TestSuite testSuite = new TestSuite("FOray Font");
+
testSuite.addTestSuite(TestFontServer4a.class);
+ testSuite.addTestSuite(TestFont4a.class);
+
return testSuite;
}
Added: trunk/foray/foray-font/src/javatest/org/foray/font/TestFont4a.java
===================================================================
--- trunk/foray/foray-font/src/javatest/org/foray/font/TestFont4a.java (rev 0)
+++ trunk/foray/foray-font/src/javatest/org/foray/font/TestFont4a.java 2008-03-20 02:39:43 UTC (rev 10461)
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2007 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font;
+
+import org.foray.ps.encode.Encoding;
+
+import org.axsl.font.FontException;
+
+import junit.framework.TestCase;
+
+/**
+ * JUnit test class for the class {@link Font4a}.
+ */
+public class TestFont4a extends TestCase {
+
+ /**
+ * Ensures that we can read the serialized metrics information for the
+ * Base-14 fonts, and some basic testing of that data.
+ * @throws FontException For font system errors.
+ */
+ public void testBase14() throws FontException {
+ final FontServer4a server = TestFontServer4a.getServer();
+ assertNotNull(server);
+ final RegisteredFont rf = server.getRegisteredFont("Base14-Times");
+ assertNotNull(rf);
+ final FreeStandingFont fsf = rf.getFreeStandingFont();
+ assertNotNull(fsf);
+ final Encoding encoding = fsf.getInternalEncoding();
+ assertNotNull(encoding);
+ /* Get the kerning value for an A-dieresis and an O-tilde, found at
+ * line 519 of the AFM for Times-Roman. */
+ final int kernValue = fsf.kern(0xC4, 0xD5);
+ assertEquals(-55, kernValue);
+ }
+
+ /**
+ * Functional test of getting the glyph widths and kerning for a String.
+ * @throws FontException For font system errors.
+ */
+ public void testWidth() throws FontException {
+ final FontServer4a server = TestFontServer4a.getServer();
+ assertNotNull(server);
+ final RegisteredFont rf = server.getRegisteredFont("Base14-Helvetica");
+ assertNotNull(rf);
+ final FreeStandingFont fsf = rf.getFreeStandingFont();
+ assertNotNull(fsf);
+
+ final String testString = "Test of Centering";
+
+ /* Test with kerning.
+ * From the Helvetica AFM file, the widths are as follows:
+ * T(611) + kern-T,e(-120) + e(556) + kern-e,s(0) + s(500) + kern-s,t(0) + t(278)
+ * + kern-t,space(0) + space(278) + kern-space,o(0)
+ * + o(556) + kern-o,f(0) + f(278)
+ * + kern-f,space(0) + space(278) + kern-space,C(0)
+ * + C(722) + kern-C,e(0) + e(556) + kern-e,n(0) + n(556) + kern-n,t(0) + t(278)
+ * + kern-t,e(0) + e(556) + kern-e,r(0) + r(333) + kern-r,i(15) + i(222) + kern-i,n(0)
+ * + n(556) + kern-n,g(0) + g(556)
+ * = 7,565.
+ * If these are scaled to 12 points, the millipoints used are 7565 * 12
+ * = 90,780. */
+ assertEquals(90780, fsf.width(testString, 12000, 0, 0, true));
+
+ /* Test without kerning.
+ * Total kerning = -105.
+ * Adjusted text space units = 7,565 + 105 = 7,670.
+ * When scaled to 12 points, the millipoints used are 7670 * 12 = 92,040. */
+ assertEquals(92040, fsf.width(testString, 12000, 0, 0, false));
+
+ /* Test with word spacing.
+ * Word spacing = 300.
+ * Number of word spaces = 2.
+ * Total word spacing = 600.
+ * Total space (kerning on) = 90,780 + 600 = 91,380. */
+ assertEquals(91380, fsf.width(testString, 12000, 0, 300, true));
+
+ /* Test with letter spacing.
+ * Letter spacing = 5.
+ * Number of word spaces = 16.
+ * Total word spacing = 80.
+ * Total space (kerning on) = 90,780 + 80 = 90,860. */
+ assertEquals(90860, fsf.width(testString, 12000, 5, 0, true));
+
+ /* Test with both word spacing and letter spacing, using same parameters as above.
+ * Total space (kerning on) = 90,780 + 600 + 80 = 91,460. */
+ assertEquals(91460, fsf.width(testString, 12000, 5, 300, true));
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/javatest/org/foray/font/TestFont4a.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Modified: trunk/foray/foray-font/src/javatest/org/foray/font/TestFontServer4a.java
===================================================================
--- trunk/foray/foray-font/src/javatest/org/foray/font/TestFontServer4a.java 2008-03-20 01:37:39 UTC (rev 10460)
+++ trunk/foray/foray-font/src/javatest/org/foray/font/TestFontServer4a.java 2008-03-20 02:39:43 UTC (rev 10461)
@@ -29,7 +29,6 @@
package org.foray.font;
import org.foray.common.Logging;
-import org.foray.ps.encode.Encoding;
import org.axsl.font.FontException;
@@ -61,23 +60,12 @@
}
/**
- * Ensures that we can read the serialized metrics information for the
- * Base-14 fonts, and some basic testing of that data.
+ * Ensures that we can create a FontServer.
* @throws FontException For font system errors.
*/
public void testBase14() throws FontException {
final FontServer4a server = TestFontServer4a.getServer();
assertNotNull(server);
- final RegisteredFont rf = server.getRegisteredFont("Base14-Times");
- assertNotNull(rf);
- final FreeStandingFont fsf = rf.getFreeStandingFont();
- assertNotNull(fsf);
- final Encoding encoding = fsf.getInternalEncoding();
- assertNotNull(encoding);
- /* Get the kerning value for an A-dieresis and an O-tilde, found at
- * line 519 of the AFM for Times-Roman. */
- final int kernValue = fsf.kern(0xC4, 0xD5);
- assertEquals(-55, kernValue);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2008-03-21 18:50:17
|
Revision: 10468
http://foray.svn.sourceforge.net/foray/?rev=10468&view=rev
Author: victormote
Date: 2008-03-21 11:50:19 -0700 (Fri, 21 Mar 2008)
Log Message:
-----------
Upgrade Apache Commons IO dependency from release 1.2 to release 1.4.
Modified Paths:
--------------
trunk/foray/doc/web/00-release/notes-unreleased.html
trunk/foray/foray-app/.classpath
trunk/foray/foray-common/.classpath
trunk/foray/foray-font/.classpath
trunk/foray/foray-graphic/.classpath
Added Paths:
-----------
trunk/foray/lib/commons-io-1.4.jar
trunk/foray/lib-build/commons-io/commons-io-1.4-sources.jar
Removed Paths:
-------------
trunk/foray/lib/commons-io-1.2.jar
trunk/foray/lib-build/commons-io/commons-io-1.2-src.zip
Modified: trunk/foray/doc/web/00-release/notes-unreleased.html
===================================================================
--- trunk/foray/doc/web/00-release/notes-unreleased.html 2008-03-21 18:14:29 UTC (rev 10467)
+++ trunk/foray/doc/web/00-release/notes-unreleased.html 2008-03-21 18:50:19 UTC (rev 10468)
@@ -58,6 +58,7 @@
factory) for details.
<li>Renamed many classes that implement aXSL interfaces so that they end with "4a" instead of
starting with "FOray".</li>
+ <li>Upgraded Apache Commons IO dependency from release 1.2 to release 1.4.</li>
</li>
</ul>
Modified: trunk/foray/foray-app/.classpath
===================================================================
--- trunk/foray/foray-app/.classpath 2008-03-21 18:14:29 UTC (rev 10467)
+++ trunk/foray/foray-app/.classpath 2008-03-21 18:50:19 UTC (rev 10468)
@@ -28,7 +28,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/axslHyphen"/>
<classpathentry combineaccessrules="false" kind="src" path="/FOrayHyphen"/>
<classpathentry combineaccessrules="false" kind="src" path="/FOrayPS"/>
- <classpathentry kind="lib" path="/FOray Lib/commons-io-1.2.jar" sourcepath="/FOray Lib-Build/commons-io/commons-io-1.2-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/resolver.jar"/>
<classpathentry kind="lib" path="/FOray Lib/servlet-2.2.jar"/>
<classpathentry kind="lib" path="/FOray Lib/xalan-2.4.1.jar"/>
@@ -39,5 +38,6 @@
<classpathentry kind="lib" path="/FOray Lib-Build/ant/ant.jar"/>
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit-4.4.jar" sourcepath="/FOray Lib-Build/junit/junit-4.4-src.jar"/>
<classpathentry kind="lib" path="/FOray Lib/foray-hyphen-0.4-rsrc.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/commons-io-1.4.jar" sourcepath="/FOray Lib-Build/commons-io/commons-io-1.4-sources.jar"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-common/.classpath
===================================================================
--- trunk/foray/foray-common/.classpath 2008-03-21 18:14:29 UTC (rev 10467)
+++ trunk/foray/foray-common/.classpath 2008-03-21 18:50:19 UTC (rev 10468)
@@ -4,8 +4,8 @@
<classpathentry kind="src" path="src/javatest"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/axslCommon"/>
- <classpathentry kind="lib" path="/FOray Lib/commons-io-1.2.jar" sourcepath="/FOray Lib-Build/commons-io/commons-io-1.2-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit-4.4.jar" sourcepath="/FOray Lib-Build/junit/junit-4.4-src.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/commons-io-1.4.jar" sourcepath="/FOray Lib-Build/commons-io/commons-io-1.4-sources.jar"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-font/.classpath
===================================================================
--- trunk/foray/foray-font/.classpath 2008-03-21 18:14:29 UTC (rev 10467)
+++ trunk/foray/foray-font/.classpath 2008-03-21 18:50:19 UTC (rev 10468)
@@ -9,7 +9,6 @@
<classpathentry kind="src" path="/axslPs"/>
<classpathentry kind="src" path="/axslCommon"/>
<classpathentry combineaccessrules="false" kind="src" path="/FOrayPretty"/>
- <classpathentry kind="lib" path="/FOray Lib/commons-io-1.2.jar" sourcepath="/FOray Lib-Build/commons-io/commons-io-1.2-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/foray-font-0.3-rsrc.jar"/>
<classpathentry kind="lib" path="/FOray Lib/xercesImpl-2.7.1.jar" sourcepath="/FOray Lib-Build/xerces/Xerces-J-src.2.7.1.zip"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
Modified: trunk/foray/foray-graphic/.classpath
===================================================================
--- trunk/foray/foray-graphic/.classpath 2008-03-21 18:14:29 UTC (rev 10467)
+++ trunk/foray/foray-graphic/.classpath 2008-03-21 18:50:19 UTC (rev 10468)
@@ -6,7 +6,6 @@
<classpathentry kind="src" path="/FOrayCommon"/>
<classpathentry kind="src" path="/axslGraphic"/>
<classpathentry kind="src" path="/axslCommon"/>
- <classpathentry kind="lib" path="/FOray Lib/commons-io-1.2.jar" sourcepath="/FOray Lib-Build/commons-io/commons-io-1.2-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar" sourcepath="/FOray Lib-Build/svg/svg-1.1-src.zip"/>
<classpathentry exported="true" kind="lib" path="/FOray Lib/mathml-2.0.jar" sourcepath="/FOray Lib-Build/mathml/mathml-2.0-src.zip"/>
@@ -30,5 +29,6 @@
<classpathentry kind="lib" path="/FOray Lib/xmlgraphics-commons-1.2.jar" sourcepath="/FOray Lib-Build/xmlgraphics-commons/xmlgraphics-commons-1.2-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/xercesImpl-2.7.1.jar" sourcepath="/FOray Lib-Build/xerces/Xerces-J-src.2.7.1.zip"/>
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit-4.4.jar" sourcepath="/FOray Lib-Build/junit/junit-4.4-src.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/commons-io-1.4.jar" sourcepath="/FOray Lib-Build/commons-io/commons-io-1.4-sources.jar"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Deleted: trunk/foray/lib/commons-io-1.2.jar
===================================================================
(Binary files differ)
Added: trunk/foray/lib/commons-io-1.4.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/commons-io-1.4.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/foray/lib-build/commons-io/commons-io-1.2-src.zip
===================================================================
(Binary files differ)
Added: trunk/foray/lib-build/commons-io/commons-io-1.4-sources.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib-build/commons-io/commons-io-1.4-sources.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|