foray-commit Mailing List for FOray (Page 257)
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(139) |
Apr
(98) |
May
(250) |
Jun
(394) |
Jul
(84) |
Aug
(13) |
Sep
(420) |
Oct
(186) |
Nov
(1) |
Dec
(3) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(108) |
Feb
(202) |
Mar
(291) |
Apr
(247) |
May
(374) |
Jun
(227) |
Jul
(231) |
Aug
(60) |
Sep
(31) |
Oct
(45) |
Nov
(18) |
Dec
|
| 2008 |
Jan
(38) |
Feb
(71) |
Mar
(142) |
Apr
|
May
(59) |
Jun
(6) |
Jul
(10) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
(12) |
Feb
(4) |
Mar
(88) |
Apr
(121) |
May
(17) |
Jun
(30) |
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2010 |
Jan
(11) |
Feb
(76) |
Mar
(11) |
Apr
|
May
(11) |
Jun
|
Jul
|
Aug
(44) |
Sep
(14) |
Oct
(7) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(168) |
| 2017 |
Jan
(77) |
Feb
(11) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
(88) |
Mar
(118) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(141) |
| 2021 |
Jan
(170) |
Feb
(20) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(62) |
Nov
(189) |
Dec
(162) |
| 2022 |
Jan
(201) |
Feb
(118) |
Mar
(8) |
Apr
|
May
(2) |
Jun
(47) |
Jul
(19) |
Aug
(14) |
Sep
(3) |
Oct
|
Nov
(28) |
Dec
(235) |
| 2023 |
Jan
(112) |
Feb
(23) |
Mar
(2) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
(70) |
Sep
(92) |
Oct
(20) |
Nov
(1) |
Dec
(1) |
| 2024 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
(14) |
Jun
(11) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(10) |
Feb
(29) |
Mar
|
Apr
(162) |
May
(245) |
Jun
(83) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <vic...@us...> - 2006-06-08 20:57:42
|
Revision: 7461 Author: victormote Date: 2006-06-08 13:57:37 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7461&view=rev Log Message: ----------- Conform to axsl changes: Rename method and change its meaning from returning the number of characters to skip to the index to the first character to be used. Modified Paths: -------------- trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java Modified: trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java 2006-06-08 20:34:50 UTC (rev 7460) +++ trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java 2006-06-08 20:57:37 UTC (rev 7461) @@ -352,10 +352,14 @@ */ HyphenationServer server = this.getHyphenationServer(); // Count the number of chars at the beginning that should be ignored. - int nonWordChars = server.nonWordChars(this.currentChars, wordStart); + int actualWordStart = server.wordStarts(this.currentChars, wordStart); + if (actualWordStart < 0) { + return this.wordStart; + } + int nonWordChars = actualWordStart - wordStart; // Extract the word that should be evaluated by the hyphenation system. String wordToHyphenate = server.getHyphenationWord( - this.currentChars, this.wordStart + nonWordChars); + this.currentChars, actualWordStart); // See if there are discretionary hyphenation points. Hyphenation hyph = server.hyphenate(wordToHyphenate, 0, wordToHyphenate.length(), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 20:34:57
|
Revision: 7460 Author: victormote Date: 2006-06-08 13:34:50 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7460&view=rev Log Message: ----------- Conform to axsl changes: Allow the CharSequence version to use a subset as well. Modified Paths: -------------- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java Modified: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java =================================================================== --- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java 2006-06-08 20:34:43 UTC (rev 7459) +++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java 2006-06-08 20:34:50 UTC (rev 7460) @@ -264,13 +264,11 @@ return null; } - public org.axsl.hyphenR.Hyphenation hyphenate(CharSequence word, - String language, String country, int remainCount, int pushCount) { - HyphenationTree hTree = getHyphenationTree(language, country); - if (hTree == null) { - return null; - } - return hTree.hyphenate(word, remainCount, pushCount); + public org.axsl.hyphenR.Hyphenation hyphenate(CharSequence word, int offset, + int len, String language, String country, int remainCount, + int pushCount) { + return this.hyphenate(word.toString().toCharArray(), offset, len, + language, country, remainCount, pushCount); } public org.axsl.hyphenR.Hyphenation hyphenate(char[] word, int offset, Modified: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java =================================================================== --- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java 2006-06-08 20:34:43 UTC (rev 7459) +++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java 2006-06-08 20:34:50 UTC (rev 7460) @@ -274,22 +274,6 @@ } /** - * Hyphenate word and return a Hyphenation object. - * @param word the word to be hyphenated - * @param remainCharCount Minimum number of characters allowed - * before the hyphenation point. - * @param pushCharCount Minimum number of characters allowed after - * the hyphenation point. - * @return a {@link Hyphenation Hyphenation} object representing - * the hyphenated word or null if word is not hyphenated. - */ - public org.axsl.hyphenR.Hyphenation hyphenate(CharSequence word, - int remainCharCount, int pushCharCount) { - char[] w = word.toString().toCharArray(); - return hyphenate(w, 0, w.length, remainCharCount, pushCharCount); - } - - /** * Hyphenate word and return an array of hyphenation points. * @param w char array that contains the word * @param offset Offset to first character in word @@ -494,8 +478,8 @@ logger.info("Word: "); token = in.readLine().trim(); logger.info("Hyphenation points: "); - logger.info(ht.hyphenate(token, minCharCount, - minCharCount).toString()); + logger.info(ht.hyphenate(token.toCharArray(), 0, token.length(), + minCharCount, minCharCount).toString()); } else if (token.equals("b")) { if (ht == null) { logger.info("No patterns has been loaded."); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 20:34:49
|
Revision: 7459 Author: victormote Date: 2006-06-08 13:34:43 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7459&view=rev Log Message: ----------- Conform to axsl changes: Allow the CharSequence version to use a subset as well. Modified Paths: -------------- trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java Modified: trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java 2006-06-08 20:22:55 UTC (rev 7458) +++ trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java 2006-06-08 20:34:43 UTC (rev 7459) @@ -357,7 +357,8 @@ String wordToHyphenate = server.getHyphenationWord( this.currentChars, this.wordStart + nonWordChars); // See if there are discretionary hyphenation points. - Hyphenation hyph = server.hyphenate(wordToHyphenate, + Hyphenation hyph = server.hyphenate(wordToHyphenate, 0, + wordToHyphenate.length(), this.currentLineText.inlineLanguage(), this.currentLineText.inlineCountry(), this.currentLineText.inlineHyphenationRemainCount(), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 20:23:04
|
Revision: 7458 Author: victormote Date: 2006-06-08 13:22:55 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7458&view=rev Log Message: ----------- Conform to axsl change: Allow any CharSequence to be the "word". Modified Paths: -------------- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java Modified: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java =================================================================== --- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java 2006-06-08 19:45:27 UTC (rev 7457) +++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java 2006-06-08 20:22:55 UTC (rev 7458) @@ -264,8 +264,8 @@ return null; } - public org.axsl.hyphenR.Hyphenation hyphenate(String word, String language, - String country, int remainCount, int pushCount) { + public org.axsl.hyphenR.Hyphenation hyphenate(CharSequence word, + String language, String country, int remainCount, int pushCount) { HyphenationTree hTree = getHyphenationTree(language, country); if (hTree == null) { return null; Modified: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java =================================================================== --- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java 2006-06-08 19:45:27 UTC (rev 7457) +++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java 2006-06-08 20:22:55 UTC (rev 7458) @@ -283,9 +283,9 @@ * @return a {@link Hyphenation Hyphenation} object representing * the hyphenated word or null if word is not hyphenated. */ - public org.axsl.hyphenR.Hyphenation hyphenate(String word, + public org.axsl.hyphenR.Hyphenation hyphenate(CharSequence word, int remainCharCount, int pushCharCount) { - char[] w = word.toCharArray(); + char[] w = word.toString().toCharArray(); return hyphenate(w, 0, w.length, remainCharCount, pushCharCount); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 19:45:33
|
Revision: 7457 Author: victormote Date: 2006-06-08 12:45:27 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7457&view=rev Log Message: ----------- Conform to axsl changes: Remove not-particularly-useful method. Modified Paths: -------------- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphenation.java Modified: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphenation.java =================================================================== --- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphenation.java 2006-06-08 19:45:20 UTC (rev 7456) +++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphenation.java 2006-06-08 19:45:27 UTC (rev 7457) @@ -46,20 +46,6 @@ } /** - * @return the pre-break text, not including the hyphen character - */ - public String getPreHyphenText(int index) { - return word.substring(0, hyphenPoints[index]); - } - - /** - * @return the post-break text - */ - public String getPostHyphenText(int index) { - return word.substring(hyphenPoints[index]); - } - - /** * @return the hyphenation points */ public int[] getHyphenationPoints() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 19:45:25
|
Revision: 7456 Author: victormote Date: 2006-06-08 12:45:20 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7456&view=rev Log Message: ----------- Conform to axsl changes: Remove not-particularly-useful method. Modified Paths: -------------- trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java Modified: trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java 2006-06-08 19:15:17 UTC (rev 7455) +++ trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java 2006-06-08 19:45:20 UTC (rev 7456) @@ -368,7 +368,7 @@ } // Select a hyphenation point. int index = selectDiscretionaryHyphenationPoint(this.currentLineText, - hyph); + wordToHyphenate, hyph); // If none fit, then the word cannot be hyphenated. if (index < 0) { return wordStart; @@ -383,18 +383,17 @@ * extracts from a hyphenated word the best (most greedy) fit */ private int selectDiscretionaryHyphenationPoint(LineText lineText, - Hyphenation hyph) throws TextException { + String word, Hyphenation hyph) throws TextException { int remainingWidth = this.currentLineWidthRemaining() - finalWidth - spaceWidth - getHyphenWidth(this.currentLineText); int[] hyphenationPoints = hyph.getHyphenationPoints(); - int numberOfHyphenationPoints = hyphenationPoints.length; int index = -1; String wordBegin = ""; - for (int i = 0; i < numberOfHyphenationPoints; i++) { - wordBegin = hyph.getPreHyphenText(i); + for (int i = 0; i < hyphenationPoints.length; i++) { + wordBegin = word.substring(0, hyphenationPoints[i]); int provisionalWordWidth = getWordWidth(lineText, wordBegin); if (provisionalWordWidth > remainingWidth) { break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 19:15:23
|
Revision: 7455 Author: victormote Date: 2006-06-08 12:15:17 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7455&view=rev Log Message: ----------- Simplify the code by just using the value returned by the hyphenation results. Modified Paths: -------------- trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java Modified: trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java 2006-06-08 18:25:45 UTC (rev 7454) +++ trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java 2006-06-08 19:15:17 UTC (rev 7455) @@ -374,7 +374,7 @@ return wordStart; } // Compute the number of characters that should be included. - int charsToInclude = hyph.getPreHyphenText(index).length(); + int charsToInclude = hyph.getHyphenationPoints()[index]; // Add it and the non-word characters to the count to be returned. return wordStart + nonWordChars + charsToInclude; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 18:25:50
|
Revision: 7454 Author: victormote Date: 2006-06-08 11:25:45 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7454&view=rev Log Message: ----------- Complete fix of Ant build process. Modified Paths: -------------- trunk/foray/foray-text/scripts/build.xml Modified: trunk/foray/foray-text/scripts/build.xml =================================================================== --- trunk/foray/foray-text/scripts/build.xml 2006-06-08 18:14:49 UTC (rev 7453) +++ trunk/foray/foray-text/scripts/build.xml 2006-06-08 18:25:45 UTC (rev 7454) @@ -82,23 +82,6 @@ <!-- =================================================================== --> - <!-- compiles hyphenation patterns --> - <!-- =================================================================== --> - <target name="hyphenation" depends="compile" > - <path id="hyph-classpath"> - <path refid="libs-build-classpath"/> - <pathelement location="${classes.dir}"/> - </path> - <taskdef name="serHyph" - classname="org.foray.text.hyphen.SerializeHyphPattern" - classpathref="hyph-classpath"/> - <serHyph includes="*.xml" - sourceDir="${hyph.source}" - targetDir="${hyph.build}" /> - </target> - - - <!-- =================================================================== --> <!-- Compiles the source directory --> <!-- =================================================================== --> <target name="compile" depends="prepare"> @@ -119,7 +102,7 @@ <!-- =================================================================== --> <!-- Creates the class package --> <!-- =================================================================== --> - <target name="package" depends="compile, style, hyphenation" + <target name="package" depends="compile, style" description="Generates the jar files (default target)"> <echo message="Creating the jar file ${build.dir}/${name}.jar"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 18:15:03
|
Revision: 7453 Author: victormote Date: 2006-06-08 11:14:49 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7453&view=rev Log Message: ----------- Steps toward getting the Ant build working. Modified Paths: -------------- trunk/foray/foray-app/scripts/build.xml trunk/foray/scripts/build.xml Modified: trunk/foray/foray-app/scripts/build.xml =================================================================== --- trunk/foray/foray-app/scripts/build.xml 2006-06-08 18:10:35 UTC (rev 7452) +++ trunk/foray/foray-app/scripts/build.xml 2006-06-08 18:14:49 UTC (rev 7453) @@ -55,6 +55,9 @@ <fileset dir="${foray.home}/foray-pdf/build/ant"> <include name="*.jar"/> </fileset> + <fileset dir="${foray.home}/foray-hyphen-r/build/ant"> + <include name="*.jar"/> + </fileset> <fileset dir="${foray.home}/foray-text/build/ant"> <include name="*.jar"/> </fileset> Modified: trunk/foray/scripts/build.xml =================================================================== --- trunk/foray/scripts/build.xml 2006-06-08 18:10:35 UTC (rev 7452) +++ trunk/foray/scripts/build.xml 2006-06-08 18:14:49 UTC (rev 7453) @@ -105,6 +105,12 @@ <property name="foray.config" value="${foray.config}"/> </ant> + <ant antfile="${foray.home}/foray-hyphen-r/scripts/build.xml" + inheritall="false" + target="package"> + <property name="foray.config" value="${foray.config}"/> + </ant> + <ant antfile="${foray.home}/foray-text/scripts/build.xml" inheritall="false" target="package"> @@ -206,14 +212,18 @@ dir="${foray.home}/foray-font/build/ant/classes"> <include name="**"/> </fileset> + <fileset id="foray-hyphen-classes" + dir="${foray.home}/foray-hyphen-r/build/ant/classes"> + <include name="**"/> + </fileset> + <fileset id="foray-hyphen-resources" + dir="${foray.home}/foray-hyphen-r/build/ant"> + <include name="hyph/**"/> + </fileset> <fileset id="foray-text-classes" dir="${foray.home}/foray-text/build/ant/classes"> <include name="**"/> </fileset> - <fileset id="foray-text-resources" - dir="${foray.home}/foray-text/build/ant"> - <include name="hyph/**"/> - </fileset> <fileset id="foray-fotree-classes" dir="${foray.home}/foray-fotree/build/ant/classes"> <include name="**"/> @@ -256,8 +266,9 @@ <fileset refid="foray-ps-classes"/> <fileset refid="foray-pdf-classes"/> <fileset refid="foray-font-classes"/> + <fileset refid="foray-hyphen-classes"/> + <fileset refid="foray-hyphen-resources"/> <fileset refid="foray-text-classes"/> - <fileset refid="foray-text-resources"/> <fileset refid="foray-fotree-classes"/> <fileset refid="foray-areatree-classes"/> <fileset refid="foray-layout-classes"/> @@ -389,6 +400,7 @@ <pathelement path="${foray.home}/foray-ps/src/java"/> <pathelement path="${foray.home}/foray-graphic/src/java"/> <pathelement path="${foray.home}/foray-font/src/java"/> + <pathelement path="${foray.home}/foray-hyphen-r/src/java"/> <pathelement path="${foray.home}/foray-fotree/src/java"/> <pathelement path="${foray.home}/foray-areatree/src/java"/> <pathelement path="${foray.home}/foray-layout/src/java"/> @@ -425,6 +437,10 @@ <package name="org.foray.font"/> <package name="org.foray.font.*"/> </group> + <group title="The FOray Hyphenation Module"> + <package name="org.foray.hyphenR"/> + <package name="org.foray.hyphenR.*"/> + </group> <group title="The FOray Text Module"> <package name="org.foray.text"/> <package name="org.foray.text.*"/> @@ -514,6 +530,10 @@ inheritall="false" target="clean"/> + <ant antfile="${foray.home}/foray-hyphen-r/scripts/build.xml" + inheritall="false" + target="clean"/> + <ant antfile="${foray.home}/foray-text/scripts/build.xml" inheritall="false" target="clean"/> @@ -577,6 +597,9 @@ <ant antfile="${foray.home}/foray-font/scripts/build.xml" inheritall="false" target="style"/> + <ant antfile="${foray.home}/foray-hyphen-r/scripts/build.xml" + inheritall="false" + target="style"/> <ant antfile="${foray.home}/foray-text/scripts/build.xml" inheritall="false" target="style"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 18:10:45
|
Revision: 7452 Author: victormote Date: 2006-06-08 11:10:35 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7452&view=rev Log Message: ----------- Move hyphenation resource from text module to hyphenation module. Removed Paths: ------------- trunk/foray/foray-text/resource/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 18:10:05
|
Revision: 7451 Author: victormote Date: 2006-06-08 11:09:47 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7451&view=rev Log Message: ----------- Move hyphenation resource from text module to hyphenation module. Added Paths: ----------- trunk/foray/foray-hyphen-r/resource/ Copied: trunk/foray/foray-hyphen-r/resource (from rev 7265, trunk/foray/foray-text/resource) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 17:54:22
|
Revision: 7450 Author: victormote Date: 2006-06-08 10:53:54 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7450&view=rev Log Message: ----------- Get new hyphenation package usable from within Eclipse. Modified Paths: -------------- trunk/foray/foray-hyphen-r/.classpath trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternParser.java trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/SerializeHyphPattern.java Modified: trunk/foray/foray-hyphen-r/.classpath =================================================================== --- trunk/foray/foray-hyphen-r/.classpath 2006-06-08 17:53:42 UTC (rev 7449) +++ trunk/foray/foray-hyphen-r/.classpath 2006-06-08 17:53:54 UTC (rev 7450) @@ -3,5 +3,9 @@ <classpathentry excluding=".#*" kind="src" path="src/java"/> <classpathentry kind="src" path="scripts"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="var" path="FORAY_LIB_ROOT/commons-logging.jar"/> + <classpathentry combineaccessrules="false" kind="src" path="/FOrayCommon"/> + <classpathentry kind="var" path="ANT_HOME/lib/ant.jar"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslHyphen-R"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> Modified: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java =================================================================== --- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java 2006-06-08 17:53:42 UTC (rev 7449) +++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java 2006-06-08 17:53:54 UTC (rev 7450) @@ -30,9 +30,8 @@ package org.foray.hyphenR; import org.foray.common.StringUtilPre5; -import org.foray.text.TextServer; -import org.axsl.text.TextException; +import org.axsl.hyphenR.HyphenationException; import org.apache.commons.logging.Log; @@ -52,10 +51,7 @@ */ public class HyphenationServer implements org.axsl.hyphenR.HyphenationServer { - /** - * The "parent" TextServer instance. - */ - private TextServer textServer; + private Log logger; /** * Collection of HyphenationTree instances that have been successfully @@ -76,11 +72,10 @@ /** * Constructor. - * @param textServer The TextServer instance that is the "parent" of this - * HyphenationServer. + * @param logger The Log instance for user messages. */ - public HyphenationServer(TextServer textServer, URL hyphenationDir) { - this.textServer = textServer; + public HyphenationServer(Log logger, URL hyphenationDir) { + this.logger = logger; // TODO: This is klunky. Use the URL. this.hyphenationDir = hyphenationDir.getFile(); } @@ -251,7 +246,7 @@ hTree.printStats(getLogger()); } return hTree; - } catch (TextException ex) { + } catch (HyphenationException ex) { if (errorDump) { getLogger().error("Can't load user patterns " + "from xml file " + this.hyphenationDir @@ -289,7 +284,7 @@ } public Log getLogger() { - return textServer.getLogger(); + return this.logger; } /** Modified: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java =================================================================== --- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java 2006-06-08 17:53:42 UTC (rev 7449) +++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java 2006-06-08 17:53:54 UTC (rev 7450) @@ -26,7 +26,7 @@ import org.foray.common.Logging; -import org.axsl.text.TextException; +import org.axsl.hyphenR.HyphenationException; import org.apache.commons.logging.Log; @@ -128,7 +128,7 @@ * Read hyphenation patterns from an XML file. */ public void loadPatterns(String filename, Log logger) - throws TextException { + throws HyphenationException { PatternParser pp = new PatternParser(this, logger); ivalues = new TernaryTree(); Modified: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternParser.java =================================================================== --- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternParser.java 2006-06-08 17:53:42 UTC (rev 7449) +++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternParser.java 2006-06-08 17:53:54 UTC (rev 7450) @@ -26,7 +26,7 @@ import org.foray.common.Logging; -import org.axsl.text.TextException; +import org.axsl.hyphenR.HyphenationException; import org.apache.commons.logging.Log; @@ -65,7 +65,7 @@ static final int ELEM_PATTERNS = 3; static final int ELEM_HYPHEN = 4; - public PatternParser(Log logger) throws TextException { + public PatternParser(Log logger) throws HyphenationException { this.logger = logger; token = new StringBuffer(); parser = createParser(); @@ -75,7 +75,7 @@ } public PatternParser(PatternConsumer consumer, Log logger) - throws TextException { + throws HyphenationException { this(logger); this.consumer = consumer; } @@ -84,17 +84,17 @@ this.consumer = consumer; } - public void parse(String filename) throws TextException { + public void parse(String filename) throws HyphenationException { InputSource uri = fileInputSource(filename); try { parser.parse(uri); } catch (SAXException e) { - throw new TextException(errMsg); + throw new HyphenationException(errMsg); } catch (IOException e) { - throw new TextException(e.getMessage()); + throw new HyphenationException(e.getMessage()); } catch (NullPointerException e) { - throw new TextException("SAX parser not available"); + throw new HyphenationException("SAX parser not available"); } } @@ -104,7 +104,7 @@ * * @return the created SAX parser */ - static XMLReader createParser() throws TextException { + static XMLReader createParser() throws HyphenationException { String parserClassName = System.getProperty("org.xml.sax.parser"); if (parserClassName == null) { parserClassName = "org.apache.xerces.parsers.SAXParser"; @@ -112,16 +112,16 @@ try { return (XMLReader)Class.forName(parserClassName).newInstance(); } catch (ClassNotFoundException e) { - throw new TextException("Could not find " + throw new HyphenationException("Could not find " + parserClassName); } catch (InstantiationException e) { - throw new TextException("Could not instantiate " + throw new HyphenationException("Could not instantiate " + parserClassName); } catch (IllegalAccessException e) { - throw new TextException("Could not access " + throw new HyphenationException("Could not access " + parserClassName); } catch (ClassCastException e) { - throw new TextException(parserClassName + throw new HyphenationException(parserClassName + " is not a SAX driver"); } } @@ -133,7 +133,7 @@ * @return the InputSource created */ protected static InputSource fileInputSource(String filename) - throws TextException { + throws HyphenationException { /* this code adapted from James Clark's in XT */ File file = new File(filename); @@ -148,7 +148,7 @@ try { return new InputSource(new URL("file", null, path).toString()); } catch (MalformedURLException e) { - throw new TextException("unexpected MalformedURLException"); + throw new HyphenationException("unexpected MalformedURLException"); } } Modified: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/SerializeHyphPattern.java =================================================================== --- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/SerializeHyphPattern.java 2006-06-08 17:53:42 UTC (rev 7449) +++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/SerializeHyphPattern.java 2006-06-08 17:53:54 UTC (rev 7450) @@ -26,7 +26,7 @@ import org.foray.common.Logging; -import org.axsl.text.TextException; +import org.axsl.hyphenR.HyphenationException; import org.apache.commons.logging.Log; import org.apache.tools.ant.BuildException; @@ -117,7 +117,7 @@ getLogger().info("Stats: "); hTree.printStats(getLogger()); } - } catch (TextException ex) { + } catch (HyphenationException ex) { getLogger().error("Can't load patterns from xml file " + infile + " - Maybe hyphenation.dtd is missing?"); if (errorDump) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 17:53:57
|
Revision: 7449 Author: victormote Date: 2006-06-08 10:53:42 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7449&view=rev Log Message: ----------- Get new hyphenation package usable from within Eclipse. Modified Paths: -------------- trunk/foray/foray-text/src/java/org/foray/text/TextServer.java trunk/foray/foray-text/src/java/org/foray/text/line/LineBreaker.java trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java Modified: trunk/foray/foray-text/src/java/org/foray/text/TextServer.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/TextServer.java 2006-06-08 17:53:28 UTC (rev 7448) +++ trunk/foray/foray-text/src/java/org/foray/text/TextServer.java 2006-06-08 17:53:42 UTC (rev 7449) @@ -24,7 +24,7 @@ package org.foray.text; -import org.foray.hyphenR.HyphenationServer; +import org.axsl.hyphenR.HyphenationServer; import org.foray.text.line.solitary.SolitaryLBS; import org.axsl.fontR.FontConsumer; @@ -35,8 +35,6 @@ import org.apache.commons.logging.Log; -import java.net.URL; - /** * This class encapsulates the various text processing functions. */ @@ -59,9 +57,9 @@ * @param logger The logger instance that should be used to log * user messages. */ - public TextServer(Log logger, URL hyphenationDir) { + public TextServer(Log logger, HyphenationServer hyphenationServer) { this.logger = logger; - this.hyphenationServer = new HyphenationServer(this, hyphenationDir); + this.hyphenationServer = hyphenationServer; } public Log getLogger() { @@ -69,9 +67,6 @@ } public HyphenationServer getHyphenationServer() { - if (this.hyphenationServer == null) { - this.hyphenationServer = new HyphenationServer(this, null); - } return this.hyphenationServer; } 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 2006-06-08 17:53:28 UTC (rev 7448) +++ trunk/foray/foray-text/src/java/org/foray/text/line/LineBreaker.java 2006-06-08 17:53:42 UTC (rev 7449) @@ -24,7 +24,7 @@ package org.foray.text.line; -import org.foray.hyphenR.HyphenationServer; +import org.axsl.hyphenR.HyphenationServer; import org.foray.text.TextServer; import org.axsl.fontR.Font; Modified: trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java 2006-06-08 17:53:28 UTC (rev 7448) +++ trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java 2006-06-08 17:53:42 UTC (rev 7449) @@ -25,7 +25,7 @@ package org.foray.text.line.solitary; import org.foray.common.StringUtilPre5; -import org.foray.hyphenR.HyphenationServer; +import org.axsl.hyphenR.HyphenationServer; import org.foray.text.line.EagerLineBreaker; import org.axsl.fontR.FontConsumer; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 17:53:43
|
Revision: 7448 Author: victormote Date: 2006-06-08 10:53:28 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7448&view=rev Log Message: ----------- Get new hyphenation package usable from within Eclipse. Modified Paths: -------------- trunk/foray/foray-app/.classpath trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java Modified: trunk/foray/foray-app/.classpath =================================================================== --- trunk/foray/foray-app/.classpath 2006-06-08 17:36:09 UTC (rev 7447) +++ trunk/foray/foray-app/.classpath 2006-06-08 17:53:28 UTC (rev 7448) @@ -34,5 +34,7 @@ <classpathentry combineaccessrules="false" kind="src" path="/axslLayout"/> <classpathentry combineaccessrules="false" kind="src" path="/FOrayCore"/> <classpathentry combineaccessrules="false" kind="src" path="/axslOutput"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslHyphen-R"/> + <classpathentry combineaccessrules="false" kind="src" path="/FOrayHyphen-R"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-06-08 17:36:09 UTC (rev 7447) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-06-08 17:53:28 UTC (rev 7448) @@ -40,6 +40,7 @@ import org.axsl.fontR.FontException; import org.axsl.fontR.FontServer; import org.axsl.graphicR.GraphicServer; +import org.axsl.hyphenR.HyphenationServer; import org.axsl.layout.LayoutFactory; import org.axsl.text.TextServer; @@ -118,8 +119,15 @@ public static TextServer makeTextServer(Log logger, SessionConfig configuration) throws FOrayException { + HyphenationServer hyphenationServer = makeHyphenationServer(logger, + configuration); + return new org.foray.text.TextServer(logger, hyphenationServer); + } + + public static HyphenationServer makeHyphenationServer(Log logger, + SessionConfig configuration) { URL hyphenationDir = configuration.optionHyphenationBaseDirectory(); - return new org.foray.text.TextServer(logger, hyphenationDir); + return new org.foray.hyphenR.HyphenationServer(logger, hyphenationDir); } public static GraphicServer makeGraphicServer(Log logger) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 17:36:42
|
Revision: 7447 Author: victormote Date: 2006-06-08 10:36:09 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7447&view=rev Log Message: ----------- Move hyphenation classes from text package to new hyphenation package (raw, compile errors left intact). Added Paths: ----------- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/ByteVector.java trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/CharVector.java trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphen.java trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphenation.java trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternConsumer.java trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternParser.java trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/SerializeHyphPattern.java trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/TernaryTree.java trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/package.html Copied: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/ByteVector.java (from rev 7265, trunk/foray/foray-text/src/java/org/foray/text/hyphen/ByteVector.java) =================================================================== --- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/ByteVector.java (rev 0) +++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/ByteVector.java 2006-06-08 17:36:09 UTC (rev 7447) @@ -0,0 +1,133 @@ +/* + * 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 + * + */ + +/* $Id$ */ + +package org.foray.hyphenR; + +import java.io.Serializable; + +/** + * This class implements a simple byte vector with access to the + * underlying array. + * + * @author Carlos Villegas <ca...@un...> + */ +public class ByteVector implements Serializable { + static final long serialVersionUID = 977379027446677063L; + + /** + * Capacity increment size + */ + private static final int DEFAULT_BLOCK_SIZE = 2048; + private int BLOCK_SIZE; + + /** + * The encapsulated array + */ + private byte[] array; + + /** + * Points to next free item + */ + private int n; + + public ByteVector() { + this(DEFAULT_BLOCK_SIZE); + } + + public ByteVector(int capacity) { + if (capacity > 0) { + BLOCK_SIZE = capacity; + } else { + BLOCK_SIZE = DEFAULT_BLOCK_SIZE; + } + array = new byte[BLOCK_SIZE]; + n = 0; + } + + public ByteVector(byte[] a) { + BLOCK_SIZE = DEFAULT_BLOCK_SIZE; + array = a; + n = 0; + } + + public ByteVector(byte[] a, int capacity) { + if (capacity > 0) { + BLOCK_SIZE = capacity; + } else { + BLOCK_SIZE = DEFAULT_BLOCK_SIZE; + } + array = a; + n = 0; + } + + public byte[] getArray() { + return array; + } + + /** + * return number of items in array + */ + public int length() { + return n; + } + + /** + * returns current capacity of array + */ + public int capacity() { + return array.length; + } + + public void put(int index, byte val) { + array[index] = val; + } + + public byte get(int index) { + return array[index]; + } + + /** + * This is to implement memory allocation in the array. Like malloc(). + */ + public int alloc(int size) { + int index = n; + int len = array.length; + if (n + size >= len) { + byte[] aux = new byte[len + BLOCK_SIZE]; + System.arraycopy(array, 0, aux, 0, len); + array = aux; + } + n += size; + return index; + } + + public void trimToSize() { + if (n < array.length) { + byte[] aux = new byte[n]; + System.arraycopy(array, 0, aux, 0, n); + array = aux; + } + } + +} Copied: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/CharVector.java (from rev 7265, trunk/foray/foray-text/src/java/org/foray/text/hyphen/CharVector.java) =================================================================== --- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/CharVector.java (rev 0) +++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/CharVector.java 2006-06-08 17:36:09 UTC (rev 7447) @@ -0,0 +1,143 @@ +/* + * 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 + * + */ + +/* $Id$ */ + +package org.foray.hyphenR; + +import java.io.Serializable; + +/** + * This class implements a simple char vector with access to the + * underlying array. + * + * @author Carlos Villegas <ca...@un...> + */ +public class CharVector implements Cloneable, Serializable { + static final long serialVersionUID = 234670840738701586L; + + /** + * Capacity increment size + */ + private static final int DEFAULT_BLOCK_SIZE = 2048; + private int BLOCK_SIZE; + + /** + * The encapsulated array + */ + private char[] array; + + /** + * Points to next free item + */ + private int n; + + public CharVector() { + this(DEFAULT_BLOCK_SIZE); + } + + public CharVector(int capacity) { + if (capacity > 0) { + BLOCK_SIZE = capacity; + } else { + BLOCK_SIZE = DEFAULT_BLOCK_SIZE; + } + array = new char[BLOCK_SIZE]; + n = 0; + } + + public CharVector(char[] a) { + BLOCK_SIZE = DEFAULT_BLOCK_SIZE; + array = a; + n = a.length; + } + + public CharVector(char[] a, int capacity) { + if (capacity > 0) { + BLOCK_SIZE = capacity; + } else { + BLOCK_SIZE = DEFAULT_BLOCK_SIZE; + } + array = a; + n = a.length; + } + + /** + * Reset Vector but don't resize or clear elements + */ + public void clear() { + n = 0; + } + + public Object clone() { + CharVector cv = new CharVector((char[])array.clone(), BLOCK_SIZE); + cv.n = this.n; + return cv; + } + + public char[] getArray() { + return array; + } + + /** + * return number of items in array + */ + public int length() { + return n; + } + + /** + * returns current capacity of array + */ + public int capacity() { + return array.length; + } + + public void put(int index, char val) { + array[index] = val; + } + + public char get(int index) { + return array[index]; + } + + public int alloc(int size) { + int index = n; + int len = array.length; + if (n + size >= len) { + char[] aux = new char[len + BLOCK_SIZE]; + System.arraycopy(array, 0, aux, 0, len); + array = aux; + } + n += size; + return index; + } + + public void trimToSize() { + if (n < array.length) { + char[] aux = new char[n]; + System.arraycopy(array, 0, aux, 0, n); + array = aux; + } + } + +} Copied: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphen.java (from rev 7265, trunk/foray/foray-text/src/java/org/foray/text/hyphen/Hyphen.java) =================================================================== --- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphen.java (rev 0) +++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphen.java 2006-06-08 17:36:09 UTC (rev 7447) @@ -0,0 +1,78 @@ +/* + * 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 + * + */ + +/* $Id$ */ + +package org.foray.hyphenR; + +import java.io.Serializable; + +/** + * This class represents a hyphen. A 'full' hyphen is made of 3 parts: + * the pre-break text, post-break text and no-break. If no line-break + * is generated at this position, the no-break text is used, otherwise, + * pre-break and post-break are used. Typically, pre-break is equal to + * the hyphen character and the others are empty. However, this general + * scheme allows support for cases in some languages where words change + * spelling if they're split across lines, like german's 'backen' which + * hyphenates 'bak-ken'. BTW, this comes from TeX. + * + * @author Carlos Villegas <ca...@un...> + */ + +public class Hyphen implements Serializable { + static final long serialVersionUID = 990405609314441965L; + + public String preBreak; + public String noBreak; + public String postBreak; + + Hyphen(String pre, String no, String post) { + preBreak = pre; + noBreak = no; + postBreak = post; + } + + Hyphen(String pre) { + preBreak = pre; + noBreak = null; + postBreak = null; + } + + public String toString() { + if (noBreak == null + && postBreak == null + && preBreak != null + && preBreak.equals("-")) { + return "-"; + } + StringBuffer res = new StringBuffer("{"); + res.append(preBreak); + res.append("}{"); + res.append(postBreak); + res.append("}{"); + res.append(noBreak); + res.append('}'); + return res.toString(); + } + +} Copied: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphenation.java (from rev 7444, trunk/foray/foray-text/src/java/org/foray/text/hyphen/Hyphenation.java) =================================================================== --- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphenation.java (rev 0) +++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphenation.java 2006-06-08 17:36:09 UTC (rev 7447) @@ -0,0 +1,80 @@ +/* + * 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 + * + */ + +/* $Id$ */ + +/* + * Known contributors: + * Carlos Villegas <ca...@un...> (original author) + */ + +package org.foray.hyphenR; + +/** + * This class represents a hyphenated word. + */ +public class Hyphenation implements org.axsl.hyphenR.Hyphenation { + int[] hyphenPoints; + String word; + + /** + * rawWord as made of alternating strings and {@link Hyphen Hyphen} + * instances + */ + Hyphenation(String word, int[] points) { + this.word = word; + hyphenPoints = points; + } + + /** + * @return the pre-break text, not including the hyphen character + */ + public String getPreHyphenText(int index) { + return word.substring(0, hyphenPoints[index]); + } + + /** + * @return the post-break text + */ + public String getPostHyphenText(int index) { + return word.substring(hyphenPoints[index]); + } + + /** + * @return the hyphenation points + */ + public int[] getHyphenationPoints() { + return hyphenPoints; + } + + public String toString() { + StringBuffer str = new StringBuffer(); + int start = 0; + for (int i = 0; i < hyphenPoints.length; i++) { + str.append(word.substring(start, hyphenPoints[i]) + "-"); + start = hyphenPoints[i]; + } + str.append(word.substring(start)); + return str.toString(); + } + +} Copied: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java (from rev 7444, trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationServer.java) =================================================================== --- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java (rev 0) +++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java 2006-06-08 17:36:09 UTC (rev 7447) @@ -0,0 +1,334 @@ +/* + * 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 + * + */ + +/* $Id$ */ + +/* + * Known contributors: + * @author Carlos Villegas <ca...@un...> (original author) + */ + +package org.foray.hyphenR; + +import org.foray.common.StringUtilPre5; +import org.foray.text.TextServer; + +import org.axsl.text.TextException; + +import org.apache.commons.logging.Log; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.lang.reflect.Method; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; + +/** + * This class is the main entry point to the hyphenation package. + */ +public class HyphenationServer implements org.axsl.hyphenR.HyphenationServer { + + /** + * The "parent" TextServer instance. + */ + private TextServer textServer; + + /** + * Collection of HyphenationTree instances that have been successfully + * deserialized or parsed. The key is the language or language and country + * connected by an underscore (e.g. en_US). + */ + HashMap hyphenTrees = new HashMap(); + + /** + * Collection of language and language_country combinations for which we + * already know we can't instantiate a HyphenationTree. This is used to + * log only one error message per language. + */ + ArrayList hyphenTreesNotFound = new ArrayList(); + + private boolean errorDump = false; + private String hyphenationDir; + + /** + * Constructor. + * @param textServer The TextServer instance that is the "parent" of this + * HyphenationServer. + */ + public HyphenationServer(TextServer textServer, URL hyphenationDir) { + this.textServer = textServer; + // TODO: This is klunky. Use the URL. + this.hyphenationDir = hyphenationDir.getFile(); + } + + private HyphenationTree getHyphenationTree(String lang, String country) { + String key = lang; + // check whether the country code has been used + if (country != null && !country.equals("none")) { + key += "_" + country; + } + // first try to find it in the cache + if (hyphenTrees.containsKey(key)) { + return (HyphenationTree)hyphenTrees.get(key); + } + if (hyphenTrees.containsKey(lang)) { + return (HyphenationTree)hyphenTrees.get(lang); + } + + /* See if it is one that we already have tried and failed. */ + Iterator iter = hyphenTreesNotFound.iterator(); + while (iter.hasNext()) { + String testedKey = (String) iter.next(); + if (key.equals(testedKey)) { + return null; + } + if (key.equals(lang)) { + return null; + } + } + + HyphenationTree hTree = getHyphenationTree(key); + if (hTree == null) { + hTree = loadHyphenationTree(key, lang); + } + // put it into the pattern cache + if (hTree != null) { + hyphenTrees.put(key, hTree); + } else { + getLogger().error("Couldn't find hyphenation pattern " + + key); + hyphenTreesNotFound.add(key); + } + return hTree; + } + + private InputStream getResourceStream(String key) { + InputStream is = null; + // Try to use Context Class Loader to load the properties file. + try { + Method getCCL = + Thread.class.getMethod("getContextClassLoader", new Class[0]); + if (getCCL != null) { + ClassLoader contextClassLoader = + (ClassLoader)getCCL.invoke(Thread.currentThread(), + new Object[0]); + is = contextClassLoader.getResourceAsStream("hyph/" + key + + ".hyp"); + } + } catch (Exception e) {} + + if (is == null) { + is = HyphenationServer.class.getResourceAsStream("/hyph/" + key + + ".hyp"); + } + + return is; + } + + private HyphenationTree getHyphenationTree(String key) { + HyphenationTree hTree = null; + ObjectInputStream ois = null; + InputStream is = null; + try { + is = getResourceStream(key); + if (is == null) { + if (key.length() == 5) { + is = getResourceStream(key.substring(0, 2)); + if (is != null) { + getLogger().error("Couldn't find hyphenation pattern " + + key + + "\nusing general language pattern " + + key.substring(0, 2) + + " instead."); + } else { + if (errorDump) { + getLogger().error("Couldn't find precompiled " + + "hyphenation pattern " + + key + ".hyp"); + } + return null; + } + } else { + if (errorDump) { + getLogger().error("Couldn't find precompiled " + + "hyphenation pattern " + + key + ".hyp"); + } + return null; + } + } + ois = new ObjectInputStream(is); + hTree = (HyphenationTree)ois.readObject(); + } catch (Exception e) { + e.printStackTrace(); + } + finally { + if (ois != null) { + try { + ois.close(); + } catch (IOException e) { + getLogger().error("can't close hyphenation object stream"); + } + } + } + return hTree; + } + + /** + * load tree from serialized file or xml file + * using configuration settings + */ + private HyphenationTree loadHyphenationTree(String key, + String language) { + if (this.hyphenationDir == null) { + return null; + } + HyphenationTree hTree = null; + // I use here the following convention. The file name specified in + // the configuration is taken as the base name. First we try + // name + ".hyp" assuming a serialized HyphenationTree. If that fails + // we try name + ".xml", assumming a raw hyphenation pattern file. + + // first try serialized object + File hyphenFile = new File(this.hyphenationDir, key + ".hyp"); + if (hyphenFile.exists()) { + ObjectInputStream ois = null; + try { + ois = new ObjectInputStream(new FileInputStream(hyphenFile)); + hTree = (HyphenationTree)ois.readObject(); + } catch (Exception e) { + e.printStackTrace(); + } + finally { + if (ois != null) { + try { + ois.close(); + } catch (IOException e) {} + } + } + return hTree; + } + + // try the raw XML file + hyphenFile = new File(this.hyphenationDir, key + ".xml"); + if (! hyphenFile.exists()) { + hyphenFile = new File(this.hyphenationDir, language + ".xml"); + } + if (hyphenFile.exists()) { + hTree = new HyphenationTree(); + if (errorDump) { + getLogger().error("reading " + this.hyphenationDir + key + + ".xml"); + } + try { + hTree.loadPatterns(hyphenFile.getPath(), getLogger()); + if (errorDump) { + getLogger().debug("Stats: "); + hTree.printStats(getLogger()); + } + return hTree; + } catch (TextException ex) { + if (errorDump) { + getLogger().error("Can't load user patterns " + + "from xml file " + this.hyphenationDir + + key + ".xml"); + } + return null; + } + } + if (errorDump) { + getLogger().error("Tried to load " + + hyphenFile.toString() + + "\nCannot find compiled nor xml file for " + + "hyphenation pattern" + key); + } + return null; + } + + public org.axsl.hyphenR.Hyphenation hyphenate(String word, String language, + String country, int remainCount, int pushCount) { + HyphenationTree hTree = getHyphenationTree(language, country); + if (hTree == null) { + return null; + } + return hTree.hyphenate(word, remainCount, pushCount); + } + + public org.axsl.hyphenR.Hyphenation hyphenate(char[] word, int offset, + int len, String language, String country, int remainCount, + int pushCount) { + HyphenationTree hTree = getHyphenationTree(language, country); + if (hTree == null) { + return null; + } + return hTree.hyphenate(word, offset, len, remainCount, pushCount); + } + + public Log getLogger() { + return textServer.getLogger(); + } + + /** + * extracts a complete word from the character data + */ + public String getHyphenationWord(char[] characters, int wordStart) { + boolean wordendFound = false; + int counter = 0; + int[] newWord = new int[characters.length]; // create a buffer + while ((!wordendFound) + && ((wordStart + counter) < characters.length)) { + int tk = characters[wordStart + counter]; + if (StringUtilPre5.isLetter(tk)) { + newWord[counter] = tk; + counter++; + } else { + wordendFound = true; + } + } + return StringUtilPre5.newString(newWord, 0, counter); + } + + /** + * Returns the count of non-word characters at the beginning of the text + * being evaluated. This includes characters like " and ' which are not + * really part of the word, but which must be passed through to the output. + * @param characters The char array being evaluated. + * @param startIndex Index into the first character in characters that + * should be evaluated. + * @return The number of characters at the start that should be ignored for + * purposes of forming a word to be evaluated for hyphenation. + */ + public int nonWordChars(char[] characters, int startIndex) { + int count = 0; + // Look for ' or " at the beginning of the word. + if (characters[startIndex] == '"' || characters[startIndex] == '\'') { + count ++; + } + return count; + } + +} Copied: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java (from rev 7444, trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationTree.java) =================================================================== --- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java (rev 0) +++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java 2006-06-08 17:36:09 UTC (rev 7447) @@ -0,0 +1,533 @@ +/* + * 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 + * + */ + +/* $Id$ */ + +package org.foray.hyphenR; + +import org.foray.common.Logging; + +import org.axsl.text.TextException; + +import org.apache.commons.logging.Log; + +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; + +/** + * This tree structure stores the hyphenation patterns in an efficient + * way for fast lookup. It provides the provides the method to + * hyphenate a word. + * + * @author Carlos Villegas <ca...@un...> + */ +public class HyphenationTree extends TernaryTree implements PatternConsumer, + Serializable { + static final long serialVersionUID = 734862840356804663L; + + /** + * value space: stores the inteletter values + */ + protected ByteVector vspace; + + /** + * This map stores hyphenation exceptions + */ + protected HashMap stoplist; + + /** + * This map stores the character classes + */ + protected TernaryTree classmap; + + /** + * Temporary map to store interletter values on pattern loading. + */ + private transient TernaryTree ivalues; + + public HyphenationTree() { + stoplist = new HashMap(23); // usually a small table + classmap = new TernaryTree(); + vspace = new ByteVector(); + vspace.alloc(1); // this reserves index 0, which we don't use + } + + /** + * Packs the values by storing them in 4 bits, two values into a byte + * Values range is from 0 to 9. We use zero as terminator, + * so we'll add 1 to the value. + * @param values a string of digits from '0' to '9' representing the + * interletter values. + * @return the index into the vspace array where the packed values + * are stored. + */ + protected int packValues(String values) { + int i, n = values.length(); + int m = (n & 1) == 1 ? (n >> 1) + 2 : (n >> 1) + 1; + int offset = vspace.alloc(m); + byte[] va = vspace.getArray(); + for (i = 0; i < n; i++) { + int j = i >> 1; + byte v = (byte)((values.charAt(i) - '0' + 1) & 0x0f); + if ((i & 1) == 1) { + va[j + offset] = (byte)(va[j + offset] | v); + } else { + va[j + offset] = (byte)(v << 4); // big endian + } + } + va[m - 1 + offset] = 0; // terminator + return offset; + } + + protected String unpackValues(int k) { + StringBuffer buf = new StringBuffer(); + byte v = vspace.get(k++); + while (v != 0) { + char c = (char)((v >>> 4) - 1 + '0'); + buf.append(c); + c = (char)(v & 0x0f); + if (c == 0) { + break; + } + c = (char)(c - 1 + '0'); + buf.append(c); + v = vspace.get(k++); + } + return buf.toString(); + } + + /** + * Read hyphenation patterns from an XML file. + */ + public void loadPatterns(String filename, Log logger) + throws TextException { + PatternParser pp = new PatternParser(this, logger); + ivalues = new TernaryTree(); + + pp.parse(filename); + + // patterns/values should be now in the tree + // let's optimize a bit + trimToSize(); + vspace.trimToSize(); + classmap.trimToSize(); + + // get rid of the auxiliary map + ivalues = null; + } + + public String findPattern(String pat) { + int k = super.find(pat); + if (k >= 0) { + return unpackValues(k); + } + return ""; + } + + /** + * String compare, returns 0 if equal or + * t is a substring of s + */ + protected int hstrcmp(char[] s, int si, char[] t, int ti) { + for (; s[si] == t[ti]; si++, ti++) { + if (s[si] == 0) { + return 0; + } + } + if (t[ti] == 0) { + return 0; + } + return s[si] - t[ti]; + } + + protected byte[] getValues(int k) { + StringBuffer buf = new StringBuffer(); + byte v = vspace.get(k++); + while (v != 0) { + char c = (char)((v >>> 4) - 1); + buf.append(c); + c = (char)(v & 0x0f); + if (c == 0) { + break; + } + c = (char)(c - 1); + buf.append(c); + v = vspace.get(k++); + } + byte[] res = new byte[buf.length()]; + for (int i = 0; i < res.length; i++) { + res[i] = (byte)buf.charAt(i); + } + return res; + } + + /** + * <p>Search for all possible partial matches of word starting + * at index an update interletter values. In other words, it + * does something like:</p> + * <code> + * for(i=0; i<patterns.length; i++) { + * if ( word.substring(index).startsWidth(patterns[i]) ) + * update_interletter_values(patterns[i]); + * } + * </code> + * <p>But it is done in an efficient way since the patterns are + * stored in a ternary tree. In fact, this is the whole purpose + * of having the tree: doing this search without having to test + * every single pattern. The number of patterns for languages + * such as English range from 4000 to 10000. Thus, doing thousands + * of string comparisons for each word to hyphenate would be + * really slow without the tree. The tradeoff is memory, but + * using a ternary tree instead of a trie, almost halves the + * the memory used by Lout or TeX. It's also faster than using + * a hash table</p> + * @param word null terminated word to match + * @param index start index from word + * @param il interletter values array to update + */ + protected void searchPatterns(char[] word, int index, byte[] il) { + byte[] values; + int i = index; + char p, q; + char sp = word[i]; + p = root; + + while (p > 0 && p < sc.length) { + if (sc[p] == 0xFFFF) { + if (hstrcmp(word, i, kv.getArray(), lo[p]) == 0) { + values = getValues(eq[p]); // data pointer is in eq[] + int j = index; + for (int k = 0; k < values.length; k++) { + if (j < il.length && values[k] > il[j]) { + il[j] = values[k]; + } + j++; + } + } + return; + } + int d = sp - sc[p]; + if (d == 0) { + if (sp == 0) { + break; + } + sp = word[++i]; + p = eq[p]; + q = p; + + // look for a pattern ending at this position by searching for + // the null char ( splitchar == 0 ) + while (q > 0 && q < sc.length) { + if (sc[q] == 0xFFFF) { // stop at compressed branch + break; + } + if (sc[q] == 0) { + values = getValues(eq[q]); + int j = index; + for (int k = 0; k < values.length; k++) { + if (j < il.length && values[k] > il[j]) { + il[j] = values[k]; + } + j++; + } + break; + } + q = lo[q]; + /** + * actually the code should be: + * q = sc[q] < 0 ? hi[q] : lo[q]; + * but java chars are unsigned + */ + } + } else { + p = d < 0 ? lo[p] : hi[p]; + } + } + } + + /** + * Hyphenate word and return a Hyphenation object. + * @param word the word to be hyphenated + * @param remainCharCount Minimum number of characters allowed + * before the hyphenation point. + * @param pushCharCount Minimum number of characters allowed after + * the hyphenation point. + * @return a {@link Hyphenation Hyphenation} object representing + * the hyphenated word or null if word is not hyphenated. + */ + public org.axsl.hyphenR.Hyphenation hyphenate(String word, + int remainCharCount, int pushCharCount) { + char[] w = word.toCharArray(); + return hyphenate(w, 0, w.length, remainCharCount, pushCharCount); + } + + /** + * Hyphenate word and return an array of hyphenation points. + * @param w char array that contains the word + * @param offset Offset to first character in word + * @param len Length of word + * @param remainCharCount Minimum number of characters allowed + * before the hyphenation point. + * @param pushCharCount Minimum number of characters allowed after + * the hyphenation point. + * @return a {@link Hyphenation Hyphenation} object representing + * the hyphenated word or null if word is not hyphenated. + */ + public org.axsl.hyphenR.Hyphenation hyphenate(char[] w, int offset, int len, + int remainCharCount, int pushCharCount) { + char[] word = new char[len + 3]; + + // normalize word + char[] c = new char[2]; + for (int i = 1; i <= len; i++) { + c[0] = w[offset + i - 1]; + int nc = classmap.find(c, 0); + if (nc < 0) { // found a non-letter character, abort + return null; + } + word[i] = (char)nc; + } + int[] result = new int[len + 1]; + int k = 0; + + // check exception list first + String sw = new String(word, 1, len); + if (stoplist.containsKey(sw)) { + /* assume only simple hyphens (Hyphen.pre="-", + * Hyphen.post = Hyphen.no = null) */ + ArrayList hw = (ArrayList)stoplist.get(sw); + int j = 0; + for (int i = 0; i < hw.size(); i++) { + Object o = hw.get(i); + if (o instanceof String) { + j += ((String)o).length(); + if (j >= remainCharCount && j < (len - pushCharCount)) { + result[k++] = j; + } + } + } + } else { + // use algorithm to get hyphenation points + word[0] = '.'; // word start marker + word[len + 1] = '.'; // word end marker + word[len + 2] = 0; // null terminated + byte[] il = new byte[len + 3]; // initialized to zero + for (int i = 0; i < len + 1; i++) { + searchPatterns(word, i, il); + } + + // hyphenation points are located where interletter value is odd + for (int i = 0; i < len; i++) { + if (((il[i + 1] & 1) == 1) && i >= remainCharCount + && i <= (len - pushCharCount)) { + result[k++] = i; + } + } + } + + + if (k > 0) { + // trim result array + int[] res = new int[k]; + System.arraycopy(result, 0, res, 0, k); + return new Hyphenation(new String(w, offset, len), res); + } + return null; + } + + /** + * Add a character class to the tree. It is used by + * {@link PatternParser PatternParser} as callback to + * add character classes. Character classes define the + * valid word characters for hyphenation. If a word contains + * a character not defined in any of the classes, it is not hyphenated. + * It also defines a way to normalize the characters in order + * to compare them with the stored patterns. Usually pattern + * files use only lower case characters, in this case a class + * for letter 'a', for example, should be defined as "aA", the first + * character being the normalization char. + */ + public void addClass(String chargroup) { + if (chargroup.length() > 0) { + char equivChar = chargroup.charAt(0); + char[] key = new char[2]; + key[1] = 0; + for (int i = 0; i < chargroup.length(); i++) { + key[0] = chargroup.charAt(i); + classmap.insert(key, 0, equivChar); + } + } + } + + /** + * Add an exception to the tree. It is used by + * {@link PatternParser PatternParser} class as callback to + * store the hyphenation exceptions. + * @param word normalized word + * @param hyphenatedword a ArrayList of alternating strings and + * {@link Hyphen hyphen} objects. + */ + public void addException(String word, ArrayList hyphenatedword) { + stoplist.put(word, hyphenatedword); + } + + /** + * Add a pattern to the tree. Mainly, to be used by + * {@link PatternParser PatternParser} class as callback to + * add a pattern to the tree. + * @param pattern the hyphenation pattern + * @param ivalue interletter weight values indicating the + * desirability and priority of hyphenating at a given point + * within the pattern. It should contain only digit characters. + * (i.e. '0' to '9'). + */ + public void addPattern(String pattern, String ivalue) { + int k = ivalues.find(ivalue); + if (k <= 0) { + k = packValues(ivalue); + ivalues.insert(ivalue, (char)k); + } + insert(pattern, (char)k); + } + + public void printStats(Log logger) { + logger.info("Value space size = " + Integer.toString(vspace.length())); + super.printStats(logger); + } + + public static void main(String[] argv) throws Exception { + Log logger = Logging.makeDefaultLogger(); + HyphenationTree ht = null; + int minCharCount = 2; + BufferedReader in = + new BufferedReader(new InputStreamReader(System.in)); + for (; ; ) { + logger.info("l:\tload patterns from XML\n" + + "L:\tload patterns from serialized object\n" + + "s:\tset minimun character count\n" + + "w:\twrite hyphenation tree to object file\n" + + "h:\thyphenate\n" + + "f:\tfind pattern\n" + + "b:\tbenchmark\n" + + "q:\tquit\n" + + "\nCommand:"); + String token = in.readLine().trim(); + if (token.equals("f")) { + logger.info("Pattern: "); + token = in.readLine().trim(); + logger.info("Values: " + ht.findPattern(token)); + } else if (token.equals("s")) { + logger.info("Minimun value: "); + token = in.readLine().trim(); + minCharCount = Integer.parseInt(token); + } else if (token.equals("l")) { + ht = new HyphenationTree(); + logger.info("XML file name: "); + token = in.readLine().trim(); + ht.loadPatterns(token, logger); + } else if (token.equals("L")) { + ObjectInputStream ois = null; + logger.info("Object file name: "); + token = in.readLine().trim(); + try { + ois = new ObjectInputStream(new FileInputStream(token)); + ht = (HyphenationTree)ois.readObject(); + } catch (Exception e) { + e.printStackTrace(); + } + finally { + if (ois != null) { + try { + ois.close(); + } catch (IOException e) {} + } + } + } else if (token.equals("w")) { + logger.info("Object file name: "); + token = in.readLine().trim(); + ObjectOutputStream oos = null; + try { + oos = new ObjectOutputStream(new FileOutputStream(token)); + oos.writeObject(ht); + } catch (Exception e) { + e.printStackTrace(); + } + finally { + if (oos != null) { + try { + oos.flush(); + } catch (IOException e) {} + try { + oos.close(); + } catch (IOException e) {} + } + } + } else if (token.equals("h")) { + logger.info("Word: "); + token = in.readLine().trim(); + logger.info("Hyphenation points: "); + logger.info(ht.hyphenate(token, minCharCount, + minCharCount).toString()); + } else if (token.equals("b")) { + if (ht == null) { + logger.info("No patterns has been loaded."); + break; + } + logger.info("Word list filename: "); + token = in.readLine().trim(); + long starttime = 0; + int counter = 0; + ; + try { + BufferedReader reader = + new BufferedReader(new FileReader(token)); + + starttime = System.currentTimeMillis(); + while ((reader.readLine()) != null) { + counter++; + } + } catch (Exception ioe) { + logger.info("Exception " + ioe); + ioe.printStackTrace(); + } + long endtime = System.currentTimeMillis(); + long result = endtime - starttime; + logger.info(counter + " words hypehanted in " + result + + " milliseconds."); + + } else if (token.equals("q")) { + break; + } + } + + } + +} Copied: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternConsumer.java (from rev 7265, trunk/foray/foray-text/src/java/org/foray/text/hyphen/PatternConsumer.java) =================================================================== --- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternConsumer.java (rev 0) +++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternConsumer.java 2006-06-08 17:36:09 UTC (rev 7447) @@ -0,0 +1,62 @@ +/* + * 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 + * + */ + +/* $Id$ */ + +package org.foray.hyphenR; + +import java.util.ArrayList; + +/** + * This interface is used to connect the XML pattern file parser to + * the hyphenation tree. + * + * @author Carlos Villegas <ca...@un...> + */ +public interface PatternConsumer { + + /** + * Add a character class. + * A character class defines characters that are considered + * equivalent for the purpose of hyphenation (e.g. "aA"). It + * usually means to ignore case. + */ + void addClass(String chargroup); + + /** + * Add a hyphenation exception. An exception replaces the + * result obtained by the algorithm for cases for which this + * fails or the user wants to provide his own hyphenation. + * A hyphenatedword is a ArrayList of alternating String's and + * {@link Hyphen Hyphen} instances + */ + void addException(String word, ArrayList hyphenatedword); + + /** + * Add hyphenation patterns. + * @param pattern + * @param values interletter values expressed as a string of + * digit characters. + */ + void addPattern(String pattern, String values); + +} Copied: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternParser.java (from rev 7265, trunk/foray/foray-text/src/java/org/foray/text/hyphen/PatternParser.java) =================================================================== --- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternParser.java (rev 0) +++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternParser.java 2006-06-08 17:36:09 UTC (rev 7447) @@ -0,0 +1,439 @@ +/* + * 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 + * + */ + +/* $Id$ */ + +package org.foray.hyphenR; + +import org.foray.common.Logging; + +import org.axsl.text.TextException; + +import org.apache.commons.logging.Log; + +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.DefaultHandler; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; + +/** + * A SAX document handler to read and parse hyphenation patterns + * from a XML file. + * + * @author Carlos Villegas <ca...@un...> + */ +public class PatternParser extends DefaultHandler implements PatternConsumer { + + XMLReader parser; + int currElement; + PatternConsumer consumer; + StringBuffer token; + ArrayList exception; + char hyphenChar; + String errMsg; + Log logger; + + static final int ELEM_CLASSES = 1; + static final int ELEM_EXCEPTIONS = 2; + static final int ELEM_PATTERNS = 3; + static final int ELEM_HYPHEN = 4; + + public PatternParser(Log logger) throws TextException { + this.logger = logger; + token = new StringBuffer(); + parser = createParser(); + parser.setContentHandler(this); + parser.setErrorHandler(this); + hyphenChar = '-'; // default + } + + public PatternParser(PatternConsumer consumer, Log logger) + throws TextException { + this(logger); + this.consumer = consumer; + } + + public void setConsumer(PatternConsumer consumer) { + this.consumer = consumer; + } + + public void parse(String filename) throws TextException { + InputSource uri = fileInputSource(filename); + + try { + parser.parse(uri); + } catch (SAXException e) { + throw new TextException(errMsg); + } catch (IOException e) { + throw new TextException(e.getMessage()); + } catch (NullPointerException e) { + throw new TextException("SAX parser not available"); + } + } + + /** + * creates a SAX parser, using the value of org.xml.sax.parser + * defaulting to org.apache.xerces.parsers.SAXParser + * + * @return the created SAX parser + */ + static XMLReader createParser() throws TextException { + String parserClassName = System.getProperty("org.xml.sax.parser"); + if (parserClassName == null) { + parserClassName = "org.apache.xerces.parsers.SAXParser"; + } + try { + return (XMLReader)Class.forName(parserClassName).newInstance(); + } catch (ClassNotFoundException e) { + throw new TextException("Could not find " + + parserClassName); + } catch (InstantiationException e) { + throw new TextException("Could not instantiate " + + parserClassName); + } catch (IllegalAccessException e) { + throw new TextException("Could not access " + + parserClassName); + } catch (ClassCastException e) { + throw new TextException(parserClassName + + " is not a SAX driver"); + } + } + + /** + * create an InputSource from a file name + * + * @param filename the name of the file + * @return the InputSource created + */ + protected static InputSource fileInputSource(String filename) + throws TextException { + + /* this code adapted from James Clark's in XT */ + File file = new File(filename); + String path = file.getAbsolutePath(); + String fSep = System.getProperty("file.separator"); + if (fSep != null && fSep.length() == 1) { + path = path.replace(fSep.charAt(0), '/'); + } + if (path.length() > 0 && path.charAt(0) != '/') { + path = '/' + path; + } + try { + return new InputSource(new URL("file", null, path).toString()); + } catch (MalformedURLException e) { + throw new TextException("unexpected MalformedURLException"); + } + } + + protected String readToken(StringBuffer chars) { + String word; + boolean space = false; + int i; + for (i = 0; i < chars.length(); i++) { + if (Character.isWhitespace(chars.charAt(i))) { + space = true; + } else { + break; + } + } + if (space) { + for (int countr = i; countr < chars.length(); countr++) { + chars.setCharAt(countr - i, chars.charAt(countr)); + } + chars.setLength(chars.length() - i); + if (token.length() > 0) { + word = token.toString(); + token.setLength(0); + return word; + } + } + space = false; + for (i = 0; i < chars.length(); i++) { + if (Character.isWhitespace(chars.charAt(i))) { + space = true; + break; + } + } + token.append(chars.toString().substring(0, i)); + for (int countr = i; countr < chars.length(); countr++) { + chars.setCharAt(countr - i, chars.charAt(countr)); + } + chars.setLength(chars.length() - i); + if (space) { + word = token.toString(); + token.setLength(0); + return word; + } + token.append(chars); + return null; + } + + protected static String getPattern(String word) { + StringBuffer pat = new StringBuffer(); + int len = word.length(); + for (int i = 0; i < len; i++) { + if (!Character.isDigit(word.charAt(i))) { + pat.append(word.charAt(i)); + } + } + return pat.toString(); + } + + protected ArrayList normalizeException(ArrayList ex) { + ArrayList res = new ArrayList(); + for (int i = 0; i < ex.size(); i++) { + Object item = ex.get(i); + if (item instanceof String) { + String str = (String)item; + StringBuffer buf = new StringBuffer(); + for (int j = 0; j < str.length(); j++) { + char c = str.charAt(j); + if (c != hyphenChar) { + buf.append(c); + } else { + res.add(buf.toString()); + buf.setLength(0); + char[] h = new char[1]; + h[0] = hyphenChar; + // we use here hyphenChar which is not necessarily + // the one to be printed + res.add(new Hyphen(new String(h), null, null)); + } + } + if (buf.length() > 0) { + res.add(buf.toString()); + } + } else { + res.add(item); + } + } + return res; + } + + protected String getExceptionWord(ArrayList ex) { + StringBuffer res = new StringBuffer(); + for (int i = 0; i < ex.size(); i++) { + Object item = ex.get(i); + if (item instanceof String) { + res.append((String)item); + } else { + if (((Hyphen)item).noBreak != null) { + res.append(((Hyphen)item).noBreak); + } + } + } + return res.toString(); + } + + protected static String getInterletterValues(String pat) { + StringBuffer il = new StringBuffer(); + String word = pat + "a"; // add dummy letter to serve as sentinel + int len = word.length(); + for (int i = 0; i < len; i++) { + char c = word.charAt(i); + if (Character.isDigit(c)) { + il.append(c); + i++; + } else { + il.append('0'); + } + } + return il.toString(); + } + + // + // DocumentHandler methods + // + + /** + * Start element. + */ + public void startElement(String uri, String local, String raw, + Attributes attrs) { + if (local.equals("hyphen-char")) { + String h = attrs.getValue("value"); + if (h != null && h.length() == 1) { + hyphenChar = h.charAt(0); + } + } else if (local.equals("classes")) { + currElement = ELEM_CLASSES; + } else if (local.equals("patterns")) { + currElement = ELEM_PATTERNS; + } else if (local.equals("exceptions")) { + currElement = ELEM_EXCEPTIONS; + exception = new ArrayList(); + } else if (local.equals("hyphen")) { + if (token.length() > 0) { + exception.add(token.toString()); + } + exception.add(new Hyphen(attrs.getValue("pre"), + attrs.getValue("no"), attrs.getValue("post"))); + currElement = ELEM_HYPHEN; + } + token.setLength(0); + } + + public void endElement(String uri, String local, String raw) { + + if (token.length() > 0) { + String word = token.toString(); + switch (currElement) { + case ELEM_CLASSES: + consumer.addClass(word); + break; + case ELEM_EXCEPTIONS: + exception.add(word); + exception = normalizeException(exception); + consumer.addException(getExceptionWord(exception), + (ArrayList) exception.clone()); + break; + case ELEM_PATTERNS: + consumer.addPattern(getPattern(word), + getInterletterValues(word)); + break; + case ELEM_HYPHEN: + break; + }... [truncated message content] |
|
From: <vic...@us...> - 2006-06-08 17:36:07
|
Revision: 7446 Author: victormote Date: 2006-06-08 10:35:48 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7446&view=rev Log Message: ----------- Move hyphenation classes from text package to new hyphenation package (raw, compile errors left intact). Modified Paths: -------------- trunk/foray/foray-text/src/java/org/foray/text/TextServer.java trunk/foray/foray-text/src/java/org/foray/text/line/LineBreaker.java trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java Removed Paths: ------------- trunk/foray/foray-text/src/java/org/foray/text/hyphen/ByteVector.java trunk/foray/foray-text/src/java/org/foray/text/hyphen/CharVector.java trunk/foray/foray-text/src/java/org/foray/text/hyphen/Hyphen.java trunk/foray/foray-text/src/java/org/foray/text/hyphen/Hyphenation.java trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationServer.java trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationTree.java trunk/foray/foray-text/src/java/org/foray/text/hyphen/PatternConsumer.java trunk/foray/foray-text/src/java/org/foray/text/hyphen/PatternParser.java trunk/foray/foray-text/src/java/org/foray/text/hyphen/SerializeHyphPattern.java trunk/foray/foray-text/src/java/org/foray/text/hyphen/TernaryTree.java trunk/foray/foray-text/src/java/org/foray/text/hyphen/package.html Modified: trunk/foray/foray-text/src/java/org/foray/text/TextServer.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/TextServer.java 2006-06-08 17:21:04 UTC (rev 7445) +++ trunk/foray/foray-text/src/java/org/foray/text/TextServer.java 2006-06-08 17:35:48 UTC (rev 7446) @@ -24,7 +24,7 @@ package org.foray.text; -import org.foray.text.hyphen.HyphenationServer; +import org.foray.hyphenR.HyphenationServer; import org.foray.text.line.solitary.SolitaryLBS; import org.axsl.fontR.FontConsumer; Deleted: trunk/foray/foray-text/src/java/org/foray/text/hyphen/ByteVector.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/hyphen/ByteVector.java 2006-06-08 17:21:04 UTC (rev 7445) +++ trunk/foray/foray-text/src/java/org/foray/text/hyphen/ByteVector.java 2006-06-08 17:35:48 UTC (rev 7446) @@ -1,133 +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 - * - */ - -/* $Id$ */ - -package org.foray.text.hyphen; - -import java.io.Serializable; - -/** - * This class implements a simple byte vector with access to the - * underlying array. - * - * @author Carlos Villegas <ca...@un...> - */ -public class ByteVector implements Serializable { - static final long serialVersionUID = 977379027446677063L; - - /** - * Capacity increment size - */ - private static final int DEFAULT_BLOCK_SIZE = 2048; - private int BLOCK_SIZE; - - /** - * The encapsulated array - */ - private byte[] array; - - /** - * Points to next free item - */ - private int n; - - public ByteVector() { - this(DEFAULT_BLOCK_SIZE); - } - - public ByteVector(int capacity) { - if (capacity > 0) { - BLOCK_SIZE = capacity; - } else { - BLOCK_SIZE = DEFAULT_BLOCK_SIZE; - } - array = new byte[BLOCK_SIZE]; - n = 0; - } - - public ByteVector(byte[] a) { - BLOCK_SIZE = DEFAULT_BLOCK_SIZE; - array = a; - n = 0; - } - - public ByteVector(byte[] a, int capacity) { - if (capacity > 0) { - BLOCK_SIZE = capacity; - } else { - BLOCK_SIZE = DEFAULT_BLOCK_SIZE; - } - array = a; - n = 0; - } - - public byte[] getArray() { - return array; - } - - /** - * return number of items in array - */ - public int length() { - return n; - } - - /** - * returns current capacity of array - */ - public int capacity() { - return array.length; - } - - public void put(int index, byte val) { - array[index] = val; - } - - public byte get(int index) { - return array[index]; - } - - /** - * This is to implement memory allocation in the array. Like malloc(). - */ - public int alloc(int size) { - int index = n; - int len = array.length; - if (n + size >= len) { - byte[] aux = new byte[len + BLOCK_SIZE]; - System.arraycopy(array, 0, aux, 0, len); - array = aux; - } - n += size; - return index; - } - - public void trimToSize() { - if (n < array.length) { - byte[] aux = new byte[n]; - System.arraycopy(array, 0, aux, 0, n); - array = aux; - } - } - -} Deleted: trunk/foray/foray-text/src/java/org/foray/text/hyphen/CharVector.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/hyphen/CharVector.java 2006-06-08 17:21:04 UTC (rev 7445) +++ trunk/foray/foray-text/src/java/org/foray/text/hyphen/CharVector.java 2006-06-08 17:35:48 UTC (rev 7446) @@ -1,143 +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 - * - */ - -/* $Id$ */ - -package org.foray.text.hyphen; - -import java.io.Serializable; - -/** - * This class implements a simple char vector with access to the - * underlying array. - * - * @author Carlos Villegas <ca...@un...> - */ -public class CharVector implements Cloneable, Serializable { - static final long serialVersionUID = 234670840738701586L; - - /** - * Capacity increment size - */ - private static final int DEFAULT_BLOCK_SIZE = 2048; - private int BLOCK_SIZE; - - /** - * The encapsulated array - */ - private char[] array; - - /** - * Points to next free item - */ - private int n; - - public CharVector() { - this(DEFAULT_BLOCK_SIZE); - } - - public CharVector(int capacity) { - if (capacity > 0) { - BLOCK_SIZE = capacity; - } else { - BLOCK_SIZE = DEFAULT_BLOCK_SIZE; - } - array = new char[BLOCK_SIZE]; - n = 0; - } - - public CharVector(char[] a) { - BLOCK_SIZE = DEFAULT_BLOCK_SIZE; - array = a; - n = a.length; - } - - public CharVector(char[] a, int capacity) { - if (capacity > 0) { - BLOCK_SIZE = capacity; - } else { - BLOCK_SIZE = DEFAULT_BLOCK_SIZE; - } - array = a; - n = a.length; - } - - /** - * Reset Vector but don't resize or clear elements - */ - public void clear() { - n = 0; - } - - public Object clone() { - CharVector cv = new CharVector((char[])array.clone(), BLOCK_SIZE); - cv.n = this.n; - return cv; - } - - public char[] getArray() { - return array; - } - - /** - * return number of items in array - */ - public int length() { - return n; - } - - /** - * returns current capacity of array - */ - public int capacity() { - return array.length; - } - - public void put(int index, char val) { - array[index] = val; - } - - public char get(int index) { - return array[index]; - } - - public int alloc(int size) { - int index = n; - int len = array.length; - if (n + size >= len) { - char[] aux = new char[len + BLOCK_SIZE]; - System.arraycopy(array, 0, aux, 0, len); - array = aux; - } - n += size; - return index; - } - - public void trimToSize() { - if (n < array.length) { - char[] aux = new char[n]; - System.arraycopy(array, 0, aux, 0, n); - array = aux; - } - } - -} Deleted: trunk/foray/foray-text/src/java/org/foray/text/hyphen/Hyphen.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/hyphen/Hyphen.java 2006-06-08 17:21:04 UTC (rev 7445) +++ trunk/foray/foray-text/src/java/org/foray/text/hyphen/Hyphen.java 2006-06-08 17:35:48 UTC (rev 7446) @@ -1,78 +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 - * - */ - -/* $Id$ */ - -package org.foray.text.hyphen; - -import java.io.Serializable; - -/** - * This class represents a hyphen. A 'full' hyphen is made of 3 parts: - * the pre-break text, post-break text and no-break. If no line-break - * is generated at this position, the no-break text is used, otherwise, - * pre-break and post-break are used. Typically, pre-break is equal to - * the hyphen character and the others are empty. However, this general - * scheme allows support for cases in some languages where words change - * spelling if they're split across lines, like german's 'backen' which - * hyphenates 'bak-ken'. BTW, this comes from TeX. - * - * @author Carlos Villegas <ca...@un...> - */ - -public class Hyphen implements Serializable { - static final long serialVersionUID = 990405609314441965L; - - public String preBreak; - public String noBreak; - public String postBreak; - - Hyphen(String pre, String no, String post) { - preBreak = pre; - noBreak = no; - postBreak = post; - } - - Hyphen(String pre) { - preBreak = pre; - noBreak = null; - postBreak = null; - } - - public String toString() { - if (noBreak == null - && postBreak == null - && preBreak != null - && preBreak.equals("-")) { - return "-"; - } - StringBuffer res = new StringBuffer("{"); - res.append(preBreak); - res.append("}{"); - res.append(postBreak); - res.append("}{"); - res.append(noBreak); - res.append('}'); - return res.toString(); - } - -} Deleted: trunk/foray/foray-text/src/java/org/foray/text/hyphen/Hyphenation.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/hyphen/Hyphenation.java 2006-06-08 17:21:04 UTC (rev 7445) +++ trunk/foray/foray-text/src/java/org/foray/text/hyphen/Hyphenation.java 2006-06-08 17:35:48 UTC (rev 7446) @@ -1,80 +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 - * - */ - -/* $Id$ */ - -/* - * Known contributors: - * Carlos Villegas <ca...@un...> (original author) - */ - -package org.foray.text.hyphen; - -/** - * This class represents a hyphenated word. - */ -public class Hyphenation implements org.axsl.hyphenR.Hyphenation { - int[] hyphenPoints; - String word; - - /** - * rawWord as made of alternating strings and {@link Hyphen Hyphen} - * instances - */ - Hyphenation(String word, int[] points) { - this.word = word; - hyphenPoints = points; - } - - /** - * @return the pre-break text, not including the hyphen character - */ - public String getPreHyphenText(int index) { - return word.substring(0, hyphenPoints[index]); - } - - /** - * @return the post-break text - */ - public String getPostHyphenText(int index) { - return word.substring(hyphenPoints[index]); - } - - /** - * @return the hyphenation points - */ - public int[] getHyphenationPoints() { - return hyphenPoints; - } - - public String toString() { - StringBuffer str = new StringBuffer(); - int start = 0; - for (int i = 0; i < hyphenPoints.length; i++) { - str.append(word.substring(start, hyphenPoints[i]) + "-"); - start = hyphenPoints[i]; - } - str.append(word.substring(start)); - return str.toString(); - } - -} Deleted: trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationServer.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationServer.java 2006-06-08 17:21:04 UTC (rev 7445) +++ trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationServer.java 2006-06-08 17:35:48 UTC (rev 7446) @@ -1,334 +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 - * - */ - -/* $Id$ */ - -/* - * Known contributors: - * @author Carlos Villegas <ca...@un...> (original author) - */ - -package org.foray.text.hyphen; - -import org.foray.common.StringUtilPre5; -import org.foray.text.TextServer; - -import org.axsl.text.TextException; - -import org.apache.commons.logging.Log; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.lang.reflect.Method; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; - -/** - * This class is the main entry point to the hyphenation package. - */ -public class HyphenationServer implements org.axsl.hyphenR.HyphenationServer { - - /** - * The "parent" TextServer instance. - */ - private TextServer textServer; - - /** - * Collection of HyphenationTree instances that have been successfully - * deserialized or parsed. The key is the language or language and country - * connected by an underscore (e.g. en_US). - */ - HashMap hyphenTrees = new HashMap(); - - /** - * Collection of language and language_country combinations for which we - * already know we can't instantiate a HyphenationTree. This is used to - * log only one error message per language. - */ - ArrayList hyphenTreesNotFound = new ArrayList(); - - private boolean errorDump = false; - private String hyphenationDir; - - /** - * Constructor. - * @param textServer The TextServer instance that is the "parent" of this - * HyphenationServer. - */ - public HyphenationServer(TextServer textServer, URL hyphenationDir) { - this.textServer = textServer; - // TODO: This is klunky. Use the URL. - this.hyphenationDir = hyphenationDir.getFile(); - } - - private HyphenationTree getHyphenationTree(String lang, String country) { - String key = lang; - // check whether the country code has been used - if (country != null && !country.equals("none")) { - key += "_" + country; - } - // first try to find it in the cache - if (hyphenTrees.containsKey(key)) { - return (HyphenationTree)hyphenTrees.get(key); - } - if (hyphenTrees.containsKey(lang)) { - return (HyphenationTree)hyphenTrees.get(lang); - } - - /* See if it is one that we already have tried and failed. */ - Iterator iter = hyphenTreesNotFound.iterator(); - while (iter.hasNext()) { - String testedKey = (String) iter.next(); - if (key.equals(testedKey)) { - return null; - } - if (key.equals(lang)) { - return null; - } - } - - HyphenationTree hTree = getHyphenationTree(key); - if (hTree == null) { - hTree = loadHyphenationTree(key, lang); - } - // put it into the pattern cache - if (hTree != null) { - hyphenTrees.put(key, hTree); - } else { - getLogger().error("Couldn't find hyphenation pattern " - + key); - hyphenTreesNotFound.add(key); - } - return hTree; - } - - private InputStream getResourceStream(String key) { - InputStream is = null; - // Try to use Context Class Loader to load the properties file. - try { - Method getCCL = - Thread.class.getMethod("getContextClassLoader", new Class[0]); - if (getCCL != null) { - ClassLoader contextClassLoader = - (ClassLoader)getCCL.invoke(Thread.currentThread(), - new Object[0]); - is = contextClassLoader.getResourceAsStream("hyph/" + key - + ".hyp"); - } - } catch (Exception e) {} - - if (is == null) { - is = HyphenationServer.class.getResourceAsStream("/hyph/" + key - + ".hyp"); - } - - return is; - } - - private HyphenationTree getHyphenationTree(String key) { - HyphenationTree hTree = null; - ObjectInputStream ois = null; - InputStream is = null; - try { - is = getResourceStream(key); - if (is == null) { - if (key.length() == 5) { - is = getResourceStream(key.substring(0, 2)); - if (is != null) { - getLogger().error("Couldn't find hyphenation pattern " - + key - + "\nusing general language pattern " - + key.substring(0, 2) - + " instead."); - } else { - if (errorDump) { - getLogger().error("Couldn't find precompiled " - + "hyphenation pattern " - + key + ".hyp"); - } - return null; - } - } else { - if (errorDump) { - getLogger().error("Couldn't find precompiled " - + "hyphenation pattern " - + key + ".hyp"); - } - return null; - } - } - ois = new ObjectInputStream(is); - hTree = (HyphenationTree)ois.readObject(); - } catch (Exception e) { - e.printStackTrace(); - } - finally { - if (ois != null) { - try { - ois.close(); - } catch (IOException e) { - getLogger().error("can't close hyphenation object stream"); - } - } - } - return hTree; - } - - /** - * load tree from serialized file or xml file - * using configuration settings - */ - private HyphenationTree loadHyphenationTree(String key, - String language) { - if (this.hyphenationDir == null) { - return null; - } - HyphenationTree hTree = null; - // I use here the following convention. The file name specified in - // the configuration is taken as the base name. First we try - // name + ".hyp" assuming a serialized HyphenationTree. If that fails - // we try name + ".xml", assumming a raw hyphenation pattern file. - - // first try serialized object - File hyphenFile = new File(this.hyphenationDir, key + ".hyp"); - if (hyphenFile.exists()) { - ObjectInputStream ois = null; - try { - ois = new ObjectInputStream(new FileInputStream(hyphenFile)); - hTree = (HyphenationTree)ois.readObject(); - } catch (Exception e) { - e.printStackTrace(); - } - finally { - if (ois != null) { - try { - ois.close(); - } catch (IOException e) {} - } - } - return hTree; - } - - // try the raw XML file - hyphenFile = new File(this.hyphenationDir, key + ".xml"); - if (! hyphenFile.exists()) { - hyphenFile = new File(this.hyphenationDir, language + ".xml"); - } - if (hyphenFile.exists()) { - hTree = new HyphenationTree(); - if (errorDump) { - getLogger().error("reading " + this.hyphenationDir + key - + ".xml"); - } - try { - hTree.loadPatterns(hyphenFile.getPath(), getLogger()); - if (errorDump) { - getLogger().debug("Stats: "); - hTree.printStats(getLogger()); - } - return hTree; - } catch (TextException ex) { - if (errorDump) { - getLogger().error("Can't load user patterns " - + "from xml file " + this.hyphenationDir - + key + ".xml"); - } - return null; - } - } - if (errorDump) { - getLogger().error("Tried to load " - + hyphenFile.toString() - + "\nCannot find compiled nor xml file for " - + "hyphenation pattern" + key); - } - return null; - } - - public org.axsl.hyphenR.Hyphenation hyphenate(String word, String language, - String country, int remainCount, int pushCount) { - HyphenationTree hTree = getHyphenationTree(language, country); - if (hTree == null) { - return null; - } - return hTree.hyphenate(word, remainCount, pushCount); - } - - public org.axsl.hyphenR.Hyphenation hyphenate(char[] word, int offset, - int len, String language, String country, int remainCount, - int pushCount) { - HyphenationTree hTree = getHyphenationTree(language, country); - if (hTree == null) { - return null; - } - return hTree.hyphenate(word, offset, len, remainCount, pushCount); - } - - public Log getLogger() { - return textServer.getLogger(); - } - - /** - * extracts a complete word from the character data - */ - public String getHyphenationWord(char[] characters, int wordStart) { - boolean wordendFound = false; - int counter = 0; - int[] newWord = new int[characters.length]; // create a buffer - while ((!wordendFound) - && ((wordStart + counter) < characters.length)) { - int tk = characters[wordStart + counter]; - if (StringUtilPre5.isLetter(tk)) { - newWord[counter] = tk; - counter++; - } else { - wordendFound = true; - } - } - return StringUtilPre5.newString(newWord, 0, counter); - } - - /** - * Returns the count of non-word characters at the beginning of the text - * being evaluated. This includes characters like " and ' which are not - * really part of the word, but which must be passed through to the output. - * @param characters The char array being evaluated. - * @param startIndex Index into the first character in characters that - * should be evaluated. - * @return The number of characters at the start that should be ignored for - * purposes of forming a word to be evaluated for hyphenation. - */ - public int nonWordChars(char[] characters, int startIndex) { - int count = 0; - // Look for ' or " at the beginning of the word. - if (characters[startIndex] == '"' || characters[startIndex] == '\'') { - count ++; - } - return count; - } - -} Deleted: trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationTree.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationTree.java 2006-06-08 17:21:04 UTC (rev 7445) +++ trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationTree.java 2006-06-08 17:35:48 UTC (rev 7446) @@ -1,533 +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 - * - */ - -/* $Id$ */ - -package org.foray.text.hyphen; - -import org.foray.common.Logging; - -import org.axsl.text.TextException; - -import org.apache.commons.logging.Log; - -import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; - -/** - * This tree structure stores the hyphenation patterns in an efficient - * way for fast lookup. It provides the provides the method to - * hyphenate a word. - * - * @author Carlos Villegas <ca...@un...> - */ -public class HyphenationTree extends TernaryTree implements PatternConsumer, - Serializable { - static final long serialVersionUID = 734862840356804663L; - - /** - * value space: stores the inteletter values - */ - protected ByteVector vspace; - - /** - * This map stores hyphenation exceptions - */ - protected HashMap stoplist; - - /** - * This map stores the character classes - */ - protected TernaryTree classmap; - - /** - * Temporary map to store interletter values on pattern loading. - */ - private transient TernaryTree ivalues; - - public HyphenationTree() { - stoplist = new HashMap(23); // usually a small table - classmap = new TernaryTree(); - vspace = new ByteVector(); - vspace.alloc(1); // this reserves index 0, which we don't use - } - - /** - * Packs the values by storing them in 4 bits, two values into a byte - * Values range is from 0 to 9. We use zero as terminator, - * so we'll add 1 to the value. - * @param values a string of digits from '0' to '9' representing the - * interletter values. - * @return the index into the vspace array where the packed values - * are stored. - */ - protected int packValues(String values) { - int i, n = values.length(); - int m = (n & 1) == 1 ? (n >> 1) + 2 : (n >> 1) + 1; - int offset = vspace.alloc(m); - byte[] va = vspace.getArray(); - for (i = 0; i < n; i++) { - int j = i >> 1; - byte v = (byte)((values.charAt(i) - '0' + 1) & 0x0f); - if ((i & 1) == 1) { - va[j + offset] = (byte)(va[j + offset] | v); - } else { - va[j + offset] = (byte)(v << 4); // big endian - } - } - va[m - 1 + offset] = 0; // terminator - return offset; - } - - protected String unpackValues(int k) { - StringBuffer buf = new StringBuffer(); - byte v = vspace.get(k++); - while (v != 0) { - char c = (char)((v >>> 4) - 1 + '0'); - buf.append(c); - c = (char)(v & 0x0f); - if (c == 0) { - break; - } - c = (char)(c - 1 + '0'); - buf.append(c); - v = vspace.get(k++); - } - return buf.toString(); - } - - /** - * Read hyphenation patterns from an XML file. - */ - public void loadPatterns(String filename, Log logger) - throws TextException { - PatternParser pp = new PatternParser(this, logger); - ivalues = new TernaryTree(); - - pp.parse(filename); - - // patterns/values should be now in the tree - // let's optimize a bit - trimToSize(); - vspace.trimToSize(); - classmap.trimToSize(); - - // get rid of the auxiliary map - ivalues = null; - } - - public String findPattern(String pat) { - int k = super.find(pat); - if (k >= 0) { - return unpackValues(k); - } - return ""; - } - - /** - * String compare, returns 0 if equal or - * t is a substring of s - */ - protected int hstrcmp(char[] s, int si, char[] t, int ti) { - for (; s[si] == t[ti]; si++, ti++) { - if (s[si] == 0) { - return 0; - } - } - if (t[ti] == 0) { - return 0; - } - return s[si] - t[ti]; - } - - protected byte[] getValues(int k) { - StringBuffer buf = new StringBuffer(); - byte v = vspace.get(k++); - while (v != 0) { - char c = (char)((v >>> 4) - 1); - buf.append(c); - c = (char)(v & 0x0f); - if (c == 0) { - break; - } - c = (char)(c - 1); - buf.append(c); - v = vspace.get(k++); - } - byte[] res = new byte[buf.length()]; - for (int i = 0; i < res.length; i++) { - res[i] = (byte)buf.charAt(i); - } - return res; - } - - /** - * <p>Search for all possible partial matches of word starting - * at index an update interletter values. In other words, it - * does something like:</p> - * <code> - * for(i=0; i<patterns.length; i++) { - * if ( word.substring(index).startsWidth(patterns[i]) ) - * update_interletter_values(patterns[i]); - * } - * </code> - * <p>But it is done in an efficient way since the patterns are - * stored in a ternary tree. In fact, this is the whole purpose - * of having the tree: doing this search without having to test - * every single pattern. The number of patterns for languages - * such as English range from 4000 to 10000. Thus, doing thousands - * of string comparisons for each word to hyphenate would be - * really slow without the tree. The tradeoff is memory, but - * using a ternary tree instead of a trie, almost halves the - * the memory used by Lout or TeX. It's also faster than using - * a hash table</p> - * @param word null terminated word to match - * @param index start index from word - * @param il interletter values array to update - */ - protected void searchPatterns(char[] word, int index, byte[] il) { - byte[] values; - int i = index; - char p, q; - char sp = word[i]; - p = root; - - while (p > 0 && p < sc.length) { - if (sc[p] == 0xFFFF) { - if (hstrcmp(word, i, kv.getArray(), lo[p]) == 0) { - values = getValues(eq[p]); // data pointer is in eq[] - int j = index; - for (int k = 0; k < values.length; k++) { - if (j < il.length && values[k] > il[j]) { - il[j] = values[k]; - } - j++; - } - } - return; - } - int d = sp - sc[p]; - if (d == 0) { - if (sp == 0) { - break; - } - sp = word[++i]; - p = eq[p]; - q = p; - - // look for a pattern ending at this position by searching for - // the null char ( splitchar == 0 ) - while (q > 0 && q < sc.length) { - if (sc[q] == 0xFFFF) { // stop at compressed branch - break; - } - if (sc[q] == 0) { - values = getValues(eq[q]); - int j = index; - for (int k = 0; k < values.length; k++) { - if (j < il.length && values[k] > il[j]) { - il[j] = values[k]; - } - j++; - } - break; - } - q = lo[q]; - /** - * actually the code should be: - * q = sc[q] < 0 ? hi[q] : lo[q]; - * but java chars are unsigned - */ - } - } else { - p = d < 0 ? lo[p] : hi[p]; - } - } - } - - /** - * Hyphenate word and return a Hyphenation object. - * @param word the word to be hyphenated - * @param remainCharCount Minimum number of characters allowed - * before the hyphenation point. - * @param pushCharCount Minimum number of characters allowed after - * the hyphenation point. - * @return a {@link Hyphenation Hyphenation} object representing - * the hyphenated word or null if word is not hyphenated. - */ - public org.axsl.hyphenR.Hyphenation hyphenate(String word, - int remainCharCount, int pushCharCount) { - char[] w = word.toCharArray(); - return hyphenate(w, 0, w.length, remainCharCount, pushCharCount); - } - - /** - * Hyphenate word and return an array of hyphenation points. - * @param w char array that contains the word - * @param offset Offset to first character in word - * @param len Length of word - * @param remainCharCount Minimum number of characters allowed - * before the hyphenation point. - * @param pushCharCount Minimum number of characters allowed after - * the hyphenation point. - * @return a {@link Hyphenation Hyphenation} object representing - * the hyphenated word or null if word is not hyphenated. - */ - public org.axsl.hyphenR.Hyphenation hyphenate(char[] w, int offset, int len, - int remainCharCount, int pushCharCount) { - char[] word = new char[len + 3]; - - // normalize word - char[] c = new char[2]; - for (int i = 1; i <= len; i++) { - c[0] = w[offset + i - 1]; - int nc = classmap.find(c, 0); - if (nc < 0) { // found a non-letter character, abort - return null; - } - word[i] = (char)nc; - } - int[] result = new int[len + 1]; - int k = 0; - - // check exception list first - String sw = new String(word, 1, len); - if (stoplist.containsKey(sw)) { - /* assume only simple hyphens (Hyphen.pre="-", - * Hyphen.post = Hyphen.no = null) */ - ArrayList hw = (ArrayList)stoplist.get(sw); - int j = 0; - for (int i = 0; i < hw.size(); i++) { - Object o = hw.get(i); - if (o instanceof String) { - j += ((String)o).length(); - if (j >= remainCharCount && j < (len - pushCharCount)) { - result[k++] = j; - } - } - } - } else { - // use algorithm to get hyphenation points - word[0] = '.'; // word start marker - word[len + 1] = '.'; // word end marker - word[len + 2] = 0; // null terminated - byte[] il = new byte[len + 3]; // initialized to zero - for (int i = 0; i < len + 1; i++) { - searchPatterns(word, i, il); - } - - // hyphenation points are located where interletter value is odd - for (int i = 0; i < len; i++) { - if (((il[i + 1] & 1) == 1) && i >= remainCharCount - && i <= (len - pushCharCount)) { - result[k++] = i; - } - } - } - - - if (k > 0) { - // trim result array - int[] res = new int[k]; - System.arraycopy(result, 0, res, 0, k); - return new Hyphenation(new String(w, offset, len), res); - } - return null; - } - - /** - * Add a character class to the tree. It is used by - * {@link PatternParser PatternParser} as callback to - * add character classes. Character classes define the - * valid word characters for hyphenation. If a word contains - * a character not defined in any of the classes, it is not hyphenated. - * It also defines a way to normalize the characters in order - * to compare them with the stored patterns. Usually pattern - * files use only lower case characters, in this case a class - * for letter 'a', for example, should be defined as "aA", the first - * character being the normalization char. - */ - public void addClass(String chargroup) { - if (chargroup.length() > 0) { - char equivChar = chargroup.charAt(0); - char[] key = new char[2]; - key[1] = 0; - for (int i = 0; i < chargroup.length(); i++) { - key[0] = chargroup.charAt(i); - classmap.insert(key, 0, equivChar); - } - } - } - - /** - * Add an exception to the tree. It is used by - * {@link PatternParser PatternParser} class as callback to - * store the hyphenation exceptions. - * @param word normalized word - * @param hyphenatedword a ArrayList of alternating strings and - * {@link Hyphen hyphen} objects. - */ - public void addException(String word, ArrayList hyphenatedword) { - stoplist.put(word, hyphenatedword); - } - - /** - * Add a pattern to the tree. Mainly, to be used by - * {@link PatternParser PatternParser} class as callback to - * add a pattern to the tree. - * @param pattern the hyphenation pattern - * @param ivalue interletter weight values indicating the - * desirability and priority of hyphenating at a given point - * within the pattern. It should contain only digit characters. - * (i.e. '0' to '9'). - */ - public void addPattern(String pattern, String ivalue) { - int k = ivalues.find(ivalue); - if (k <= 0) { - k = packValues(ivalue); - ivalues.insert(ivalue, (char)k); - } - insert(pattern, (char)k); - } - - public void printStats(Log logger) { - logger.info("Value space size = " + Integer.toString(vspace.length())); - super.printStats(logger); - } - - public static void main(String[] argv) throws Exception { - Log logger = Logging.makeDefaultLogger(); - HyphenationTree ht = null; - int minCharCount = 2; - BufferedReader in = - new BufferedReader(new InputStreamReader(System.in)); - for (; ; ) { - logger.info("l:\tload patterns from XML\n" - + "L:\tload patterns from serialized object\n" - + "s:\tset minimun character count\n" - + "w:\twrite hyphenation tree to object file\n" - + "h:\thyphenate\n" - + "f:\tfind pattern\n" - + "b:\tbenchmark\n" - + "q:\tquit\n" - + "\nCommand:"); - String token = in.readLine().trim(); - if (token.equals("f")) { - logger.info("Pattern: "); - token = in.readLine().trim(); - logger.info("Values: " + ht.findPattern(token)); - } else if (token.equals("s")) { - logger.info("Minimun value: "); - token = in.readLine().trim(); - minCharCount = Integer.parseInt(token); - } else if (token.equals("l")) { - ht = new HyphenationTree(); - logger.info("XML file name: "); - token = in.readLine().trim(); - ht.loadPatterns(token, logger); - } else if (token.equals("L")) { - ObjectInputStream ois = null; - logger.info("Object file name: "); - token = in.readLine().trim(); - try { - ois = new ObjectInputStream(new FileInputStream(token)); - ht = (HyphenationTree)ois.readObject(); - } catch (Exception e) { - e.printStackTrace(); - } - finally { - if (ois != null) { - try { - ois.close(); - } catch (IOException e) {} - } - } - } else if (token.equals("w")) { - logger.info("Object file name: "); - token = in.readLine().trim(); - ObjectOutputStream oos = null; - try { - oos = new ObjectOutputStream(new FileOutputStream(token)); - oos.writeObject(ht); - } catch (Exception e) { - e.printStackTrace(); - } - finally { - if (oos != null) { - try { - oos.flush(); - } catch (IOException e) {} - try { - oos.close(); - } catch (IOException e) {} - } - } - } else if (token.equals("h")) { - logger.info("Word: "); - token = in.readLine().trim(); - logger.info("Hyphenation points: "); - logger.info(ht.hyphenate(token, minCharCount, - minCharCount).toString()); - } else if (token.equals("b")) { - if (ht == null) { - logger.info("No patterns has been loaded."); - break; - } - logger.info("Word list filename: "); - token = in.readLine().trim(); - long starttime = 0; - int counter = 0; - ; - try { - BufferedReader reader = - new BufferedReader(new FileReader(token)); - - starttime = System.currentTimeMillis(); - while ((reader.readLine()) != null) { - counter++; - } - } catch (Exception ioe) { - logger.info("Exception " + ioe); - ioe.printStackTrace(); - } - long endtime = System.currentTimeMillis(); - long result = endtime - starttime; - logger.info(counter + " words hypehanted in " + result - + " milliseconds."); - - } else if (token.equals("q")) { - break; - } - } - - } - -} Deleted: trunk/foray/foray-text/src/java/org/foray/text/hyphen/PatternConsumer.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/hyphen/PatternConsumer.java 2006-06-08 17:21:04 UTC (rev 7445) +++ trunk/foray/foray-text/src/java/org/foray/text/hyphen/PatternConsumer.java 2006-06-08 17:35:48 UTC (rev 7446) @@ -1,62 +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 - * - */ - -/* $Id$ */ - -package org.foray.text.hyphen; - -import java.util.ArrayList; - -/** - * This interface is used to connect the XML pattern file parser to - * the hyphenation tree. - * - * @author Carlos Villegas <ca...@un...> - */ -public interface PatternConsumer { - - /** - * Add a character class. - * A character class defines characters that are considered - * equivalent for the purpose of hyphenation (e.g. "aA"). It - * usually means to ignore case. - */ - void addClass(String chargroup); - - /** - * Add a hyphenation exception. An exception replaces the - * result obtained by the algorithm for cases for which this - * fails or the user wants to provide his own hyphenation. - * A hyphenatedword is a ArrayList of alternating String's and - * {@link Hyphen Hyphen} instances - */ - void addException(String word, ArrayList hyphenatedword); - - /** - * Add hyphenation patterns. - * @param pattern - * @param values interletter values expressed as a string of - * digit characters. - */ - void addPattern(String pattern, String values); - -} Deleted: trunk/foray/foray-text/src/java/org/foray/text/hyphen/PatternParser.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/hyphen/PatternParser.java 2006-06-08 17:21:04 UTC (rev 7445) +++ trunk/foray/foray-text/src/java/org/foray/text/hyphen/PatternParser.java 2006-06-08 17:35:48 UTC (rev 7446) @@ -1,439 +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 - * - */ - -/* $Id$ */ - -package org.foray.text.hyphen; - -import org.foray.common.Logging; - -import org.axsl.text.TextException; - -import org.apache.commons.logging.Log; - -import org.xml.sax.Attributes; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.DefaultHandler; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; - -/** - * A SAX document handler to read and parse hyphenation patterns - * from a XML file. - * - * @author Carlos Villegas <ca...@un...> - */ -public class PatternParser extends DefaultHandler implements PatternConsumer { - - XMLReader parser; - int currElement; - PatternConsumer consumer; - StringBuffer token; - ArrayList exception; - char hyphenChar; - String errMsg; - Log logger; - - static final int ELEM_CLASSES = 1; - static final int ELEM_EXCEPTIONS = 2; - static final int ELEM_PATTERNS = 3; - static final int ELEM_HYPHEN = 4; - - public PatternParser(Log logger) throws TextException { - this.logger = logger; - token = new StringBuffer(); - parser = createParser(); - parser.setContentHandler(this); - parser.setErrorHandler(this); - hyphenChar = '-'; // default - } - - public PatternParser(PatternConsumer consumer, Log logger) - throws TextException { - this(logger); - this.consumer = consumer; - } - - public void setConsumer(PatternConsumer consumer) { - this.consumer = consumer; - } - - public void parse(String filename) throws TextException { - InputSource uri = fileInputSource(filename); - - try { - parser.parse(uri); - } catch (SAXException e) { - throw new TextException(errMsg); - } catch (IOException e) { - throw new TextException(e.getMessage()); - } catch (NullPointerException e) { - throw new TextException("SAX parser not available"); - } - } - - /** - * creates a SAX parser, using the value of org.xml.sax.parser - * defaulting to org.apache.xerces.parsers.SAXParser - * - * @return the created SAX parser - */ - static XMLReader createParser() throws TextException { - String parserClassName = System.getProperty("org.xml.sax.parser"); - if (parserClassName == null) { - parserClassName = "org.apache.xerces.parsers.SAXParser"; - } - try { - return (XMLReader)Class.forName(parserClassName).newInstance(); - } catch (ClassNotFoundException e) { - throw new TextException("Could not find " - + parserClassName); - } catch (InstantiationException e) { - throw new TextException("Could not instantiate " - + parserClassName); - } catch (IllegalAccessException e) { - throw new TextException("Could not access " - + parserClassName); - } catch (ClassCastException e) { - throw new TextException(parserClassName - + " is not a SAX driver"); - } - } - - /** - * create an InputSource from a file name - * - * @param filename the name of the file - * @return the InputSource created - */ - protected static InputSource fileInputSource(String filename) - throws TextException { - - /* this code adapted from James Clark's in XT */ - File file = new File(filename); - String path = file.getAbsolutePath(); - String fSep = System.getProperty("file.separator"); - if (fSep != null && fSep.length() == 1) { - path = path.replace(fSep.charAt(0), '/'); - } - if (path.length() > 0 && path.charAt(0) != '/') { - path = '/' + path; - } - try { - return new InputSource(new URL("file", null, path).toString()); - } catch (MalformedURLException e) { - throw new TextException("unexpected MalformedURLException"); - } - } - - protected String readToken(StringBuffer chars) { - String word; - boolean space = false; - int i; - for (i = 0; i < chars.length(); i++) { - if (Character.isWhitespace(chars.charAt(i))) { - space = true; - } else { - break; - } - } - if (space) { - for (int countr = i; countr < chars.length(); countr++) { - chars.setCharAt(countr - i, chars.charAt(countr)); - } - chars.setLength(chars.length() - i); - if (token.length() > 0) { - word = token.toString(); - token.setLength(0); - return word; - } - } - space = false; - for (i = 0; i < chars.length(); i++) { - if (Character.isWhitespace(chars.charAt(i))) { - space = true; - break; - } - } - token.append(chars.toString().substring(0, i)); - for (int countr = i; countr < chars.length(); countr++) { - chars.setCharAt(countr - i, chars.charAt(countr)); - } - chars.setLength(chars.length() - i); - if (space) { - word = token.toString(); - token.setLength(0); - return word; - } - token.append(chars); - return null; - } - - protected static String getPattern(String word) { - StringBuffer pat = new StringBuffer(); - int len = word.length(); - for (int i = 0; i < len; i++) { - if (!Character.isDigit(word.charAt(i))) { - pat.append(word.charAt(i)); - } - } - return pat.toString(); - } - - protected ArrayList normalizeException(ArrayList ex) { - ArrayList res = new ArrayList(); - for (int i = 0; i < ex.size(); i++) { - Object item = ex.get(i); - if (item instanceof String) { - String str = (String)item; - StringBuffer buf = new StringBuffer(); - for (int j = 0; j < str.length(); j++) { - char c = str.charAt(j); - if (c != hyphenChar) { - buf.append(c); - } else { - res.add(buf.toString()); - buf.setLength(0); - char[] h = new char[1]; - h[0] = hyphenChar; - // we use here hyphenChar which is not necessarily - // the one to be printed - res.add(new Hyphen(new String(h), null, null)); - } - } - if (buf.length() > 0) { - res.add(buf.toString()); - } - } else { - res.add(item); - } - } - return res; - } - - protected String getExceptionWord(ArrayList ex) { - StringBuffer res = new StringBuffer(); - for (int i = 0; i < ex.size(); i++) { - Object item = ex.get(i); - if (item instanceof String) { - res.append((String)item); - } else { - if (((Hyphen)item).noBreak != null) { - res.append(((Hyphen)item).noBreak); - } - } - } - return res.toString(); - } - - protected static String getInterletterValues(String pat) { - StringBuffer il = new StringBuffer(); - String word = pat + "a"; // add dummy letter to serve as sentinel - int len = word.length(); - for (int i = 0; i < len; i++) { - char c = word.charAt(i); - if (Character.isDigit(c)) { - il.append(c); - i++; - } else { - il.append('0'); - } - } - return il.toString(); - } - - // - // DocumentHandler methods - // - - /** - * Start element. - */ - public void startElement(String uri, String local, String raw, - Attributes attrs) { - if (local.equals("hyphen-char")) { - String h = attrs.getValue("value"); - if (h != null && h.length() == 1) { - hyphenChar = h.charAt(0); - } - } else if (local.equals("classes")) { - currElement = ELEM_CLASSES; - } else if (local.equals("patterns")) { - currElement = ELEM_PATTERNS; - } else if (local.equals("exceptions")) { - currElement = ELEM_EXCEPTIONS; - exception = new ArrayList(); - } else if (local.equals("hyphen")) { - if (token.length() > 0) { - exception.add(token.toString()); - } - exception.add(new Hyphen(attrs.getValue("pre"), - attrs.getValue("no"), attrs.getValue("post"))); - currElement = ELEM_HYPHEN; - } - token.setLength(0); - } - - public void endElement(String uri, String local, String raw) { - - if (token.length() > 0) { - String word = token.toString(); - switch (currElement) { - case ELEM_CLASSES: - consumer.addClass(word); - break; - case ELEM_EXCEPTIONS: - exception.add(word); - exception = normalizeException(exception); - consumer.addException(getExceptionWord(exception), - (ArrayList) exception.clone()); - break; - case ELEM_PATTERNS: - ... [truncated message content] |
|
From: <vic...@us...> - 2006-06-08 17:21:23
|
Revision: 7445 Author: victormote Date: 2006-06-08 10:21:04 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7445&view=rev Log Message: ----------- Initial creation of separate hyphenation package. Added Paths: ----------- trunk/foray/foray-hyphen-r/ trunk/foray/foray-hyphen-r/.checkstyle trunk/foray/foray-hyphen-r/.classpath trunk/foray/foray-hyphen-r/.project trunk/foray/foray-hyphen-r/scripts/ trunk/foray/foray-hyphen-r/scripts/build.bat trunk/foray/foray-hyphen-r/scripts/build.sh trunk/foray/foray-hyphen-r/scripts/build.xml trunk/foray/foray-hyphen-r/src/ trunk/foray/foray-hyphen-r/src/java/ trunk/foray/foray-hyphen-r/src/java/org/ trunk/foray/foray-hyphen-r/src/java/org/foray/ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/ Property changes on: trunk/foray/foray-hyphen-r ___________________________________________________________________ Name: svn:ignore + build zzlocal Added: trunk/foray/foray-hyphen-r/.checkstyle =================================================================== --- trunk/foray/foray-hyphen-r/.checkstyle (rev 0) +++ trunk/foray/foray-hyphen-r/.checkstyle 2006-06-08 17:21:04 UTC (rev 7445) @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<fileset-config file-format-version="1.2.0" simple-config="true"> + <fileset name="all" enabled="true" check-config-name="FOray Checkstyle" local="false"> + <file-match-pattern match-pattern="." include-pattern="true"/> + </fileset> +</fileset-config> Added: trunk/foray/foray-hyphen-r/.classpath =================================================================== --- trunk/foray/foray-hyphen-r/.classpath (rev 0) +++ trunk/foray/foray-hyphen-r/.classpath 2006-06-08 17:21:04 UTC (rev 7445) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry excluding=".#*" kind="src" path="src/java"/> + <classpathentry kind="src" path="scripts"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="output" path="build/eclipse"/> +</classpath> Added: trunk/foray/foray-hyphen-r/.project =================================================================== --- trunk/foray/foray-hyphen-r/.project (rev 0) +++ trunk/foray/foray-hyphen-r/.project 2006-06-08 17:21:04 UTC (rev 7445) @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>FOrayHyphenR</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature> + </natures> +</projectDescription> Added: trunk/foray/foray-hyphen-r/scripts/build.bat =================================================================== --- trunk/foray/foray-hyphen-r/scripts/build.bat (rev 0) +++ trunk/foray/foray-hyphen-r/scripts/build.bat 2006-06-08 17:21:04 UTC (rev 7445) @@ -0,0 +1,27 @@ +@echo off + +echo "FOray Build System" +echo "------------------" + +IF "%JAVA_HOME%" == "" GOTO JAVA_HOME_ERR +IF "%ANT_HOME%" == "" GOTO ANT_HOME_ERR + +call %ANT_HOME%\bin\ant.bat %* + +GOTO END + +:JAVA_HOME_ERR + echo ERROR: JAVA_HOME not found in your environment. + echo + echo Please set the JAVA_HOME variable in your environment to match the + echo location of the Java Virtual Machine you want to use. +GOTO END + +:ANT_HOME_ERR + echo ERROR: ANT_HOME not found in your environment. + echo + echo Please set the ANT_HOME variable in your environment to match the + echo location of the root of your ANT installation. +GOTO END + +:END Added: trunk/foray/foray-hyphen-r/scripts/build.sh =================================================================== --- trunk/foray/foray-hyphen-r/scripts/build.sh (rev 0) +++ trunk/foray/foray-hyphen-r/scripts/build.sh 2006-06-08 17:21:04 UTC (rev 7445) @@ -0,0 +1,29 @@ +#!/bin/sh + +# This file must be executable. + +echo +echo "FOray Build System" +echo "------------------" + +if [ "$JAVA_HOME" = "" ] +then + echo "ERROR: JAVA_HOME not found in your environment." + echo + echo "Please set the JAVA_HOME variable in your environment to match the" + echo "location of the Java Virtual Machine you want to use." + exit 1 +fi + +if [ "$ANT_HOME" = "" ] +then + echo "ERROR: ANT_HOME not found in your environment." + echo + echo "Please set the ANT_HOME variable in your environment to match the" + echo "location of the root of your ANT installation." + exit 1 +fi + +"$ANT_HOME"/bin/ant "$@" + +##### Last Line of $RCSfile$ ##### Property changes on: trunk/foray/foray-hyphen-r/scripts/build.sh ___________________________________________________________________ Name: svn:executable + * Name: svn:keywords + "Author Id Rev Date URL" Name: svn:eol-style + native Added: trunk/foray/foray-hyphen-r/scripts/build.xml =================================================================== --- trunk/foray/foray-hyphen-r/scripts/build.xml (rev 0) +++ trunk/foray/foray-hyphen-r/scripts/build.xml 2006-06-08 17:21:04 UTC (rev 7445) @@ -0,0 +1,204 @@ +<?xml version="1.0"?> +<!-- $Id$ --> + +<project default="package" basedir="."> + + <!-- Set up a prefix to designate environment variables. --> + <property environment="env"/> + + <target name="env"> + <!-- If the environment variable FORAY_CONFIG is set, use it. --> + <condition property="foray.config" value="${env.FORAY_CONFIG}"> + <and> + <isset property="env.FORAY_CONFIG"/> + <available file="${env.FORAY_CONFIG}"/> + </and> + </condition> + <!-- Otherwise, set it to the FOray scripts directory. --> + <property name="foray.config" location="../../scripts"/> + <echo>foray.config: ${foray.config}</echo> + + <!-- Retrieve externally-configured properties. --> + <property file="${foray.config}/foray-build.properties"/> + + <!-- Get a default for {foray.home}. --> + <property name="foray.home" location="../.."/> + <echo>foray.home: ${foray.home}</echo> + + <!-- Set up dependent properties. --> + <property name="lib.dir" location="${foray.home}/lib"/> + <property name="axsl.build" location="${lib.dir}"/> + + <path id="libs-build-classpath"> + <fileset dir="${axsl.build}"> + <include name="**/axsl*.jar"/> + </fileset> + <fileset dir="${lib.dir}"> + <include name="avalon-framework*.jar"/> + <include name="xml-apis*.jar"/> + <include name="xerces*.jar"/> + <include name="axsl*.jar"/> + <include name="commons-logging.jar"/> + </fileset> + <fileset dir="${foray.home}/foray-common/build/ant"> + <include name="*.jar"/> + </fileset> + </path> + </target> + + <!-- =================================================================== --> + <!-- Initialization target --> + <!-- =================================================================== --> + <target name="init" depends="env"> + <tstamp/> + <property name="name" value="foray"/> + <property name="contact.info" + value="The FOray project http://www.foray.org"/> + <property name="module" value="hyphen-r"/> + <property name="module.dir" value="${foray.home}/foray-${module}"/> + <property name="version" value="0.1"/> + <property name="src.dir" value="${module.dir}/src"/> + <property name="build.dir" value="${module.dir}/build/ant"/> + <property name="classes.dir" value="${build.dir}/classes"/> + <property name="resource.dir" value="${module.dir}/resource"/> + <property name="debug" value="on"/> + <property name="optimize" value="off"/> + <property name="deprecation" value="off"/> + <property name="source" value="1.4"/> + <property name="hyph.source" value="${resource.dir}/hyph-patterns"/> + <property name="hyph.build" value="${build.dir}/hyph"/> + </target> + + <!-- =================================================================== --> + <!-- Prepares the build directory --> + <!-- =================================================================== --> + <target name="prepare" depends="init"> + <!-- create directories --> + <echo message="Preparing the build directories"/> + <mkdir dir="${build.dir}"/> + <mkdir dir="${classes.dir}"/> + <mkdir dir="${hyph.build}"/> + </target> + + + <!-- =================================================================== --> + <!-- compiles hyphenation patterns --> + <!-- =================================================================== --> + <target name="hyphenation" depends="compile" > + <path id="hyph-classpath"> + <path refid="libs-build-classpath"/> + <pathelement location="${classes.dir}"/> + </path> + <taskdef name="serHyph" + classname="org.foray.hyphenR.SerializeHyphPattern" + classpathref="hyph-classpath"/> + <serHyph includes="*.xml" + sourceDir="${hyph.source}" + targetDir="${hyph.build}" /> + </target> + + + <!-- =================================================================== --> + <!-- Compiles the source directory --> + <!-- =================================================================== --> + <target name="compile" depends="prepare"> + <echo message="Compiling the sources "/> + <!-- create directories --> + <mkdir dir="${build.dir}"/> + <javac srcdir="${src.dir}" + destdir="${classes.dir}" + debug="${debug}" + deprecation="${deprecation}" + optimize="${optimize}" + source="${source}" + > + <classpath refid="libs-build-classpath"/> + </javac> + </target> + + <!-- =================================================================== --> + <!-- Creates the class package --> + <!-- =================================================================== --> + <target name="package" depends="compile, style, hyphenation" + description="Generates the jar files (default target)"> + <echo message="Creating the jar file ${build.dir}/${name}.jar"/> + + <tstamp> + <format property="ts" pattern="yyyyMMdd-HHmmss-z"/> + </tstamp> + <fileset id="foray-hyphen-classes" + dir="${foray.home}/foray-hyphen-r/build/ant/classes"> + <include name="**"/> + </fileset> + <fileset id="foray-hyphen-resources" + dir="${foray.home}/foray-hyphen-r/build/ant"> + <include name="hyph/**"/> + </fileset> + <jar jarfile="${build.dir}/${name}-${module}.jar"> + <fileset refid="foray-hyphen-classes"/> + <fileset refid="foray-hyphen-resources"/> + <manifest> + <attribute name="Implementation-Title" value="${name}-${module}"/> + <attribute name="Implementation-Version" value="${version}"/> + <attribute name="Implementation-Vendor" + value="${contact.info}"/> + </manifest> + </jar> + + </target> + + <target name="javadoc-api" depends="init" description="Creates API + documentation"> + <echo message="Producing the javadoc files "/> + <mkdir dir="${build.dir}/javadoc-api"/> + <javadoc + packagenames="org.foray.hyphenR" + sourcepath="${src.dir}/java" + destdir="${build.dir}/javadoc-api" + classpathref="libs-build-classpath" + author="true" + version="true" + windowtitle="FOray Hyphenation API" + doctitle="FOray Hyphenation API" + bottom="Copyright © 2004 The FOray Project. All Rights Reserved." + overview="${src.dir}/java/org/foray/hyphenR/overview.html" + use="true" + access="public" + failonerror="true"> + <classpath refid="libs-build-classpath"/> + <classpath> + <fileset dir="${lib.dir}"> + <include name="ant*.jar"/> + </fileset> + </classpath> + </javadoc> + </target> + + <!-- =================================================================== --> + <!-- Clean targets --> + <!-- =================================================================== --> + <target name="clean" depends="init" description="Cleans the build directory"> + <delete dir="${build.dir}"/> + </target> + + <!-- =================================================================== --> + <!-- Checkstyle --> + <!-- =================================================================== --> + <target name="style" depends="init" description="Runs checkstyle" + if="checkstyle.home"> + <taskdef name="checkstyle" + classname="com.puppycrawl.tools.checkstyle.CheckStyleTask"> + <classpath> + <fileset dir="${checkstyle.home}"> + <include name="checkstyle-all-*.jar"/> + </fileset> + </classpath> + </taskdef> + <checkstyle config="../../scripts/checkstyle-config.xml"> + <fileset dir="${src.dir}" includes="**/*.java"/> + </checkstyle> + </target> + +</project> + +<!-- Last Line of $RCSfile$ --> Property changes on: trunk/foray/foray-hyphen-r/scripts/build.xml ___________________________________________________________________ Name: svn:keywords + "Author Id Rev Date URL" Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 16:35:15
|
Revision: 7444 Author: victormote Date: 2006-06-08 09:34:58 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7444&view=rev Log Message: ----------- 1. Make dependent on axsl-HyphenR package. 2. Make the hyphenation classes implement the axsl interfaces (Doh!!). Modified Paths: -------------- trunk/foray/foray-text/.classpath trunk/foray/foray-text/src/java/org/foray/text/hyphen/Hyphenation.java trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationServer.java trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationTree.java trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java Modified: trunk/foray/foray-text/.classpath =================================================================== --- trunk/foray/foray-text/.classpath 2006-06-08 16:31:23 UTC (rev 7443) +++ trunk/foray/foray-text/.classpath 2006-06-08 16:34:58 UTC (rev 7444) @@ -9,5 +9,6 @@ <classpathentry kind="src" path="/FOrayCommon"/> <classpathentry kind="var" path="ANT_HOME/lib/ant.jar"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/commons-logging.jar"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslHyphen-R"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> Modified: trunk/foray/foray-text/src/java/org/foray/text/hyphen/Hyphenation.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/hyphen/Hyphenation.java 2006-06-08 16:31:23 UTC (rev 7443) +++ trunk/foray/foray-text/src/java/org/foray/text/hyphen/Hyphenation.java 2006-06-08 16:34:58 UTC (rev 7444) @@ -32,7 +32,7 @@ /** * This class represents a hyphenated word. */ -public class Hyphenation { +public class Hyphenation implements org.axsl.hyphenR.Hyphenation { int[] hyphenPoints; String word; Modified: trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationServer.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationServer.java 2006-06-08 16:31:23 UTC (rev 7443) +++ trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationServer.java 2006-06-08 16:34:58 UTC (rev 7444) @@ -33,7 +33,6 @@ import org.foray.text.TextServer; import org.axsl.text.TextException; -import org.axsl.text.line.LineText; import org.apache.commons.logging.Log; @@ -51,7 +50,7 @@ /** * This class is the main entry point to the hyphenation package. */ -public class HyphenationServer { +public class HyphenationServer implements org.axsl.hyphenR.HyphenationServer { /** * The "parent" TextServer instance. @@ -270,29 +269,23 @@ return null; } - public Hyphenation hyphenate(String word, LineText lineText) { - String lang = lineText.inlineLanguage(); - String country = lineText.inlineCountry(); - int leftMin = lineText.inlineHyphenationRemainCount(); - int rightMin = lineText.inlineHyphenationPushCount(); - HyphenationTree hTree = getHyphenationTree(lang, country); + public org.axsl.hyphenR.Hyphenation hyphenate(String word, String language, + String country, int remainCount, int pushCount) { + HyphenationTree hTree = getHyphenationTree(language, country); if (hTree == null) { return null; } - return hTree.hyphenate(word, leftMin, rightMin); + return hTree.hyphenate(word, remainCount, pushCount); } - public Hyphenation hyphenate(char[] word, int offset, int len, - LineText lineText) { - String lang = lineText.inlineLanguage(); - String country = lineText.inlineCountry(); - int leftMin = lineText.inlineHyphenationRemainCount(); - int rightMin = lineText.inlineHyphenationPushCount(); - HyphenationTree hTree = getHyphenationTree(lang, country); + public org.axsl.hyphenR.Hyphenation hyphenate(char[] word, int offset, + int len, String language, String country, int remainCount, + int pushCount) { + HyphenationTree hTree = getHyphenationTree(language, country); if (hTree == null) { return null; } - return hTree.hyphenate(word, offset, len, leftMin, rightMin); + return hTree.hyphenate(word, offset, len, remainCount, pushCount); } public Log getLogger() { @@ -302,7 +295,7 @@ /** * extracts a complete word from the character data */ - public String getHyphenationWord(int[] characters, int wordStart) { + public String getHyphenationWord(char[] characters, int wordStart) { boolean wordendFound = false; int counter = 0; int[] newWord = new int[characters.length]; // create a buffer @@ -329,7 +322,7 @@ * @return The number of characters at the start that should be ignored for * purposes of forming a word to be evaluated for hyphenation. */ - public int nonWordChars(int[] characters, int startIndex) { + public int nonWordChars(char[] characters, int startIndex) { int count = 0; // Look for ' or " at the beginning of the word. if (characters[startIndex] == '"' || characters[startIndex] == '\'') { Modified: trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationTree.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationTree.java 2006-06-08 16:31:23 UTC (rev 7443) +++ trunk/foray/foray-text/src/java/org/foray/text/hyphen/HyphenationTree.java 2006-06-08 16:34:58 UTC (rev 7444) @@ -283,8 +283,8 @@ * @return a {@link Hyphenation Hyphenation} object representing * the hyphenated word or null if word is not hyphenated. */ - public Hyphenation hyphenate(String word, int remainCharCount, - int pushCharCount) { + public org.axsl.hyphenR.Hyphenation hyphenate(String word, + int remainCharCount, int pushCharCount) { char[] w = word.toCharArray(); return hyphenate(w, 0, w.length, remainCharCount, pushCharCount); } @@ -301,7 +301,7 @@ * @return a {@link Hyphenation Hyphenation} object representing * the hyphenated word or null if word is not hyphenated. */ - public Hyphenation hyphenate(char[] w, int offset, int len, + public org.axsl.hyphenR.Hyphenation hyphenate(char[] w, int offset, int len, int remainCharCount, int pushCharCount) { char[] word = new char[len + 3]; Modified: trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java =================================================================== --- trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java 2006-06-08 16:31:23 UTC (rev 7443) +++ trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java 2006-06-08 16:34:58 UTC (rev 7444) @@ -24,13 +24,12 @@ package org.foray.text.line.solitary; -import org.foray.common.StringUtil; import org.foray.common.StringUtilPre5; -import org.foray.text.hyphen.Hyphenation; import org.foray.text.hyphen.HyphenationServer; import org.foray.text.line.EagerLineBreaker; import org.axsl.fontR.FontConsumer; +import org.axsl.hyphenR.Hyphenation; import org.axsl.text.TextException; import org.axsl.text.line.LineBreakControl; import org.axsl.text.line.LineBreakHandler; @@ -91,7 +90,6 @@ private LineText currentLineText = null; private char[] currentChars = null; - private int[] currentCodePoints = null; private boolean canEatLeadingSpaces = true; @@ -108,7 +106,6 @@ throws TextException { this.currentLineText = lineText; this.currentChars = currentLineText.inlineText(); - this.currentCodePoints = StringUtil.toCodePoints(currentChars); String language = lineText.inlineLanguage(); finalWidth = 0; @@ -355,14 +352,16 @@ */ HyphenationServer server = this.getHyphenationServer(); // Count the number of chars at the beginning that should be ignored. - int nonWordChars = server.nonWordChars(this.currentCodePoints, - wordStart); + int nonWordChars = server.nonWordChars(this.currentChars, wordStart); // Extract the word that should be evaluated by the hyphenation system. String wordToHyphenate = server.getHyphenationWord( - this.currentCodePoints, this.wordStart + nonWordChars); + this.currentChars, this.wordStart + nonWordChars); // See if there are discretionary hyphenation points. Hyphenation hyph = server.hyphenate(wordToHyphenate, - this.currentLineText); + this.currentLineText.inlineLanguage(), + this.currentLineText.inlineCountry(), + this.currentLineText.inlineHyphenationRemainCount(), + this.currentLineText.inlineHyphenationPushCount()); // If none, the word cannot be hyphenated. if (hyph == null) { return this.wordStart; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 16:31:31
|
Revision: 7443 Author: victormote Date: 2006-06-08 09:31:23 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7443&view=rev Log Message: ----------- Fix index-out-of-bounds exception. Modified Paths: -------------- trunk/foray/foray-fotree/src/java/org/foray/fotree/FOText.java Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/FOText.java =================================================================== --- trunk/foray/foray-fotree/src/java/org/foray/fotree/FOText.java 2006-06-07 21:36:17 UTC (rev 7442) +++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FOText.java 2006-06-08 16:31:23 UTC (rev 7443) @@ -673,7 +673,8 @@ default: { // If first element, only check next. if (index == 0) { - if (charArray[index + 1] == 0x000a) { + if (index < charArray.length - 1 + && charArray[index + 1] == 0x000a) { return DISCARD_CHAR; } return c; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 02:11:37
|
Revision: 7442 Author: victormote Date: 2006-06-07 14:36:17 -0700 (Wed, 07 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7442&view=rev Log Message: ----------- 1. Add implementation of new MarkerContentArea interface. 2. Add abstract superclass for above that handles the "not an area" Area logic. 3. Add logic for getting the new class used in the AreaTree creation. Modified Paths: -------------- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/RetrieveMarkerPL.java Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/RetrieveMarkerPL.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/RetrieveMarkerPL.java 2006-06-07 21:36:05 UTC (rev 7441) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/RetrieveMarkerPL.java 2006-06-07 21:36:17 UTC (rev 7442) @@ -25,9 +25,9 @@ package org.foray.pioneer; import org.axsl.areaW.Area; +import org.axsl.areaW.AreaWException; +import org.axsl.areaW.MarkerContentArea; import org.axsl.areaW.PageArea; - -import org.axsl.areaW.AreaWException; import org.axsl.foR.FONode; import org.axsl.foR.fo.Marker; import org.axsl.foR.fo.RetrieveMarker; @@ -55,13 +55,15 @@ if (bestMarker == null) { return Status.OK; } + MarkerContentArea markerArea = area.makeMarkerContentArea(node, + bestMarker); MarkerPL markerPL = (MarkerPL) this.getLayoutProxy(bestMarker); // Necessary because the marker may get used multiple times. markerPL.resetProgress(); markerPL.setProgress(0); for (int i = 0; i < bestMarker.getChildren().size(); i++) { FONode fo = (FONode) bestMarker.getChildren().get(i); - getLayoutProxy(fo).layout(area); + getLayoutProxy(fo).layout(markerArea); } return Status.OK; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 02:11:34
|
Revision: 7441 Author: victormote Date: 2006-06-07 14:36:05 -0700 (Wed, 07 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7441&view=rev Log Message: ----------- 1. Add implementation of new MarkerContentArea interface. 2. Add abstract superclass for above that handles the "not an area" Area logic. 3. Add logic for getting the new class used in the AreaTree creation. Modified Paths: -------------- trunk/foray/foray-areatree/src/java/org/foray/area/Area.java Added Paths: ----------- trunk/foray/foray-areatree/src/java/org/foray/area/AbstractPlaceholder.java trunk/foray/foray-areatree/src/java/org/foray/area/MarkerContentArea.java Added: trunk/foray/foray-areatree/src/java/org/foray/area/AbstractPlaceholder.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/AbstractPlaceholder.java (rev 0) +++ trunk/foray/foray-areatree/src/java/org/foray/area/AbstractPlaceholder.java 2006-06-07 21:36:05 UTC (rev 7441) @@ -0,0 +1,117 @@ +/* + * 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 + * + */ + +/* $Id$ */ + +package org.foray.area; + +import org.axsl.areaW.AreaWException; +import org.axsl.foR.FObj; + +/** + * Marks a place in the AreaTree, but does not have any area itself. + * Pretends to be its parent for most purposes. + */ +public abstract class AbstractPlaceholder extends Area { + + public AbstractPlaceholder(FObj generatedBy, Area parentArea) { + super(generatedBy, parentArea); + } + + /** + * {@inheritDoc} + */ + public int pdUsedBySiblings() { + return this.getParentArea().pdUsedBySiblings(); + } + + /** + * {@inheritDoc} + */ + public int crIPD() { + return this.getParentArea().crIPD(); + } + + /** + * {@inheritDoc} + */ + public int crBPD() { + return this.getParentArea().crBPD(); + } + + /** + * {@inheritDoc} + */ + public int crOriginIPDOffset() { + return this.getParentArea().crOriginIPDOffset(); + } + + /** + * {@inheritDoc} + */ + public int crOriginBPDOffset() { + return this.getParentArea().crOriginBPDOffset(); + } + + /** + * {@inheritDoc} + */ + public Area getOverflowArea(Area childRequesting) throws AreaWException { + return this.getParentArea().getOverflowArea(childRequesting); + } + + /** + * {@inheritDoc} + */ + public int getProgressionDimension() { + return 0; + } + + /** + * {@inheritDoc} + */ + public int progressionDimensionAvailable() { + return this.getParentArea().progressionDimensionAvailable(); + } + + /** + * {@inheritDoc} + */ + public void setProgressionDimension(int progressionDimension) { + return; + } + + /** + * {@inheritDoc} + */ + public void setMinimumProgressionDimension(int minimumPD) { + return; + } + + /** + * {@inheritDoc} + */ + public void incrementProgressionDimension(int incrementAmount) { + return; + } + +} Property changes on: trunk/foray/foray-areatree/src/java/org/foray/area/AbstractPlaceholder.java ___________________________________________________________________ Name: svn:keywords + "Author Id Rev Date URL" Name: svn:eol-style + native Modified: trunk/foray/foray-areatree/src/java/org/foray/area/Area.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/Area.java 2006-06-07 18:29:27 UTC (rev 7440) +++ trunk/foray/foray-areatree/src/java/org/foray/area/Area.java 2006-06-07 21:36:05 UTC (rev 7441) @@ -36,6 +36,8 @@ import org.axsl.foR.fo.Block; import org.axsl.foR.fo.BlockContainer; import org.axsl.foR.fo.ListBlock; +import org.axsl.foR.fo.Marker; +import org.axsl.foR.fo.RetrieveMarker; import org.axsl.foR.fo.Table; import org.axsl.fontR.Font; import org.axsl.fontR.FontUse; @@ -1243,4 +1245,9 @@ return true; } + public org.axsl.areaW.MarkerContentArea makeMarkerContentArea( + RetrieveMarker retrieve, Marker marker) { + return new MarkerContentArea(retrieve, this, marker); + } + } Added: trunk/foray/foray-areatree/src/java/org/foray/area/MarkerContentArea.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/MarkerContentArea.java (rev 0) +++ trunk/foray/foray-areatree/src/java/org/foray/area/MarkerContentArea.java 2006-06-07 21:36:05 UTC (rev 7441) @@ -0,0 +1,64 @@ +/* + * 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 + * + */ + +/* $Id$ */ + +package org.foray.area; + +import org.axsl.common.ConstantsAreaTree; +import org.axsl.foR.fo.Marker; +import org.axsl.foR.fo.RetrieveMarker; + +/** + * A non-area that is a marker in the Area Tree to allow the AreaTree to + * remember which RetrieveMarker and Marker items combined to create the + * content below it. + */ +public class MarkerContentArea extends AbstractPlaceholder + implements org.axsl.areaW.MarkerContentArea { + + private Marker marker; + + public MarkerContentArea(RetrieveMarker generatedBy, Area parentArea, + Marker marker) { + super(generatedBy, parentArea); + this.marker = marker; + } + + public byte getAreaType() { + return ConstantsAreaTree.AREATYPE_MARKER_CONTENT; + } + + public String getAreaName() { + return "marker-content"; + } + + public Marker getMarker() { + return this.marker; + } + + public RetrieveMarker getRetrieveMarker() { + /* Cast verified at construction. */ + return (RetrieveMarker) this.generatedBy; + } + +} Property changes on: trunk/foray/foray-areatree/src/java/org/foray/area/MarkerContentArea.java ___________________________________________________________________ Name: svn:keywords + "Author Id Rev Date URL" Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 02:11:08
|
Revision: 7440 Author: victormote Date: 2006-06-07 11:29:27 -0700 (Wed, 07 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7440&view=rev Log Message: ----------- 1. Fix overridding method that didn't change its signature when the overridden method did. 2. Remove debugging code. Modified Paths: -------------- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FONodePL.java Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FONodePL.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FONodePL.java 2006-06-07 18:29:19 UTC (rev 7439) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FONodePL.java 2006-06-07 18:29:27 UTC (rev 7440) @@ -68,9 +68,6 @@ protected PioneerLS layout; public FONodePL(FONode realFObj, PioneerLS layout) { - if (realFObj == null) { - return; - } this.realFONode = realFObj; realFObj.setProxy(this); this.layout = layout; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-08 02:11:07
|
Revision: 7439 Author: victormote Date: 2006-06-07 11:29:19 -0700 (Wed, 07 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7439&view=rev Log Message: ----------- 1. Fix overridding method that didn't change its signature when the overridden method did. 2. Remove debugging code. Modified Paths: -------------- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java =================================================================== --- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java 2006-06-07 18:08:03 UTC (rev 7438) +++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java 2006-06-07 18:29:19 UTC (rev 7439) @@ -177,7 +177,7 @@ return pageNumberGenerator.makeFormattedPageNumber(pageNumber); } - public org.axsl.foR.fo.Flow getFlow() { + public org.axsl.foR.fo.Flow getFlow(FOContext context) { return this.flow; } @@ -216,7 +216,7 @@ return spm; } if (pageSequenceMaster != null) { - Flow flow = getFlow(); + Flow flow = getFlow(context); spm = pageSequenceMaster.getNextSimplePageMaster( ((pageNumberInDocument % 2) == 1), isBlank); Region region = (Region) spm.getRegionBody(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-07 18:08:24
|
Revision: 7438 Author: victormote Date: 2006-06-07 11:08:03 -0700 (Wed, 07 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7438&view=rev Log Message: ----------- Conform to axsl changes: Use new FOContext interface to provide information to the FOTree. Modified Paths: -------------- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/AbstractTableBodyPL.java trunk/foray/foray-pioneer/src/java/org/foray/pioneer/BlockPL.java trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ContinuedLabelPL.java trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ExternalGraphicPL.java trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FONodePL.java trunk/foray/foray-pioneer/src/java/org/foray/pioneer/PioneerLS.java trunk/foray/foray-pioneer/src/java/org/foray/pioneer/RowSpanMgr.java trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TableCellPL.java trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TableColumnPL.java trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TablePL.java trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TableRowPL.java Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/AbstractTableBodyPL.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/AbstractTableBodyPL.java 2006-06-07 18:05:55 UTC (rev 7437) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/AbstractTableBodyPL.java 2006-06-07 18:08:03 UTC (rev 7438) @@ -32,6 +32,7 @@ import org.axsl.areaW.NormalBlockArea; import org.axsl.areaW.TableArea; import org.axsl.common.Constants; +import org.axsl.foR.FOContext; import org.axsl.foR.FONode; import org.axsl.foR.fo.AbstractTableBody; import org.axsl.foR.fo.Marker; @@ -64,23 +65,23 @@ return ((GenericContainer)areaContainerRef.get()).getYPosition(); } - public int getHeight() { - return ((GenericContainer)areaContainerRef.get()).crBPD() - + getReal().traitSpaceBeforeOptimum() - + getReal().traitSpaceAfterOptimum(); + public int getHeight(FOContext context) { + return ((GenericContainer)areaContainerRef.get()).crBPD() + + getReal().traitSpaceBeforeOptimum(context) + + getReal().traitSpaceAfterOptimum(context); } public void removeLayout(Area area) { if (areaContainerRef != null) { area.removeChild((GenericContainer)areaContainerRef.get()); } - if (getReal().traitSpaceBeforeOptimum() != 0) { + if (getReal().traitSpaceBeforeOptimum(area) != 0) { area.incrementProgressionDimension(-getReal() - .traitSpaceBeforeOptimum()); + .traitSpaceBeforeOptimum(area)); } - if (getReal().traitSpaceAfterOptimum() != 0) { + if (getReal().traitSpaceAfterOptimum(area) != 0) { area.incrementProgressionDimension(-getReal() - .traitSpaceAfterOptimum()); + .traitSpaceAfterOptimum(area)); } resetProgress(); } @@ -113,7 +114,7 @@ public int layout(Area area) throws AreaWException { AbstractTableBody node = getReal(); TableArea tableArea = (TableArea) area; - Table table = node.getNearestTable(); + Table table = node.getNearestTable(area); if (getProgress() == FONodePL.BREAK_AFTER) { return Status.OK; } @@ -135,9 +136,10 @@ } - if ((node.traitSpaceBeforeOptimum() != 0) && (getProgress() == 0)) { + if ((node.traitSpaceBeforeOptimum(area) != 0) + && (getProgress() == 0)) { area.incrementProgressionDimension(node - .traitSpaceBeforeOptimum()); + .traitSpaceBeforeOptimum(area)); } /* @@ -179,7 +181,7 @@ TableRowPL rowPL = (TableRowPL) getLayoutProxy(row); rowPL.setRowSpanMgr(rowSpanMgr); - if (row.traitKeepWithPreviousWithinColumn() > 0 + if (row.traitKeepWithPreviousWithinColumn(area) > 0 && lastRow != null && keepWith.indexOf(lastRow) == -1) { keepWith.add(lastRow); @@ -219,9 +221,9 @@ area.incrementProgressionDimension(areaContainer.crBPD()); if (i == numChildren - 1) { setProgress(FONodePL.BREAK_AFTER); - if (node.traitSpaceAfterOptimum() != 0) { + if (node.traitSpaceAfterOptimum(area) != 0) { area.incrementProgressionDimension( - node.traitSpaceAfterOptimum()); + node.traitSpaceAfterOptimum(area)); } } return status; @@ -270,8 +272,9 @@ } area.incrementProgressionDimension(areaContainer.crBPD()); - if (node.traitSpaceAfterOptimum() != 0) { - area.incrementProgressionDimension(node.traitSpaceAfterOptimum()); + if (node.traitSpaceAfterOptimum(area) != 0) { + area.incrementProgressionDimension( + node.traitSpaceAfterOptimum(area)); } return Status.OK; Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/BlockPL.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/BlockPL.java 2006-06-07 18:05:55 UTC (rev 7437) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/BlockPL.java 2006-06-07 18:08:03 UTC (rev 7438) @@ -128,14 +128,15 @@ // no break if last in area tree, or trailing in context // area - int breakAfterStatus = Status.checkBreakAfter(node.traitBreakAfter()); + int breakAfterStatus = Status.checkBreakAfter( + node.traitBreakAfter(area)); if (breakAfterStatus != Status.OK) { setProgress(FONodePL.BREAK_AFTER); blockArea = null; return breakAfterStatus; } - if (node.traitKeepWithNextWithinColumn() > 0 - || node.traitKeepWithNextWithinPage() > 0) { + if (node.traitKeepWithNextWithinColumn(area) > 0 + || node.traitKeepWithNextWithinPage(area) > 0) { return Status.KEEP_WITH_NEXT; } return Status.OK; Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ContinuedLabelPL.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ContinuedLabelPL.java 2006-06-07 18:05:55 UTC (rev 7437) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ContinuedLabelPL.java 2006-06-07 18:08:03 UTC (rev 7438) @@ -60,7 +60,7 @@ } // See if ancestor table has generated any areas yet. - Table table = label.getNearestTable(); + Table table = label.getNearestTable(area); FOLinkage linkage = (FOLinkage) table.getResult(); if (linkage != null && linkage.qtyAreasGenerated() > 0) { int numChildren = label.getChildren().size(); Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ExternalGraphicPL.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ExternalGraphicPL.java 2006-06-07 18:05:55 UTC (rev 7437) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ExternalGraphicPL.java 2006-06-07 18:08:03 UTC (rev 7438) @@ -51,9 +51,9 @@ org.axsl.areaW.Area parentForDimensions = area.nearestGeneratedByBlockLevelFO(); - int height = node.viewportBPD(parentForDimensions.crBPD()); + int height = node.viewportBPD(area, parentForDimensions.crBPD()); if (area.progressionDimensionAvailable() - < (height + node.traitSpaceBeforeOptimum())) { + < (height + node.traitSpaceBeforeOptimum(area))) { return Status.AREA_FULL_NONE; } Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FONodePL.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FONodePL.java 2006-06-07 18:05:55 UTC (rev 7437) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FONodePL.java 2006-06-07 18:08:03 UTC (rev 7438) @@ -68,6 +68,9 @@ protected PioneerLS layout; public FONodePL(FONode realFObj, PioneerLS layout) { + if (realFObj == null) { + return; + } this.realFONode = realFObj; realFObj.setProxy(this); this.layout = layout; Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/PioneerLS.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/PioneerLS.java 2006-06-07 18:05:55 UTC (rev 7437) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/PioneerLS.java 2006-06-07 18:08:03 UTC (rev 7438) @@ -126,7 +126,7 @@ public void processPageSequence(PageCollection pageCollection) throws AreaWException { PageSequence pageSeq = pageCollection.getPageSequence(); - org.axsl.foR.fo.Flow flow = pageSeq.getFlow(); + org.axsl.foR.fo.Flow flow = pageSeq.getFlow(pageCollection); flow.setProxy(new FlowPL(flow, this)); pageCollection.padPagesAtBeginning(); @@ -202,7 +202,7 @@ public int checkBreakBefore(FObj node, Area area) { if (!(area instanceof NormalFlowRA)) { - switch (node.traitBreakBefore()) { + switch (node.traitBreakBefore(area)) { case Constants.FOVAL_PAGE: return Status.FORCE_PAGE_BREAK; case Constants.FOVAL_ODD_PAGE: @@ -216,7 +216,7 @@ } } NormalFlowRA colArea = (NormalFlowRA)area; - switch (node.traitBreakBefore()) { + switch (node.traitBreakBefore(area)) { case Constants.FOVAL_PAGE: { // if first ColumnArea, and empty, return OK if (!colArea.hasChildren() && (colArea.siblingIndex() == 0)) { Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/RowSpanMgr.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/RowSpanMgr.java 2006-06-07 18:05:55 UTC (rev 7437) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/RowSpanMgr.java 2006-06-07 18:08:03 UTC (rev 7438) @@ -60,7 +60,8 @@ totalRowHeight += rowHeight; if (--rowsRemaining == 0) { if (cell != null) { - getTableCellPL().setRowHeight(totalRowHeight); + /* TODO: Fix FOContext item below. */ + getTableCellPL().setRowHeight(null, totalRowHeight); } return true; } Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TableCellPL.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TableCellPL.java 2006-06-07 18:05:55 UTC (rev 7437) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TableCellPL.java 2006-06-07 18:08:03 UTC (rev 7438) @@ -25,11 +25,11 @@ package org.foray.pioneer; import org.axsl.areaW.Area; +import org.axsl.areaW.AreaWException; import org.axsl.areaW.TableCellArea; import org.axsl.areaW.TableRowContainer; - -import org.axsl.areaW.AreaWException; import org.axsl.common.Constants; +import org.axsl.foR.FOContext; import org.axsl.foR.FObj; import org.axsl.foR.fo.TableCell; @@ -54,11 +54,11 @@ * adjustment for collapse style (because current scheme makes cell * overestimate the allocation height). */ - public int getHeight() { + public int getHeight(FOContext context) { return areaContainer.crBPD() - + getReal().traitBorderSeparationBPD() - - (getReal().traitBorderTopWidth() - + getReal().traitBorderBottomWidth()) + + getReal().traitBorderSeparationBPD(context) + - (getReal().traitBorderTopWidth(context) + + getReal().traitBorderBottomWidth(context)) / 2; } @@ -69,10 +69,10 @@ * the allocation height of all the cells in the row, including any * border separation values. */ - public void setRowHeight(int h) { - int delta = h - getHeight(); + public void setRowHeight(FOContext context, int h) { + int delta = h - getHeight(context); // cellArea.increaseHeight(h + borderHeight/2 - cellArea.getHeight()); - if (getReal().traitDisplayAlign() == Constants.FOVAL_AUTO) { + if (getReal().traitDisplayAlign(context) == Constants.FOVAL_AUTO) { // Must get info for all cells starting in row! // verticalAlign can be BEFORE or BASELINE // For now just treat like "before" @@ -83,10 +83,10 @@ return; } // Vertical cell alignment - short verticalAlign = getReal().traitDisplayAlign(); + short verticalAlign = getReal().traitDisplayAlign(context); if (verticalAlign == Constants.FOVAL_AUTO) { // Depends on all cells starting in row - verticalAlign = getReal().traitAlignmentBaseline(); + verticalAlign = getReal().traitAlignmentBaseline(context); } switch (verticalAlign) { case Constants.FOVAL_CENTER: @@ -145,7 +145,7 @@ bDone = true; // Adjust for minimum cell content height - int minCellHeight = node.traitBPDimensionMin(area.crBPD()); + int minCellHeight = node.traitBPDimensionMin(area, area.crBPD()); if (minCellHeight > cellArea.crBPD()) { cellArea.setProgressionDimension(minCellHeight); } Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TableColumnPL.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TableColumnPL.java 2006-06-07 18:05:55 UTC (rev 7437) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TableColumnPL.java 2006-06-07 18:08:03 UTC (rev 7438) @@ -59,7 +59,7 @@ public int layout(Area area) throws AreaWException { TableColumn node = getFO(); TableArea tableArea = (TableArea) area; - Table table = node.getNearestTable(); + Table table = node.getNearestTable(area); if (getProgress() == FONodePL.BREAK_AFTER) { return Status.OK; } Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TablePL.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TablePL.java 2006-06-07 18:05:55 UTC (rev 7437) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TablePL.java 2006-06-07 18:08:03 UTC (rev 7438) @@ -30,6 +30,7 @@ import org.axsl.areaW.AreaWException; import org.axsl.common.Constants; +import org.axsl.foR.FOContext; import org.axsl.foR.FONode; import org.axsl.foR.fo.Marker; import org.axsl.foR.fo.Table; @@ -78,15 +79,15 @@ } setProgress(0); - if (node.traitBreakBefore() == Constants.FOVAL_PAGE) { + if (node.traitBreakBefore(area) == Constants.FOVAL_PAGE) { return Status.FORCE_PAGE_BREAK; } - if (node.traitBreakBefore() == Constants.FOVAL_ODD_PAGE) { + if (node.traitBreakBefore(area) == Constants.FOVAL_ODD_PAGE) { return Status.FORCE_PAGE_BREAK_ODD; } - if (node.traitBreakBefore() == Constants.FOVAL_EVEN_PAGE) { + if (node.traitBreakBefore(area) == Constants.FOVAL_EVEN_PAGE) { return Status.FORCE_PAGE_BREAK_EVEN; } @@ -151,7 +152,7 @@ headerPL.resetProgress(); } if (node.getTableFooter() != null - && ! node.traitTableOmitFooterAtBreak() + && ! node.traitTableOmitFooterAtBreak(area) &&!addedFooter) { tf = node.getTableFooter(); TableFooterPL tfPL = (TableFooterPL) @@ -186,12 +187,12 @@ area.incrementProgressionDimension( areaContainer.crBPD()); if (node.getTableFooter() != null - && ! node.traitTableOmitFooterAtBreak()) { + && ! node.traitTableOmitFooterAtBreak(area)) { // move footer to bottom of area and move up body - int yPosition = getTableFooterYPosition(tf); + int yPosition = getTableFooterYPosition(area, tf); tableBodyPL.setYPosition(yPosition); tableFooterPL.setYPosition(yPosition - + tableBodyPL.getHeight()); + + tableBodyPL.getHeight(area)); } setupColumnHeights(node, areaContainer); status = Status.AREA_FULL_SOME; @@ -200,19 +201,19 @@ } this.bodyCount++; if (node.getTableFooter() != null - && ! node.traitTableOmitFooterAtBreak()) { + && ! node.traitTableOmitFooterAtBreak(area)) { // move footer to bottom of area and move up body // space before and after footer will make this wrong - int yPosition = getTableFooterYPosition(tf); + int yPosition = getTableFooterYPosition(area, tf); tableBodyPL.setYPosition(yPosition); tableFooterPL.setYPosition(yPosition - + tableBodyPL.getHeight()); + + tableBodyPL.getHeight(area)); } } } if (node.getTableFooter() != null - && node.traitTableOmitFooterAtBreak()) { + && node.traitTableOmitFooterAtBreak(area)) { TableFooter tf = node.getTableFooter(); TableFooterPL tfPL = (TableFooterPL) getLayoutProxy(tf); int status = tfPL.layout(areaContainer); @@ -232,7 +233,7 @@ } } - int height = node.traitBPDimensionOpt(area.crBPD()); + int height = node.traitBPDimensionOpt(area, area.crBPD()); if (height != 0) { areaContainer.setProgressionDimension(height); } @@ -242,17 +243,17 @@ /* should this be combined into above? */ area.incrementProgressionDimension(areaContainer.crBPD()); - if (node.traitBreakAfter() == Constants.FOVAL_PAGE) { + if (node.traitBreakAfter(area) == Constants.FOVAL_PAGE) { setProgress(FONodePL.BREAK_AFTER); return Status.FORCE_PAGE_BREAK; } - if (node.traitBreakAfter() == Constants.FOVAL_ODD_PAGE) { + if (node.traitBreakAfter(area) == Constants.FOVAL_ODD_PAGE) { setProgress(FONodePL.BREAK_AFTER); return Status.FORCE_PAGE_BREAK_ODD; } - if (node.traitBreakAfter() == Constants.FOVAL_EVEN_PAGE) { + if (node.traitBreakAfter(area) == Constants.FOVAL_EVEN_PAGE) { setProgress(FONodePL.BREAK_AFTER); return Status.FORCE_PAGE_BREAK_EVEN; } @@ -272,9 +273,9 @@ } // FIXME: this seems odd. - public int getTableFooterYPosition(TableFooter tFooter) { + public int getTableFooterYPosition(FOContext context, TableFooter tFooter) { TableFooterPL tfPL = (TableFooterPL) getLayoutProxy(tFooter); - return tfPL.getYPosition() - tFooter.traitSpaceBeforeOptimum(); + return tfPL.getYPosition() - tFooter.traitSpaceBeforeOptimum(context); } public void setupColumnHeights(Table table, TableArea areaContainer) { @@ -290,7 +291,7 @@ public int calcFixedColumnWidths(TableArea tableArea, int maxAllocationWidth) { Table node = getTableFO(); - int tableWidth = node.traitIPDimensionOpt(tableArea.crIPD()); + int tableWidth = node.traitIPDimensionOpt(tableArea, tableArea.crIPD()); /* Accumulates the total table units used in columns in this table. */ double totalTableUnits = 0.0; /* @@ -315,17 +316,19 @@ * in any column which has only proportional units. */ if (tu > 0 && tu < tuMin - && column.traitColumnWidth(tableWidth) == 0) { + && column.traitColumnWidth(tableArea, + tableWidth) == 0) { tuMin = tu; } totalTableUnits += tu; - totalFixedWidth += column.traitColumnWidth(tableWidth); + totalFixedWidth += column.traitColumnWidth(tableArea, + tableWidth); } } double dWidthFactor = 0.0; double dUnitLength = 0.0; - setIPD((totalTableUnits > 0.0), maxAllocationWidth); + setIPD(tableArea, (totalTableUnits > 0.0), maxAllocationWidth); if (totalTableUnits > 0.0) { int iProportionalWidth = 0; if (this.optIPD > totalFixedWidth) { @@ -391,7 +394,7 @@ * dUnitLength)); } else { //Fixed width - colWidth = column.traitColumnWidth(tableWidth); + colWidth = column.traitColumnWidth(tableArea, tableWidth); } // Check minimum values and adjust if necessary @@ -416,37 +419,38 @@ * standard getIPD... methods in FObj. Whatever is different should probably * be factored into methods that override (but use) the FObj methods. */ - private void setIPD(boolean bHasProportionalUnits, int maxAllocIPD) { + private void setIPD(FOContext context, boolean bHasProportionalUnits, + int maxAllocIPD) { Table node = getTableFO(); - if (node.traitIPDimensionMax(maxAllocIPD) >= 0) { - this.maxIPD = node.traitIPDimensionMax(maxAllocIPD); + if (node.traitIPDimensionMax(context, maxAllocIPD) >= 0) { + this.maxIPD = node.traitIPDimensionMax(context, maxAllocIPD); } else { this.maxIPD = maxAllocIPD; } - if (node.traitIPDimensionOpt(maxAllocIPD) < 0) { + if (node.traitIPDimensionOpt(context, maxAllocIPD) < 0) { this.optIPD = -1; } else { /* TODO: This looks like a bug. Should be getIPDOptimum()? */ - this.optIPD = node.traitIPDimensionMax(maxAllocIPD); + this.optIPD = node.traitIPDimensionMax(context, maxAllocIPD); } - if (node.traitIPDimensionMin(maxAllocIPD) < 0) { + if (node.traitIPDimensionMin(context, maxAllocIPD) < 0) { this.minIPD = -1; } else { - this.minIPD = node.traitIPDimensionMin(maxAllocIPD); + this.minIPD = node.traitIPDimensionMin(context, maxAllocIPD); } if (bHasProportionalUnits && this.optIPD < 0) { if (this.minIPD > 0) { - if (node.traitIPDimensionMax(maxAllocIPD) >= 0) { + if (node.traitIPDimensionMax(context, maxAllocIPD) >= 0) { this.optIPD = (minIPD + maxIPD)/2; } else { this.optIPD = this.minIPD; } } - else if (node.traitIPDimensionMax(maxAllocIPD) >= 0) { + else if (node.traitIPDimensionMax(context, maxAllocIPD) >= 0) { this.optIPD = this.maxIPD; } else { Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TableRowPL.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TableRowPL.java 2006-06-07 18:05:55 UTC (rev 7437) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TableRowPL.java 2006-06-07 18:08:03 UTC (rev 7438) @@ -26,11 +26,11 @@ import org.axsl.areaW.AbstractTableContainer; import org.axsl.areaW.Area; -import org.axsl.areaW.TableRowContainer; - import org.axsl.areaW.AreaWException; import org.axsl.areaW.TableArea; +import org.axsl.areaW.TableRowContainer; import org.axsl.common.Constants; +import org.axsl.foR.FOContext; import org.axsl.foR.Keep; import org.axsl.foR.fo.TableCell; import org.axsl.foR.fo.TableRow; @@ -63,9 +63,9 @@ * Before starting layout for the first time, initialize information * about spanning rows, empty cells and spanning columns. */ - private void initCellArray() throws AreaWException { + private void initCellArray(FOContext context) throws AreaWException { TableRow node = getReal(); - List columns = node.getNearestTable().getTableColumns(); + List columns = node.getNearestTable(context).getTableColumns(); cellArray = new RowCellArray(rowSpanMgr, columns.size()); int colNum = 1; for (int i = 0; i < getReal().getChildren().size(); i++) { @@ -75,7 +75,7 @@ TableCell cell = (TableCell)getReal().getChildren().get(i); int numCols = cell.traitNumberColumnsSpanned(); - int cellColNum = cell.traitColumnNumber(); + int cellColNum = cell.traitColumnNumber(context); if (cellColNum == 0) { // Not explicitly specified, so put in next available colummn @@ -131,7 +131,7 @@ public int layout(Area area) throws AreaWException { TableRow node = getReal(); - List columns = node.getNearestTable().getTableColumns(); + List columns = node.getNearestTable(area).getTableColumns(); if (getProgress() == FONodePL.BREAK_AFTER) { return Status.OK; } @@ -141,7 +141,7 @@ // Only do this once. If the row is "thrown" and we start // layout over again, we can skip this. if (cellArray == null) { - initCellArray(); + initCellArray(area); // check to make sure this row hasn't been partially // laid out yet (with an id created already) } @@ -156,7 +156,7 @@ TableRowContainer areaContainer = container.makeTableRowContainer(node); /* Set a reasonable starting BPD for this row. */ - this.largestCellHeight = node.traitBPDimensionMin(area.crBPD()); + this.largestCellHeight = node.traitBPDimensionMin(area, area.crBPD()); // Flag indicaing whether any cell didn't fit in available space boolean someCellDidNotLayoutCompletely = false; @@ -206,7 +206,7 @@ int rowSpan = cell.traitNumberRowsSpanned(); int status = cellPL.layout(areaContainer); if (Status.isIncomplete(status)) { - if ((node.traitKeepTogetherWithinColumn() == Keep.ALWAYS + if ((node.traitKeepTogetherWithinColumn(area) == Keep.ALWAYS && bIgnoreKeepTogether == false) || (status == Status.AREA_FULL_NONE) || rowSpan > 1) { @@ -226,7 +226,7 @@ } } // else { // layout was complete for a particular cell - int h = cellPL.getHeight(); // allocation height of cell + int h = cellPL.getHeight(area); // allocation height of cell if (rowSpan > 1) { // pass cell fo or area??? rowSpanMgr.addRowSpan(cell, iColIndex, cell.traitNumberColumnsSpanned(), h, rowSpan, layout); @@ -243,7 +243,7 @@ && rowSpanMgr.isSpanned(iCol) == false) { TableCell cell = cellArray.getCell(iCol); TableCellPL cellPL = (TableCellPL) getLayoutProxy(cell); - cellPL.setRowHeight(largestCellHeight); + cellPL.setRowHeight(area, largestCellHeight); } } @@ -260,7 +260,7 @@ // Ignore break after if row span! return Status.KEEP_WITH_NEXT; } - short breakAfter = node.traitBreakAfter(); + short breakAfter = node.traitBreakAfter(area); if (breakAfter == Constants.FOVAL_PAGE) { setProgress(FONodePL.BREAK_AFTER); return Status.FORCE_PAGE_BREAK; @@ -280,7 +280,7 @@ setProgress(FONodePL.BREAK_AFTER); return Status.FORCE_COLUMN_BREAK; } - if (node.traitKeepWithNextWithinColumn() > Keep.AUTO) { + if (node.traitKeepWithNextWithinColumn(area) > Keep.AUTO) { return Status.KEEP_WITH_NEXT; } return Status.OK; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-06-07 18:08:02
|
Revision: 7437 Author: victormote Date: 2006-06-07 11:05:55 -0700 (Wed, 07 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7437&view=rev Log Message: ----------- Conform to axsl changes: Use new FOContext interface to provide information to the FOTree. Modified Paths: -------------- trunk/foray/foray-fotree/src/java/org/foray/fotree/FONode.java trunk/foray/foray-fotree/src/java/org/foray/fotree/FOText.java trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java trunk/foray/foray-fotree/src/java/org/foray/fotree/FObjMixed.java trunk/foray/foray-fotree/src/java/org/foray/fotree/FObjScaled.java trunk/foray/foray-fotree/src/java/org/foray/fotree/PropertyList.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/AbstractFlow.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BasicLink.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Block.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Bookmark.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/ConditionalPageMasterReference.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ExternalGraphic.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Flow.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/LayoutMasterSet.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Leader.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ListItem.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ListItemBody.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ListItemLabel.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Marker.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/PageSequence.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequenceMaster.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Region.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RegionAfter.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RegionBefore.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RegionBody.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RegionEnd.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RegionStart.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMAlternatives.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMReference.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Root.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SimplePageMaster.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SinglePageMasterReference.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SubSequenceSpecifier.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Table.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/TableColumn.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Wrapper.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AbsoluteDimension.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AbsoluteOffset.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AlignmentAdjust.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AlignmentBaseline.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AudioDial.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Azimuth.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundImage.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundPosition.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BaselineShift.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Boolean.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderPrecedence.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderSeparation.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderStyle.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderWidth.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Character.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Clip.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Color.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnCount.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnGap.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnNumber.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnWidth.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ContentDimension.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Country.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Cue.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/DestinationPlacementOffset.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/DisplayAlign.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/DominantBaseline.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Elevation.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Enumerated.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Extent.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontFamily.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSize.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSizeAdjust.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontStretch.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontStyle.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontVariant.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontWeight.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ForcePageCount.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/GlyphOrientation.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/HyphLadderCount.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/HyphPushCharCount.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/HyphRemainCharCount.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Indent.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/InitialPageNumber.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Keep.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Language.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LastLineEndIndent.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LeaderLength.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LeaderPatternWidth.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LetterSpacing.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LineHeight.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Margin.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/MaximumRepeats.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Name.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Orphans.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Padding.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/PageDimension.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Pause.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Pitch.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/PlayDuring.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ProvDistanceBetween.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ProvLabelSeparation.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RefId.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeDimension.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeSpace.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Role.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RuleThickness.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Script.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Size.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/SourceDocument.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/SpeechRate.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Src.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextAlign.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextAlignLast.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextAltitude.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextDecoration.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextDepth.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextIndent.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextShadow.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TreatAsWordSpace.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/VoiceFamily.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Volume.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Widows.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/WordSpacing.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/WritingMode.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ZIndex.java trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnBodyStart.java trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFromParent.java trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnInheritedProp.java trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnLabelEnd.java trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnNearestSpecProp.java trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnProportionalColWidth.java Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/FONode.java =================================================================== --- trunk/foray/foray-fotree/src/java/org/foray/fotree/FONode.java 2006-06-07 18:05:37 UTC (rev 7436) +++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FONode.java 2006-06-07 18:05:55 UTC (rev 7437) @@ -25,10 +25,16 @@ package org.foray.fotree; import org.foray.common.OrderedTreeNode; +import org.foray.fotree.fo.obj.Marker; +import org.axsl.foR.FOContext; import org.axsl.foR.FONodeProxy; import org.axsl.foR.FONodeResult; +import org.axsl.foR.FOTreeException; +import org.axsl.foR.fo.RetrieveMarker; +import javax.swing.tree.TreeNode; + /** * Base class for nodes in the formatting object tree. */ @@ -43,6 +49,39 @@ super(parent); } + /** + * Return this node's effective parent, cast as an FObj. + * This differs from the value returned by + * @param context TODO + * @return This node's effective parent. + */ + public FObj effectiveParent(FOContext context) { + TreeNode parent = this.getParent(); + if (parent instanceof Marker) { + if (context == null) { + return realParent(); + } + Marker marker = (Marker) parent; + RetrieveMarker retrieve; + try { + retrieve = context.getRetrieveMarker(marker); + } catch (FOTreeException e) { + return realParent(); + } + if (retrieve instanceof org.foray.fotree.fo.obj.RetrieveMarker) { + return (org.foray.fotree.fo.obj.RetrieveMarker) retrieve; + } else { + /* Hopefully this never happens. */ + return realParent(); + } + } + return realParent(); + } + + /** + * Return this node's real parent, cast as an FObj. + * @return This node's real parent. + */ public FObj realParent() { return (FObj) this.getParent(); } Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/FOText.java =================================================================== --- trunk/foray/foray-fotree/src/java/org/foray/fotree/FOText.java 2006-06-07 18:05:37 UTC (rev 7436) +++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FOText.java 2006-06-07 18:05:55 UTC (rev 7437) @@ -27,6 +27,7 @@ import org.foray.common.XMLCharacter; import org.axsl.common.Constants; +import org.axsl.foR.FOContext; import org.axsl.foR.fo.Block; import org.axsl.foR.fo.Leader; import org.axsl.fontR.FontUse; @@ -70,10 +71,12 @@ public FOText(FObj parent, char[] chars) { super(parent); this.ca = chars; + /* TODO: Handle context better. */ + FOContext context = null; /* Convert the text as far as possible, store it, and set the status. * We cannot filter text-transform yet, because we may need subsequent * FOText instances. */ - this.ca = this.getPreTextTransformText(); + this.ca = this.getPreTextTransformText(context); this.filterStatus = FILTER_PRE_TRANSFORM; } @@ -117,21 +120,25 @@ * <li>linefeed-treatment. See XSL-FO Standard 1.0 Section 7.15.7.</li> * <li>text-transform. See XSL-FO Standard 1.0 Section 7.16.6.</li> * </ul> + * @param context TODO * * @return The text that should appear in the refined FO tree. */ - public char[] getRefinedText() { + public char[] getRefinedText(FOContext context) { + /* TODO: This needs to come from effectiveParent, with context. */ + FObj effectiveParent = this.realParent(); if (this.filterStatus >= FILTER_REFINED_FO_TREE) { /* The stored text has already been filtered. Just return it. */ return this.ca; } - char[] charArray = getPreTextTransformText(); + char[] charArray = getPreTextTransformText(context); // Now handle text-transform. - short textTransform = realParent().traitTextTransform(); + short textTransform = effectiveParent.traitTextTransform(context); if (textTransform != Constants.FOVAL_NONE) { for (int i = 0; i < charArray.length; i++) { - charArray[i] = applyTextTransform(charArray, i, textTransform); + charArray[i] = applyTextTransform(context, charArray, i, + textTransform); } } @@ -154,11 +161,13 @@ * is applied it does not create a stack overflow. This is possible because * text-transform looks at previous and subsequent FOText items, which must * inevitably look back at the original FOText instance.</p> + * @param context TODO * * @return The text that should appear in the refined FO tree, except that * text-transform is not applied. */ - private char[] getPreTextTransformText() { + private char[] getPreTextTransformText(FOContext context) { + FObj effectiveParent = this.effectiveParent(context); if (this.filterStatus >= FILTER_PRE_TRANSFORM) { /* The stored text has already been filtered. Just return it. */ return this.ca; @@ -166,11 +175,11 @@ /* Must handle white-space-treatment first. */ char[] workArray = applyWhiteSpaceTreatment(this.ca, - realParent().traitWhiteSpaceTreatment()); + effectiveParent.traitWhiteSpaceTreatment(context)); // Now handle linefeed-treatment. workArray = applyLinefeedTreatment(workArray, - realParent().traitLinefeedTreatment()); + effectiveParent.traitLinefeedTreatment(context)); /* Update this instance's text with the filtered value and update the * status. */ @@ -181,14 +190,15 @@ /** * Applies text-transform to one character of the array. + * @param context TODO * @param charArray The array which is being transformed. * @param index The 0-based index into charArray, which points to the * character being transformed. * @param textTransform The value of the text-transform enumerated property. * @return The transformed char. */ - private char applyTextTransform(char[] charArray, int index, - short textTransform) { + private char applyTextTransform(FOContext context, char[] charArray, + int index, short textTransform) { char c = charArray[index]; switch (textTransform) { /* This method not be entered if value is NONE. */ @@ -197,7 +207,7 @@ case Constants.FOVAL_LOWERCASE: return Character.toLowerCase(c); case Constants.FOVAL_CAPITALIZE: - if (isStartOfWord(charArray, index)) { + if (isStartOfWord(context, charArray, index)) { /* Use toTitleCase here. Apparently, some languages use a different character to represent a letter when using @@ -228,15 +238,17 @@ * ambiguous and appears to be definable by the user agent. * See http://lists.w3.org/Archives/Public/xsl-editors/2005AprJun/0006.html * for a discussion of this matter. - * + * @param context TODO * @param charArray The char[] being transformed. * @param index The 0-based index into charArray pointing to the character * that is being tested. + * * @return True iff the character at this location is the start of a new * word. */ - private boolean isStartOfWord(char[] charArray, int index) { - char prevChar = getRelativeCharInBlock(charArray, index, -1); + private boolean isStartOfWord(FOContext context, char[] charArray, + int index) { + char prevChar = getRelativeCharInBlock(context, charArray, index, -1); /* All we are really concerned about here is of what type prevChar is. If inputChar is not part of a word, then the Java conversions will (we hope) simply return inputChar. @@ -251,7 +263,8 @@ * as a possessive or a contraction, or might be a closing quote. */ case IS_WORD_CHAR_MAYBE: - char prevPrevChar = getRelativeCharInBlock(charArray, index, -2); + char prevPrevChar = getRelativeCharInBlock(context, charArray, + index, -2); switch (isWordChar(prevPrevChar)) { case IS_WORD_CHAR_TRUE: return false; @@ -356,17 +369,18 @@ * to a character in the current FOText. Treats all FOText objects within a * block as one unit, allowing text in adjoining FOText objects to be * returned if the parameters are outside of the current object. - * + * @param context TODO * @param charArray The charArray to be tested. * @param index 0-based index into charArray. * @param offset Signed integer with relative position within the block of * the character to return. To return the character immediately preceding i, * pass -1. To return the character immediately after i, pass 1. + * * @return the character in the offset position within the block; 0x0000 if * the offset points to an area outside of the block. */ - private char getRelativeCharInBlock(char[] charArray, int index, - int offset) { + private char getRelativeCharInBlock(FOContext context, char[] charArray, + int index, int offset) { // The easy case is where the desired character is in the same FOText int desiredIndex = index + offset; if (desiredIndex >= 0 && desiredIndex < charArray.length) { @@ -379,7 +393,7 @@ remainingOffset = offset - (charArray.length - 1 - index); FOText nextFOText = this.getNextContiguousTextInBlock(); while (nextFOText != null) { - char[] nextText = nextFOText.getPreTextTransformText(); + char[] nextText = nextFOText.getPreTextTransformText(context); if (nextText.length >= remainingOffset) { return nextText[remainingOffset - 1]; } @@ -392,7 +406,7 @@ remainingOffset = offset + index; FOText prevFOText = this.getPreviousContiguousTextInBlock(); while (prevFOText != null) { - char[] prevText = prevFOText.getPreTextTransformText(); + char[] prevText = prevFOText.getPreTextTransformText(context); if (prevText.length >= Math.abs(remainingOffset)) { return prevText[prevText.length + remainingOffset]; } @@ -436,6 +450,8 @@ * If any of these are not true, null is returned. */ private FOText getContiguousTextInBlock(FONode leafToTest) { + FObj effectiveParent = this.realParent(); + FOContext context = null; if (leafToTest == null) { return null; } @@ -444,13 +460,16 @@ } /* If either is within a Leader, they both need to be in the same one. */ - Leader thisLeader = this.realParent().getNearestLeader(); - Leader testLeader = leafToTest.realParent().getNearestLeader(); + Leader thisLeader = effectiveParent.getNearestLeader(context); + Leader testLeader = leafToTest.effectiveParent(context) + .getNearestLeader(context); if (thisLeader != testLeader) { return null; } - Block thisBlock = this.realParent().getContainingBlock(); - Block testBlock = leafToTest.realParent().getContainingBlock(); + Block thisBlock = this.effectiveParent(context).getContainingBlock( + context); + Block testBlock = leafToTest.effectiveParent(context) + .getContainingBlock(context); if (thisBlock != testBlock) { return null; } @@ -467,16 +486,18 @@ * * @return The text that should appear in the area tree. */ - public char[] getAreaTreeText() { + public char[] getAreaTreeText(FOContext context) { + FObj effectiveParent = this.realParent(); if (this.filterStatus >= FILTER_AREA_TREE) { /* The stored text has already been filtered. Just return it. */ return this.ca; } // Start with the refined FO Tree text - char[] returnArray = getRefinedText(); + char[] returnArray = getRefinedText(context); // Apply white-space-collapse. - boolean whiteSpaceCollapse = realParent().traitWhiteSpaceCollapse(); + boolean whiteSpaceCollapse = effectiveParent.traitWhiteSpaceCollapse( + context); returnArray = applyWhiteSpaceCollapse(returnArray, whiteSpaceCollapse); /* Set the instance text to the more refined value and update the @@ -487,56 +508,86 @@ } public char[] inlineText() { - return getAreaTreeText(); + /* TODO: Handle context better. */ + FOContext context = null; + return getAreaTreeText(context); } public FontUse inlinePrimaryFont() { - return realParent().getPrimaryFont(); + /* TODO: Handle context better. */ + FOContext context = null; + return effectiveParent(null).getPrimaryFont(context); } public FontUse inlineSecondaryFont(char c) { - return realParent().getSecondaryFont(c); + /* TODO: Handle context better. */ + FOContext context = null; + return effectiveParent(null).getSecondaryFont(context, c); } public int inlineFontSize() { - return realParent().traitFontSize(); + /* TODO: Handle context better. */ + FOContext context = null; + return effectiveParent(null).traitFontSize(context); } public int inlineLetterSpacingOptimum() { - return realParent().traitLetterSpacingOpt(); + /* TODO: Handle context better. */ + FOContext context = null; + return effectiveParent(null).traitLetterSpacingOpt(context); } public boolean inlineWrapOption() { - return (realParent().traitWrapOption() == Constants.FOVAL_WRAP); + /* TODO: Handle context better. */ + FOContext context = null; + return (effectiveParent(null).traitWrapOption(context) + == Constants.FOVAL_WRAP); } public boolean inlineHyphenate() { - return realParent().traitHyphenate(); + /* TODO: Handle context better. */ + FOContext context = null; + return effectiveParent(null).traitHyphenate(context); } public String inlineLanguage() { - return realParent().traitLanguage(); + /* TODO: Handle context better. */ + FOContext context = null; + return effectiveParent(null).traitLanguage(context); } public String inlineCountry() { - return realParent().traitCountry(); + /* TODO: Handle context better. */ + FOContext context = null; + return effectiveParent(null).traitCountry(context); } public int inlineHyphenationRemainCount() { - return realParent().traitHyphenationRemainCharacterCount(); + /* TODO: Handle context better. */ + FOContext context = null; + return effectiveParent(null).traitHyphenationRemainCharacterCount( + context); } public int inlineHyphenationPushCount() { - return realParent().traitHyphenationPushCharacterCount(); + /* TODO: Handle context better. */ + FOContext context = null; + return effectiveParent(null).traitHyphenationPushCharacterCount( + context); } public char inlineHyphenationCharacter() { - return realParent().traitHyphenationCharacter(); + /* TODO: Handle context better. */ + FOContext context = null; + return effectiveParent(null).traitHyphenationCharacter( + context); } public boolean inlineIsFauxSmallCaps() { - FObj parent = this.realParent(); - if (parent.traitFontVariant() != Constants.FOVAL_SMALL_CAPS) { + /* TODO: Handle context better. */ + FOContext context = null; + FObj parent = this.effectiveParent(context); + if (parent.traitFontVariant(context) != Constants.FOVAL_SMALL_CAPS) { return false; } /* @@ -550,7 +601,9 @@ } public int inlineFauxSmallCapsFontSize() { - return this.realParent().getFauxSmallCapFontSize(); + /* TODO: Handle context better. */ + FOContext context = null; + return this.effectiveParent(null).getFauxSmallCapFontSize(context); } public LineText nextContiguousLineText() { Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java =================================================================== --- trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java 2006-06-07 18:05:37 UTC (rev 7436) +++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java 2006-06-07 18:05:55 UTC (rev 7437) @@ -27,6 +27,7 @@ import org.foray.common.XMLCharacter; import org.axsl.common.Constants; +import org.axsl.foR.FOContext; import org.axsl.foR.FOTreeException; import org.axsl.foR.ShadowEffect; import org.axsl.foR.Shape; @@ -185,65 +186,66 @@ /** * {@inheritDoc} */ - public org.axsl.foR.FObj getNearestAncestorGeneratingRA() { - if (realParent().traitIsReferenceArea()) { - return realParent(); + public org.axsl.foR.FObj getNearestAncestorGeneratingRA(FOContext context) { + if (effectiveParent(context).traitIsReferenceArea()) { + return effectiveParent(context); } - return realParent().getNearestAncestorGeneratingRA(); + return effectiveParent(context).getNearestAncestorGeneratingRA(context); } /** * @return Self or the nearest ancestor FObj that generates reference areas. */ - public org.axsl.foR.FObj getNearestGeneratingRA() { + public org.axsl.foR.FObj getNearestGeneratingRA(FOContext context) { if (this.traitIsReferenceArea()) { return this; } - return getNearestAncestorGeneratingRA(); + return getNearestAncestorGeneratingRA(context); } /** * {@inheritDoc} */ - public org.axsl.foR.fo.ListItem getNearestListItem() { - return realParent().getNearestListItem(); + public org.axsl.foR.fo.ListItem getNearestListItem(FOContext context) { + return effectiveParent(context).getNearestListItem(context); } /** * {@inheritDoc} */ - public org.axsl.foR.fo.ListBlock getNearestAncestorListBlock() { + public org.axsl.foR.fo.ListBlock getNearestAncestorListBlock( + FOContext context) { if (getParent() == null) { return null; } if (getParent() instanceof org.axsl.foR.fo.ListBlock) { return (org.axsl.foR.fo.ListBlock) getParent(); } - return realParent().getNearestAncestorListBlock(); + return effectiveParent(context).getNearestAncestorListBlock(context); } /** * {@inheritDoc} */ - public org.axsl.foR.fo.Root getRoot() { - return realParent().getRoot(); + public org.axsl.foR.fo.Root getRoot(FOContext context) { + return effectiveParent(context).getRoot(context); } /** * {@inheritDoc} */ - public org.axsl.foR.fo.Block getContainingBlock() { - return realParent().getContainingBlock(); + public org.axsl.foR.fo.Block getContainingBlock(FOContext context) { + return effectiveParent(context).getContainingBlock(context); } /** * {@inheritDoc} */ - public org.axsl.foR.fo.Flow getFlow() { + public org.axsl.foR.fo.Flow getFlow(FOContext context) { if (getParent() == null) { return null; } - return realParent().getFlow(); + return effectiveParent(context).getFlow(context); } public FOTreeBuilder getFOTreeBuilder() { @@ -257,29 +259,29 @@ /** * {@inheritDoc} */ - public org.axsl.foR.fo.Table getNearestTable() { - return realParent().getNearestTable(); + public org.axsl.foR.fo.Table getNearestTable(FOContext context) { + return effectiveParent(context).getNearestTable(context); } /** * {@inheritDoc} */ - public org.axsl.foR.fo.Leader getNearestLeader() { - return realParent().getNearestLeader(); + public org.axsl.foR.fo.Leader getNearestLeader(FOContext context) { + return effectiveParent(context).getNearestLeader(context); } /** * {@inheritDoc} */ - public org.axsl.foR.fo.BasicLink getBasicLink() { - return realParent().getBasicLink(); + public org.axsl.foR.fo.BasicLink getBasicLink(FOContext context) { + return effectiveParent(context).getBasicLink(context); } /** * {@inheritDoc} */ - public org.axsl.foR.FObj ancestorListRelatedObject() { - return realParent().ancestorListRelatedObject(); + public org.axsl.foR.FObj ancestorListRelatedObject(FOContext context) { + return effectiveParent(context).ancestorListRelatedObject(context); } /** @@ -386,103 +388,103 @@ /** * {@inheritDoc} */ - public int getMarginLeft(int widthContainingBlock) { - return propertyList.getMarginLeft(widthContainingBlock); + public int getMarginLeft(FOContext context, int widthContainingBlock) { + return propertyList.getMarginLeft(context, widthContainingBlock); } /** * {@inheritDoc} */ - public int getMarginRight(int widthContainingBlock) { - return propertyList.getMarginRight(widthContainingBlock); + public int getMarginRight(FOContext context, int widthContainingBlock) { + return propertyList.getMarginRight(context, widthContainingBlock); } /** * {@inheritDoc} */ - public int getMarginTop(int widthContainingBlock) { - return propertyList.getMarginTop(widthContainingBlock); + public int getMarginTop(FOContext context, int widthContainingBlock) { + return propertyList.getMarginTop(context, widthContainingBlock); } /** * {@inheritDoc} */ - public int getMarginBottom(int widthContainingBlock) { - return propertyList.getMarginBottom(widthContainingBlock); + public int getMarginBottom(FOContext context, int widthContainingBlock) { + return propertyList.getMarginBottom(context, widthContainingBlock); } /** * {@inheritDoc} */ - public Color traitColor() { - return propertyList.getColor(); + public Color traitColor(FOContext context) { + return propertyList.getColor(context); } /** * {@inheritDoc} */ - public short traitWrapOption() { - return propertyList.getWrapOption(); + public short traitWrapOption(FOContext context) { + return propertyList.getWrapOption(context); } /** * {@inheritDoc} */ - public boolean traitWhiteSpaceCollapse() { - return propertyList.getWhiteSpaceCollapse(); + public boolean traitWhiteSpaceCollapse(FOContext context) { + return propertyList.getWhiteSpaceCollapse(context); } /** * {@inheritDoc} */ - public boolean traitUnderlineScore() { - return propertyList.getUnderlineScore(); + public boolean traitUnderlineScore(FOContext context) { + return propertyList.getUnderlineScore(context); } /** * {@inheritDoc} */ - public boolean traitOverlineScore() { - return propertyList.getOverlineScore(); + public boolean traitOverlineScore(FOContext context) { + return propertyList.getOverlineScore(context); } /** * {@inheritDoc} */ - public boolean traitThroughScore() { - return propertyList.getThroughScore(); + public boolean traitThroughScore(FOContext context) { + return propertyList.getThroughScore(context); } /** * {@inheritDoc} */ - public Color traitUnderlineScoreColor() { + public Color traitUnderlineScoreColor(FOContext context) { /* TODO: This is not right. See Sections 5.5.6 and 7.16.4. Inheritance * is unusual here, and we need to fix it. */ - return traitColor(); + return traitColor(context); } /** * {@inheritDoc} */ - public Color traitOverlineScoreColor() { + public Color traitOverlineScoreColor(FOContext context) { // Value is the same as for underline. - return traitUnderlineScoreColor(); + return traitUnderlineScoreColor(context); } /** * {@inheritDoc} */ - public Color traitThroughScoreColor() { + public Color traitThroughScoreColor(FOContext context) { // Value is the same as for underline. - return traitUnderlineScoreColor(); + return traitUnderlineScoreColor(context); } /** * {@inheritDoc} */ - public boolean traitBlink() { - return propertyList.getBlink(); + public boolean traitBlink(FOContext context) { + return propertyList.getBlink(context); } /** @@ -509,21 +511,21 @@ /** * {@inheritDoc} */ - public int traitStartIndent(int ipdContainingRA) { - return propertyList.getIndent(Constants.DIRECTION_START, + public int traitStartIndent(FOContext context, int ipdContainingRA) { + return propertyList.getIndent(context, Constants.DIRECTION_START, ipdContainingRA); } /** * {@inheritDoc} */ - public short traitSpan() { + public short traitSpan(FOContext context) { /* * Only block-level FOs are affected by column-count, so, for all other * FOs, treat them as if the span trait were "all". */ if (this.isBlockLevelFO()) { - return propertyList.getSpan(); + return propertyList.getSpan(context); } return Constants.FOVAL_ALL; } @@ -531,43 +533,43 @@ /** * {@inheritDoc} */ - public String traitFlowName() { - return propertyList.getFlowName(); + public String traitFlowName(FOContext context) { + return propertyList.getFlowName(context); } /** * {@inheritDoc} */ - public String traitMarkerClassName() { - return propertyList.getMarkerClassName(); + public String traitMarkerClassName(FOContext context) { + return propertyList.getMarkerClassName(context); } /** * {@inheritDoc} */ - public String traitRetrieveClassName() { - return propertyList.getRetrieveClassName(); + public String traitRetrieveClassName(FOContext context) { + return propertyList.getRetrieveClassName(context); } /** * {@inheritDoc} */ - public short traitRetrievePosition() { - return propertyList.getRetrievePosition(); + public short traitRetrievePosition(FOContext context) { + return propertyList.getRetrievePosition(context); } /** * {@inheritDoc} */ - public short traitRetrieveBoundary() { - return propertyList.getRetrieveBoundary(); + public short traitRetrieveBoundary(FOContext context) { + return propertyList.getRetrieveBoundary(context); } /** * {@inheritDoc} */ - public int traitColumnNumber() { - return propertyList.getColumnNumber(); + public int traitColumnNumber(FOContext context) { + return propertyList.getColumnNumber(context); } /** @@ -587,36 +589,36 @@ /** * {@inheritDoc} */ - public short traitBorderCollapse() { - return propertyList.getBorderCollapse(); + public short traitBorderCollapse(FOContext context) { + return propertyList.getBorderCollapse(context); } /** * {@inheritDoc} */ - public short traitDisplayAlign() { - return propertyList.getDisplayAlign(); + public short traitDisplayAlign(FOContext context) { + return propertyList.getDisplayAlign(context); } /** * {@inheritDoc} */ - public short traitRelativeAlign() { - return propertyList.getRelativeAlign(); + public short traitRelativeAlign(FOContext context) { + return propertyList.getRelativeAlign(context); } /** * {@inheritDoc} */ - public int traitBorderSeparationIPD() { - return propertyList.getBorderSeparationIPD(); + public int traitBorderSeparationIPD(FOContext context) { + return propertyList.getBorderSeparationIPD(context); } /** * {@inheritDoc} */ - public int traitBorderSeparationBPD() { - return propertyList.getBorderSeparationBPD(); + public int traitBorderSeparationBPD(FOContext context) { + return propertyList.getBorderSeparationBPD(context); } /** @@ -629,8 +631,8 @@ /** * {@inheritDoc} */ - public int traitColumnWidth(int tableWidth) { - return propertyList.getColumnWidth(tableWidth); + public int traitColumnWidth(FOContext context, int tableWidth) { + return propertyList.getColumnWidth(context, tableWidth); } /** @@ -643,113 +645,114 @@ /** * {@inheritDoc} */ - public short traitBreakAfter() { - return propertyList.getBreakAfter(); + public short traitBreakAfter(FOContext context) { + return propertyList.getBreakAfter(context); } /** * {@inheritDoc} */ - public int traitKeepTogetherWithinLine() { - return propertyList.traitKeepTogetherWithinLine(); + public int traitKeepTogetherWithinLine(FOContext context) { + return propertyList.traitKeepTogetherWithinLine(context); } /** * {@inheritDoc} */ - public int traitKeepTogetherWithinColumn() { - return propertyList.traitKeepTogetherWithinColumn(); + public int traitKeepTogetherWithinColumn(FOContext context) { + return propertyList.traitKeepTogetherWithinColumn(context); } /** * {@inheritDoc} */ - public int traitKeepTogetherWithinPage() { - return propertyList.traitKeepTogetherWithinPage(); + public int traitKeepTogetherWithinPage(FOContext context) { + return propertyList.traitKeepTogetherWithinPage(context); } /** * {@inheritDoc} */ - public int traitKeepWithNextWithinLine() { - return propertyList.traitKeepWithNextWithinLine(); + public int traitKeepWithNextWithinLine(FOContext context) { + return propertyList.traitKeepWithNextWithinLine(context); } /** * {@inheritDoc} */ - public int traitKeepWithNextWithinColumn() { - return propertyList.traitKeepWithNextWithinColumn(); + public int traitKeepWithNextWithinColumn(FOContext context) { + return propertyList.traitKeepWithNextWithinColumn(context); } /** * {@inheritDoc} */ - public int traitKeepWithNextWithinPage() { - return propertyList.traitKeepWithNextWithinPage(); + public int traitKeepWithNextWithinPage(FOContext context) { + return propertyList.traitKeepWithNextWithinPage(context); } /** * {@inheritDoc} */ - public int traitKeepWithPreviousWithinLine() { - return propertyList.traitKeepWithPreviousWithinLine(); + public int traitKeepWithPreviousWithinLine(FOContext context) { + return propertyList.traitKeepWithPreviousWithinLine(context); } /** * {@inheritDoc} */ - public int traitKeepWithPreviousWithinColumn() { - return propertyList.traitKeepWithPreviousWithinColumn(); + public int traitKeepWithPreviousWithinColumn(FOContext context) { + return propertyList.traitKeepWithPreviousWithinColumn(context); } /** * {@inheritDoc} */ - public int traitKeepWithPreviousWithinPage() { - return propertyList.traitKeepWithPreviousWithinPage(); + public int traitKeepWithPreviousWithinPage(FOContext context) { + return propertyList.traitKeepWithPreviousWithinPage(context); } /** * {@inheritDoc} */ - public String traitMasterReference() { - return propertyList.getMasterReference(); + public String traitMasterReference(FOContext context) { + return propertyList.getMasterReference(context); } /** * {@inheritDoc} */ - public short traitPagePosition() { - return propertyList.getPagePosition(); + public short traitPagePosition(FOContext context) { + return propertyList.getPagePosition(context); } /** * {@inheritDoc} */ - public short traitOddOrEven() { - return propertyList.getOddOrEven(); + public short traitOddOrEven(FOContext context) { + return propertyList.getOddOrEven(context); } /** * {@inheritDoc} */ - public short traitBlankOrNotBlank() { - return propertyList.getBlankOrNotBlank(); + public short traitBlankOrNotBlank(FOContext context) { + return propertyList.getBlankOrNotBlank(context); } /** * {@inheritDoc} */ - public int traitInitialPageNumber(int lastPageNumberUsed) { - return propertyList.getInitialPageNumber(lastPageNumberUsed); + public int traitInitialPageNumber(FOContext context, + int lastPageNumberUsed) { + return propertyList.getInitialPageNumber(context, lastPageNumberUsed); } /** * {@inheritDoc} */ - public short getRawInitialPageNumber() { - return propertyList.getRawInitialPageNumber(); + public short getRawInitialPageNumber(FOContext context) { + return propertyList.getRawInitialPageNumber(context); } /** @@ -762,8 +765,8 @@ /** * {@inheritDoc} */ - public char traitGroupingSeparator() { - return propertyList.getGroupingSeparator(); + public char traitGroupingSeparator(FOContext context) { + return propertyList.getGroupingSeparator(context); } /** @@ -776,22 +779,22 @@ /** * {@inheritDoc} */ - public short traitLetterValue() { - return propertyList.getLetterValue(); + public short traitLetterValue(FOContext context) { + return propertyList.getLetterValue(context); } /** * {@inheritDoc} */ - public short traitForcePageCount() { - return propertyList.getForcePageCount(); + public short traitForcePageCount(FOContext context) { + return propertyList.getForcePageCount(context); } /** * {@inheritDoc} */ - public String traitMasterName() { - return propertyList.getMasterName(); + public String traitMasterName(FOContext context) { + return propertyList.getMasterName(context); } /** @@ -804,64 +807,64 @@ /** * {@inheritDoc} */ - public boolean traitPrecedence() { - return propertyList.getPrecedence(); + public boolean traitPrecedence(FOContext context) { + return propertyList.getPrecedence(context); } /** * {@inheritDoc} */ - public int traitExtent() { - return propertyList.getExtent(); + public int traitExtent(FOContext context) { + return propertyList.getExtent(context); } /** * {@inheritDoc} */ - public int traitColumnGap() { - return propertyList.getColumnGap(); + public int traitColumnGap(FOContext context) { + return propertyList.getColumnGap(context); } /** * {@inheritDoc} */ - public short traitOverflow() { - return propertyList.getOverflow(); + public short traitOverflow(FOContext context) { + return propertyList.getOverflow(context); } /** * {@inheritDoc} */ - public int traitColumnCount() { - return propertyList.getColumnCount(); + public int traitColumnCount(FOContext context) { + return propertyList.getColumnCount(context); } /** * {@inheritDoc} */ - public int traitMaximumRepeats() { - return propertyList.getMaximumRepeats(); + public int traitMaximumRepeats(FOContext context) { + return propertyList.getMaximumRepeats(context); } /** * {@inheritDoc} */ - public int traitPageWidth() { - return propertyList.getPageWidth(); + public int traitPageWidth(FOContext context) { + return propertyList.getPageWidth(context); } /** * {@inheritDoc} */ - public int traitPageHeight() { - return propertyList.getPageHeight(); + public int traitPageHeight(FOContext context) { + return propertyList.getPageHeight(context); } /** * {@inheritDoc} */ - public short traitTextAlign() { - return propertyList.getTextAlign(); + public short traitTextAlign(FOContext context) { + return propertyList.getTextAlign(context); } /** @@ -874,44 +877,44 @@ /** * {@inheritDoc} */ - public short traitTextAlignLast() { - return propertyList.getTextAlignLast(); + public short traitTextAlignLast(FOContext context) { + return propertyList.getTextAlignLast(context); } /** * {@inheritDoc} */ - public int traitEndIndent(int ipdContainingRA) { - return propertyList.getIndent(Constants.DIRECTION_END, + public int traitEndIndent(FOContext context, int ipdContainingRA) { + return propertyList.getIndent(context, Constants.DIRECTION_END, ipdContainingRA); } /** * {@inheritDoc} */ - public int traitSpaceBeforeMinimum() { - return propertyList.traitSpaceBeforeLength(Property.MINIMUM); + public int traitSpaceBeforeMinimum(FOContext context) { + return propertyList.traitSpaceBeforeLength(context, Property.MINIMUM); } /** * {@inheritDoc} */ - public int traitSpaceBeforeOptimum() { - return propertyList.traitSpaceBeforeLength(Property.OPTIMUM); + public int traitSpaceBeforeOptimum(FOContext context) { + return propertyList.traitSpaceBeforeLength(context, Property.OPTIMUM); } /** * {@inheritDoc} */ - public int traitSpaceBeforeMaximum() { - return propertyList.traitSpaceBeforeLength(Property.MAXIMUM); + public int traitSpaceBeforeMaximum(FOContext context) { + return propertyList.traitSpaceBeforeLength(context, Property.MAXIMUM); } /** * {@inheritDoc} */ - public short traitSpaceBeforeConditionality() { - return propertyList.traitSpaceBeforeConditionality(); + public short traitSpaceBeforeConditionality(FOContext context) { + return propertyList.traitSpaceBeforeConditionality(context); } /** @@ -924,29 +927,29 @@ /** * {@inheritDoc} */ - public int traitSpaceAfterMinimum() { - return propertyList.traitSpaceAfterLength(Property.MINIMUM); + public int traitSpaceAfterMinimum(FOContext context) { + return propertyList.traitSpaceAfterLength(context, Property.MINIMUM); } /** * {@inheritDoc} */ - public int traitSpaceAfterOptimum() { - return propertyList.traitSpaceAfterLength(Property.OPTIMUM); + public int traitSpaceAfterOptimum(FOContext context) { + return propertyList.traitSpaceAfterLength(context, Property.OPTIMUM); } /** * {@inheritDoc} */ - public int traitSpaceAfterMaximum() { - return propertyList.traitSpaceAfterLength(Property.MAXIMUM); + public int traitSpaceAfterMaximum(FOContext context) { + return propertyList.traitSpaceAfterLength(context, Property.MAXIMUM); } /** * {@inheritDoc} */ - public short traitSpaceAfterConditionality() { - return propertyList.traitSpaceAfterConditionality(); + public short traitSpaceAfterConditionality(FOContext context) { + return propertyList.traitSpaceAfterConditionality(context); } /** @@ -959,24 +962,27 @@ /** * {@inheritDoc} */ - public int traitSpaceStartMinimum(int ipdAncestorBlockArea) { - return propertyList.traitSpaceStartLength(Property.MINIMUM, + public int traitSpaceStartMinimum(FOContext context, + int ipdAncestorBlockArea) { + return propertyList.traitSpaceStartLength(context, Property.MINIMUM, ipdAncestorBlockArea); } /** * {@inheritDoc} */ - public int traitSpaceStartOptimum(int ipdAncestorBlockArea) { - return propertyList.traitSpaceStartLength(Property.OPTIMUM, + public int traitSpaceStartOptimum(FOContext context, + int ipdAncestorBlockArea) { + return propertyList.traitSpaceStartLength(context, Property.OPTIMUM, ipdAncestorBlockArea); } /** * {@inheritDoc} */ - public int traitSpaceStartMaximum(int ipdAncestorBlockArea) { - return propertyList.traitSpaceStartLength(Property.MAXIMUM, + public int traitSpaceStartMaximum(FOContext context, + int ipdAncestorBlockArea) { + return propertyList.traitSpaceStartLength(context, Property.MAXIMUM, ipdAncestorBlockArea); } @@ -997,24 +1003,27 @@ /** * {@inheritDoc} */ - public int traitSpaceEndMinimum(int ipdAncestorBlockArea) { - return propertyList.traitSpaceEndLength(Property.MINIMUM, + public int traitSpaceEndMinimum(FOContext context, + int ipdAncestorBlockArea) { + return propertyList.traitSpaceEndLength(context, Property.MINIMUM, ipdAncestorBlockArea); } /** * {@inheritDoc} */ - public int traitSpaceEndOptimum(int ipdAncestorBlockArea) { - return propertyList.traitSpaceEndLength(Property.OPTIMUM, + public int traitSpaceEndOptimum(FOContext context, + int ipdAncestorBlockArea) { + return propertyList.traitSpaceEndLength(context, Property.OPTIMUM, ipdAncestorBlockArea); } /** * {@inheritDoc} */ - public int traitSpaceEndMaximum(int ipdAncestorBlockArea) { - return propertyList.traitSpaceEndLength(Property.MAXIMUM, + public int traitSpaceEndMaximum(FOContext context, + int ipdAncestorBlockArea) { + return propertyList.traitSpaceEndLength(context, Property.MAXIMUM, ipdAncestorBlockArea); } @@ -1035,130 +1044,130 @@ /** * {@inheritDoc} */ - public int traitTextIndent(int widthContainingBlock) { - return propertyList.getTextIndent(widthContainingBlock); + public int traitTextIndent(FOContext context, int widthContainingBlock) { + return propertyList.getTextIndent(context, widthContainingBlock); } /** * {@inheritDoc} */ - public int traitTop(int heightContainingBlock) { - return propertyList.getTop(heightContainingBlock); + public int traitTop(FOContext context, int heightContainingBlock) { + return propertyList.getTop(context, heightContainingBlock); } /** * {@inheritDoc} */ - public int traitBottom(int heightContainingBlock) { - return propertyList.getBottom(heightContainingBlock); + public int traitBottom(FOContext context, int heightContainingBlock) { + return propertyList.getBottom(context, heightContainingBlock); } /** * {@inheritDoc} */ - public int traitLeft(int widthContainingBlock) { - return propertyList.getLeft(widthContainingBlock); + public int traitLeft(FOContext context, int widthContainingBlock) { + return propertyList.getLeft(context, widthContainingBlock); } /** * {@inheritDoc} */ - public int traitRight(int widthContainingBlock) { - return propertyList.getRight(widthContainingBlock); + public int traitRight(FOContext context, int widthContainingBlock) { + return propertyList.getRight(context, widthContainingBlock); } /** * {@inheritDoc} */ - public char traitCharacter() { - return propertyList.getCharacter(); + public char traitCharacter(FOContext context) { + return propertyList.getCharacter(context); } /** * {@inheritDoc} */ - public String traitSrc() { - return propertyList.getSrc(); + public String traitSrc(FOContext context) { + return propertyList.getSrc(context); } /** * {@inheritDoc} */ - public short traitBreakBefore() { - return propertyList.getBreakBefore(); + public short traitBreakBefore(FOContext context) { + return propertyList.getBreakBefore(context); } /** * {@inheritDoc} */ - public short traitScaling() { - return propertyList.getScaling(); + public short traitScaling(FOContext context) { + return propertyList.getScaling(context); } /** * {@inheritDoc} */ - public short traitLeaderPattern() { - return propertyList.getLeaderPattern(); + public short traitLeaderPattern(FOContext context) { + return propertyList.getLeaderPattern(context); } /** * {@inheritDoc} */ - public int traitLeaderLengthMin(int parentAreaCR_IPD) { - return propertyList.getLeaderLengthMinimum(parentAreaCR_IPD); + public int traitLeaderLengthMin(FOContext context, int parentAreaCR_IPD) { + return propertyList.getLeaderLengthMinimum(context, parentAreaCR_IPD); } /** * {@inheritDoc} */ - public int traitLeaderLengthOpt(int parentAreaCR_IPD) { - return propertyList.getLeaderLengthOptimum(parentAreaCR_IPD); + public int traitLeaderLengthOpt(FOContext context, int parentAreaCR_IPD) { + return propertyList.getLeaderLengthOptimum(context, parentAreaCR_IPD); } /** * {@inheritDoc} */ - public int traitLeaderLengthMax(int parentAreaCR_IPD) { - return propertyList.getLeaderLengthMaximum(parentAreaCR_IPD); + public int traitLeaderLengthMax(FOContext context, int parentAreaCR_IPD) { + return propertyList.getLeaderLengthMaximum(context, parentAreaCR_IPD); } /** * {@inheritDoc} */ - public int traitRuleThickness() { - if (traitRuleStyle() == Constants.FOVAL_NONE) { + public int traitRuleThickness(FOContext context) { + if (traitRuleStyle(context) == Constants.FOVAL_NONE) { return 0; } - return propertyList.getRuleThickness(); + return propertyList.getRuleThickness(context); } /** * {@inheritDoc} */ - public short traitRuleStyle() { - return propertyList.getRuleStyle(); + public short traitRuleStyle(FOContext context) { + return propertyList.getRuleStyle(context); } /** * {@inheritDoc} */ - public int traitLeaderPatternWidth(int ipd_CR_Parent) { - return propertyList.getLeaderPatternWidth(ipd_CR_Parent); + public int traitLeaderPatternWidth(FOContext context, int ipd_CR_Parent) { + return propertyList.getLeaderPatternWidth(context, ipd_CR_Parent); } /** * {@inheritDoc} */ - public short traitLeaderAlignment() { - return propertyList.getLeaderAlignment(); + public short traitLeaderAlignment(FOContext context) { + return propertyList.getLeaderAlignment(context); } /** * {@inheritDoc} */ - public String traitRefId() { - return propertyList.getRefId(); + public String traitRefId(FOContext context) { + return propertyList.getRefId(context); } /** @@ -1171,107 +1180,107 @@ /** * {@inheritDoc} */ - public boolean traitTableOmitHeaderAtBreak() { - return propertyList.getTableOmitHeaderAtBreak(); + public boolean traitTableOmitHeaderAtBreak(FOContext context) { + return propertyList.getTableOmitHeaderAtBreak(context); } /** * {@inheritDoc} */ - public boolean traitTableOmitFooterAtBreak() { - return propertyList.getTableOmitFooterAtBreak(); + public boolean traitTableOmitFooterAtBreak(FOContext context) { + return propertyList.getTableOmitFooterAtBreak(context); } /** * {@inheritDoc} */ - public int traitBPDimensionMax(int parentAreaCR_BPD) { - return propertyList.traitBPDimensionMax(parentAreaCR_BPD); + public int traitBPDimensionMax(FOContext context, int parentAreaCR_BPD) { + return propertyList.traitBPDimensionMax(context, parentAreaCR_BPD); } /** * {@inheritDoc} */ - public int traitBPDimensionOpt(int parentAreaCR_BPD) { - return propertyList.traitBPDimensionOpt(parentAreaCR_BPD); + public int traitBPDimensionOpt(FOContext context, int parentAreaCR_BPD) { + return propertyList.traitBPDimensionOpt(context, parentAreaCR_BPD); } /** * {@inheritDoc} */ - public int traitBPDimensionMin(int parentAreaCR_BPD) { - return propertyList.traitBPDimensionMin(parent... [truncated message content] |