foray-commit Mailing List for FOray (Page 60)
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
(4) |
Dec
|
|
From: <vic...@us...> - 2022-01-15 01:19:05
|
Revision: 12402
http://sourceforge.net/p/foray/code/12402
Author: victormote
Date: 2022-01-15 01:19:03 +0000 (Sat, 15 Jan 2022)
Log Message:
-----------
Turn transitive resolution off for more dependencies.
Modified Paths:
--------------
trunk/foray/foray-graphic/build.gradle
trunk/foray/foray-orthography/build.gradle
Modified: trunk/foray/foray-graphic/build.gradle
===================================================================
--- trunk/foray/foray-graphic/build.gradle 2022-01-14 22:49:06 UTC (rev 12401)
+++ trunk/foray/foray-graphic/build.gradle 2022-01-15 01:19:03 UTC (rev 12402)
@@ -1,32 +1,32 @@
description = 'foray-graphic'
dependencies {
- api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
- api group: 'commons-io', name: 'commons-io', version: commonsIoVersion
- api group: 'org.apache.xmlgraphics', name: 'xmlgraphics-commons', version: xmlgraphicsCommonsVersion
- api group: 'org.apache.xmlgraphics', name: 'batik-bridge', version: batikVersion
- api group: 'org.apache.xmlgraphics', name: 'batik-gvt', version: batikVersion
- api group: 'org.apache.xmlgraphics', name: 'batik-parser', version: batikVersion
- api group: 'org.apache.xmlgraphics', name: 'batik-transcoder', version: batikVersion
- api group: 'org.apache.xmlgraphics', name: 'batik-svg-dom', version: batikVersion
- api group: 'org.apache.xmlgraphics', name: 'batik-css', version: batikVersion
-// api group: 'net.sourceforge.jeuclid', name: 'jeuclid-core', version: jeuclidVersion
- api group: 'de.rototor.jeuclid', name: 'jeuclid-core', version: jeuclidVersion
+ api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
+ api group: 'commons-io', name: 'commons-io', version: commonsIoVersion
+ api group: 'org.apache.xmlgraphics', name: 'xmlgraphics-commons', version: xmlgraphicsCommonsVersion
+ api group: 'org.apache.xmlgraphics', name: 'batik-bridge', version: batikVersion
+ api group: 'org.apache.xmlgraphics', name: 'batik-gvt', version: batikVersion
+ api group: 'org.apache.xmlgraphics', name: 'batik-parser', version: batikVersion
+ api group: 'org.apache.xmlgraphics', name: 'batik-transcoder', version: batikVersion
+ api group: 'org.apache.xmlgraphics', name: 'batik-svg-dom', version: batikVersion
+ api group: 'org.apache.xmlgraphics', name: 'batik-css', version: batikVersion
+// api group: 'net.sourceforge.jeuclid', name: 'jeuclid-core', version: jeuclidVersion
+ api group: 'de.rototor.jeuclid', name: 'jeuclid-core', version: jeuclidVersion
-
/* Turn transitive resolution OFF for both aXSL and FOray modules, for greater design visibility. */
- api (group: 'org.axsl', name: 'axsl-common', version: axslVersion) { transitive = false }
- api (group: 'org.axsl', name: 'axsl-font', version: axslVersion) { transitive = false }
- api (group: 'org.axsl', name: 'axsl-graphic', version: axslVersion) { transitive = false }
- api (group: 'org.axsl', name: 'axsl-orthography', version: axslVersion) { transitive = false }
- api (group: 'org.axsl', name: 'axsl-pdf', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-common', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-font', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-graphic', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-orthography', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-pdf', version: axslVersion) { transitive = false }
+
api (project(':foray-common')) { transitive = false }
api (project(':foray-xml')) { transitive = false }
- implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
+ implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
- testImplementation group: 'junit', name: 'junit', version: junitVersion
+ testImplementation group: 'junit', name: 'junit', version: junitVersion
}
javadoc {
Modified: trunk/foray/foray-orthography/build.gradle
===================================================================
--- trunk/foray/foray-orthography/build.gradle 2022-01-14 22:49:06 UTC (rev 12401)
+++ trunk/foray/foray-orthography/build.gradle 2022-01-15 01:19:03 UTC (rev 12402)
@@ -1,23 +1,26 @@
description = 'foray-orthography'
dependencies {
- api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
- api group: 'xml-resolver', name: 'xml-resolver', version: xmlResolverVersion
- api group: 'org.apache.ant', name: 'ant-launcher', version: antVersion
- api group: 'commons-cli', name: 'commons-cli', version: commonsCliVersion
- api group: 'commons-io', name: 'commons-io', version: commonsIoVersion
- api group: 'com.ibm.icu', name: 'icu4j', version: icu4jVersion
+ api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
+ api group: 'xml-resolver', name: 'xml-resolver', version: xmlResolverVersion
+ api group: 'org.apache.ant', name: 'ant-launcher', version: antVersion
+ api group: 'commons-cli', name: 'commons-cli', version: commonsCliVersion
+ api group: 'commons-io', name: 'commons-io', version: commonsIoVersion
+ api group: 'com.ibm.icu', name: 'icu4j', version: icu4jVersion
- api group: 'org.axsl', name: 'axsl-common', version: axslVersion
- api group: 'org.axsl', name: 'axsl-orthography', version: axslVersion
- api group: 'org.axsl', name: 'axsl-fotree', version: axslVersion
- api group: 'org.axsl', name: 'axsl-kp-model', version: axslVersion
- api group: 'org.axsl', name: 'axsl-unicode', version: axslVersion
- api project(':foray-common')
+ /* Turn transitive resolution OFF for both aXSL and FOray modules, for greater design visibility. */
- implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
+ api (group: 'org.axsl', name: 'axsl-common', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-orthography', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-fotree', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-kp-model', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-unicode', version: axslVersion) { transitive = false }
- testImplementation group: 'junit', name: 'junit', version: junitVersion
+ api (project(':foray-common')) { transitive = false }
+
+ implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
+
+ testImplementation group: 'junit', name: 'junit', version: junitVersion
testImplementation group: 'org.mockito', name: 'mockito-core', version: mockitoVersion
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-14 22:49:08
|
Revision: 12401
http://sourceforge.net/p/foray/code/12401
Author: victormote
Date: 2022-01-14 22:49:06 +0000 (Fri, 14 Jan 2022)
Log Message:
-----------
Turn off transitive resolution for aXSL and FOray dependencies.
Modified Paths:
--------------
trunk/foray/foray-graphic/build.gradle
trunk/foray/master/build.gradle
Modified: trunk/foray/foray-graphic/build.gradle
===================================================================
--- trunk/foray/foray-graphic/build.gradle 2022-01-14 21:39:24 UTC (rev 12400)
+++ trunk/foray/foray-graphic/build.gradle 2022-01-14 22:49:06 UTC (rev 12401)
@@ -12,11 +12,18 @@
api group: 'org.apache.xmlgraphics', name: 'batik-css', version: batikVersion
// api group: 'net.sourceforge.jeuclid', name: 'jeuclid-core', version: jeuclidVersion
api group: 'de.rototor.jeuclid', name: 'jeuclid-core', version: jeuclidVersion
- api group: 'org.axsl', name: 'axsl-graphic', version: axslVersion
- api group: 'org.axsl', name: 'axsl-pdf', version: axslVersion
- api project(':foray-common')
- api project(':foray-xml')
+
+ /* Turn transitive resolution OFF for both aXSL and FOray modules, for greater design visibility. */
+ api (group: 'org.axsl', name: 'axsl-common', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-font', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-graphic', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-orthography', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-pdf', version: axslVersion) { transitive = false }
+
+ api (project(':foray-common')) { transitive = false }
+ api (project(':foray-xml')) { transitive = false }
+
implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
testImplementation group: 'junit', name: 'junit', version: junitVersion
Modified: trunk/foray/master/build.gradle
===================================================================
--- trunk/foray/master/build.gradle 2022-01-14 21:39:24 UTC (rev 12400)
+++ trunk/foray/master/build.gradle 2022-01-14 22:49:06 UTC (rev 12401)
@@ -93,12 +93,6 @@
*
*/
- /* Force each project to declare its dependencies explicitly instead of transitively. This should make it easier to
- see dependencies that are design flaws. */
-// configurations.all {
-// transitive = false
-// }
-
}
subprojects {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-14 21:39:26
|
Revision: 12400
http://sourceforge.net/p/foray/code/12400
Author: victormote
Date: 2022-01-14 21:39:24 +0000 (Fri, 14 Jan 2022)
Log Message:
-----------
Convert some projects to explicit (instead of transitive) dependencies.
Modified Paths:
--------------
trunk/foray/foray-app/build.gradle
trunk/foray/foray-core/build.gradle
trunk/foray/foray-pioneer/build.gradle
Modified: trunk/foray/foray-app/build.gradle
===================================================================
--- trunk/foray/foray-app/build.gradle 2022-01-14 21:04:01 UTC (rev 12399)
+++ trunk/foray/foray-app/build.gradle 2022-01-14 21:39:24 UTC (rev 12400)
@@ -1,13 +1,28 @@
description = 'foray-app'
dependencies {
- api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
- api group: 'javax.servlet', name: 'javax.servlet-api', version: servletApiVersion
- api group: 'xml-resolver', name: 'xml-resolver', version: xmlResolverVersion
-// api group: 'xerces', name: 'xercesImpl', version: xercesImplVersion
- api group: 'org.apache.ant', name: 'ant', version: antVersion
- api group: 'commons-io', name: 'commons-io', version: commonsIoVersion
- api group: 'commons-cli', name: 'commons-cli', version: commonsCliVersion
+ api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
+ api group: 'javax.servlet', name: 'javax.servlet-api', version: servletApiVersion
+ api group: 'xml-resolver', name: 'xml-resolver', version: xmlResolverVersion
+// api group: 'xerces', name: 'xercesImpl', version: xercesImplVersion
+ api group: 'org.apache.ant', name: 'ant', version: antVersion
+ api group: 'commons-io', name: 'commons-io', version: commonsIoVersion
+ api group: 'commons-cli', name: 'commons-cli', version: commonsCliVersion
+
+ api group: 'org.axsl', name: 'axsl-font', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-linebreak', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-ps', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-areatree', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-output', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-fotree', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-galley', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-orthography', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-graphic', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-layout', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-speech', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-mif', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-pdf', version: axslVersion
+
api project(':foray-areatree')
api project(':foray-common')
Modified: trunk/foray/foray-core/build.gradle
===================================================================
--- trunk/foray/foray-core/build.gradle 2022-01-14 21:04:01 UTC (rev 12399)
+++ trunk/foray/foray-core/build.gradle 2022-01-14 21:39:24 UTC (rev 12400)
@@ -6,6 +6,7 @@
api group: 'org.axsl', name: 'axsl-areatree', version: axslVersion
api group: 'org.axsl', name: 'axsl-common', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-fotree', version: axslVersion
api group: 'org.axsl', name: 'axsl-font', version: axslVersion
api group: 'org.axsl', name: 'axsl-galley', version: axslVersion
api group: 'org.axsl', name: 'axsl-graphic', version: axslVersion
Modified: trunk/foray/foray-pioneer/build.gradle
===================================================================
--- trunk/foray/foray-pioneer/build.gradle 2022-01-14 21:04:01 UTC (rev 12399)
+++ trunk/foray/foray-pioneer/build.gradle 2022-01-14 21:39:24 UTC (rev 12400)
@@ -2,7 +2,18 @@
dependencies {
api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
+
+ api group: 'org.axsl', name: 'axsl-common', version: axslVersion
api group: 'org.axsl', name: 'axsl-layout', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-fotree', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-areatree', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-galley', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-linebreak', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-kp-model', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-graphic', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-font', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-orthography', version: axslVersion
+
api project(':foray-common')
api project(':foray-layout')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-14 21:04:04
|
Revision: 12399
http://sourceforge.net/p/foray/code/12399
Author: victormote
Date: 2022-01-14 21:04:01 +0000 (Fri, 14 Jan 2022)
Log Message:
-----------
Convert some projects to explicit (instead of transitive) dependencies.
Modified Paths:
--------------
trunk/foray/foray-fotree/build.gradle
trunk/foray/foray-layout/build.gradle
trunk/foray/master/build.gradle
Modified: trunk/foray/foray-fotree/build.gradle
===================================================================
--- trunk/foray/foray-fotree/build.gradle 2022-01-14 19:57:53 UTC (rev 12398)
+++ trunk/foray/foray-fotree/build.gradle 2022-01-14 21:04:01 UTC (rev 12399)
@@ -1,14 +1,26 @@
description = 'foray-fotree'
dependencies {
- api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
- api group: 'org.axsl', name: 'axsl-fotree', version: axslVersion
+ api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
+ api group: 'org.axsl.org.w3c.dom.svg', name: 'svg-dom-java', version: svgDomVersion
+ api group: 'org.axsl.org.w3c.dom.mathml', name: 'mathml-dom-java', version: mathMlDomVersion
+
+ api group: 'org.axsl', name: 'axsl-fotree', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-common', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-font', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-graphic', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-orthography', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-speech', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-linebreak', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-kp-model', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-unicode', version: axslVersion
+
api project(':foray-common')
- implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
+ implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
- testImplementation group: 'junit', name: 'junit', version: junitVersion
- testImplementation group: 'org.mockito', name: 'mockito-core', version: mockitoVersion
+ testImplementation group: 'junit', name: 'junit', version: junitVersion
+ testImplementation group: 'org.mockito', name: 'mockito-core', version: mockitoVersion
}
javadoc {
Modified: trunk/foray/foray-layout/build.gradle
===================================================================
--- trunk/foray/foray-layout/build.gradle 2022-01-14 19:57:53 UTC (rev 12398)
+++ trunk/foray/foray-layout/build.gradle 2022-01-14 21:04:01 UTC (rev 12399)
@@ -2,7 +2,13 @@
dependencies {
api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
+
api group: 'org.axsl', name: 'axsl-layout', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-areatree', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-galley', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-fotree', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-linebreak', version: axslVersion
+
api project(':foray-common')
implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
Modified: trunk/foray/master/build.gradle
===================================================================
--- trunk/foray/master/build.gradle 2022-01-14 19:57:53 UTC (rev 12398)
+++ trunk/foray/master/build.gradle 2022-01-14 21:04:01 UTC (rev 12399)
@@ -93,8 +93,8 @@
*
*/
- /* Force each project to delare its dependencies explicitly. This should make it easier to see dependencies that
- are design flaws. */
+ /* Force each project to declare its dependencies explicitly instead of transitively. This should make it easier to
+ see dependencies that are design flaws. */
// configurations.all {
// transitive = false
// }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-14 19:57:56
|
Revision: 12398
http://sourceforge.net/p/foray/code/12398
Author: victormote
Date: 2022-01-14 19:57:53 +0000 (Fri, 14 Jan 2022)
Log Message:
-----------
Convert some projects to explicit (instead of transitive) dependencies.
Modified Paths:
--------------
trunk/foray/foray-common/build.gradle
trunk/foray/foray-font/build.gradle
trunk/foray/foray-mif/build.gradle
trunk/foray/foray-orthography/build.gradle
trunk/foray/foray-output/build.gradle
trunk/foray/foray-ps/build.gradle
trunk/foray/master/build.gradle
Modified: trunk/foray/foray-common/build.gradle
===================================================================
--- trunk/foray/foray-common/build.gradle 2022-01-14 16:15:11 UTC (rev 12397)
+++ trunk/foray/foray-common/build.gradle 2022-01-14 19:57:53 UTC (rev 12398)
@@ -1,21 +1,25 @@
description = 'foray-common'
dependencies {
- api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
- api group: 'commons-io', name: 'commons-io', version: commonsIoVersion
- api group: 'xml-resolver', name: 'xml-resolver', version: xmlResolverVersion
- api group: 'com.ibm.icu', name: 'icu4j', version: icu4jVersion
+ api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
+ api group: 'commons-io', name: 'commons-io', version: commonsIoVersion
+ api group: 'xml-resolver', name: 'xml-resolver', version: xmlResolverVersion
+ api group: 'com.ibm.icu', name: 'icu4j', version: icu4jVersion
- api group: 'org.axsl', name: 'axsl-common', version: axslVersion
- api group: 'org.axsl', name: 'axsl-kp-model', version: axslVersion
- api group: 'org.axsl', name: 'axsl-ps', version: axslVersion
- api group: 'org.axsl', name: 'axsl-font', version: axslVersion
- api group: 'org.axsl', name: 'axsl-unicode', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-common', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-kp-model', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-orthography', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-ps', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-font', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-unicode', version: axslVersion
- implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
+ implementation group:
+ 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
- testImplementation group: 'junit', name: 'junit', version: junitVersion
- testImplementation group: 'org.mockito', name: 'mockito-core', version: mockitoVersion
+ testImplementation group:
+ 'junit', name: 'junit', version: junitVersion
+ testImplementation group:
+ 'org.mockito', name: 'mockito-core', version: mockitoVersion
}
javadoc {
Modified: trunk/foray/foray-font/build.gradle
===================================================================
--- trunk/foray/foray-font/build.gradle 2022-01-14 16:15:11 UTC (rev 12397)
+++ trunk/foray/foray-font/build.gradle 2022-01-14 19:57:53 UTC (rev 12398)
@@ -9,6 +9,9 @@
api group: 'org.axsl', name: 'axsl-common', version: axslVersion
api group: 'org.axsl', name: 'axsl-font', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-ps', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-orthography', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-unicode', version: axslVersion
api project(':foray-common')
api project(':foray-ps')
Modified: trunk/foray/foray-mif/build.gradle
===================================================================
--- trunk/foray/foray-mif/build.gradle 2022-01-14 16:15:11 UTC (rev 12397)
+++ trunk/foray/foray-mif/build.gradle 2022-01-14 19:57:53 UTC (rev 12398)
@@ -2,7 +2,10 @@
dependencies {
api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
+
api group: 'org.axsl', name: 'axsl-mif', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-output', version: axslVersion
+
api project(':foray-common')
implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
Modified: trunk/foray/foray-orthography/build.gradle
===================================================================
--- trunk/foray/foray-orthography/build.gradle 2022-01-14 16:15:11 UTC (rev 12397)
+++ trunk/foray/foray-orthography/build.gradle 2022-01-14 19:57:53 UTC (rev 12398)
@@ -5,9 +5,14 @@
api group: 'xml-resolver', name: 'xml-resolver', version: xmlResolverVersion
api group: 'org.apache.ant', name: 'ant-launcher', version: antVersion
api group: 'commons-cli', name: 'commons-cli', version: commonsCliVersion
+ api group: 'commons-io', name: 'commons-io', version: commonsIoVersion
api group: 'com.ibm.icu', name: 'icu4j', version: icu4jVersion
+
+ api group: 'org.axsl', name: 'axsl-common', version: axslVersion
api group: 'org.axsl', name: 'axsl-orthography', version: axslVersion
api group: 'org.axsl', name: 'axsl-fotree', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-kp-model', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-unicode', version: axslVersion
api project(':foray-common')
implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
Modified: trunk/foray/foray-output/build.gradle
===================================================================
--- trunk/foray/foray-output/build.gradle 2022-01-14 16:15:11 UTC (rev 12397)
+++ trunk/foray/foray-output/build.gradle 2022-01-14 19:57:53 UTC (rev 12398)
@@ -2,9 +2,12 @@
dependencies {
api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
+
+ api group: 'org.axsl', name: 'axsl-font', version: axslVersion
api group: 'org.axsl', name: 'axsl-output', version: axslVersion
api group: 'org.axsl', name: 'axsl-mif', version: axslVersion
api group: 'org.axsl', name: 'axsl-fotree', version: axslVersion
+
api project(':foray-common')
implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
Modified: trunk/foray/foray-ps/build.gradle
===================================================================
--- trunk/foray/foray-ps/build.gradle 2022-01-14 16:15:11 UTC (rev 12397)
+++ trunk/foray/foray-ps/build.gradle 2022-01-14 19:57:53 UTC (rev 12398)
@@ -1,15 +1,18 @@
description = 'foray-ps'
dependencies {
- api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
- api group: 'commons-cli', name: 'commons-cli', version: commonsCliVersion
- api group: 'org.axsl', name: 'axsl-common', version: axslVersion
- api group: 'org.axsl', name: 'axsl-ps', version: axslVersion
+ api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
+ api group: 'commons-cli', name: 'commons-cli', version: commonsCliVersion
+ api group: 'commons-io', name: 'commons-io', version: commonsIoVersion
+
+ api group: 'org.axsl', name: 'axsl-common', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-ps', version: axslVersion
+
api project(':foray-common')
- implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
+ implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
- testImplementation group: 'junit', name: 'junit', version: junitVersion
+ testImplementation group: 'junit', name: 'junit', version: junitVersion
}
javadoc {
Modified: trunk/foray/master/build.gradle
===================================================================
--- trunk/foray/master/build.gradle 2022-01-14 16:15:11 UTC (rev 12397)
+++ trunk/foray/master/build.gradle 2022-01-14 19:57:53 UTC (rev 12398)
@@ -32,8 +32,13 @@
/******************** See Note 1 below for information about dependency releases. ********************/
ext.javaSourceCompatibility = JavaVersion.VERSION_1_7
ext.javaTargetCompatibility = JavaVersion.VERSION_1_7
-
+
+ /* Dependencies related to aXSL. These should be maintained at the same versions used by aXSL. */
ext.axslVersion = '0.3-SNAPSHOT' // Latest is 0.3-SNAPSHOT as of 2021-01-12. See Note 2.
+ ext.svgDomVersion = '1.1' // See aXSL master/build.gradle
+ ext.mathMlDomVersion = '2.0' // See aXSL master/build.gradle
+ /* End of aXSL-related dependencies. */
+
ext.slf4jVersion = '1.7.30' // Latest is 1.7.30 as of 2021-01-12.
ext.commonsIoVersion = '2.6' // Latest is 2.8.0 as of 2021-01-12. See Note 3.
ext.commonsDiscoveryVersion = '0.5' // Latest is 0.5 as of 2021-01-12.
@@ -88,6 +93,12 @@
*
*/
+ /* Force each project to delare its dependencies explicitly. This should make it easier to see dependencies that
+ are design flaws. */
+// configurations.all {
+// transitive = false
+// }
+
}
subprojects {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-14 16:15:18
|
Revision: 12397
http://sourceforge.net/p/foray/code/12397
Author: victormote
Date: 2022-01-14 16:15:11 +0000 (Fri, 14 Jan 2022)
Log Message:
-----------
Conform to aXSL change: Break the Knuth-Plass model interfaces into a new project axsl-kp-model.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractAncestralInlineArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/NormalBlockArea4a.java
trunk/foray/foray-common/build.gradle
trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBox4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBoxChars.java
trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4aIterator.java
trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaConfig4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaGlue4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaGlueChars.java
trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaLeaf4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaPenalty4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaPenaltyChars.java
trunk/foray/foray-common/src/test/java/org/foray/common/para/ParaBranch4aTests.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/BlockDiscrete4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/BestFitLb.java
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LbBreakpoint.java
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LbNodeWrapper.java
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/ParaContentIterator.java
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/TotalFitLb.java
trunk/foray/foray-linebreak/src/main/java/org/foray/text/TextServer4a.java
trunk/foray/foray-linebreak/src/main/java/org/foray/text/line/EagerLineBreaker.java
trunk/foray/foray-linebreak/src/main/java/org/foray/text/line/LineBreaker.java
trunk/foray/foray-linebreak/src/main/java/org/foray/text/line/solitary/SolitaryLineBreaker.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/TotalFitLbTests.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/util/DumpLayout.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/util/DumpParaBranch.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/DiscretionaryHyphen4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/DiscretionaryHyphenMutating4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Punctuation4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWord.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentLatin1.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentUtf16.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Word4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/WordSegment4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/CapitalizedWord.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/DecoratedWord.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/ExactWord.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPast1Word.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPlural1Word.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPlural2Word.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPossessive1Word.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPossessive2Word.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/UppercaseWord.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/HyphenationConsumer4aTests.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/SegmentDictionaryWordTests.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/WordWrapperTests.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/BlockDiscretePnr.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractAncestralInlineArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractAncestralInlineArea.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractAncestralInlineArea.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -31,8 +31,6 @@
import org.foray.common.FontContext4a;
import org.axsl.area.AreaTreeException;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaLeaf;
import org.axsl.font.FontContext;
import org.axsl.fotree.fo.BasicLink;
import org.axsl.fotree.fo.BidiOverride;
@@ -52,6 +50,8 @@
import org.axsl.fotree.fo.ScalingValueCitation;
import org.axsl.fotree.text.FoTokenFlow;
import org.axsl.galley.GlyphAreaSequenceG5;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaLeaf;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -33,8 +33,6 @@
import org.axsl.area.AreaTreeException;
import org.axsl.area.LineArea;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaLeaf;
import org.axsl.common.value.Conditionality;
import org.axsl.common.value.LineStackingStrategy;
import org.axsl.common.value.RelativeAxis;
@@ -67,6 +65,8 @@
import org.axsl.galley.GalleyVisitor;
import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GlyphAreaSequenceG5;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaLeaf;
import java.util.ArrayList;
import java.util.Iterator;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/NormalBlockArea4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/NormalBlockArea4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/NormalBlockArea4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -34,8 +34,6 @@
import org.axsl.area.AreaTreeException;
import org.axsl.area.NormalBlockArea;
import org.axsl.area.factory.BlockLevelAreaFactory;
-import org.axsl.common.para.ParaContext;
-import org.axsl.common.para.ParaPenalty;
import org.axsl.common.value.BackgroundRepeat;
import org.axsl.common.value.BorderStyle;
import org.axsl.common.value.RelativeAxis;
@@ -51,6 +49,8 @@
import org.axsl.galley.GalleyVisitor;
import org.axsl.galley.GalleyVisitorException;
import org.axsl.graphic.Graphic;
+import org.axsl.kpModel.ParaContext;
+import org.axsl.kpModel.ParaPenalty;
import java.awt.Color;
import java.util.ArrayList;
Modified: trunk/foray/foray-common/build.gradle
===================================================================
--- trunk/foray/foray-common/build.gradle 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-common/build.gradle 2022-01-14 16:15:11 UTC (rev 12397)
@@ -7,6 +7,7 @@
api group: 'com.ibm.icu', name: 'icu4j', version: icu4jVersion
api group: 'org.axsl', name: 'axsl-common', version: axslVersion
+ api group: 'org.axsl', name: 'axsl-kp-model', version: axslVersion
api group: 'org.axsl', name: 'axsl-ps', version: axslVersion
api group: 'org.axsl', name: 'axsl-font', version: axslVersion
api group: 'org.axsl', name: 'axsl-unicode', version: axslVersion
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBox4a.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBox4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBox4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -30,9 +30,9 @@
import org.foray.common.primitive.StringUtils;
-import org.axsl.common.para.ParaBox;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaLeaf;
+import org.axsl.kpModel.ParaBox;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaLeaf;
/**
* A hard-wired implementation of a Knuth-Plass box.
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBoxChars.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBoxChars.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBoxChars.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -28,11 +28,11 @@
package org.foray.common.para;
-import org.axsl.common.para.ParaBox;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaGlue;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaPenalty;
+import org.axsl.kpModel.ParaBox;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaGlue;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaPenalty;
/**
* An implementation of Knuth-Plass penalty that wraps text content.
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4a.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -28,9 +28,9 @@
package org.foray.common.para;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaNode;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaNode;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4aIterator.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4aIterator.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4aIterator.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -31,9 +31,9 @@
import org.foray.common.MarkedIndexOutOfBoundsException;
import org.foray.common.sequence.IntArrayBuilder;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaNode;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaNode;
import java.util.ListIterator;
import java.util.NoSuchElementException;
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaConfig4a.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaConfig4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaConfig4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -28,11 +28,11 @@
package org.foray.common.para;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaGlue;
-import org.axsl.common.para.ParaLeaf;
import org.axsl.font.FontContext;
import org.axsl.font.FontUse;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaGlue;
+import org.axsl.kpModel.ParaLeaf;
import org.axsl.orthography.Orthography;
/**
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaGlue4a.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaGlue4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaGlue4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -30,11 +30,11 @@
import org.foray.common.primitive.StringUtils;
-import org.axsl.common.para.ParaBox;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaGlue;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaPenalty;
+import org.axsl.kpModel.ParaBox;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaGlue;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaPenalty;
/**
* A hard-wired implementation of a Knuth-Plass glue item.
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaGlueChars.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaGlueChars.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaGlueChars.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -28,11 +28,11 @@
package org.foray.common.para;
-import org.axsl.common.para.ParaBox;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaGlue;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaPenalty;
+import org.axsl.kpModel.ParaBox;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaGlue;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaPenalty;
/**
* An implementation of Knuth-Plass glue that wraps text content.
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaLeaf4a.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaLeaf4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaLeaf4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -28,9 +28,9 @@
package org.foray.common.para;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaNode;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaNode;
/**
* Abstract superclass for FOray implementations of {@link ParaLeaf}.
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaPenalty4a.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaPenalty4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaPenalty4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -30,12 +30,12 @@
import org.foray.common.primitive.StringUtils;
-import org.axsl.common.para.ParaBox;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaContext;
-import org.axsl.common.para.ParaGlue;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaPenalty;
+import org.axsl.kpModel.ParaBox;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaContext;
+import org.axsl.kpModel.ParaGlue;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaPenalty;
/**
* A hard-wired implementation of Knuth-Plass penalty.
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaPenaltyChars.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaPenaltyChars.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaPenaltyChars.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -28,12 +28,12 @@
package org.foray.common.para;
-import org.axsl.common.para.ParaBox;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaContext;
-import org.axsl.common.para.ParaGlue;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaPenalty;
+import org.axsl.kpModel.ParaBox;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaContext;
+import org.axsl.kpModel.ParaGlue;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaPenalty;
/**
* An implementation of Knuth-Plass penalty that wraps text content.
Modified: trunk/foray/foray-common/src/test/java/org/foray/common/para/ParaBranch4aTests.java
===================================================================
--- trunk/foray/foray-common/src/test/java/org/foray/common/para/ParaBranch4aTests.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-common/src/test/java/org/foray/common/para/ParaBranch4aTests.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -28,7 +28,7 @@
package org.foray.common.para;
-import org.axsl.common.para.ParaPenalty;
+import org.axsl.kpModel.ParaPenalty;
import org.junit.Assert;
import org.junit.Test;
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -60,9 +60,6 @@
import org.foray.fotree.value.DtWritingMode;
import org.axsl.common.i18n.Script;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaGlue;
-import org.axsl.common.para.ParaLeaf;
import org.axsl.common.value.AbsoluteDirection;
import org.axsl.common.value.AbsolutePosition;
import org.axsl.common.value.ActiveState;
@@ -143,6 +140,9 @@
import org.axsl.fotree.text.FoOrthographyServer;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicServer;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaGlue;
+import org.axsl.kpModel.ParaLeaf;
import org.axsl.orthography.Orthography;
import org.axsl.orthography.OrthographyServer;
import org.axsl.orthography.WritingSystem;
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/BlockDiscrete4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/BlockDiscrete4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/BlockDiscrete4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -35,14 +35,14 @@
import org.foray.fotree.Namespace;
import org.foray.fotree.PropertyList;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaNode;
import org.axsl.font.FontUse;
import org.axsl.fotree.FoContext;
import org.axsl.fotree.FoTreeException;
import org.axsl.fotree.FoVisitor;
import org.axsl.fotree.fo.BlockDiscrete;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaNode;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -30,7 +30,6 @@
import org.foray.fotree.FoObj;
-import org.axsl.common.para.ParaNode;
import org.axsl.fotree.FoVisitor;
import org.axsl.fotree.fo.FoTextWords;
import org.axsl.fotree.text.FoOrthography;
@@ -37,6 +36,7 @@
import org.axsl.fotree.text.FoOrthographyServer;
import org.axsl.fotree.text.FoToken;
import org.axsl.fotree.text.FoTokenFlow;
+import org.axsl.kpModel.ParaNode;
import org.axsl.orthography.OrthographyException;
import org.axsl.orthography.Whitespace;
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/BestFitLb.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/BestFitLb.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/BestFitLb.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -28,9 +28,9 @@
package org.foray.linebreak;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaContext;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaContext;
/**
* Implementation of the Knuth-Plass "best-fit" linebreaking algorithm.
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -30,12 +30,12 @@
import org.foray.common.sequence.IntArrayBuilder;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaContext;
-import org.axsl.common.para.ParaGlue;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaPenalty;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaContext;
+import org.axsl.kpModel.ParaGlue;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaPenalty;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LbBreakpoint.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LbBreakpoint.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LbBreakpoint.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -28,7 +28,7 @@
package org.foray.linebreak;
-import org.axsl.common.para.ParaContext;
+import org.axsl.kpModel.ParaContext;
import org.axsl.linebreak.KpFitnessClass;
/**
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LbNodeWrapper.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LbNodeWrapper.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LbNodeWrapper.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -30,10 +30,10 @@
import org.foray.common.data.OrderedTreePath4a;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaContext;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaPenalty;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaContext;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaPenalty;
import java.util.List;
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/ParaContentIterator.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/ParaContentIterator.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/ParaContentIterator.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -31,8 +31,8 @@
import org.foray.common.data.OrderedTreePath4a;
import org.foray.common.sequence.IntArrayBuilder;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaNode;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaNode;
import java.util.Iterator;
import java.util.Stack;
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/TotalFitLb.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/TotalFitLb.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/TotalFitLb.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -34,14 +34,14 @@
import org.foray.common.primitive.BooleanUtils;
import org.foray.common.sequence.IntArrayBuilder;
-import org.axsl.common.para.ParaBox;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaContext;
-import org.axsl.common.para.ParaGlue;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaNode;
-import org.axsl.common.para.ParaPenalty;
+import org.axsl.kpModel.ParaBox;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaContext;
+import org.axsl.kpModel.ParaGlue;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaNode;
+import org.axsl.kpModel.ParaPenalty;
import org.axsl.linebreak.KpFitnessClass;
import java.util.ArrayList;
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/text/TextServer4a.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/text/TextServer4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/text/TextServer4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -30,8 +30,8 @@
import org.foray.text.line.solitary.SolitaryLineBreaker;
-import org.axsl.common.para.ParaContext;
import org.axsl.font.FontConsumer;
+import org.axsl.kpModel.ParaContext;
import org.axsl.orthography.OrthographyServer;
import org.axsl.text.line.EagerLineBreaker;
import org.axsl.text.line.LineBreakHandler;
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/text/line/EagerLineBreaker.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/text/line/EagerLineBreaker.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/text/line/EagerLineBreaker.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -31,8 +31,8 @@
import org.foray.text.TextServer4a;
import org.axsl.common.TextModifiers;
-import org.axsl.common.para.ParaContext;
import org.axsl.font.FontConsumer;
+import org.axsl.kpModel.ParaContext;
import org.axsl.linebreak.OutputLine;
import org.axsl.text.TextException;
import org.axsl.text.line.LineBreakHandler;
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/text/line/LineBreaker.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/text/line/LineBreaker.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/text/line/LineBreaker.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -30,9 +30,9 @@
import org.foray.text.TextServer4a;
-import org.axsl.common.para.ParaContext;
import org.axsl.font.FontConsumer;
import org.axsl.font.FontUse;
+import org.axsl.kpModel.ParaContext;
import org.axsl.text.line.LineBreakHandler;
import org.axsl.text.line.LineText;
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/text/line/solitary/SolitaryLineBreaker.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/text/line/solitary/SolitaryLineBreaker.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/text/line/solitary/SolitaryLineBreaker.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -32,8 +32,8 @@
import org.foray.text.line.EagerLineBreaker;
import org.axsl.common.TextModifiers;
-import org.axsl.common.para.ParaContext;
import org.axsl.font.FontConsumer;
+import org.axsl.kpModel.ParaContext;
import org.axsl.orthography.Orthography;
import org.axsl.orthography.Word;
import org.axsl.text.TextException;
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -30,8 +30,8 @@
import org.foray.common.para.ParaBranch4a;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaContext;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaContext;
import org.junit.Assert;
import org.junit.Test;
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -37,8 +37,8 @@
import org.foray.font.util.MockFontUse;
import org.foray.orthography.Punctuation4a;
-import org.axsl.common.para.ParaContext;
-import org.axsl.common.para.ParaPenalty;
+import org.axsl.kpModel.ParaContext;
+import org.axsl.kpModel.ParaPenalty;
import org.junit.Assert;
import org.mockito.Mockito;
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/TotalFitLbTests.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/TotalFitLbTests.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/TotalFitLbTests.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -30,8 +30,8 @@
import org.foray.common.para.ParaBranch4a;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaContext;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaContext;
import org.junit.Assert;
import org.junit.Ignore;
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/util/DumpLayout.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/util/DumpLayout.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/util/DumpLayout.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -33,8 +33,8 @@
import org.foray.common.sequence.IntArray;
import org.foray.linebreak.FirstFitLbTests;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaLeaf;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaLeaf;
import java.io.PrintStream;
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/util/DumpParaBranch.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/util/DumpParaBranch.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/util/DumpParaBranch.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -31,8 +31,8 @@
import org.foray.common.para.ParaBranch4a;
import org.foray.linebreak.FirstFitLbTests;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaNode;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaNode;
import java.io.PrintStream;
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/DiscretionaryHyphen4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/DiscretionaryHyphen4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/DiscretionaryHyphen4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -30,13 +30,13 @@
import org.foray.common.para.ParaLeaf4a;
-import org.axsl.common.para.ParaBox;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaContext;
-import org.axsl.common.para.ParaGlue;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaPenalty;
import org.axsl.fotree.text.FoDiscretionaryHyphen;
+import org.axsl.kpModel.ParaBox;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaContext;
+import org.axsl.kpModel.ParaGlue;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaPenalty;
import org.axsl.orthography.DiscretionaryHyphen;
import java.util.Collections;
@@ -88,7 +88,7 @@
/**
* Protected constructor. There are only 3 possible normal values, so these are pre-constructed.
- * Use {@link #fromQuality(org.axsl.common.para.ParaPenalty.Quality)} to obtain an instance of this class.
+ * Use {@link #fromQuality(org.axsl.kpModel.ParaPenalty.Quality)} to obtain an instance of this class.
* @param quality The quality for this instance.
*/
protected DiscretionaryHyphen4a(final DiscretionaryHyphen.Quality quality) {
@@ -120,7 +120,7 @@
}
@Override
- public org.axsl.common.para.ParaPenalty.Quality getPenaltyQuality() {
+ public org.axsl.kpModel.ParaPenalty.Quality getPenaltyQuality() {
return PENALTY_MAP.get(this.quality);
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/DiscretionaryHyphenMutating4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/DiscretionaryHyphenMutating4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/DiscretionaryHyphenMutating4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -36,15 +36,15 @@
import org.foray.common.WellKnownConstants;
-import org.axsl.common.para.ParaBox;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaContext;
-import org.axsl.common.para.ParaGlue;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaNode;
-import org.axsl.common.para.ParaPenalty;
import org.axsl.fotree.text.FoDiscretionaryHyphen;
+import org.axsl.kpModel.ParaBox;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaContext;
+import org.axsl.kpModel.ParaGlue;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaNode;
+import org.axsl.kpModel.ParaPenalty;
import org.axsl.orthography.DiscretionaryHyphen;
import org.axsl.orthography.DiscretionaryHyphenMutating;
@@ -157,7 +157,7 @@
}
@Override
- public org.axsl.common.para.ParaPenalty.Quality getPenaltyQuality() {
+ public org.axsl.kpModel.ParaPenalty.Quality getPenaltyQuality() {
return DiscretionaryHyphen4a.PENALTY_MAP.get(this.quality);
}
@@ -193,7 +193,7 @@
}
@Override
- public org.axsl.common.para.ParaNode.Type getParaNodeType() {
+ public org.axsl.kpModel.ParaNode.Type getParaNodeType() {
return ParaNode.Type.LEAF;
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Punctuation4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Punctuation4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Punctuation4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -31,14 +31,14 @@
import org.foray.common.primitive.CharSequenceUtils;
import org.axsl.common.TextModifiers;
-import org.axsl.common.para.ParaBox;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaGlue;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaNode;
-import org.axsl.common.para.ParaPenalty;
import org.axsl.fotree.text.FoPunctuation;
+import org.axsl.kpModel.ParaBox;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaGlue;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaNode;
+import org.axsl.kpModel.ParaPenalty;
import java.util.ArrayList;
import java.util.List;
@@ -182,7 +182,7 @@
}
@Override
- public org.axsl.common.para.ParaNode.Type getParaNodeType() {
+ public org.axsl.kpModel.ParaNode.Type getParaNodeType() {
return ParaNode.Type.LEAF;
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWord.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWord.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWord.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -31,8 +31,8 @@
import org.foray.common.primitive.CharSequenceUtils;
import org.foray.common.primitive.NumberUtils;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaPenalty;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaPenalty;
/**
* A word implementation that wraps a set of {@link StringWordSegmentUtf16}, a thin wrapper around a {@link String}.
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentLatin1.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentLatin1.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentLatin1.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -31,13 +31,13 @@
import org.foray.common.primitive.StringLatin1;
import org.axsl.common.TextModifiers;
-import org.axsl.common.para.ParaBox;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaGlue;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaNode;
-import org.axsl.common.para.ParaPenalty;
+import org.axsl.kpModel.ParaBox;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaGlue;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaNode;
+import org.axsl.kpModel.ParaPenalty;
import org.axsl.orthography.WordSegment;
/**
@@ -66,7 +66,7 @@
}
@Override
- public org.axsl.common.para.ParaNode.Type getParaNodeType() {
+ public org.axsl.kpModel.ParaNode.Type getParaNodeType() {
return ParaNode.Type.LEAF;
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentUtf16.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentUtf16.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentUtf16.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -31,13 +31,13 @@
import org.foray.common.primitive.StringUtf16;
import org.axsl.common.TextModifiers;
-import org.axsl.common.para.ParaBox;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaGlue;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaNode;
-import org.axsl.common.para.ParaPenalty;
+import org.axsl.kpModel.ParaBox;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaGlue;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaNode;
+import org.axsl.kpModel.ParaPenalty;
import org.axsl.orthography.WordSegment;
/**
@@ -66,7 +66,7 @@
}
@Override
- public org.axsl.common.para.ParaNode.Type getParaNodeType() {
+ public org.axsl.kpModel.ParaNode.Type getParaNodeType() {
return ParaNode.Type.LEAF;
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -33,14 +33,14 @@
import org.foray.common.para.ParaBranch4aIterator;
import org.axsl.common.TextModifiers;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaNode;
import org.axsl.common.value.WhiteSpaceTreatment;
import org.axsl.fotree.text.FoToken;
import org.axsl.fotree.text.FoTokenFlow;
import org.axsl.fotree.text.FoWord;
import org.axsl.fotree.text.FoWordSegment;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaNode;
import org.axsl.orthography.TokenFlow;
import org.axsl.orthography.Whitespace;
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -34,14 +34,14 @@
import org.foray.common.primitive.XmlCharacterUtils;
import org.axsl.common.TextModifiers;
-import org.axsl.common.para.ParaBox;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaGlue;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaPenalty;
import org.axsl.common.value.LinefeedTreatment;
import org.axsl.fotree.text.FoWhitespace;
+import org.axsl.kpModel.ParaBox;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaGlue;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaPenalty;
import org.axsl.unicode.block.General_Punctuation_Block;
import org.slf4j.LoggerFactory;
@@ -117,8 +117,8 @@
}
@Override
- public org.axsl.common.para.ParaNode.Type getParaNodeType() {
- return org.axsl.common.para.ParaNode.Type.LEAF;
+ public org.axsl.kpModel.ParaNode.Type getParaNodeType() {
+ return org.axsl.kpModel.ParaNode.Type.LEAF;
}
@Override
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Word4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Word4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Word4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -32,10 +32,6 @@
import org.foray.common.primitive.NumberUtils;
import org.axsl.common.TextModifiers;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaNode;
-import org.axsl.common.para.ParaPenalty;
import org.axsl.common.sequence.ByteSequence;
import org.axsl.common.value.TextTransform;
import org.axsl.fotree.text.FoDiscretionaryHyphen;
@@ -42,6 +38,10 @@
import org.axsl.fotree.text.FoWord;
import org.axsl.fotree.text.FoWordComponent;
import org.axsl.fotree.text.FoWordSegment;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaNode;
+import org.axsl.kpModel.ParaPenalty;
import org.axsl.orthography.Word;
import org.axsl.orthography.WordSegment;
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/WordSegment4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/WordSegment4a.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/WordSegment4a.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -31,13 +31,13 @@
import org.foray.common.para.ParaLeaf4a;
import org.axsl.common.TextModifiers;
-import org.axsl.common.para.ParaBox;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaGlue;
-import org.axsl.common.para.ParaLeaf;
-import org.axsl.common.para.ParaPenalty;
import org.axsl.common.value.TextTransform;
import org.axsl.fotree.text.FoWordSegment;
+import org.axsl.kpModel.ParaBox;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaGlue;
+import org.axsl.kpModel.ParaLeaf;
+import org.axsl.kpModel.ParaPenalty;
import org.axsl.orthography.WordSegment;
import java.io.Serializable;
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/CapitalizedWord.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/CapitalizedWord.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/CapitalizedWord.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -30,9 +30,9 @@
import org.foray.orthography.WordSegmentWrapper;
-import org.axsl.common.para.ParaLeaf;
import org.axsl.fotree.text.FoWord;
import org.axsl.fotree.text.FoWordSegment;
+import org.axsl.kpModel.ParaLeaf;
import org.axsl.orthography.WordSegment;
/**
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/DecoratedWord.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/DecoratedWord.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/DecoratedWord.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -32,10 +32,10 @@
import org.foray.orthography.DiscretionaryHyphen4a;
import org.foray.orthography.WordWrapper;
-import org.axsl.common.para.ParaNode;
-import org.axsl.common.para.ParaPenalty;
import org.axsl.fotree.text.FoWord;
import org.axsl.fotree.text.FoWordComponent;
+import org.axsl.kpModel.ParaNode;
+import org.axsl.kpModel.ParaPenalty;
/**
* Decorates a normalized word with some additional data.
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/ExactWord.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/ExactWord.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/ExactWord.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -32,9 +32,9 @@
import org.foray.orthography.StringWord;
import org.foray.orthography.StringWordSegmentUtf16;
-import org.axsl.common.para.ParaLeaf;
import org.axsl.fotree.text.FoWord;
import org.axsl.fotree.text.FoWordSegment;
+import org.axsl.kpModel.ParaLeaf;
/**
* Decorates a normalized word with an exact representation of the actual capitalization.
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPast1Word.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPast1Word.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPast1Word.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -30,8 +30,8 @@
import org.foray.orthography.StringWordSegmentUtf16;
-import org.axsl.common.para.ParaLeaf;
import org.axsl.fotree.text.FoWord;
+import org.axsl.kpModel.ParaLeaf;
/**
* Wraps a word, usually a verb, and adds a syllable "ed" to the end.
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPlural1Word.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPlural1Word.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPlural1Word.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -28,9 +28,9 @@
package org.foray.orthography.wrapper;
-import org.axsl.common.para.ParaLeaf;
import org.axsl.fotree.text.FoWord;
import org.axsl.fotree.text.FoWordSegment;
+import org.axsl.kpModel.ParaLeaf;
import org.axsl.orthography.WordSegment;
/**
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPlural2Word.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPlural2Word.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPlural2Word.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -28,9 +28,9 @@
package org.foray.orthography.wrapper;
-import org.axsl.common.para.ParaLeaf;
import org.axsl.fotree.text.FoWord;
import org.axsl.fotree.text.FoWordSegment;
+import org.axsl.kpModel.ParaLeaf;
import org.axsl.orthography.WordSegment;
/**
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPossessive1Word.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPossessive1Word.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPossessive1Word.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -28,9 +28,9 @@
package org.foray.orthography.wrapper;
-import org.axsl.common.para.ParaLeaf;
import org.axsl.fotree.text.FoWord;
import org.axsl.fotree.text.FoWordSegment;
+import org.axsl.kpModel.ParaLeaf;
import org.axsl.orthography.WordSegment;
/**
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPossessive2Word.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPossessive2Word.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/LatinPossessive2Word.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -28,9 +28,9 @@
package org.foray.orthography.wrapper;
-import org.axsl.common.para.ParaLeaf;
import org.axsl.fotree.text.FoWord;
import org.axsl.fotree.text.FoWordSegment;
+import org.axsl.kpModel.ParaLeaf;
import org.axsl.orthography.WordSegment;
/**
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/UppercaseWord.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/UppercaseWord.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/wrapper/UppercaseWord.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -30,9 +30,9 @@
import org.foray.orthography.WordSegmentWrapper;
-import org.axsl.common.para.ParaLeaf;
import org.axsl.fotree.text.FoWord;
import org.axsl.fotree.text.FoWordSegment;
+import org.axsl.kpModel.ParaLeaf;
import org.axsl.orthography.WordSegment;
/**
Modified: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/HyphenationConsumer4aTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/HyphenationConsumer4aTests.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/HyphenationConsumer4aTests.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -30,7 +30,7 @@
import org.foray.common.i18n.WritingSystem4a;
-import org.axsl.common.para.ParaConfig;
+import org.axsl.kpModel.ParaConfig;
import org.axsl.orthography.OrthographyException;
import org.axsl.orthography.Word;
Modified: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/SegmentDictionaryWordTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/SegmentDictionaryWordTests.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/SegmentDictionaryWordTests.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -28,7 +28,7 @@
package org.foray.orthography;
-import org.axsl.common.para.ParaNode;
+import org.axsl.kpModel.ParaNode;
import org.axsl.orthography.DiscretionaryHyphen.Quality;
import org.junit.Assert;
Modified: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/WordWrapperTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/WordWrapperTests.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/WordWrapperTests.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -28,7 +28,7 @@
package org.foray.orthography;
-import org.axsl.common.para.ParaNode;
+import org.axsl.kpModel.ParaNode;
import org.axsl.orthography.DiscretionaryHyphen.Quality;
import org.axsl.orthography.Word;
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/BlockDiscretePnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/BlockDiscretePnr.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/BlockDiscretePnr.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -33,10 +33,10 @@
import org.axsl.area.LineArea;
import org.axsl.area.NormalBlockArea;
import org.axsl.area.factory.BlockLevelAreaFactory;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaNode;
import org.axsl.fotree.fo.BlockDiscrete;
+import org.axsl.kpModel.ParaBranch;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaNode;
import org.axsl.linebreak.LineBreakResult;
import org.axsl.linebreak.LineBreaker;
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java 2022-01-14 14:12:59 UTC (rev 12396)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java 2022-01-14 16:15:11 UTC (rev 12397)
@@ -34,10 +34,10 @@
import org.axsl.area.AreaTreeException;
import org.axsl.area.LineArea;
import org.axsl.area.NormalBlockArea;
-import org.axsl.common.para.ParaConfig;
-import org.axsl.common.para.ParaContext;
import org.axsl.fotree.fo.FoTextWords;
import org.axsl.fotree.text.FoTokenFlow;
+import org.axsl.kpModel.ParaConfig;
+import org.axsl.kpModel.ParaContext;
import org.axsl.linebreak.LineBreakResult;
import org.axsl.linebreak.LineBreaker;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-14 14:13:02
|
Revision: 12396
http://sourceforge.net/p/foray/code/12396
Author: victormote
Date: 2022-01-14 14:12:59 +0000 (Fri, 14 Jan 2022)
Log Message:
-----------
Rename instance variable for clarity.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-14 13:55:19 UTC (rev 12395)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-14 14:12:59 UTC (rev 12396)
@@ -41,7 +41,8 @@
import org.axsl.orthography.Whitespace;
/**
- * Text in an FO document that is already broken into words.
+ * Text in an FO document that has been tokenized into words.
+ * This is a thin wrapper around an instance of {@link FoTokenFlow} that allows that token flow to live in an FO tree.
*/
public class FoTextWords4a extends FoText4a implements FoTextWords {
@@ -49,7 +50,7 @@
private FoObj parent;
/** The parsed words. */
- private FoTokenFlow paraBranch;
+ private FoTokenFlow tokenFlow;
/**
* Constructor.
@@ -62,7 +63,7 @@
this.parent = parent;
final FoOrthographyServer orthographyServer = getOrthographyServer();
final FoOrthography orthography = orthographyServer.getOrthography(getWritingSystem());
- this.paraBranch = orthography.tokenize(content, 0, content.length());
+ this.tokenFlow = orthography.tokenize(content, 0, content.length());
}
@Override
@@ -72,8 +73,8 @@
@Override
public boolean isAllWhiteSpace() {
- for (int index = 0; index < this.paraBranch.qtyTokens(); index ++) {
- final FoToken token = this.paraBranch.tokenAt(index);
+ for (int index = 0; index < this.tokenFlow.qtyTokens(); index ++) {
+ final FoToken token = this.tokenFlow.tokenAt(index);
if (! (token instanceof Whitespace)) {
return false;
}
@@ -92,8 +93,8 @@
*/
public CharSequence getRawText() {
final StringBuilder builder = new StringBuilder();
- for (int nodeIndex = 0; nodeIndex < this.paraBranch.qtyTokens(); nodeIndex ++) {
- final ParaNode node = this.paraBranch.paraNodeAt(nodeIndex);
+ for (int nodeIndex = 0; nodeIndex < this.tokenFlow.qtyTokens(); nodeIndex ++) {
+ final ParaNode node = this.tokenFlow.paraNodeAt(nodeIndex);
builder.append(node.getText());
}
return builder.toString();
@@ -106,7 +107,7 @@
@Override
public FoTokenFlow getFoTokenFlow() {
- return this.paraBranch;
+ return this.tokenFlow;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-14 13:55:21
|
Revision: 12395
http://sourceforge.net/p/foray/code/12395
Author: victormote
Date: 2022-01-14 13:55:19 +0000 (Fri, 14 Jan 2022)
Log Message:
-----------
Conform to aXSL change: Remove unnecessary method.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-14 13:29:25 UTC (rev 12394)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-14 13:55:19 UTC (rev 12395)
@@ -86,7 +86,10 @@
return visitor.visit(this);
}
- @Override
+ /**
+ * Returns the raw (unfiltered by text modifiers) text.
+ * @return The raw text.
+ */
public CharSequence getRawText() {
final StringBuilder builder = new StringBuilder();
for (int nodeIndex = 0; nodeIndex < this.paraBranch.qtyTokens(); nodeIndex ++) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-14 13:29:29
|
Revision: 12394
http://sourceforge.net/p/foray/code/12394
Author: victormote
Date: 2022-01-14 13:29:25 +0000 (Fri, 14 Jan 2022)
Log Message:
-----------
Conform to aXSL changes: 1. Move method not needed by FoTextWords from FoText to FoTextCharacters. 2. Rename getAreaTreeText to getRefinedText for clarity.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaCharacters.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/axsl/obj/Metadata4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractCharacterSequence.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/BookmarkTitle4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextCharacters4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2022-01-13 20:48:41 UTC (rev 12393)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2022-01-14 13:29:25 UTC (rev 12394)
@@ -978,7 +978,7 @@
}
/* If the final text will be empty, don't create the TextArea. */
- final CharSequence rawText = foText.getAreaTreeText(context);
+ final CharSequence rawText = foText.getRefinedText(context);
final boolean isFirstItemOnline = parentArea.getChildren().size() == 0;
final int ignoreAtStart = TextArea.ignoreAtStart(rawText, startOffset,
sizeInChars, isFirstItemOnline,
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaCharacters.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaCharacters.java 2022-01-13 20:48:41 UTC (rev 12393)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaCharacters.java 2022-01-14 13:29:25 UTC (rev 12394)
@@ -156,7 +156,7 @@
final boolean hasDiscretionaryHyphen,
final boolean hasFauxSmallCaps) {
final FoTextCharacters generatedBy = this.traitGeneratedBy();
- this.charSequence = new TextAreaCharSequence(generatedBy.getAreaTreeText(this),
+ this.charSequence = new TextAreaCharSequence(generatedBy.getRefinedText(this),
backingOffset, backingSize, hasDiscretionaryHyphen, hasFauxSmallCaps);
setResolvedLetterSpacing(traitLetterSpacingOpt());
setResolvedWordSpacing(traitWordSpacingOpt());
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java 2022-01-13 20:48:41 UTC (rev 12393)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java 2022-01-14 13:29:25 UTC (rev 12394)
@@ -3309,7 +3309,7 @@
final FoObj fobj = iterator.next();
if (fobj instanceof FoTextCharacters) {
final FoTextCharacters text = (FoTextCharacters) fobj;
- builder.append(text.getAreaTreeText(null));
+ builder.append(text.getRefinedText(null));
}
}
return builder.toString();
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/axsl/obj/Metadata4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/axsl/obj/Metadata4a.java 2022-01-13 20:48:41 UTC (rev 12393)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/axsl/obj/Metadata4a.java 2022-01-14 13:29:25 UTC (rev 12394)
@@ -143,7 +143,7 @@
/* Existence and casting verified at validateDescendants(). */
final FoTextCharacters4a text =
(FoTextCharacters4a) this.formattingObjectAt(0);
- return text.getAreaTreeText(null).toString();
+ return text.getRefinedText(null).toString();
}
/**
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractCharacterSequence.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractCharacterSequence.java 2022-01-13 20:48:41 UTC (rev 12393)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractCharacterSequence.java 2022-01-14 13:29:25 UTC (rev 12394)
@@ -64,7 +64,7 @@
@Override
public CharSequence inlineText(final FoContext context) {
- return getAreaTreeText(context);
+ return getRefinedText(context);
}
@Override
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/BookmarkTitle4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/BookmarkTitle4a.java 2022-01-13 20:48:41 UTC (rev 12393)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/BookmarkTitle4a.java 2022-01-14 13:29:25 UTC (rev 12394)
@@ -193,7 +193,7 @@
return WellKnownConstants.EMPTY_STRING;
}
final AbstractCharacterSequence child = this.formattingObjectAt(0);
- final CharSequence text = child.getAreaTreeText(null);
+ final CharSequence text = child.getRefinedText(null);
return text.toString();
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextCharacters4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextCharacters4a.java 2022-01-13 20:48:41 UTC (rev 12393)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextCharacters4a.java 2022-01-14 13:29:25 UTC (rev 12394)
@@ -30,7 +30,6 @@
import org.foray.fotree.FoObj;
-import org.axsl.common.value.LinefeedTreatment;
import org.axsl.common.value.TextTransform;
import org.axsl.fotree.FoContext;
import org.axsl.fotree.FoVisitor;
@@ -134,29 +133,21 @@
return true;
}
- /**
- * <p>Filters the raw text as needed to present the text that should appear
- * in the "refined FO tree".
- * Specifically, this effectively filters for the following properties:</p>
- * <ul>
- * <li>white-space-treatment. See XSL-FO Standard 1.0 Section 7.15.8.</li>
- * <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 An object that knows how to resolve FO Tree context
- * issues.
- *
- * @return The text that should appear in the refined FO tree.
- */
- public StringBuilder getRefinedText(final FoContext context) {
+ @Override
+ public CharSequence getRefinedText(final FoContext context) {
+ /* TODO: This needs a lot of work. It effectively handles white-space-treatment first, which really cannot be
+ * handled until line-breaking has been done. */
+
+
+
/* TODO: This needs to come from effectiveParent, with context. */
final FoObj effectiveParent = this.getParent();
- if (this.filterStatus >= FoTextCharacters4a.FILTER_REFINED_FO_TREE) {
- /* The stored text has already been filtered. Just return it. */
- return this.ca;
- }
+// if (this.filterStatus >= FoTextCharacters4a.FILTER_REFINED_FO_TREE) {
+// /* The stored text has already been filtered. Just return it. */
+// return this.ca;
+// }
- final StringBuilder charArray = getPreTextTransformText(context);
+ StringBuilder charArray = getPreTextTransformText(context);
// Now handle text-transform.
final TextTransform textTransform = effectiveParent.traitTextTransform(
context);
@@ -170,6 +161,31 @@
* status. */
this.ca = charArray;
this.filterStatus = FoTextCharacters4a.FILTER_REFINED_FO_TREE;
+
+
+
+
+
+
+
+
+// final FoObj effectiveParent = this.getParent();
+// if (this.filterStatus >= FoTextCharacters4a.FILTER_AREA_TREE) {
+// /* The stored text has already been filtered. Just return it. */
+// return this.ca;
+// }
+//
+// // Start with the refined FO Tree text
+// StringBuilder returnArray = getRefinedText(context);
+ // Apply white-space-collapse.
+ final boolean whiteSpaceCollapse =
+ effectiveParent.traitWhiteSpaceCollapse(context);
+ charArray = applyWhiteSpaceCollapse(charArray, whiteSpaceCollapse);
+
+ /* Set the instance text to the more refined value and update the
+ * status. */
+// this.ca = returnArray;
+ this.filterStatus = FoTextCharacters4a.FILTER_AREA_TREE;
return charArray;
}
@@ -427,28 +443,6 @@
return 0x0000;
}
- @Override
- public CharSequence getAreaTreeText(final FoContext context) {
- final FoObj effectiveParent = this.getParent();
- if (this.filterStatus >= FoTextCharacters4a.FILTER_AREA_TREE) {
- /* The stored text has already been filtered. Just return it. */
- return this.ca;
- }
-
- // Start with the refined FO Tree text
- StringBuilder returnArray = getRefinedText(context);
- // Apply white-space-collapse.
- final boolean whiteSpaceCollapse =
- effectiveParent.traitWhiteSpaceCollapse(context);
- returnArray = applyWhiteSpaceCollapse(returnArray, whiteSpaceCollapse);
-
- /* Set the instance text to the more refined value and update the
- * status. */
- this.ca = returnArray;
- this.filterStatus = FoTextCharacters4a.FILTER_AREA_TREE;
- return returnArray;
- }
-
/**
* Returns the raw char array.
* @return The raw char array.
@@ -457,37 +451,9 @@
return this.ca;
}
-// @Override
-// public int length() {
-// return this.ca.length();
-// }
-//
-// @Override
-// public char charAt(final int index) {
-// return this.ca.charAt(index);
-// }
-//
-// @Override
-// public CharSequence subSequence(final int start, final int end) {
-// return this.ca.subSequence(start, end);
-// }
-
@Override
public <T> T acceptVisitor(final FoVisitor<T> visitor) {
return visitor.visit(this);
}
- @Override
- public CharSequence getRefinedText(final LinefeedTreatment linefeedTreatment, final TextTransform textTransform,
- final boolean whiteSpaceCollapse, final int codepointBefore, final int codepointAfter) {
- /* If none of the factors will result in any change, just return this. */
- if (linefeedTreatment == LinefeedTreatment.PRESERVE
- && textTransform == TextTransform.NONE
- && whiteSpaceCollapse == false) {
- return this.ca;
- }
- return new FoRefinedText4a(this.ca, linefeedTreatment, textTransform, whiteSpaceCollapse, codepointBefore,
- codepointAfter);
- }
-
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-13 20:48:41 UTC (rev 12393)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-14 13:29:25 UTC (rev 12394)
@@ -31,8 +31,6 @@
import org.foray.fotree.FoObj;
import org.axsl.common.para.ParaNode;
-import org.axsl.common.value.LinefeedTreatment;
-import org.axsl.common.value.TextTransform;
import org.axsl.fotree.FoVisitor;
import org.axsl.fotree.fo.FoTextWords;
import org.axsl.fotree.text.FoOrthography;
@@ -99,19 +97,6 @@
}
@Override
- public CharSequence getRefinedText(final LinefeedTreatment linefeedTreatment, final TextTransform textTransform,
- final boolean whiteSpaceCollapse, final int codepointBefore, final int codepointAfter) {
- /* If none of the factors will result in any change, just return this. */
- if (linefeedTreatment == LinefeedTreatment.PRESERVE
- && textTransform == TextTransform.NONE
- && whiteSpaceCollapse == false) {
- return getRawText();
- }
- return new FoRefinedText4a(getRawText(), linefeedTreatment, textTransform, whiteSpaceCollapse, codepointBefore,
- codepointAfter);
- }
-
- @Override
public String toString() {
return getRawText().toString();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-13 20:48:44
|
Revision: 12393
http://sourceforge.net/p/foray/code/12393
Author: victormote
Date: 2022-01-13 20:48:41 +0000 (Thu, 13 Jan 2022)
Log Message:
-----------
Use new MarkedIndexOutOfBoundsException for sequence classes.
Modified Paths:
--------------
trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ByteArrayBuilder.java
trunk/foray/foray-common/src/main/java/org/foray/common/sequence/CharArrayBuilder.java
trunk/foray/foray-common/src/main/java/org/foray/common/sequence/IntArrayBuilder.java
trunk/foray/foray-common/src/main/java/org/foray/common/sequence/LongArrayBuilder.java
trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ShortArrayBuilder.java
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ByteArrayBuilder.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ByteArrayBuilder.java 2022-01-13 18:40:50 UTC (rev 12392)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ByteArrayBuilder.java 2022-01-13 20:48:41 UTC (rev 12393)
@@ -33,6 +33,8 @@
package org.foray.common.sequence;
+import org.foray.common.MarkedIndexOutOfBoundsException;
+
import org.axsl.common.sequence.ByteSequenceMutable;
import org.axsl.common.sequence.ByteSequencePlus;
@@ -319,7 +321,7 @@
@Override
public byte byteAt(final int index) {
if ((index < 0) || (index >= this.length)) {
- throw new IndexOutOfBoundsException("Index out of bounds: " + index);
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
return this.backingArray[index];
}
@@ -361,7 +363,7 @@
@Override
public void setLength(final int newLength) {
if (newLength < 0) {
- throw new IndexOutOfBoundsException("Index out of bounds: " + newLength);
+ throw new MarkedIndexOutOfBoundsException(newLength, this.length);
}
ensureCapacityInternal(newLength);
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/sequence/CharArrayBuilder.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/sequence/CharArrayBuilder.java 2022-01-13 18:40:50 UTC (rev 12392)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/sequence/CharArrayBuilder.java 2022-01-13 20:48:41 UTC (rev 12393)
@@ -28,6 +28,8 @@
package org.foray.common.sequence;
+import org.foray.common.MarkedIndexOutOfBoundsException;
+
import org.axsl.common.sequence.CharSequenceMutable;
import java.util.Arrays;
@@ -211,7 +213,7 @@
@Override
public void setLength(final int newLength) {
if (newLength < 0) {
- throw new IndexOutOfBoundsException("Index out of bounds: " + newLength);
+ throw new MarkedIndexOutOfBoundsException(newLength, this.length);
}
ensureCapacityInternal(newLength);
@@ -253,7 +255,7 @@
@Override
public char charAt(final int index) {
if ((index < 0) || (index >= this.length)) {
- throw new IndexOutOfBoundsException("Index out of bounds: " + index);
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
return this.backingArray[index];
}
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/sequence/IntArrayBuilder.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/sequence/IntArrayBuilder.java 2022-01-13 18:40:50 UTC (rev 12392)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/sequence/IntArrayBuilder.java 2022-01-13 20:48:41 UTC (rev 12393)
@@ -28,6 +28,8 @@
package org.foray.common.sequence;
+import org.foray.common.MarkedIndexOutOfBoundsException;
+
import org.axsl.common.sequence.IntSequence;
import org.axsl.common.sequence.IntSequenceMutable;
@@ -79,7 +81,7 @@
@Override
public int intAt(final int index) {
if ((index < 0) || (index >= this.length)) {
- throw new IndexOutOfBoundsException("Index out of range: " + index);
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
return this.backingArray[index];
}
@@ -87,13 +89,13 @@
@Override
public IntSequence subSequence(final int start, final int end) {
if (start < 0) {
- throw new IndexOutOfBoundsException("Index out of range: " + start);
+ throw new MarkedIndexOutOfBoundsException(start, this.length);
}
if (end > this.length) {
- throw new IndexOutOfBoundsException("Index out of range: " + end);
+ throw new MarkedIndexOutOfBoundsException(end, this.length);
}
if (start > end) {
- throw new StringIndexOutOfBoundsException("Index out of range: " + (end - start));
+ throw new IllegalArgumentException("start " + start + " exceeds end " + end);
}
final IntArrayBuilder returnBuilder = new IntArrayBuilder(this.length);
for (int index = start; index < end; index ++) {
@@ -176,7 +178,7 @@
@Override
public void setLength(final int newLength) {
if (newLength < 0) {
- throw new IndexOutOfBoundsException("Index out of bounds: " + newLength);
+ throw new MarkedIndexOutOfBoundsException(newLength, this.length);
}
ensureCapacity(newLength);
if (newLength > this.length) {
@@ -271,7 +273,7 @@
*/
public IntArrayBuilder deleteIntAt(final int index) throws IndexOutOfBoundsException {
if ((index < 0) || (index >= this.length)) {
- throw new IndexOutOfBoundsException("Index out of range: " + index);
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
System.arraycopy(this.backingArray, index + 1, this.backingArray, index, this.length - index - 1);
this.length--;
@@ -291,7 +293,7 @@
*/
public IntArrayBuilder delete(final int start, final int end) throws IndexOutOfBoundsException {
if (start < 0) {
- throw new IndexOutOfBoundsException("Index out of range: " + start);
+ throw new MarkedIndexOutOfBoundsException(start, this.length);
}
int adjustedEnd = end;
if (end > this.length) {
@@ -298,7 +300,7 @@
adjustedEnd = this.length;
}
if (start > adjustedEnd) {
- throw new IndexOutOfBoundsException("Index out of range: " + start);
+ throw new MarkedIndexOutOfBoundsException(start, this.length);
}
final int len = adjustedEnd - start;
if (len > 0) {
@@ -362,7 +364,7 @@
public void insert(final int index, final int newInt) {
if (index < 0
|| index > length()) {
- throw new IndexOutOfBoundsException();
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
ensureCapacity(length() + 1);
System.arraycopy(this.backingArray, index, this.backingArray, index + 1, this.length - index);
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/sequence/LongArrayBuilder.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/sequence/LongArrayBuilder.java 2022-01-13 18:40:50 UTC (rev 12392)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/sequence/LongArrayBuilder.java 2022-01-13 20:48:41 UTC (rev 12393)
@@ -28,6 +28,8 @@
package org.foray.common.sequence;
+import org.foray.common.MarkedIndexOutOfBoundsException;
+
import org.axsl.common.sequence.LongPrimitiveIterator;
import org.axsl.common.sequence.LongSequence;
import org.axsl.common.sequence.LongSequenceMutable;
@@ -81,7 +83,7 @@
@Override
public long longAt(final int index) {
if ((index < 0) || (index >= this.length)) {
- throw new IndexOutOfBoundsException("Index out of range: " + index);
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
return this.backingArray[index];
}
@@ -89,10 +91,10 @@
@Override
public LongSequence subSequence(final int start, final int end) {
if (start < 0) {
- throw new IndexOutOfBoundsException("Index out of range: " + start);
+ throw new MarkedIndexOutOfBoundsException(start, this.length);
}
if (end > this.length) {
- throw new IndexOutOfBoundsException("Index out of range: " + end);
+ throw new MarkedIndexOutOfBoundsException(end, this.length);
}
if (start > end) {
throw new StringIndexOutOfBoundsException("Index out of range: " + (end - start));
@@ -223,7 +225,7 @@
*/
public LongArrayBuilder deleteLongAt(final int index) throws IndexOutOfBoundsException {
if ((index < 0) || (index >= this.length)) {
- throw new IndexOutOfBoundsException("Index out of range: " + index);
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
System.arraycopy(this.backingArray, index + 1, this.backingArray, index, this.length - index - 1);
this.length--;
@@ -243,7 +245,7 @@
*/
public LongArrayBuilder delete(final int start, final int end) throws IndexOutOfBoundsException {
if (start < 0) {
- throw new IndexOutOfBoundsException("Index out of range: " + start);
+ throw new MarkedIndexOutOfBoundsException(start, this.length);
}
int adjustedEnd = end;
if (end > this.length) {
@@ -250,7 +252,7 @@
adjustedEnd = this.length;
}
if (start > adjustedEnd) {
- throw new IndexOutOfBoundsException("Index out of range: " + start);
+ throw new MarkedIndexOutOfBoundsException(start, this.length);
}
final int len = adjustedEnd - start;
if (len > 0) {
@@ -311,7 +313,7 @@
@Override
public void setLength(final int newLength) {
if (newLength < 0) {
- throw new IndexOutOfBoundsException("Index out of bounds: " + newLength);
+ throw new MarkedIndexOutOfBoundsException(newLength, this.length);
}
ensureCapacity(newLength);
if (newLength > this.length) {
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ShortArrayBuilder.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ShortArrayBuilder.java 2022-01-13 18:40:50 UTC (rev 12392)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ShortArrayBuilder.java 2022-01-13 20:48:41 UTC (rev 12393)
@@ -28,6 +28,8 @@
package org.foray.common.sequence;
+import org.foray.common.MarkedIndexOutOfBoundsException;
+
import org.axsl.common.sequence.ShortSequence;
import org.axsl.common.sequence.ShortSequenceMutable;
@@ -79,7 +81,7 @@
@Override
public short shortAt(final int index) {
if ((index < 0) || (index >= this.length)) {
- throw new IndexOutOfBoundsException("Index out of range: " + index);
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
return this.backingArray[index];
}
@@ -87,10 +89,10 @@
@Override
public ShortSequence subSequence(final int start, final int end) {
if (start < 0) {
- throw new IndexOutOfBoundsException("Index out of range: " + start);
+ throw new MarkedIndexOutOfBoundsException(start, this.length);
}
if (end > this.length) {
- throw new IndexOutOfBoundsException("Index out of range: " + end);
+ throw new MarkedIndexOutOfBoundsException(end, this.length);
}
if (start > end) {
throw new StringIndexOutOfBoundsException("Index out of range: " + (end - start));
@@ -204,7 +206,7 @@
*/
public ShortArrayBuilder deleteShortAt(final int index) throws IndexOutOfBoundsException {
if ((index < 0) || (index >= this.length)) {
- throw new IndexOutOfBoundsException("Index out of range: " + index);
+ throw new MarkedIndexOutOfBoundsException(index, this.length);
}
System.arraycopy(this.backingArray, index + 1, this.backingArray, index, this.length - index - 1);
this.length--;
@@ -224,7 +226,7 @@
*/
public ShortArrayBuilder delete(final int start, final int end) throws IndexOutOfBoundsException {
if (start < 0) {
- throw new IndexOutOfBoundsException("Index out of range: " + start);
+ throw new MarkedIndexOutOfBoundsException(start, this.length);
}
int adjustedEnd = end;
if (end > this.length) {
@@ -277,7 +279,7 @@
@Override
public void setLength(final int newLength) {
if (newLength < 0) {
- throw new IndexOutOfBoundsException("Index out of bounds: " + newLength);
+ throw new MarkedIndexOutOfBoundsException(newLength, this.length);
}
ensureCapacity(newLength);
if (newLength > this.length) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-13 18:40:52
|
Revision: 12392
http://sourceforge.net/p/foray/code/12392
Author: victormote
Date: 2022-01-13 18:40:50 +0000 (Thu, 13 Jan 2022)
Log Message:
-----------
Handle empty content better.
Modified Paths:
--------------
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java 2022-01-13 18:06:06 UTC (rev 12391)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java 2022-01-13 18:40:50 UTC (rev 12392)
@@ -259,6 +259,14 @@
this.clearProvisionalContent();
}
+ /**
+ * Creates the result of the line-breaking computation.
+ * @return The result.
+ */
+ private LineBreakResult4a createResult() {
+ return new LineBreakResult4a(lineLengths.toArray(), breakpoints.toArray());
+ }
+
}
@Override
@@ -268,6 +276,10 @@
* (b) is glue, (c) is non-glue, and (d) is glue, then (a) is the end of the previous word, and (b) and (c)
* together are the current word, and (d) is the beginning of the next word. */
+ if (paragraph.qtyParaLeaves() < 1) {
+ return LineBreakResult4a.EMPTY_RESULT;
+ }
+
final State state = new State(paraConfig, paraContext);
final ListIterator<ParaLeaf> leafIterator = paragraph.leafIterator();
@@ -310,9 +322,9 @@
}
}
- /* Make sure there is at least one line if there is any content. */
- if (state.breakpoints.length() < 1
- && paragraph.qtyParaLeaves() > 0) {
+ /* We tested above to ensure that there is at least one leaf node. Make sure there is at least one line in the
+ * result. */
+ if (state.breakpoints.length() < 1) {
state.breakpoints.append(paragraph.qtyParaLeaves());
}
@@ -325,7 +337,7 @@
state.lineLengths.pop();
}
- return new LineBreakResult4a(state.lineLengths.toArray(), state.breakpoints.toArray());
+ return state.createResult();
}
private void processEndOfLine(final State state, final int lineCapacity) {
Modified: trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java 2022-01-13 18:06:06 UTC (rev 12391)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/LineBreakResult4a.java 2022-01-13 18:40:50 UTC (rev 12392)
@@ -30,12 +30,18 @@
import org.axsl.linebreak.LineBreakResult;
+import java.util.Arrays;
+
/**
* The results of a line-breaking computation.
* See {@link LineBreakResult} interface documentation for more details.
+ * Instances of this class are immutable.
*/
-public class LineBreakResult4a implements LineBreakResult {
+public final class LineBreakResult4a implements LineBreakResult {
+ /** Result suitable for cases an empty result should be returned. */
+ public static final LineBreakResult4a EMPTY_RESULT = new LineBreakResult4a(new int[0], new int[0]);
+
/** The array of line lengths, in millipoints, for the paragraph. */
private int[] lineLengths;
@@ -46,8 +52,9 @@
if (lineLengths.length != breakPositions.length) {
throw new IllegalArgumentException("Line length and breakpoint arrays must be of equal length.");
}
- this.lineLengths = lineLengths;
- this.breakPositions = breakPositions;
+ /* Copy to ensure immutability. */
+ this.lineLengths = Arrays.copyOf(lineLengths, lineLengths.length);
+ this.breakPositions = Arrays.copyOf(breakPositions, breakPositions.length);
}
@Override
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-13 18:06:08
|
Revision: 12391
http://sourceforge.net/p/foray/code/12391
Author: victormote
Date: 2022-01-13 18:06:06 +0000 (Thu, 13 Jan 2022)
Log Message:
-----------
Add test of punctuation in the middle of the text.
Modified Paths:
--------------
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java
Modified: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java 2022-01-13 17:29:49 UTC (rev 12390)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java 2022-01-13 18:06:06 UTC (rev 12391)
@@ -162,27 +162,32 @@
*/
@Test
public void extract_Test_001() {
- /* William Shakespeare, "King Lear," Act iii, Scene 2. */
+ /* Robert Burns, "Address to the Unco Guid," last two lines. */
final TokenFlow4a out = new TokenFlow4a();
- out.addToken(new StringWord(0, "I")); // Token 0
+ out.addToken(new StringWord(0, "What’s")); // Token 0
out.addToken(Whitespace4a.SPACE); // Token 1
- out.addToken(new StringWord(0, "am")); // Token 2
+ out.addToken(new StringWord(0, "done")); // Token 2
out.addToken(Whitespace4a.SPACE); // Token 3
- out.addToken(new StringWord(0, "a")); // Token 4
+ out.addToken(new StringWord(0, "we")); // Token 4
out.addToken(Whitespace4a.SPACE); // Token 5
- out.addToken(new StringWord(0, "man")); // Token 6
- out.addToken(Whitespace4a.LINE_FEED); // Token 7
- out.addToken(new StringWord(0, "More")); // Token 8
+ out.addToken(new StringWord(0, "part", "ly")); // Token 6
+ out.addToken(Whitespace4a.SPACE); // Token 7
+ out.addToken(new StringWord(0, "may")); // Token 8
out.addToken(Whitespace4a.SPACE); // Token 9
- out.addToken(new StringWord(0, "sinn’d")); // Token 10
- out.addToken(Whitespace4a.SPACE); // Token 11
- out.addToken(new StringWord(0, "a", "gainst")); // Token 12
- out.addToken(Whitespace4a.SPACE); // Token 13
- out.addToken(new StringWord(0, "than")); // Token 14
- out.addToken(Whitespace4a.SPACE); // Token 15
- out.addToken(new StringWord(0, "sin", "ning")); // Token 16
- out.addToken(Punctuation4a.PERIOD); // Token 17
- Assert.assertEquals(18, out.qtyTokens());
+ out.addToken(new StringWord(0, "com", "pute")); // Token 10
+ out.addToken(Punctuation4a.COMMA); // Token 11
+ out.addToken(Whitespace4a.LINE_FEED); // Token 12
+ out.addToken(new StringWord(0, "But")); // Token 13
+ out.addToken(Whitespace4a.SPACE); // Token 14
+ out.addToken(new StringWord(0, "know")); // Token 15
+ out.addToken(Whitespace4a.SPACE); // Token 16
+ out.addToken(new StringWord(0, "not")); // Token 17
+ out.addToken(Whitespace4a.SPACE); // Token 18
+ out.addToken(new StringWord(0, "what’s")); // Token 19
+ out.addToken(Whitespace4a.SPACE); // Token 20
+ out.addToken(new StringWord(0, "re", "sist", "ed")); // Token 21
+ out.addToken(Punctuation4a.PERIOD); // Token 22
+ Assert.assertEquals(23, out.qtyTokens());
final TextModifiers textModifiers = Mockito.mock(TextModifiers.class);
Mockito.when(textModifiers.traitLinefeedTreatment()).thenReturn(LinefeedTreatment.TREAT_AS_SPACE);
@@ -195,33 +200,38 @@
/* Test extract starting at the start. */
TokenFlow.Location start = out.markLocation(0, 0, 0);
TokenFlow.Location end = out.markLocation(7, 0, 0);
- Assert.assertEquals("I am a man", out.extract(start, end, textModifiers, false, false));
+ Assert.assertEquals("What’s done we partly", out.extract(start, end, textModifiers, false, false));
/* Test extract ending with a space. */
end = out.markLocation(8, 0, 0);
- Assert.assertEquals("I am a man ", out.extract(start, end, textModifiers, false, false));
+ Assert.assertEquals("What’s done we partly ", out.extract(start, end, textModifiers, false, false));
/* Test extract ending at the end. */
- start = out.markLocation(8, 0, 0);
- end = out.markLocation(18, 0, 0);
- Assert.assertEquals("More sinn’d against than sinning.", out.extract(start, end, textModifiers, false, false));
+ start = out.markLocation(19, 0, 0);
+ end = out.markLocation(23, 0, 0);
+ Assert.assertEquals("what’s resisted.", out.extract(start, end, textModifiers, false, false));
+ /* Test extract ending on punctuation in the middle. */
+ start = out.markLocation(4, 0, 0);
+ end = out.markLocation(12, 0, 0);
+ Assert.assertEquals("we partly may compute,", out.extract(start, end, textModifiers, false, false));
+
/* Test extract starting in the middle of a word. */
- start = out.markLocation(12, 1, 0);
+ start = out.markLocation(10, 1, 0);
end = out.markLocation(18, 0, 0);
- Assert.assertEquals("gainst than sinning.", out.extract(start, end, textModifiers, false, false));
+ Assert.assertEquals("pute, But know not", out.extract(start, end, textModifiers, false, false));
/* Test extract starting in the middle of a word and ending in the middle of a word, where the text is not at
* the end of the line. */
- start = out.markLocation(12, 1, 0);
- end = out.markLocation(16, 1, 0);
- Assert.assertEquals("gainst than sin", out.extract(start, end, textModifiers, false, false));
+ start = out.markLocation(10, 1, 0);
+ end = out.markLocation(21, 1, 0);
+ Assert.assertEquals("pute, But know not what’s re", out.extract(start, end, textModifiers, false, false));
/* Test extract starting in the middle of a word and ending in the middle of a word, where the text IS at the
* end of the line, i.e. where a discretionary hyphen should be added. */
- start = out.markLocation(12, 1, 0);
- end = out.markLocation(16, 1, 0);
- Assert.assertEquals("gainst than sin-", out.extract(start, end, textModifiers, false, true));
+ start = out.markLocation(10, 1, 0);
+ end = out.markLocation(21, 1, 0);
+ Assert.assertEquals("pute, But know not what’s re-", out.extract(start, end, textModifiers, false, true));
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-13 17:29:52
|
Revision: 12390
http://sourceforge.net/p/foray/code/12390
Author: victormote
Date: 2022-01-13 17:29:49 +0000 (Thu, 13 Jan 2022)
Log Message:
-----------
1. Conform to and use results of aXSL change: Add the hyphenation character as part of the TextModifiers. 2. Add test of hyphenated line.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java
trunk/foray/foray-fotree/src/test/java/org/foray/fotree/AbstractPropertyTest.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/OverrideGraftingContext.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java 2022-01-13 14:33:00 UTC (rev 12389)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java 2022-01-13 17:29:49 UTC (rev 12390)
@@ -43,6 +43,7 @@
import org.axsl.fotree.fo.GraftingPoint;
import org.axsl.fotree.fo.Table;
import org.axsl.fotree.fo.prop.ColorPa;
+import org.axsl.fotree.fo.prop.CommonHyphenationPa;
import org.axsl.galley.AreaNodeG5;
import org.axsl.galley.Galley;
import org.axsl.orthography.Orthography;
@@ -766,4 +767,21 @@
final Block block = nearestBlockArea.traitGeneratedBy();
return block.traitWhiteSpaceCollapse(nearestBlockArea);
}
+
+ @Override
+ public int traitHyphenationCharacter() {
+ AreaNode4a areaNode = this;
+ Fo generator = traitGeneratedBy();
+ while (areaNode != null
+ && ! (generator instanceof CommonHyphenationPa)) {
+ areaNode = areaNode.getParent();
+ generator = areaNode.traitGeneratedBy();
+ }
+ if (areaNode == null) {
+ throw new IllegalStateException(this.getClass().getName() + " unable to find hyphenation character");
+ }
+ final CommonHyphenationPa fo = (CommonHyphenationPa) generator;
+ return fo.traitHyphenationCharacter(this);
+ }
+
}
Modified: trunk/foray/foray-fotree/src/test/java/org/foray/fotree/AbstractPropertyTest.java
===================================================================
--- trunk/foray/foray-fotree/src/test/java/org/foray/fotree/AbstractPropertyTest.java 2022-01-13 14:33:00 UTC (rev 12389)
+++ trunk/foray/foray-fotree/src/test/java/org/foray/fotree/AbstractPropertyTest.java 2022-01-13 17:29:49 UTC (rev 12390)
@@ -100,6 +100,10 @@
public WhiteSpaceTreatment traitWhiteSpaceTreatment() {
return WhiteSpaceTreatment.IGNORE_IF_SURROUNDING_LINEFEED;
}
+ @Override
+ public int traitHyphenationCharacter() {
+ return '-';
+ }
};
/** Constant providing a standard, but completely bogus context to be
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java 2022-01-13 14:33:00 UTC (rev 12389)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java 2022-01-13 17:29:49 UTC (rev 12390)
@@ -261,10 +261,33 @@
currentLocation.markTokenComplete();
}
+ if (isHyphenNeeded(isEndOfLine, endLocation)) {
+ builder.append(Character.toChars(textModifiers.traitHyphenationCharacter()));
+ }
+
applyWhiteSpaceTreatmentToLine(builder, textModifiers.traitWhiteSpaceTreatment(), isStartOfLine, isEndOfLine);
return builder.toString();
}
+ private boolean isHyphenNeeded(final boolean isEndOfLine, final TokenFlow.Location endLocation) {
+ if (! isEndOfLine) {
+ return false;
+ }
+ if (endLocation.getTokenIndex() >= this.qtyTokens()) {
+ /* The token marked as being the end of the token flow is past the end, indicating that all of the last
+ * token was included. */
+ return false;
+ }
+ final FoToken lastToken = this.tokenAt(endLocation.getTokenIndex());
+ if (lastToken instanceof FoWord) {
+ final FoWord word = (FoWord) lastToken;
+ final int qtySegments = word.qtyWordSegments();
+ return endLocation.getSegmentIndex() < qtySegments;
+ } else {
+ return false;
+ }
+ }
+
/**
* For tokens where it matters, computes the whitespace Unicode codepoint, if any, immediately before that token.
* This computation is only relevant for contiguous whitespace tokens, so that white-space-collapse can be properly
Modified: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java 2022-01-13 14:33:00 UTC (rev 12389)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java 2022-01-13 17:29:49 UTC (rev 12390)
@@ -34,6 +34,7 @@
import org.axsl.common.value.WhiteSpaceTreatment;
import org.axsl.fotree.text.FoTokenFlow;
import org.axsl.orthography.TokenFlow;
+import org.axsl.unicode.block.Basic_Latin_Block;
import org.junit.Assert;
import org.junit.Test;
@@ -189,6 +190,7 @@
Mockito.when(textModifiers.traitWhiteSpaceTreatment()).thenReturn(
WhiteSpaceTreatment.IGNORE_IF_SURROUNDING_LINEFEED);
Mockito.when(textModifiers.traitWhiteSpaceCollapse()).thenReturn(true);
+ Mockito.when(textModifiers.traitHyphenationCharacter()).thenReturn((int) Basic_Latin_Block.HYPHEN_MINUS);
/* Test extract starting at the start. */
TokenFlow.Location start = out.markLocation(0, 0, 0);
@@ -208,6 +210,18 @@
start = out.markLocation(12, 1, 0);
end = out.markLocation(18, 0, 0);
Assert.assertEquals("gainst than sinning.", out.extract(start, end, textModifiers, false, false));
+
+ /* Test extract starting in the middle of a word and ending in the middle of a word, where the text is not at
+ * the end of the line. */
+ start = out.markLocation(12, 1, 0);
+ end = out.markLocation(16, 1, 0);
+ Assert.assertEquals("gainst than sin", out.extract(start, end, textModifiers, false, false));
+
+ /* Test extract starting in the middle of a word and ending in the middle of a word, where the text IS at the
+ * end of the line, i.e. where a discretionary hyphen should be added. */
+ start = out.markLocation(12, 1, 0);
+ end = out.markLocation(16, 1, 0);
+ Assert.assertEquals("gainst than sin-", out.extract(start, end, textModifiers, false, true));
}
}
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/OverrideGraftingContext.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/OverrideGraftingContext.java 2022-01-13 14:33:00 UTC (rev 12389)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/OverrideGraftingContext.java 2022-01-13 17:29:49 UTC (rev 12390)
@@ -140,4 +140,9 @@
return this.wrappedContext.traitWhiteSpaceTreatment();
}
+ @Override
+ public int traitHyphenationCharacter() {
+ return this.wrappedContext.traitHyphenationCharacter();
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-13 14:33:03
|
Revision: 12389
http://sourceforge.net/p/foray/code/12389
Author: victormote
Date: 2022-01-13 14:33:00 +0000 (Thu, 13 Jan 2022)
Log Message:
-----------
When computing refined text, iterate the segments in the word.
Modified Paths:
--------------
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/MutableTokenFlowLocation.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/MutableTokenFlowLocation.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/MutableTokenFlowLocation.java 2022-01-13 13:16:05 UTC (rev 12388)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/MutableTokenFlowLocation.java 2022-01-13 14:33:00 UTC (rev 12389)
@@ -69,22 +69,42 @@
}
@Override
- public int compareTo(final TokenFlow.Location o) {
- if (this.tokenIndex == o.getTokenIndex()) {
- if (this.segmentIndex == o.getSegmentIndex()) {
- if (this.charIndex == o.getCharIndex()) {
+ public int compareTo(final TokenFlow.Location other) {
+ if (this.tokenIndex == other.getTokenIndex()) {
+ if (this.segmentIndex == other.getSegmentIndex()) {
+ if (this.charIndex == other.getCharIndex()) {
return 0;
} else {
- return this.charIndex - o.getCharIndex();
+ return this.charIndex - other.getCharIndex();
}
} else {
- return this.segmentIndex - o.getSegmentIndex();
+ return this.segmentIndex - other.getSegmentIndex();
}
} else {
- return this.tokenIndex - o.getTokenIndex();
+ return this.tokenIndex - other.getTokenIndex();
}
}
+ /**
+ * Indicates whether this location has the same token index as another.
+ * @param other The other location.
+ * @return True if and only if the token index in this location is the same as the token index in {@code other}.
+ */
+ public boolean isSameTokenAs(final TokenFlow.Location other) {
+ return this.tokenIndex == other.getTokenIndex();
+ }
+
+ /**
+ * Indicates whether this location has the same token index and segment index as another.
+ * @param other The other location.
+ * @return True if and only if the token index in this location is the same as the token index in {@code other},
+ * <em>and</em> the segment index in this location is the same as the segment index in {@code other}.
+ */
+ public boolean isSameTokenAndSegmentAs(final TokenFlow.Location other) {
+ return (this.tokenIndex == other.getTokenIndex())
+ && (this.segmentIndex == other.getSegmentIndex());
+ }
+
@Override
public String toString() {
return String.format(TO_STRING_FORMAT, this.tokenIndex, this.segmentIndex, this.charIndex);
@@ -100,4 +120,12 @@
this.charIndex = 0;
}
+ /**
+ * Marks the current token complete by incrementing the segment index and setting the charIndex to zero.
+ */
+ public void markSegmentComplete() {
+ this.segmentIndex ++;
+ this.charIndex = 0;
+ }
+
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java 2022-01-13 13:16:05 UTC (rev 12388)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java 2022-01-13 14:33:00 UTC (rev 12389)
@@ -39,6 +39,8 @@
import org.axsl.common.value.WhiteSpaceTreatment;
import org.axsl.fotree.text.FoToken;
import org.axsl.fotree.text.FoTokenFlow;
+import org.axsl.fotree.text.FoWord;
+import org.axsl.fotree.text.FoWordSegment;
import org.axsl.orthography.TokenFlow;
import org.axsl.orthography.Whitespace;
@@ -228,10 +230,33 @@
final FoToken token = tokenAt(currentLocation.getTokenIndex());
final int codepointBefore = relevantWhitespaceBefore(currentLocation.getTokenIndex());
final int codepointAfter = relevantWhitespaceAfter(currentLocation.getTokenIndex());
- for (int charIndex = 0; charIndex < token.qtyRefinedChars(textModifiers, codepointBefore, codepointAfter);
- charIndex ++) {
- final char refinedChar = token.refinedCharAt(charIndex, textModifiers, codepointBefore, codepointAfter);
- builder.append(refinedChar);
+ if (token instanceof FoWord) {
+ final FoWord word = (FoWord) token;
+ int endSegmentIndex = currentLocation.isSameTokenAs(endLocation) ?
+ endLocation.getSegmentIndex() : word.qtyWordSegments();
+ endSegmentIndex = Math.min(endSegmentIndex, word.qtyWordSegments());
+ for (int segmentIndex = currentLocation.getSegmentIndex();
+ segmentIndex < endSegmentIndex; segmentIndex ++) {
+ final FoWordSegment segment = word.wordSegmentAt(segmentIndex);
+ final boolean isFirstSegmentInWord = segmentIndex == 0;
+ final int endCharIndex =
+ currentLocation.isSameTokenAndSegmentAs(endLocation) ?
+ endLocation.getCharIndex() : segment.length();
+ for (int charIndex = currentLocation.getCharIndex(); charIndex < endCharIndex; charIndex ++) {
+ final char refinedChar =
+ segment.refinedCharAt(charIndex, textModifiers, isFirstSegmentInWord);
+ builder.append(refinedChar);
+ }
+ currentLocation.markSegmentComplete();
+ }
+ } else {
+ for (int charIndex = 0;
+ charIndex < token.qtyRefinedChars(textModifiers, codepointBefore, codepointAfter);
+ charIndex ++) {
+ final char refinedChar =
+ token.refinedCharAt(charIndex, textModifiers, codepointBefore, codepointAfter);
+ builder.append(refinedChar);
+ }
}
currentLocation.markTokenComplete();
}
Modified: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java 2022-01-13 13:16:05 UTC (rev 12388)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java 2022-01-13 14:33:00 UTC (rev 12389)
@@ -191,23 +191,23 @@
Mockito.when(textModifiers.traitWhiteSpaceCollapse()).thenReturn(true);
/* Test extract starting at the start. */
- TokenFlow.Location start = out.markLocation(0, (byte) 0, (byte) 0);
- TokenFlow.Location end = out.markLocation(7, (byte) 0, (byte) 0);
+ TokenFlow.Location start = out.markLocation(0, 0, 0);
+ TokenFlow.Location end = out.markLocation(7, 0, 0);
Assert.assertEquals("I am a man", out.extract(start, end, textModifiers, false, false));
/* Test extract ending with a space. */
- end = out.markLocation(8, (byte) 0, (byte) 0);
+ end = out.markLocation(8, 0, 0);
Assert.assertEquals("I am a man ", out.extract(start, end, textModifiers, false, false));
/* Test extract ending at the end. */
- start = out.markLocation(8, (byte) 0, (byte) 0);
- end = out.markLocation(18, (byte) 0, (byte) 0);
+ start = out.markLocation(8, 0, 0);
+ end = out.markLocation(18, 0, 0);
Assert.assertEquals("More sinn’d against than sinning.", out.extract(start, end, textModifiers, false, false));
-// /* Test extract starting in the middle of a word. */
-// start = out.markLocation(12, (byte) 2, (byte) 0);
-// end = out.markLocation(18, (byte) 0, (byte) 0);
-// Assert.assertEquals("gainst than sinning.", out.extract(start, end, textModifiers, false, false));
+ /* Test extract starting in the middle of a word. */
+ start = out.markLocation(12, 1, 0);
+ end = out.markLocation(18, 0, 0);
+ Assert.assertEquals("gainst than sinning.", out.extract(start, end, textModifiers, false, false));
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-13 13:16:08
|
Revision: 12388
http://sourceforge.net/p/foray/code/12388
Author: victormote
Date: 2022-01-13 13:16:05 +0000 (Thu, 13 Jan 2022)
Log Message:
-----------
1. Add tests for TokenFlow4a.extract(). 2. Improvements to Location marking.
Modified Paths:
--------------
trunk/foray/foray-common/src/main/java/org/foray/common/WellKnownConstants.java
trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4aIterator.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/MutableTokenFlowLocation.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/WellKnownConstants.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/WellKnownConstants.java 2022-01-12 21:01:38 UTC (rev 12387)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/WellKnownConstants.java 2022-01-13 13:16:05 UTC (rev 12388)
@@ -54,16 +54,16 @@
* 16. */
public static final byte MAX_4_BIT_UNSIGNED_VALUES = 16;
- /** The maximum number of values that can be stored in 8 bits, that is,
- * 256. */
+ /** The maximum number of values that can be stored in 8 bits, that is, 256. */
public static final short MAX_8_BIT_UNSIGNED_VALUES = 256;
- /** The maximum number of values that can be stored in 7 bits, that is,
- * 128. */
+ /** The maximum number of values that can be stored in 7 unsigned bits, which is {@value}. */
public static final short MAX_7_BIT_UNSIGNED_VALUES = 128;
- /** The maximum number of values that can be stored in 16 bits, that is,
- * 65,536. */
+ /** The maximum value that can be stored in 7 unsigned bits, which is {@value}. */
+ public static final short MAX_7_BIT_UNSIGNED_VALUE = 127;
+
+ /** The maximum number of values that can be stored in 16 bits, that is, 65,536. */
public static final int MAX_16_BIT_UNSIGNED_VALUES = 65536;
/** The number of bytes in a long, that is, 8. */
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4aIterator.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4aIterator.java 2022-01-12 21:01:38 UTC (rev 12387)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4aIterator.java 2022-01-13 13:16:05 UTC (rev 12388)
@@ -28,6 +28,7 @@
package org.foray.common.para;
+import org.foray.common.MarkedIndexOutOfBoundsException;
import org.foray.common.sequence.IntArrayBuilder;
import org.axsl.common.para.ParaBranch;
@@ -206,7 +207,30 @@
* @return The content of the branches stack at index {@code index}.
*/
public int branchIndexAt(final int index) {
- return this.branchIndexes.intAt(0);
+ return this.branchIndexes.intAt(index);
}
+ /**
+ * Advances to a given leaf index.
+ * @param newLeafIndex The leaf index to which the iterator should be advanced.
+ * @throws IllegalArgumentException If {@code newLeafIndex} is less than the current internal location of this
+ * iterator.
+ */
+ public void advanceToLeaf(final int newLeafIndex) {
+ if (newLeafIndex < 0
+ || newLeafIndex > this.paraLeafSize) {
+ throw new MarkedIndexOutOfBoundsException(newLeafIndex, this.paraLeafSize);
+ }
+ if (newLeafIndex < this.leafIndex) {
+ throw new IllegalArgumentException("Iterator is already past requested leaf index: " + newLeafIndex);
+ }
+ while (nextIndex() < newLeafIndex) {
+ if (hasNext()) {
+ next();
+ } else {
+ throw new IllegalStateException("Iterator cannot go past last element.");
+ }
+ }
+ }
+
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/MutableTokenFlowLocation.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/MutableTokenFlowLocation.java 2022-01-12 21:01:38 UTC (rev 12387)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/MutableTokenFlowLocation.java 2022-01-13 13:16:05 UTC (rev 12388)
@@ -35,6 +35,9 @@
*/
public class MutableTokenFlowLocation implements TokenFlow.Location {
+ /** String format for {@link #toString()}. */
+ private static final String TO_STRING_FORMAT = "[%d, %d, %d]";
+
/** The token index. See {@link TokenFlow.Location#getTokenIndex()}. */
private int tokenIndex;
@@ -82,6 +85,11 @@
}
}
+ @Override
+ public String toString() {
+ return String.format(TO_STRING_FORMAT, this.tokenIndex, this.segmentIndex, this.charIndex);
+ }
+
/**
* Marks the current token complete by incrementing the token index and setting the segmentIndex and charIndex to
* zero.
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java 2022-01-12 21:01:38 UTC (rev 12387)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java 2022-01-13 13:16:05 UTC (rev 12388)
@@ -28,6 +28,7 @@
package org.foray.orthography;
+import org.foray.common.WellKnownConstants;
import org.foray.common.para.ParaBranch4a;
import org.foray.common.para.ParaBranch4aIterator;
@@ -59,6 +60,9 @@
* using the 32 bits as 20 bits for the token, 6 for the segment, and 6 for the char, adding 4 bits to the size
* of the token index. */
+ /** String format for {@link #toString()}. */
+ private static final String TO_STRING_FORMAT = "[%d, %d, %d]";
+
/** The token index. See {@link TokenFlow.Location#getTokenIndex()}. */
private char tokenIndex;
@@ -68,12 +72,31 @@
/** The char index. See {@link TokenFlow.Location#getCharIndex()}. */
private byte charIndex;
- Location(final int tokenIndex, final byte segmentIndex, final byte charIndex) {
- /* A char can index 65,536 tokens, which is probably 30,000 words, allowing half of the tokens to be
- * whitespace, and some others to be punctuation. */
+ /**
+ * Constructor.
+ * @param tokenIndex The token index, in the range 0 thru 65,535.
+ * Estimating that half of the tokens are whitespace, and a good chunk more are punctuation, this should allow
+ * 25,000 to 30,000 words, which, for now, we consider sufficient.
+ * @param segmentIndex The segment index, in the range 0 thru 127.
+ * @param charIndex The char index, in the range 0 thru 127.
+ */
+ Location(final int tokenIndex, final int segmentIndex, final int charIndex) {
+ if (tokenIndex < 0
+ || tokenIndex > Character.MAX_VALUE) {
+ throw new IllegalArgumentException("The tokenIndex is out of range: " + tokenIndex);
+ }
+ if (segmentIndex < 0
+ || segmentIndex > WellKnownConstants.MAX_7_BIT_UNSIGNED_VALUE) {
+ throw new IllegalArgumentException("The segmentIndex is out of range: " + segmentIndex);
+ }
+ if (charIndex < 0
+ || charIndex > WellKnownConstants.MAX_7_BIT_UNSIGNED_VALUE) {
+ throw new IllegalArgumentException("The charIndex is out of range: " + charIndex);
+ }
+
this.tokenIndex = (char) tokenIndex;
- this.segmentIndex = segmentIndex;
- this.charIndex = charIndex;
+ this.segmentIndex = (byte) segmentIndex;
+ this.charIndex = (byte) charIndex;
}
@Override
@@ -108,6 +131,11 @@
}
}
+ @Override
+ public String toString() {
+ return String.format(TO_STRING_FORMAT, (int) this.tokenIndex, this.segmentIndex, this.charIndex);
+ }
+
}
/** The tokens (children) of this text flow. */
@@ -187,7 +215,7 @@
}
@Override
- public TokenFlow.Location markLocation(final int tokenIndex, final byte segmentIndex, final byte charIndex) {
+ public TokenFlow.Location markLocation(final int tokenIndex, final int segmentIndex, final int charIndex) {
return new Location(tokenIndex, segmentIndex, charIndex);
}
Modified: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java 2022-01-12 21:01:38 UTC (rev 12387)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java 2022-01-13 13:16:05 UTC (rev 12388)
@@ -28,10 +28,16 @@
package org.foray.orthography;
+import org.axsl.common.TextModifiers;
+import org.axsl.common.value.LinefeedTreatment;
+import org.axsl.common.value.TextTransform;
import org.axsl.common.value.WhiteSpaceTreatment;
+import org.axsl.fotree.text.FoTokenFlow;
+import org.axsl.orthography.TokenFlow;
import org.junit.Assert;
import org.junit.Test;
+import org.mockito.Mockito;
/**
* Tests of {@link TokenFlow4a}.
@@ -149,4 +155,59 @@
}
+ /**
+ * Tests of {@link TokenFlow4a#extract(FoTokenFlow.Location, FoTokenFlow.Location, TextModifiers, boolean,
+ * boolean)}.
+ */
+ @Test
+ public void extract_Test_001() {
+ /* William Shakespeare, "King Lear," Act iii, Scene 2. */
+ final TokenFlow4a out = new TokenFlow4a();
+ out.addToken(new StringWord(0, "I")); // Token 0
+ out.addToken(Whitespace4a.SPACE); // Token 1
+ out.addToken(new StringWord(0, "am")); // Token 2
+ out.addToken(Whitespace4a.SPACE); // Token 3
+ out.addToken(new StringWord(0, "a")); // Token 4
+ out.addToken(Whitespace4a.SPACE); // Token 5
+ out.addToken(new StringWord(0, "man")); // Token 6
+ out.addToken(Whitespace4a.LINE_FEED); // Token 7
+ out.addToken(new StringWord(0, "More")); // Token 8
+ out.addToken(Whitespace4a.SPACE); // Token 9
+ out.addToken(new StringWord(0, "sinn’d")); // Token 10
+ out.addToken(Whitespace4a.SPACE); // Token 11
+ out.addToken(new StringWord(0, "a", "gainst")); // Token 12
+ out.addToken(Whitespace4a.SPACE); // Token 13
+ out.addToken(new StringWord(0, "than")); // Token 14
+ out.addToken(Whitespace4a.SPACE); // Token 15
+ out.addToken(new StringWord(0, "sin", "ning")); // Token 16
+ out.addToken(Punctuation4a.PERIOD); // Token 17
+ Assert.assertEquals(18, out.qtyTokens());
+
+ final TextModifiers textModifiers = Mockito.mock(TextModifiers.class);
+ Mockito.when(textModifiers.traitLinefeedTreatment()).thenReturn(LinefeedTreatment.TREAT_AS_SPACE);
+ Mockito.when(textModifiers.traitTextTransform()).thenReturn(TextTransform.NONE);
+ Mockito.when(textModifiers.traitWhiteSpaceTreatment()).thenReturn(
+ WhiteSpaceTreatment.IGNORE_IF_SURROUNDING_LINEFEED);
+ Mockito.when(textModifiers.traitWhiteSpaceCollapse()).thenReturn(true);
+
+ /* Test extract starting at the start. */
+ TokenFlow.Location start = out.markLocation(0, (byte) 0, (byte) 0);
+ TokenFlow.Location end = out.markLocation(7, (byte) 0, (byte) 0);
+ Assert.assertEquals("I am a man", out.extract(start, end, textModifiers, false, false));
+
+ /* Test extract ending with a space. */
+ end = out.markLocation(8, (byte) 0, (byte) 0);
+ Assert.assertEquals("I am a man ", out.extract(start, end, textModifiers, false, false));
+
+ /* Test extract ending at the end. */
+ start = out.markLocation(8, (byte) 0, (byte) 0);
+ end = out.markLocation(18, (byte) 0, (byte) 0);
+ Assert.assertEquals("More sinn’d against than sinning.", out.extract(start, end, textModifiers, false, false));
+
+// /* Test extract starting in the middle of a word. */
+// start = out.markLocation(12, (byte) 2, (byte) 0);
+// end = out.markLocation(18, (byte) 0, (byte) 0);
+// Assert.assertEquals("gainst than sinning.", out.extract(start, end, textModifiers, false, false));
+ }
+
}
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java 2022-01-12 21:01:38 UTC (rev 12387)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java 2022-01-13 13:16:05 UTC (rev 12388)
@@ -77,7 +77,7 @@
final LineBreakResult result =
lb.breakIntoLines(this.node.getFoTokenFlow(), (ParaConfig) this.node, paraContext);
- FoTokenFlow.Location startLocation = this.node.getFoTokenFlow().markLocation(0, (byte) -1, (byte) -1);
+ FoTokenFlow.Location startLocation = this.node.getFoTokenFlow().markLocation(0, 0, 0);
/* Run a leaf iterator alongside the iteration of the line-break results, so that we can conveniently retrieve
* the branch indexes. */
final ParaBranch4aIterator iterator = new ParaBranch4aIterator(this.node.getFoTokenFlow());
@@ -84,18 +84,12 @@
for (int index = 0; index < result.getQtyLines(); index ++) {
final int currentLeafIndex = result.getBreakPosition(index);
final LineArea lineArea = normalBlockArea.makeLineArea(true);
- while (iterator.nextIndex() < currentLeafIndex) {
- if (iterator.hasNext()) {
- iterator.next();
- } else {
- throw new IllegalStateException("Iterator cannot go past last element.");
- }
- }
- /* Element 0 should be the token index. If there is an element 1, it should be the segment index. */
+ iterator.advanceToLeaf(currentLeafIndex);
+ /* Element 0 should be the token index. If there is an element 1, it is the segment index. */
final int tokenIndex = iterator.branchIndexAt(0);
- final byte segmentIndex = iterator.depth() > 1 ? (byte) iterator.branchIndexAt(1) : -1;
+ final int segmentIndex = iterator.depth() > 1 ? iterator.branchIndexAt(1) : 0;
final FoTokenFlow.Location endLocation =
- this.node.getFoTokenFlow().markLocation(tokenIndex, segmentIndex, (byte) -1);
+ this.node.getFoTokenFlow().markLocation(tokenIndex, segmentIndex, 0);
lineArea.makeGlyphAreaSequence(this.node, startLocation, endLocation, false);
startLocation = endLocation;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-12 21:01:42
|
Revision: 12387
http://sourceforge.net/p/foray/code/12387
Author: victormote
Date: 2022-01-12 21:01:38 +0000 (Wed, 12 Jan 2022)
Log Message:
-----------
Conform to aXSL change: Push method for extracting TokenFlow content to the lower-level FoTokenFlow interface.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractAncestralInlineArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaWords.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoText4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java
Added Paths:
-----------
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/MutableTokenFlowLocation.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java
Removed Paths:
-------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/MutableTokenFlowLocation.java
trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/obj/FoText4aTests.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractAncestralInlineArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractAncestralInlineArea.java 2022-01-12 17:56:35 UTC (rev 12386)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractAncestralInlineArea.java 2022-01-12 21:01:38 UTC (rev 12387)
@@ -50,6 +50,7 @@
import org.axsl.fotree.fo.PageNumberCitationLast;
import org.axsl.fotree.fo.RetrieveMarker;
import org.axsl.fotree.fo.ScalingValueCitation;
+import org.axsl.fotree.text.FoTokenFlow;
import org.axsl.galley.GlyphAreaSequenceG5;
import java.util.ArrayList;
@@ -93,7 +94,7 @@
@Override
public GlyphAreaSequenceG5 makeGlyphAreaSequence(final FoTextWords paragraph,
- final FoTextWords.Location startLocation, final FoTextWords.Location endLocation,
+ final FoTokenFlow.Location startLocation, final FoTokenFlow.Location endLocation,
final boolean hasFauxSmallCaps) {
throw new UnsupportedOperationException();
}
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2022-01-12 17:56:35 UTC (rev 12386)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2022-01-12 21:01:38 UTC (rev 12387)
@@ -63,6 +63,7 @@
import org.axsl.fotree.fo.PageNumberCitationLast;
import org.axsl.fotree.fo.RetrieveMarker;
import org.axsl.fotree.fo.ScalingValueCitation;
+import org.axsl.fotree.text.FoTokenFlow;
import org.axsl.galley.GalleyVisitor;
import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GlyphAreaSequenceG5;
@@ -1015,7 +1016,7 @@
@Override
public GlyphAreaSequenceG5 makeGlyphAreaSequence(final FoTextWords paragraph,
- final FoTextWords.Location startLocation, final FoTextWords.Location endLocation,
+ final FoTokenFlow.Location startLocation, final FoTokenFlow.Location endLocation,
final boolean hasFauxSmallCaps) {
final TextAreaWords newTextArea = TextAreaWords.makeTextArea(paragraph, this, startLocation, endLocation);
this.children.add(newTextArea);
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaWords.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaWords.java 2022-01-12 17:56:35 UTC (rev 12386)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaWords.java 2022-01-12 21:01:38 UTC (rev 12387)
@@ -31,6 +31,7 @@
import org.foray.area.link.Link;
import org.axsl.fotree.fo.FoTextWords;
+import org.axsl.fotree.text.FoTokenFlow;
public class TextAreaWords extends TextArea {
@@ -38,10 +39,10 @@
private Link<FoTextWords> foLink;
/** The starting location in {@link #foLink#traitGeneratedBy()} for the text in this area, inclusive. */
- private FoTextWords.Location startLocation;
+ private FoTokenFlow.Location startLocation;
/** The ending location in {@link #foLink#traitGeneratedBy()} for the text in this area, exclusive. */
- private FoTextWords.Location endLocation;
+ private FoTokenFlow.Location endLocation;
/**
* Constructor.
@@ -51,7 +52,7 @@
* @param endLocation The ending location in {@code generatedBy} for the text in this area, exclusive.
*/
public TextAreaWords(final LineArea4a parentArea, final Link<FoTextWords> generatedBy,
- final FoTextWords.Location startLocation, final FoTextWords.Location endLocation) {
+ final FoTokenFlow.Location startLocation, final FoTokenFlow.Location endLocation) {
super(parentArea);
this.foLink = generatedBy;
this.startLocation = startLocation;
@@ -67,7 +68,7 @@
* @return The newly-created TextArea.
*/
static TextAreaWords makeTextArea(final FoTextWords generatedBy, final LineArea4a parentArea,
- final FoTextWords.Location startLocation, final FoTextWords.Location endLocation) {
+ final FoTokenFlow.Location startLocation, final FoTokenFlow.Location endLocation) {
final Link<FoTextWords> linkage = parentArea.getLink(generatedBy);
final TextAreaWords newTextArea = new TextAreaWords(parentArea, linkage, startLocation, endLocation);
newTextArea.registerLink(generatedBy);
@@ -85,7 +86,8 @@
final int whichChild = getParent().getOtnChildIndex(this);
final boolean isStartOfLine = whichChild == 0;
final boolean isEndOfLine = whichChild == getParent().getOtnChildCount() - 1;
- return generator.extract(this.startLocation, this.endLocation, this, isStartOfLine, isEndOfLine);
+ return generator.getFoTokenFlow().extract(
+ this.startLocation, this.endLocation, this, isStartOfLine, isEndOfLine);
}
@Override
Deleted: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/MutableTokenFlowLocation.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/MutableTokenFlowLocation.java 2022-01-12 17:56:35 UTC (rev 12386)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/MutableTokenFlowLocation.java 2022-01-12 21:01:38 UTC (rev 12387)
@@ -1,95 +0,0 @@
-/*
- * Copyright 2017 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.fotree;
-
-import org.axsl.orthography.TokenFlow;
-
-/**
- * A mutable version of {@link TokenFlow.Location}, useful when iterating locations.
- */
-public class MutableTokenFlowLocation implements TokenFlow.Location {
-
- /** The token index. See {@link TokenFlow.Location#getTokenIndex()}. */
- private int tokenIndex;
-
- /** The segment index. See {@link TokenFlow.Location#getSegmentIndex()}. */
- private byte segmentIndex;
-
- /** The char index. See {@link TokenFlow.Location#getCharIndex()}. */
- private byte charIndex;
-
- public MutableTokenFlowLocation(final TokenFlow.Location location) {
- this.tokenIndex = location.getTokenIndex();
- this.segmentIndex = location.getSegmentIndex();
- this.charIndex = location.getCharIndex();
- }
-
- @Override
- public int getTokenIndex() {
- return this.tokenIndex;
- }
-
- @Override
- public byte getSegmentIndex() {
- return this.segmentIndex;
- }
-
- @Override
- public byte getCharIndex() {
- return this.charIndex;
- }
-
- @Override
- public int compareTo(final TokenFlow.Location o) {
- if (this.tokenIndex == o.getTokenIndex()) {
- if (this.segmentIndex == o.getSegmentIndex()) {
- if (this.charIndex == o.getCharIndex()) {
- return 0;
- } else {
- return this.charIndex - o.getCharIndex();
- }
- } else {
- return this.segmentIndex - o.getSegmentIndex();
- }
- } else {
- return this.tokenIndex - o.getTokenIndex();
- }
- }
-
- /**
- * Marks the current token complete by incrementing the token index and setting the segmentIndex and charIndex to
- * zero.
- */
- public void markTokenComplete() {
- this.tokenIndex ++;
- this.segmentIndex = 0;
- this.charIndex = 0;
- }
-
-}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoText4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoText4a.java 2022-01-12 17:56:35 UTC (rev 12386)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoText4a.java 2022-01-12 21:01:38 UTC (rev 12387)
@@ -345,46 +345,6 @@
}
/**
- * Applies white-space-treatment to the characters in a {@link StringBuilder}.
- * @param builder The text to be (possibly) modifed.
- * @param whiteSpaceTreatment The white-space-treatment trait.
- * @param isStartOfLine Indicates whether {@code builder} is at the start of a line.
- * @param isEndOfLine Indicates whether {@code builder} is at the end of a line.
- */
- public static void applyWhiteSpaceTreatmentToLine(final StringBuilder builder,
- final WhiteSpaceTreatment whiteSpaceTreatment, final boolean isStartOfLine, final boolean isEndOfLine) {
- /* Because suppress-at-line-break applies only to fo:character, and it cannot be inherited, there is no
- * possibility that any character other than U+0020 can be affected by white-space-treatment. */
- if (whiteSpaceTreatment == WhiteSpaceTreatment.PRESERVE) {
- return;
- }
- if (isStartOfLine
- && whiteSpaceTreatment.ignoreAtStartOfLine()) {
- while (builder.length() > 0
- && builder.charAt(0) == ' ') {
- builder.deleteCharAt(0);
- }
- }
- if (isEndOfLine
- && whiteSpaceTreatment.ignoreAtEndOfLine()) {
- while (builder.length() > 0
- && builder.charAt(builder.length() - 1) == ' ') {
- builder.deleteCharAt(builder.length() - 1);
- }
- }
- if (whiteSpaceTreatment == WhiteSpaceTreatment.IGNORE) {
- for (int index = 0; index < builder.length(); index ++) {
- final char c = builder.charAt(index);
- if (c == ' ') {
- builder.deleteCharAt(index);
- /* We need to decrement the index here to avoid skipping the next char. */
- index --;
- }
- }
- }
- }
-
- /**
* Applies the linefeed treatment to a specific character.
* @param c The character being processed, which should always be a linefeed character.
* @param linefeedTreatment The value of the linefeed-treatment trait.
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-12 17:56:35 UTC (rev 12386)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-12 21:01:38 UTC (rev 12387)
@@ -29,11 +29,7 @@
package org.foray.fotree.fo.obj;
import org.foray.fotree.FoObj;
-import org.foray.fotree.MutableTokenFlowLocation;
-import org.axsl.common.TextModifiers;
-import org.axsl.common.para.ParaBranch;
-import org.axsl.common.para.ParaLeaf;
import org.axsl.common.para.ParaNode;
import org.axsl.common.value.LinefeedTreatment;
import org.axsl.common.value.TextTransform;
@@ -44,11 +40,8 @@
import org.axsl.fotree.text.FoToken;
import org.axsl.fotree.text.FoTokenFlow;
import org.axsl.orthography.OrthographyException;
-import org.axsl.orthography.TokenFlow;
import org.axsl.orthography.Whitespace;
-import java.util.ListIterator;
-
/**
* Text in an FO document that is already broken into words.
*/
@@ -80,56 +73,6 @@
}
@Override
- public int qtyParaNodes() {
- return this.paraBranch.qtyTokens();
- }
-
- @Override
- public ParaNode paraNodeAt(final int nodeIndex) {
- return this.paraBranch.paraNodeAt(nodeIndex);
- }
-
- @Override
- public int qtyParaLeaves() {
- return this.paraBranch.qtyParaLeaves();
- }
-
- @Override
- public ParaLeaf paraLeafAt(final int leafIndex) {
- return this.paraBranch.paraLeafAt(leafIndex);
- }
-
- @Override
- public ListIterator<ParaLeaf> leafIterator() {
- return this.paraBranch.leafIterator();
- }
-
- @Override
- public Type getParaNodeType() {
- return this.paraBranch.getParaNodeType();
- }
-
- @Override
- public ParaLeaf asParaLeaf() {
- return this.paraBranch.asParaLeaf();
- }
-
- @Override
- public ParaBranch asParaBranch() {
- return this.paraBranch.asParaBranch();
- }
-
- @Override
- public int qtyKpLeaves() {
- return this.paraBranch.qtyKpLeaves();
- }
-
- @Override
- public CharSequence getText() {
- return this.paraBranch.getText();
- }
-
- @Override
public boolean isAllWhiteSpace() {
for (int index = 0; index < this.paraBranch.qtyTokens(); index ++) {
final FoToken token = this.paraBranch.tokenAt(index);
@@ -174,91 +117,8 @@
}
@Override
- public int qtyTokens() {
- return this.paraBranch.qtyTokens();
+ public FoTokenFlow getFoTokenFlow() {
+ return this.paraBranch;
}
- @Override
- public FoToken tokenAt(final int index) {
- return this.paraBranch.tokenAt(index);
- }
-
- @Override
- public CharSequence extract(final TokenFlow.Location startLocation, final TokenFlow.Location endLocation,
- final TextModifiers textModifiers, final boolean isStartOfLine, final boolean isEndOfLine) {
- final StringBuilder builder = new StringBuilder();
- final MutableTokenFlowLocation currentLocation = new MutableTokenFlowLocation(startLocation);
- while (currentLocation.compareTo(endLocation) < 0) {
- final FoToken token = tokenAt(currentLocation.getTokenIndex());
- final int codepointBefore = relevantWhitespaceBefore(currentLocation.getTokenIndex());
- final int codepointAfter = relevantWhitespaceAfter(currentLocation.getTokenIndex());
- for (int charIndex = 0; charIndex < token.qtyRefinedChars(textModifiers, codepointBefore, codepointAfter);
- charIndex ++) {
- final char refinedChar = token.refinedCharAt(charIndex, textModifiers, codepointBefore, codepointAfter);
- builder.append(refinedChar);
- }
- currentLocation.markTokenComplete();
- }
-
- applyWhiteSpaceTreatmentToLine(builder, textModifiers.traitWhiteSpaceTreatment(), isStartOfLine, isEndOfLine);
- return builder.toString();
- }
-
- /**
- * For tokens where it matters, computes the whitespace Unicode codepoint, if any, immediately before that token.
- * This computation is only relevant for contiguous whitespace tokens, so that white-space-collapse can be properly
- * computed.
- * @param tokenIndex The index to the token for which the prior codepoint is being computed.
- * @return If the token at {@code tokenIndex} is whitespace, and the previous token is also whitespace, returns the
- * raw Unicode codepoint of that subsequent whitespace token.
- * For all other tokens, returns -1, as this computation is not relevant.
- */
- private int relevantWhitespaceBefore(final int tokenIndex) {
- final FoToken token = this.paraBranch.tokenAt(tokenIndex);
- if (! (token instanceof Whitespace)) {
- return -1;
- }
- if (tokenIndex == 0) {
- return -1;
- }
- final FoToken previousToken = this.paraBranch.tokenAt(tokenIndex - 1);
- if (previousToken instanceof Whitespace) {
- final Whitespace whitespace = (Whitespace) previousToken;
- return whitespace.charAt(whitespace.length() - 1);
- }
- /* The previous token is not whitespace. */
- return -1;
- }
-
- /**
- * For tokens where it matters, computes the whitespace Unicode codepoint, if any, immediately after a given token.
- * This computation is only relevant for contiguous whitespace tokens, so that white-space-collapse can be properly
- * computed.
- * @param tokenIndex The index to the token for which the subsequent codepoint is being computed.
- * @return If the token at {@code tokenIndex} is whitespace, and the next token is also whitespace, returns the
- * raw Unicode codepoint of that subsequent whitespace token.
- * For all other tokens, returns -1, as this computation is not relevant.
- */
- private int relevantWhitespaceAfter(final int tokenIndex) {
- final FoToken token = this.paraBranch.tokenAt(tokenIndex);
- if (! (token instanceof Whitespace)) {
- return -1;
- }
- if (tokenIndex == this.paraBranch.qtyTokens() - 1) {
- return -1;
- }
- final FoToken nextToken = this.paraBranch.tokenAt(tokenIndex + 1);
- if (nextToken instanceof Whitespace) {
- final Whitespace whitespace = (Whitespace) nextToken;
- return whitespace.charAt(0);
- }
- /* The next token is not whitespace. */
- return -1;
- }
-
- @Override
- public Location markLocation(final int tokenIndex, final byte segmentIndex, final byte charIndex) {
- return this.paraBranch.markLocation(tokenIndex, segmentIndex, charIndex);
- }
-
}
Deleted: trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/obj/FoText4aTests.java
===================================================================
--- trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/obj/FoText4aTests.java 2022-01-12 17:56:35 UTC (rev 12386)
+++ trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/obj/FoText4aTests.java 2022-01-12 21:01:38 UTC (rev 12387)
@@ -1,151 +0,0 @@
-/*
- * Copyright 2021 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.fotree.fo.obj;
-
-import org.axsl.common.value.WhiteSpaceTreatment;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Tests of {@link FoText4a}.
- */
-public class FoText4aTests {
-
- /**
- * Tests of {@link FoText4a#applyWhiteSpaceTreatmentToLine(StringBuilder, WhiteSpaceTreatment, boolean, boolean)}
- * for a string with both leading and trailing spaces.
- */
- @Test
- public void applyWhiteSpaceTreatmentToLine_Test_001() {
- final String string1 = " A test string. ";
-
- StringBuilder builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.PRESERVE, false, false);
- Assert.assertEquals(string1, builder.toString());
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.PRESERVE, false, true);
- Assert.assertEquals(string1, builder.toString());
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.PRESERVE, true, false);
- Assert.assertEquals(string1, builder.toString());
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.PRESERVE, true, true);
- Assert.assertEquals(string1, builder.toString());
-
-
-
-
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE, false, false);
- Assert.assertEquals("Ateststring.", builder.toString());
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE, false, true);
- Assert.assertEquals("Ateststring.", builder.toString());
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE, true, false);
- Assert.assertEquals("Ateststring.", builder.toString());
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE, true, true);
- Assert.assertEquals("Ateststring.", builder.toString());
-
-
-
-
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_BEFORE_LINEFEED, false, false);
- Assert.assertEquals(string1, builder.toString());
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_BEFORE_LINEFEED, false, true);
- Assert.assertEquals(" A test string.", builder.toString());
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_BEFORE_LINEFEED, true, false);
- Assert.assertEquals(string1, builder.toString());
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_BEFORE_LINEFEED, true, true);
- Assert.assertEquals(" A test string.", builder.toString());
-
-
-
-
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_AFTER_LINEFEED, false, false);
- Assert.assertEquals(string1, builder.toString());
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_AFTER_LINEFEED, false, true);
- Assert.assertEquals(string1, builder.toString());
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_AFTER_LINEFEED, true, false);
- Assert.assertEquals("A test string. ", builder.toString());
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_AFTER_LINEFEED, true, true);
- Assert.assertEquals("A test string. ", builder.toString());
-
-
-
-
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(
- builder, WhiteSpaceTreatment.IGNORE_IF_SURROUNDING_LINEFEED, false, false);
- Assert.assertEquals(string1, builder.toString());
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(
- builder, WhiteSpaceTreatment.IGNORE_IF_SURROUNDING_LINEFEED, false, true);
- Assert.assertEquals(" A test string.", builder.toString());
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(
- builder, WhiteSpaceTreatment.IGNORE_IF_SURROUNDING_LINEFEED, true, false);
- Assert.assertEquals("A test string. ", builder.toString());
-
- builder = new StringBuilder(string1);
- FoText4a.applyWhiteSpaceTreatmentToLine(
- builder, WhiteSpaceTreatment.IGNORE_IF_SURROUNDING_LINEFEED, true, true);
- Assert.assertEquals("A test string.", builder.toString());
-
- }
-
-}
Copied: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/MutableTokenFlowLocation.java (from rev 12383, trunk/foray/foray-fotree/src/main/java/org/foray/fotree/MutableTokenFlowLocation.java)
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/MutableTokenFlowLocation.java (rev 0)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/MutableTokenFlowLocation.java 2022-01-12 21:01:38 UTC (rev 12387)
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2017 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.orthography;
+
+import org.axsl.orthography.TokenFlow;
+
+/**
+ * A mutable version of {@link TokenFlow.Location}, useful when iterating locations.
+ */
+public class MutableTokenFlowLocation implements TokenFlow.Location {
+
+ /** The token index. See {@link TokenFlow.Location#getTokenIndex()}. */
+ private int tokenIndex;
+
+ /** The segment index. See {@link TokenFlow.Location#getSegmentIndex()}. */
+ private byte segmentIndex;
+
+ /** The char index. See {@link TokenFlow.Location#getCharIndex()}. */
+ private byte charIndex;
+
+ public MutableTokenFlowLocation(final TokenFlow.Location location) {
+ this.tokenIndex = location.getTokenIndex();
+ this.segmentIndex = location.getSegmentIndex();
+ this.charIndex = location.getCharIndex();
+ }
+
+ @Override
+ public int getTokenIndex() {
+ return this.tokenIndex;
+ }
+
+ @Override
+ public byte getSegmentIndex() {
+ return this.segmentIndex;
+ }
+
+ @Override
+ public byte getCharIndex() {
+ return this.charIndex;
+ }
+
+ @Override
+ public int compareTo(final TokenFlow.Location o) {
+ if (this.tokenIndex == o.getTokenIndex()) {
+ if (this.segmentIndex == o.getSegmentIndex()) {
+ if (this.charIndex == o.getCharIndex()) {
+ return 0;
+ } else {
+ return this.charIndex - o.getCharIndex();
+ }
+ } else {
+ return this.segmentIndex - o.getSegmentIndex();
+ }
+ } else {
+ return this.tokenIndex - o.getTokenIndex();
+ }
+ }
+
+ /**
+ * Marks the current token complete by incrementing the token index and setting the segmentIndex and charIndex to
+ * zero.
+ */
+ public void markTokenComplete() {
+ this.tokenIndex ++;
+ this.segmentIndex = 0;
+ this.charIndex = 0;
+ }
+
+}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java 2022-01-12 17:56:35 UTC (rev 12386)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java 2022-01-12 21:01:38 UTC (rev 12387)
@@ -31,12 +31,15 @@
import org.foray.common.para.ParaBranch4a;
import org.foray.common.para.ParaBranch4aIterator;
+import org.axsl.common.TextModifiers;
import org.axsl.common.para.ParaBranch;
import org.axsl.common.para.ParaLeaf;
import org.axsl.common.para.ParaNode;
+import org.axsl.common.value.WhiteSpaceTreatment;
import org.axsl.fotree.text.FoToken;
import org.axsl.fotree.text.FoTokenFlow;
import org.axsl.orthography.TokenFlow;
+import org.axsl.orthography.Whitespace;
import java.util.ArrayList;
import java.util.List;
@@ -188,4 +191,117 @@
return new Location(tokenIndex, segmentIndex, charIndex);
}
+ @Override
+ public CharSequence extract(final TokenFlow.Location startLocation, final TokenFlow.Location endLocation,
+ final TextModifiers textModifiers, final boolean isStartOfLine, final boolean isEndOfLine) {
+ final StringBuilder builder = new StringBuilder();
+ final MutableTokenFlowLocation currentLocation = new MutableTokenFlowLocation(startLocation);
+ while (currentLocation.compareTo(endLocation) < 0) {
+ final FoToken token = tokenAt(currentLocation.getTokenIndex());
+ final int codepointBefore = relevantWhitespaceBefore(currentLocation.getTokenIndex());
+ final int codepointAfter = relevantWhitespaceAfter(currentLocation.getTokenIndex());
+ for (int charIndex = 0; charIndex < token.qtyRefinedChars(textModifiers, codepointBefore, codepointAfter);
+ charIndex ++) {
+ final char refinedChar = token.refinedCharAt(charIndex, textModifiers, codepointBefore, codepointAfter);
+ builder.append(refinedChar);
+ }
+ currentLocation.markTokenComplete();
+ }
+
+ applyWhiteSpaceTreatmentToLine(builder, textModifiers.traitWhiteSpaceTreatment(), isStartOfLine, isEndOfLine);
+ return builder.toString();
+ }
+
+ /**
+ * For tokens where it matters, computes the whitespace Unicode codepoint, if any, immediately before that token.
+ * This computation is only relevant for contiguous whitespace tokens, so that white-space-collapse can be properly
+ * computed.
+ * @param tokenIndex The index to the token for which the prior codepoint is being computed.
+ * @return If the token at {@code tokenIndex} is whitespace, and the previous token is also whitespace, returns the
+ * raw Unicode codepoint of that subsequent whitespace token.
+ * For all other tokens, returns -1, as this computation is not relevant.
+ */
+ private int relevantWhitespaceBefore(final int tokenIndex) {
+ final FoToken token = tokenAt(tokenIndex);
+ if (! (token instanceof Whitespace)) {
+ return -1;
+ }
+ if (tokenIndex == 0) {
+ return -1;
+ }
+ final FoToken previousToken = tokenAt(tokenIndex - 1);
+ if (previousToken instanceof Whitespace) {
+ final Whitespace whitespace = (Whitespace) previousToken;
+ return whitespace.charAt(whitespace.length() - 1);
+ }
+ /* The previous token is not whitespace. */
+ return -1;
+ }
+
+ /**
+ * For tokens where it matters, computes the whitespace Unicode codepoint, if any, immediately after a given token.
+ * This computation is only relevant for contiguous whitespace tokens, so that white-space-collapse can be properly
+ * computed.
+ * @param tokenIndex The index to the token for which the subsequent codepoint is being computed.
+ * @return If the token at {@code tokenIndex} is whitespace, and the next token is also whitespace, returns the
+ * raw Unicode codepoint of that subsequent whitespace token.
+ * For all other tokens, returns -1, as this computation is not relevant.
+ */
+ private int relevantWhitespaceAfter(final int tokenIndex) {
+ final FoToken token = tokenAt(tokenIndex);
+ if (! (token instanceof Whitespace)) {
+ return -1;
+ }
+ if (tokenIndex == qtyTokens() - 1) {
+ return -1;
+ }
+ final FoToken nextToken = tokenAt(tokenIndex + 1);
+ if (nextToken instanceof Whitespace) {
+ final Whitespace whitespace = (Whitespace) nextToken;
+ return whitespace.charAt(0);
+ }
+ /* The next token is not whitespace. */
+ return -1;
+ }
+
+ /**
+ * Applies white-space-treatment to the characters in a {@link StringBuilder}.
+ * @param builder The text to be (possibly) modifed.
+ * @param whiteSpaceTreatment The white-space-treatment trait.
+ * @param isStartOfLine Indicates whether {@code builder} is at the start of a line.
+ * @param isEndOfLine Indicates whether {@code builder} is at the end of a line.
+ */
+ public static void applyWhiteSpaceTreatmentToLine(final StringBuilder builder,
+ final WhiteSpaceTreatment whiteSpaceTreatment, final boolean isStartOfLine, final boolean isEndOfLine) {
+ /* Because suppress-at-line-break applies only to fo:character, and it cannot be inherited, there is no
+ * possibility that any character other than U+0020 can be affected by white-space-treatment. */
+ if (whiteSpaceTreatment == WhiteSpaceTreatment.PRESERVE) {
+ return;
+ }
+ if (isStartOfLine
+ && whiteSpaceTreatment.ignoreAtStartOfLine()) {
+ while (builder.length() > 0
+ && builder.charAt(0) == ' ') {
+ builder.deleteCharAt(0);
+ }
+ }
+ if (isEndOfLine
+ && whiteSpaceTreatment.ignoreAtEndOfLine()) {
+ while (builder.length() > 0
+ && builder.charAt(builder.length() - 1) == ' ') {
+ builder.deleteCharAt(builder.length() - 1);
+ }
+ }
+ if (whiteSpaceTreatment == WhiteSpaceTreatment.IGNORE) {
+ for (int index = 0; index < builder.length(); index ++) {
+ final char c = builder.charAt(index);
+ if (c == ' ') {
+ builder.deleteCharAt(index);
+ /* We need to decrement the index here to avoid skipping the next char. */
+ index --;
+ }
+ }
+ }
+ }
+
}
Copied: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java (from rev 12381, trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/obj/FoText4aTests.java)
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java (rev 0)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java 2022-01-12 21:01:38 UTC (rev 12387)
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2021 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.orthography;
+
+import org.axsl.common.value.WhiteSpaceTreatment;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Tests of {@link TokenFlow4a}.
+ */
+public class TokenFlow4aTests {
+
+ /**
+ * Tests of {@link TokenFlow4a#applyWhiteSpaceTreatmentToLine(StringBuilder, WhiteSpaceTreatment, boolean, boolean)}
+ * for a string with both leading and trailing spaces.
+ */
+ @Test
+ public void applyWhiteSpaceTreatmentToLine_Test_001() {
+ final String string1 = " A test string. ";
+
+ StringBuilder builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.PRESERVE, false, false);
+ Assert.assertEquals(string1, builder.toString());
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.PRESERVE, false, true);
+ Assert.assertEquals(string1, builder.toString());
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.PRESERVE, true, false);
+ Assert.assertEquals(string1, builder.toString());
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.PRESERVE, true, true);
+ Assert.assertEquals(string1, builder.toString());
+
+
+
+
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE, false, false);
+ Assert.assertEquals("Ateststring.", builder.toString());
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE, false, true);
+ Assert.assertEquals("Ateststring.", builder.toString());
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE, true, false);
+ Assert.assertEquals("Ateststring.", builder.toString());
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE, true, true);
+ Assert.assertEquals("Ateststring.", builder.toString());
+
+
+
+
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(
+ builder, WhiteSpaceTreatment.IGNORE_IF_BEFORE_LINEFEED, false, false);
+ Assert.assertEquals(string1, builder.toString());
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_BEFORE_LINEFEED, false, true);
+ Assert.assertEquals(" A test string.", builder.toString());
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_BEFORE_LINEFEED, true, false);
+ Assert.assertEquals(string1, builder.toString());
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_BEFORE_LINEFEED, true, true);
+ Assert.assertEquals(" A test string.", builder.toString());
+
+
+
+
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_AFTER_LINEFEED, false, false);
+ Assert.assertEquals(string1, builder.toString());
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_AFTER_LINEFEED, false, true);
+ Assert.assertEquals(string1, builder.toString());
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_AFTER_LINEFEED, true, false);
+ Assert.assertEquals("A test string. ", builder.toString());
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_AFTER_LINEFEED, true, true);
+ Assert.assertEquals("A test string. ", builder.toString());
+
+
+
+
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(
+ builder, WhiteSpaceTreatment.IGNORE_IF_SURROUNDING_LINEFEED, false, false);
+ Assert.assertEquals(string1, builder.toString());
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(
+ builder, WhiteSpaceTreatment.IGNORE_IF_SURROUNDING_LINEFEED, false, true);
+ Assert.assertEquals(" A test string.", builder.toString());
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(
+ builder, WhiteSpaceTreatment.IGNORE_IF_SURROUNDING_LINEFEED, true, false);
+ Assert.assertEquals("A test string. ", builder.toString());
+
+ builder = new StringBuilder(string1);
+ TokenFlow4a.applyWhiteSpaceTreatmentToLine(
+ builder, WhiteSpaceTreatment.IGNORE_IF_SURROUNDING_LINEFEED, true, true);
+ Assert.assertEquals("A test string.", builder.toString());
+
+ }
+
+}
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java 2022-01-12 17:56:35 UTC (rev 12386)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java 2022-01-12 21:01:38 UTC (rev 12387)
@@ -37,6 +37,7 @@
import org.axsl.common.para.ParaConfig;
import org.axsl.common.para.ParaContext;
import org.axsl.fotree.fo.FoTextWords;
+import org.axsl.fotree.text.FoTokenFlow;
import org.axsl.linebreak.LineBreakResult;
import org.axsl.linebreak.LineBreaker;
@@ -73,12 +74,13 @@
final ParaContext paraContext = normalBlockArea.getParaContext();
final LineBreaker lb = areaNode.getAreaTree().getLineBreaker();
- final LineBreakResult result = lb.breakIntoLines(this.node, (ParaConfig) this.node, paraContext);
+ final LineBreakResult result =
+ lb.breakIntoLines(this.node.getFoTokenFlow(), (ParaConfig) this.node, paraContext);
- FoTextWords.Location startLocation = this.node.markLocation(0, (byte) -1, (byte) -1);
+ FoTokenFlow.Location startLocation = this.node.getFoTokenFlow().markLocation(0, (byte) -1, (byte) -1);
/* Run a leaf iterator alongside the iteration of the line-break results, so that we can conveniently retrieve
* the branch indexes. */
- final ParaBranch4aIterator iterator = new ParaBranch4aIterator(this.node);
+ final ParaBranch4aIterator iterator = new ParaBranch4aIterator(this.node.getFoTokenFlow());
for (int index = 0; index < result.getQtyLines(); index ++) {
final int currentLeafIndex = result.getBreakPosition(index);
final LineArea lineArea = normalBlockArea.makeLineArea(true);
@@ -92,7 +94,8 @@
/* Element 0 should be the token index. If there is an element 1, it should be the segment index. */
final int tokenIndex = iterator.branchIndexAt(0);
final byte segmentIndex = iterator.depth() > 1 ? (byte) iterator.branchIndexAt(1) : -1;
- final FoTextWords.Location endLocation = this.node.markLocation(tokenIndex, segmentIndex, (byte) -1);
+ final FoTokenFlow.Location endLocation =
+ this.node.getFoTokenFlow().markLocation(tokenIndex, segmentIndex, (byte) -1);
lineArea.makeGlyphAreaSequence(this.node, startLocation, endLocation, false);
startLocation = endLocation;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-12 17:56:44
|
Revision: 12386
http://sourceforge.net/p/foray/code/12386
Author: victormote
Date: 2022-01-12 17:56:35 +0000 (Wed, 12 Jan 2022)
Log Message:
-----------
Add tests of refined text for Word4a, making fixes where needed.
Modified Paths:
--------------
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentLatin1.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentUtf16.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Word4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/WordSegment4a.java
Added Paths:
-----------
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/Word4aTests.java
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentLatin1.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentLatin1.java 2022-01-12 16:44:11 UTC (rev 12385)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentLatin1.java 2022-01-12 17:56:35 UTC (rev 12386)
@@ -131,8 +131,8 @@
}
@Override
- public char refinedCharAt(final int index, final TextModifiers textModifiers) {
- return WordSegment4a.refinedCharAt(this, index, textModifiers);
+ public char refinedCharAt(final int index, final TextModifiers textModifiers, final boolean isFirstSegmentInWord) {
+ return WordSegment4a.refinedCharAt(this, index, textModifiers, isFirstSegmentInWord);
}
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentUtf16.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentUtf16.java 2022-01-12 16:44:11 UTC (rev 12385)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentUtf16.java 2022-01-12 17:56:35 UTC (rev 12386)
@@ -131,8 +131,8 @@
}
@Override
- public char refinedCharAt(final int index, final TextModifiers textModifiers) {
- return WordSegment4a.refinedCharAt(this, index, textModifiers);
+ public char refinedCharAt(final int index, final TextModifiers textModifiers, final boolean isFirstSegmentInWord) {
+ return WordSegment4a.refinedCharAt(this, index, textModifiers, isFirstSegmentInWord);
}
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Word4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Word4a.java 2022-01-12 16:44:11 UTC (rev 12385)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Word4a.java 2022-01-12 17:56:35 UTC (rev 12386)
@@ -37,6 +37,7 @@
import org.axsl.common.para.ParaNode;
import org.axsl.common.para.ParaPenalty;
import org.axsl.common.sequence.ByteSequence;
+import org.axsl.common.value.TextTransform;
import org.axsl.fotree.text.FoDiscretionaryHyphen;
import org.axsl.fotree.text.FoWord;
import org.axsl.fotree.text.FoWordComponent;
@@ -292,7 +293,14 @@
final int countThisSegment = segment.qtyRefinedChars(textModifiers);
if (count + countThisSegment > index) {
final int charIndex = index - count;
- return segment.refinedCharAt(charIndex, textModifiers);
+ final boolean isFirstSegmentInWord = segmentIndex == 0;
+ final char refinedFromSegment = segment.refinedCharAt(charIndex, textModifiers, isFirstSegmentInWord);
+ if (index == 0
+ && textModifiers.traitTextTransform() == TextTransform.CAPITALIZE) {
+ return Character.toUpperCase(refinedFromSegment);
+ } else {
+ return refinedFromSegment;
+ }
}
count += countThisSegment;
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/WordSegment4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/WordSegment4a.java 2022-01-12 16:44:11 UTC (rev 12385)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/WordSegment4a.java 2022-01-12 17:56:35 UTC (rev 12386)
@@ -36,6 +36,7 @@
import org.axsl.common.para.ParaGlue;
import org.axsl.common.para.ParaLeaf;
import org.axsl.common.para.ParaPenalty;
+import org.axsl.common.value.TextTransform;
import org.axsl.fotree.text.FoWordSegment;
import org.axsl.orthography.WordSegment;
@@ -124,18 +125,25 @@
* @param segment The segment whose refined characters are being examined.
* @param index The index into the refined text for {@code segment}.
* @param textModifiers The text modifiers needed to compute the refined text for {@code segment}.
+ * @param isFirstSegmentInWord Indicates whether the segment should be treated as the first segment in the word.
+ * This is needed to properly handle {@link TextTransform#CAPITALIZE}.
* @return The refined char at index {@code index} for this {@code segment}.
*/
- public static char refinedCharAt(final FoWordSegment segment, final int index, final TextModifiers textModifiers) {
+ public static char refinedCharAt(final FoWordSegment segment, final int index, final TextModifiers textModifiers,
+ final boolean isFirstSegmentInWord) {
char refinedChar = segment.charAt(index);
/* The linefeed-treatment trait does not affect words. */
/* The text-transform trait DOES affect words. */
switch (textModifiers.traitTextTransform()) {
- case NONE:
- case CAPITALIZE:
- /* Handle CAPITALIZE at the word level instead of here at the segment level. */
+ case NONE: break;
+ case CAPITALIZE: {
+ if (isFirstSegmentInWord
+ && index == 0) {
+ refinedChar = Character.toUpperCase(refinedChar);
+ }
break;
+ }
case UPPERCASE:
refinedChar = Character.toUpperCase(refinedChar);
break;
@@ -156,8 +164,8 @@
}
@Override
- public char refinedCharAt(final int index, final TextModifiers textModifiers) {
- return WordSegment4a.refinedCharAt(this, index, textModifiers);
+ public char refinedCharAt(final int index, final TextModifiers textModifiers, final boolean isFirstSegmentInWord) {
+ return WordSegment4a.refinedCharAt(this, index, textModifiers, isFirstSegmentInWord);
}
}
Added: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/Word4aTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/Word4aTests.java (rev 0)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/Word4aTests.java 2022-01-12 17:56:35 UTC (rev 12386)
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2022 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.orthography;
+
+import org.axsl.common.TextModifiers;
+import org.axsl.common.value.TextTransform;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+
+/**
+ * Tests of {@Link Word4a}.
+ */
+public class Word4aTests {
+
+ private void refinedCharsAssertions(final Word4a word, final TextTransform textTransform, final int expectedLength,
+ final String expectedRefined) {
+ final TextModifiers textModifiers = Mockito.mock(TextModifiers.class);
+ Mockito.when(textModifiers.traitTextTransform()).thenReturn(textTransform);
+ final int actualLength = word.qtyRefinedChars(textModifiers, -1, -1);
+ Assert.assertEquals(expectedLength, actualLength);
+
+ final StringBuilder builder = new StringBuilder();
+ for (int index = 0; index < expectedLength; index ++) {
+ final char refinedChar = word.refinedCharAt(index, textModifiers, -1, -1);
+ builder.append(refinedChar);
+ }
+ Assert.assertEquals(expectedRefined, builder.toString());
+ }
+
+ /**
+ * Test of {@link Word4a#qtyRefinedChars(TextModifiers, int, int)}.
+ */
+ @Test
+ public void qtyRefinedChars_Test_001() {
+ final StringWord word = new StringWord(0, "ty", "POG", "ra", "phy");
+
+ refinedCharsAssertions(word, TextTransform.NONE, 10, "tyPOGraphy");
+ refinedCharsAssertions(word, TextTransform.UPPERCASE, 10, "TYPOGRAPHY");
+ refinedCharsAssertions(word, TextTransform.LOWERCASE, 10, "typography");
+ refinedCharsAssertions(word, TextTransform.CAPITALIZE, 10, "TyPOGraphy");
+ }
+
+}
Property changes on: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/Word4aTests.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-12 16:44:14
|
Revision: 12385
http://sourceforge.net/p/foray/code/12385
Author: victormote
Date: 2022-01-12 16:44:11 +0000 (Wed, 12 Jan 2022)
Log Message:
-----------
Remove obsolete classes.
Removed Paths:
-------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoPunctuation.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWhitespace.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWord4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWordSequenceContent.java
Deleted: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoPunctuation.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoPunctuation.java 2022-01-12 16:30:02 UTC (rev 12384)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoPunctuation.java 2022-01-12 16:44:11 UTC (rev 12385)
@@ -1,88 +0,0 @@
-/*
- * Copyright 2021 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.fotree.fo.obj;
-
-import org.axsl.common.value.LinefeedTreatment;
-import org.axsl.common.value.TextTransform;
-import org.axsl.common.value.WhiteSpaceTreatment;
-import org.axsl.orthography.Punctuation;
-
-/**
- * Fo wrapper around an instance of {@link Punctuation}.
- */
-public class FoPunctuation extends FoWordSequenceContent {
-
- /** The wrapped punctuation. */
- private Punctuation punctuation;
-
- /**
- * Constructor.
- * @param punctuation The wrapped punctuation.
- */
- public FoPunctuation(final Punctuation punctuation) {
- this.punctuation = punctuation;
- }
-
- /**
- * Returns the wrapped punctuation.
- * @return The wrapped punctuation.
- */
- public Punctuation getPunctuation() {
- return this.punctuation;
- }
-
- @Override
- public int length() {
- return this.punctuation.length();
- }
-
- @Override
- public char charAt(final int index) {
- return this.punctuation.charAt(index);
- }
-
- @Override
- public CharSequence subSequence(final int start, final int end) {
- return this.punctuation.subSequence(start, end);
- }
-
- @Override
- public char textTransformCharAt(final WhiteSpaceTreatment whiteSpaceTreatment,
- final LinefeedTreatment linefeedTreatment, final TextTransform textTransform,
- final int textTransformIndex) {
- /* For now assume that punctuation never contains a character that can be affected by text-transform. */
- return linefeedTreatmentCharAt(whiteSpaceTreatment, linefeedTreatment, textTransformIndex);
- }
-
- @Override
- public String toString() {
- return this.punctuation.toString();
- }
-
-}
Deleted: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWhitespace.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWhitespace.java 2022-01-12 16:30:02 UTC (rev 12384)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWhitespace.java 2022-01-12 16:44:11 UTC (rev 12385)
@@ -1,88 +0,0 @@
-/*
- * Copyright 2021 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.fotree.fo.obj;
-
-import org.axsl.common.value.LinefeedTreatment;
-import org.axsl.common.value.TextTransform;
-import org.axsl.common.value.WhiteSpaceTreatment;
-import org.axsl.orthography.Whitespace;
-
-/**
- * Fo wrapper around an instance of {@link Whitespace}.
- */
-public class FoWhitespace extends FoWordSequenceContent {
-
- /** The wrapped whitespace. */
- private Whitespace whitespace;
-
- /**
- * Constructor.
- * @param whitespace The wrapped whitespace.
- */
- public FoWhitespace(final Whitespace whitespace) {
- this.whitespace = whitespace;
- }
-
- /**
- * Returns the wrapped whitespace.
- * @return The wrapped whitespace.
- */
- public Whitespace getWhitespace() {
- return this.whitespace;
- }
-
- @Override
- public int length() {
- return this.whitespace.length();
- }
-
- @Override
- public char charAt(final int index) {
- return this.whitespace.charAt(index);
- }
-
- @Override
- public CharSequence subSequence(final int start, final int end) {
- return this.whitespace.subSequence(start, end);
- }
-
- @Override
- public char textTransformCharAt(final WhiteSpaceTreatment whiteSpaceTreatment,
- final LinefeedTreatment linefeedTreatment, final TextTransform textTransform,
- final int textTransformIndex) {
- /* For now assume that whitespace never contains a character that can be affected by text-transform. */
- return linefeedTreatmentCharAt(whiteSpaceTreatment, linefeedTreatment, textTransformIndex);
- }
-
- @Override
- public String toString() {
- return this.whitespace.toString();
- }
-
-}
Deleted: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWord4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWord4a.java 2022-01-12 16:30:02 UTC (rev 12384)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWord4a.java 2022-01-12 16:44:11 UTC (rev 12385)
@@ -1,133 +0,0 @@
-/*
- * Copyright 2017 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.fotree.fo.obj;
-
-import org.axsl.common.value.LinefeedTreatment;
-import org.axsl.common.value.TextTransform;
-import org.axsl.common.value.WhiteSpaceTreatment;
-import org.axsl.orthography.Word;
-
-/**
- * Fo wrapper around a word.
- */
-public class FoWord4a extends FoWordSequenceContent {
-
- /** The wrapped word. */
- private Word word;
-
- /**
- * Constructor.
- * @param word The wrapped word.
- */
- public FoWord4a(final Word word) {
- this.word = word;
- }
-
- /**
- * Returns the wrapped word.
- * @return The wrapped word.
- */
- public Word getWord() {
- return this.word;
- }
-
- @Override
- public int length() {
- return this.word.length();
- }
-
- @Override
- public char charAt(final int index) {
- return this.word.charAt(index);
- }
-
- @Override
- public CharSequence subSequence(final int start, final int end) {
- return this.word.subSequence(start, end);
- }
-
- @Override
- public int whiteSpaceTreatmentLength(final WhiteSpaceTreatment whiteSpaceTreatment) {
- /* For now we assume that words do not have white-space and therefore have no white-space treatment. */
- return this.word.length();
- }
-
- @Override
- public char whiteSpaceTreatmentCharAt(final WhiteSpaceTreatment whiteSpaceTreatment,
- final int whiteSpaceTreatmentIndex) {
- /* For now we assume that words do not have white-space and therefore have no white-space treatment. */
- return this.word.charAt(whiteSpaceTreatmentIndex);
- }
-
- @Override
- public int linefeedTreatmentLength(final WhiteSpaceTreatment whiteSpaceTreatment,
- final LinefeedTreatment linefeedTreatment) {
- /* For now we assume that words do not contain linefeeds and therefore have no linefeed treatment. */
- return whiteSpaceTreatmentLength(whiteSpaceTreatment);
- }
-
- @Override
- public char linefeedTreatmentCharAt(final WhiteSpaceTreatment whiteSpaceTreatment,
- final LinefeedTreatment linefeedTreatment, final int linefeedTreatmentIndex) {
- /* For now we assume that words do not contain linefeeds and therefore have no linefeed treatment. */
- return whiteSpaceTreatmentCharAt(whiteSpaceTreatment, linefeedTreatmentIndex);
- }
-
- @Override
- public char textTransformCharAt(final WhiteSpaceTreatment whiteSpaceTreatment,
- final LinefeedTreatment linefeedTreatment, final TextTransform textTransform,
- final int textTransformIndex) {
- final boolean isFirstCharInWord = (textTransformIndex == 0) ? true : false;
- final char c = linefeedTreatmentCharAt(whiteSpaceTreatment, linefeedTreatment, textTransformIndex);
- return AbstractCharacterSequence.applyTextTransform(textTransform, isFirstCharInWord, c);
- }
-
- @Override
- public int whiteSpaceCollapseLength(final WhiteSpaceTreatment whiteSpaceTreatment,
- final LinefeedTreatment linefeedTreatment, final TextTransform textTransform,
- final boolean isWhiteSpaceCollapse) {
- /* For now we assume that words do not contain white-space and therefore we have no white-space-collapse. */
- return textTransformLength(whiteSpaceTreatment, linefeedTreatment, textTransform);
- }
-
- @Override
- public char whiteSpaceCollapseCharAt(final WhiteSpaceTreatment whiteSpaceTreatment,
- final LinefeedTreatment linefeedTreatment, final TextTransform textTransform,
- final boolean isWhiteSpaceCollapse, final int whiteSpaceCollapseIndex) {
- /* For now we assume that words do not contain white-space and therefore we have no white-space-collapse. */
- return textTransformCharAt(whiteSpaceTreatment, linefeedTreatment, textTransform, whiteSpaceCollapseIndex);
-
- }
-
- @Override
- public String toString() {
- return this.word.toString();
- }
-
-}
Deleted: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWordSequenceContent.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWordSequenceContent.java 2022-01-12 16:30:02 UTC (rev 12384)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWordSequenceContent.java 2022-01-12 16:44:11 UTC (rev 12385)
@@ -1,266 +0,0 @@
-/*
- * Copyright 2017 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.fotree.fo.obj;
-
-import org.foray.common.WellKnownConstants;
-
-import org.axsl.common.para.ParaNode;
-import org.axsl.common.value.LinefeedTreatment;
-import org.axsl.common.value.TextTransform;
-import org.axsl.common.value.WhiteSpaceTreatment;
-import org.axsl.orthography.Punctuation;
-import org.axsl.orthography.Whitespace;
-import org.axsl.orthography.Word;
-
-/**
- * Abstract superclass for the content of an Fo Word Sequence.
- */
-public abstract class FoWordSequenceContent implements CharSequence {
-
- /* TODO: In the unlikely case that an FoInterword contains a large number of characters, the current implementation
- * provides truly horrible performance. Add a caching mechanism to prevent that. Or change the implementation to
- * not traverse the entire CharSequence for each character. */
-
- /**
- * Factory method that creates an instance of the appropriate subclass.
- * @param wordSequenceContent The word sequence content to be wrapped.
- * @return An FO wrapper for {@code wordSequenceContent}.
- */
- static FoWordSequenceContent create(final ParaNode wordSequenceContent) {
- if (wordSequenceContent instanceof Word) {
- final Word word = (Word) wordSequenceContent;
- return new FoWord4a(word);
- }
- if (wordSequenceContent instanceof Punctuation) {
- final Punctuation interword = (Punctuation) wordSequenceContent;
- return new FoPunctuation(interword);
- }
- if (wordSequenceContent instanceof Whitespace) {
- final Whitespace interword = (Whitespace) wordSequenceContent;
- return new FoWhitespace(interword);
- }
- throw new IllegalArgumentException("Unexpected word sequence type: " +
- wordSequenceContent.getClass().getSimpleName());
- }
-
- /**
- * Returns the number of chars in this object after white-space-treatment is applied.
- * @param whiteSpaceTreatment The white-space-treatment to be used in evaluation.
- * @return The number of chars in this object after white-space-treatment is applied.
- */
- public int whiteSpaceTreatmentLength(final WhiteSpaceTreatment whiteSpaceTreatment) {
- int length = 0;
- for (int index = 0; index < length(); index ++) {
- /* The char immediately before. */
- final char before = (index == 0) ? WellKnownConstants.INVALID_UNICODE_CHARACTER : charAt(index - 1);
- /* The char we want to test. */
- final char c = charAt(index);
- /* The char immediately after. */
- final char after = (index == length() - 1) ? WellKnownConstants.INVALID_UNICODE_CHARACTER :
- charAt(index + 1);
-
- final char converted = FoTextCharacters4a.applyWhiteSpaceTreatment(before, c, after, whiteSpaceTreatment);
- if (converted != WellKnownConstants.INVALID_UNICODE_CHARACTER) {
- length ++;
- }
- }
- return length;
- }
-
- /**
- * Returns the char at a given index after white-space-treatment is applied.
- * @param whiteSpaceTreatment The white-space-treatment to be used in evaluation.
- * @param whiteSpaceTreatmentIndex The index into the chars in this instance, after white-space-treatment is
- * applied.
- * @return The char at a given index after white-space-treatment is applied.
- */
- public char whiteSpaceTreatmentCharAt(final WhiteSpaceTreatment whiteSpaceTreatment,
- final int whiteSpaceTreatmentIndex) {
- int currentIndex = -1;
- for (int index = 0; index < length(); index ++) {
- /* The char immediately before. */
- final char before = (index == 0) ? WellKnownConstants.INVALID_UNICODE_CHARACTER : charAt(index - 1);
- /* The char we want to test. */
- final char c = charAt(index);
- /* The char immediately after. */
- final char after = (index == length() - 1) ? WellKnownConstants.INVALID_UNICODE_CHARACTER :
- charAt(index + 1);
-
- final char converted = FoTextCharacters4a.applyWhiteSpaceTreatment(before, c, after, whiteSpaceTreatment);
- if (converted != WellKnownConstants.INVALID_UNICODE_CHARACTER) {
- currentIndex ++;
- }
- if (currentIndex == whiteSpaceTreatmentIndex) {
- return converted;
- }
- }
- throw new IndexOutOfBoundsException("Index: " + whiteSpaceTreatmentIndex + ", Length: " + length());
- }
-
- /**
- * Returns the number of chars in this object after linefeed-treatment is applied.
- * The linefeed-treatment is applied after white-space-treatment, so this method shows the effect of both of those
- * properties.
- * @param whiteSpaceTreatment The white-space-treatment to be used in evaluation.
- * @param linefeedTreatment The linefeed-treatment to be used in evaluation.
- * @return The number of chars in this object after linefeed-treatment is applied.
- */
- public int linefeedTreatmentLength(final WhiteSpaceTreatment whiteSpaceTreatment,
- final LinefeedTreatment linefeedTreatment) {
- int length = 0;
- for (int index = 0; index < whiteSpaceTreatmentLength(whiteSpaceTreatment); index ++) {
- final char c = charAt(index);
- final char converted = FoTextCharacters4a.applyLinefeedTreatment(c, linefeedTreatment);
- if (converted != WellKnownConstants.INVALID_UNICODE_CHARACTER) {
- length ++;
- }
- }
- return length;
- }
-
- /**
- * Returns the char at a given index after linefeed-treatment is applied.
- * The linefeed-treatment is applied after white-space-treatment, so this method shows the effect of both of those
- * properties.
- * @param whiteSpaceTreatment The white-space-treatment to be used in evaluation.
- * @param linefeedTreatment The linefeed-treatment to be used in evaluation.
- * @param linefeedTreatmentIndex The index into the chars in this instance, after linefeed-treatment is applied.
- * @return The char at a given index after white-space-treatment is applied.
- */
- public char linefeedTreatmentCharAt(final WhiteSpaceTreatment whiteSpaceTreatment,
- final LinefeedTreatment linefeedTreatment, final int linefeedTreatmentIndex) {
- int currentIndex = -1;
- final int whiteSpaceTreatmentLength = whiteSpaceTreatmentLength(whiteSpaceTreatment);
- for (int index = 0; index < whiteSpaceTreatmentLength; index ++) {
- final char c = charAt(index);
- final char converted = FoTextCharacters4a.applyLinefeedTreatment(c, linefeedTreatment);
- if (converted != WellKnownConstants.INVALID_UNICODE_CHARACTER) {
- currentIndex ++;
- }
- if (currentIndex == linefeedTreatmentIndex) {
- return converted;
- }
- }
- throw new IndexOutOfBoundsException("Index: " + linefeedTreatmentIndex + ", Length: " +
- whiteSpaceTreatmentLength);
- }
-
- /**
- * Returns the number of chars in this object after text-transform is applied.
- * The text-transform is applied after linefeed-treatment, which is applied after white-space-treatment, so this
- * method shows the effect of all of those properties.
- * @param whiteSpaceTreatment The white-space-treatment to be used in evaluation.
- * @param linefeedTreatment The linefeed-treatment to be used in evaluation.
- * @param textTransform The text-transform to be used in evaluation.
- * @return The number of chars in this object after text-transform is applied.
- */
- public int textTransformLength(final WhiteSpaceTreatment whiteSpaceTreatment,
- final LinefeedTreatment linefeedTreatment, final TextTransform textTransform) {
- /* For now, assume that text-transform never changes the number of chars. */
- return linefeedTreatmentLength(whiteSpaceTreatment, linefeedTreatment);
- }
-
- /**
- * Returns the char at a given index after text-transform is applied.
- * The text-transform is applied after linefeed-treatment, which is applied after white-space-treatment, so this
- * method shows the effect of all of those properties.
- * @param whiteSpaceTreatment The white-space-treatment to be used in evaluation.
- * @param linefeedTreatment The linefeed-treatment to be used in evaluation.
- * @param textTransform The text-transform to be used in evaluation.
- * @param textTransformIndex The index into the chars in this instance, after text-transform is applied.
- * @return The char at a given index after text-transform is applied.
- */
- public abstract char textTransformCharAt(WhiteSpaceTreatment whiteSpaceTreatment,
- LinefeedTreatment linefeedTreatment, TextTransform textTransform, int textTransformIndex);
-
- /**
- * Returns the number of chars in this object after white-space-collapse is applied.
- * The white-space-collapse is applied after text-transform is applied, which is applied after linefeed-treatment,
- * which is applied after white-space-treatment, so this method shows the effect of all of those properties.
- * @param whiteSpaceTreatment The white-space-treatment to be used in evaluation.
- * @param linefeedTreatment The linefeed-treatment to be used in evaluation.
- * @param textTransform The text-transform to be used in evaluation.
- * @param isWhiteSpaceCollapse The white-space-collapse to be used in evaluation.
- * @return The number of chars in this object after white-space-collapse is applied.
- */
- public int whiteSpaceCollapseLength(final WhiteSpaceTreatment whiteSpaceTreatment,
- final LinefeedTreatment linefeedTreatment, final TextTransform textTransform,
- final boolean isWhiteSpaceCollapse) {
- int length = 0;
- final int textTransformLength = textTransformLength(whiteSpaceTreatment, linefeedTreatment, textTransform);
- for (int index = 0; index < textTransformLength; index ++) {
- final char charBefore = (index == 0) ? WellKnownConstants.INVALID_UNICODE_CHARACTER :
- textTransformCharAt(whiteSpaceTreatment, linefeedTreatment, textTransform, index - 1);
- final char c = textTransformCharAt(whiteSpaceTreatment, linefeedTreatment, textTransform, index);
- final char charAfter = (index == textTransformLength - 1) ?
- WellKnownConstants.INVALID_UNICODE_CHARACTER :
- textTransformCharAt(whiteSpaceTreatment, linefeedTreatment, textTransform, index + 1);
- final char converted = AbstractCharacterSequence.applyWhiteSpaceCollapse(charBefore, c, charAfter);
- if (converted != WellKnownConstants.INVALID_UNICODE_CHARACTER) {
- length ++;
- }
- }
- return length;
- }
-
- /**
- * Returns the char at a given index after white-space-collapse is applied.
- * The white-space-collapse is applied after text-transform is applied, which is applied after linefeed-treatment,
- * which is applied after white-space-treatment, so this method shows the effect of all of those properties.
- * @param whiteSpaceTreatment The white-space-treatment to be used in evaluation.
- * @param linefeedTreatment The linefeed-treatment to be used in evaluation.
- * @param textTransform The text-transform to be used in evaluation.
- * @param isWhiteSpaceCollapse The white-space-collapse to be used in evaluation.
- * @param whiteSpaceCollapseIndex The index into the chars in this instance, after white-space-collapse is applied.
- * @return The char at a given index after white-space-collapse is applied.
- */
- public char whiteSpaceCollapseCharAt(final WhiteSpaceTreatment whiteSpaceTreatment,
- final LinefeedTreatment linefeedTreatment, final TextTransform textTransform,
- final boolean isWhiteSpaceCollapse, final int whiteSpaceCollapseIndex) {
- int currentIndex = -1;
- final int textTransformLength = textTransformLength(whiteSpaceTreatment, linefeedTreatment, textTransform);
- for (int index = 0; index < textTransformLength; index ++) {
- final char charBefore = (index == 0) ? WellKnownConstants.INVALID_UNICODE_CHARACTER :
- textTransformCharAt(whiteSpaceTreatment, linefeedTreatment, textTransform, index - 1);
- final char c = textTransformCharAt(whiteSpaceTreatment, linefeedTreatment, textTransform, index);
- final char charAfter = (index == textTransformLength - 1) ?
- WellKnownConstants.INVALID_UNICODE_CHARACTER :
- textTransformCharAt(whiteSpaceTreatment, linefeedTreatment, textTransform, index + 1);
- final char converted = AbstractCharacterSequence.applyWhiteSpaceCollapse(charBefore, c, charAfter);
- if (converted != WellKnownConstants.INVALID_UNICODE_CHARACTER) {
- currentIndex ++;
- }
- if (currentIndex == whiteSpaceCollapseIndex) {
- return converted;
- }
- }
- throw new IndexOutOfBoundsException("Index: " + whiteSpaceCollapseIndex + ", Length: " + textTransformLength);
- }
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-12 16:30:05
|
Revision: 12384
http://sourceforge.net/p/foray/code/12384
Author: victormote
Date: 2022-01-12 16:30:02 +0000 (Wed, 12 Jan 2022)
Log Message:
-----------
Basic implementation of refined text production.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentLatin1.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentUtf16.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/WordSegment4a.java
Added Paths:
-----------
trunk/foray/foray-common/src/main/java/org/foray/common/MarkedIndexOutOfBoundsException.java
Added: trunk/foray/foray-common/src/main/java/org/foray/common/MarkedIndexOutOfBoundsException.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/MarkedIndexOutOfBoundsException.java (rev 0)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/MarkedIndexOutOfBoundsException.java 2022-01-12 16:30:02 UTC (rev 12384)
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2022 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.common;
+
+/**
+ * Subclass of {@link IndexOutOfBoundsException} that creates a message indicating the offending index and the size of
+ * the item offended.
+ */
+public class MarkedIndexOutOfBoundsException extends IndexOutOfBoundsException {
+
+ /** Constant needed for serialization. */
+ private static final long serialVersionUID = -5276895086078511992L;
+
+ /** The template for the message for this exception. */
+ private static final String FORMAT = "Index = %d, Size = %d";
+
+ /**
+ * Constructor.
+ * @param offendingIndex The index value that is out-of-bounds.
+ * @param sizeOfOffendedItem The size of the indexed object whose range was violated.
+ */
+ public MarkedIndexOutOfBoundsException(final int offendingIndex, final int sizeOfOffendedItem) {
+ super(String.format(FORMAT, offendingIndex, sizeOfOffendedItem));
+ }
+
+}
Property changes on: trunk/foray/foray-common/src/main/java/org/foray/common/MarkedIndexOutOfBoundsException.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-12 13:07:35 UTC (rev 12383)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-12 16:30:02 UTC (rev 12384)
@@ -190,7 +190,13 @@
final MutableTokenFlowLocation currentLocation = new MutableTokenFlowLocation(startLocation);
while (currentLocation.compareTo(endLocation) < 0) {
final FoToken token = tokenAt(currentLocation.getTokenIndex());
- builder.append(token.getText());
+ final int codepointBefore = relevantWhitespaceBefore(currentLocation.getTokenIndex());
+ final int codepointAfter = relevantWhitespaceAfter(currentLocation.getTokenIndex());
+ for (int charIndex = 0; charIndex < token.qtyRefinedChars(textModifiers, codepointBefore, codepointAfter);
+ charIndex ++) {
+ final char refinedChar = token.refinedCharAt(charIndex, textModifiers, codepointBefore, codepointAfter);
+ builder.append(refinedChar);
+ }
currentLocation.markTokenComplete();
}
@@ -198,6 +204,58 @@
return builder.toString();
}
+ /**
+ * For tokens where it matters, computes the whitespace Unicode codepoint, if any, immediately before that token.
+ * This computation is only relevant for contiguous whitespace tokens, so that white-space-collapse can be properly
+ * computed.
+ * @param tokenIndex The index to the token for which the prior codepoint is being computed.
+ * @return If the token at {@code tokenIndex} is whitespace, and the previous token is also whitespace, returns the
+ * raw Unicode codepoint of that subsequent whitespace token.
+ * For all other tokens, returns -1, as this computation is not relevant.
+ */
+ private int relevantWhitespaceBefore(final int tokenIndex) {
+ final FoToken token = this.paraBranch.tokenAt(tokenIndex);
+ if (! (token instanceof Whitespace)) {
+ return -1;
+ }
+ if (tokenIndex == 0) {
+ return -1;
+ }
+ final FoToken previousToken = this.paraBranch.tokenAt(tokenIndex - 1);
+ if (previousToken instanceof Whitespace) {
+ final Whitespace whitespace = (Whitespace) previousToken;
+ return whitespace.charAt(whitespace.length() - 1);
+ }
+ /* The previous token is not whitespace. */
+ return -1;
+ }
+
+ /**
+ * For tokens where it matters, computes the whitespace Unicode codepoint, if any, immediately after a given token.
+ * This computation is only relevant for contiguous whitespace tokens, so that white-space-collapse can be properly
+ * computed.
+ * @param tokenIndex The index to the token for which the subsequent codepoint is being computed.
+ * @return If the token at {@code tokenIndex} is whitespace, and the next token is also whitespace, returns the
+ * raw Unicode codepoint of that subsequent whitespace token.
+ * For all other tokens, returns -1, as this computation is not relevant.
+ */
+ private int relevantWhitespaceAfter(final int tokenIndex) {
+ final FoToken token = this.paraBranch.tokenAt(tokenIndex);
+ if (! (token instanceof Whitespace)) {
+ return -1;
+ }
+ if (tokenIndex == this.paraBranch.qtyTokens() - 1) {
+ return -1;
+ }
+ final FoToken nextToken = this.paraBranch.tokenAt(tokenIndex + 1);
+ if (nextToken instanceof Whitespace) {
+ final Whitespace whitespace = (Whitespace) nextToken;
+ return whitespace.charAt(0);
+ }
+ /* The next token is not whitespace. */
+ return -1;
+ }
+
@Override
public Location markLocation(final int tokenIndex, final byte segmentIndex, final byte charIndex) {
return this.paraBranch.markLocation(tokenIndex, segmentIndex, charIndex);
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentLatin1.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentLatin1.java 2022-01-12 13:07:35 UTC (rev 12383)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentLatin1.java 2022-01-12 16:30:02 UTC (rev 12384)
@@ -127,14 +127,12 @@
@Override
public int qtyRefinedChars(final TextModifiers textModifiers) {
- // TODO Auto-generated method stub
- return 0;
+ return WordSegment4a.qtyRefinedChars(this, textModifiers);
}
@Override
public char refinedCharAt(final int index, final TextModifiers textModifiers) {
- // TODO Auto-generated method stub
- return 0;
+ return WordSegment4a.refinedCharAt(this, index, textModifiers);
}
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentUtf16.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentUtf16.java 2022-01-12 13:07:35 UTC (rev 12383)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentUtf16.java 2022-01-12 16:30:02 UTC (rev 12384)
@@ -127,14 +127,12 @@
@Override
public int qtyRefinedChars(final TextModifiers textModifiers) {
- // TODO Auto-generated method stub
- return 0;
+ return WordSegment4a.qtyRefinedChars(this, textModifiers);
}
@Override
public char refinedCharAt(final int index, final TextModifiers textModifiers) {
- // TODO Auto-generated method stub
- return 0;
+ return WordSegment4a.refinedCharAt(this, index, textModifiers);
}
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java 2022-01-12 13:07:35 UTC (rev 12383)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java 2022-01-12 16:30:02 UTC (rev 12384)
@@ -28,6 +28,8 @@
package org.foray.orthography;
+import org.foray.common.MarkedIndexOutOfBoundsException;
+import org.foray.common.WellKnownConstants;
import org.foray.common.primitive.CharSequenceUtils;
import org.foray.common.primitive.XmlCharacterUtils;
@@ -206,10 +208,11 @@
@Override
public int qtyRefinedChars(final TextModifiers textModifiers, final int codepointBefore, final int codepointAfter) {
+ char returnValue = this.nativeChar;
/* Apply linefeed-treatment. */
- if (this.nativeChar == '\n'
- && textModifiers.traitLinefeedTreatment() == LinefeedTreatment.IGNORE) {
+ returnValue = applyLinefeedTreatment(returnValue, textModifiers.traitLinefeedTreatment());
+ if (returnValue == WellKnownConstants.INVALID_UNICODE_CHARACTER) {
return 0;
}
@@ -216,7 +219,7 @@
/* The text-transform trait does not affect whitespace. */
/* Apply white-space-collapse. */
- if (whiteSpaceCollapseApplies(this.nativeChar, textModifiers.traitWhiteSpaceCollapse(), codepointBefore,
+ if (whiteSpaceCollapseApplies(returnValue, textModifiers.traitWhiteSpaceCollapse(), codepointBefore,
codepointAfter)) {
/* This "character flow object ... shall not generate an area." */
return 0;
@@ -230,20 +233,10 @@
final int codepointAfter) {
char returnValue = this.nativeChar;
- /* Apply linefeed-treatment. */
- if (returnValue == '\n') {
- switch (textModifiers.traitLinefeedTreatment()) {
- case IGNORE: throw new IndexOutOfBoundsException();
- case PRESERVE: break;
- case TREAT_AS_SPACE: {
- returnValue = ' ';
- break;
- }
- case TREAT_AS_ZERO_WIDTH_SPACE: {
- returnValue = General_Punctuation_Block.ZERO_WIDTH_SPACE;
- break;
- }
- }
+ returnValue = applyLinefeedTreatment(returnValue, textModifiers.traitLinefeedTreatment());
+ if (returnValue == WellKnownConstants.INVALID_UNICODE_CHARACTER) {
+ final int size = qtyRefinedChars(textModifiers, codepointBefore, codepointAfter);
+ throw new MarkedIndexOutOfBoundsException(index, size);
}
/* The text-transform trait does not affect whitespace. */
@@ -251,8 +244,10 @@
/* Apply white-space-collapse. */
if (whiteSpaceCollapseApplies(returnValue, textModifiers.traitWhiteSpaceCollapse(), codepointBefore,
codepointAfter)) {
+
/* This "character flow object ... shall not generate an area." */
- throw new IndexOutOfBoundsException();
+ final int size = qtyRefinedChars(textModifiers, codepointBefore, codepointAfter);
+ throw new MarkedIndexOutOfBoundsException(index, size);
}
return returnValue;
@@ -259,6 +254,26 @@
}
/**
+ * Applies linefeed-treatment to a given character.
+ * @param input The char to which the linefeed-treatment should be applied.
+ * @param linefeedTreatment The linefeed-treatment trait to be applied.
+ * @return The converted value, or {@link WellKnownConstants.INVALID_UNICODE_CHARACTER} if the character should be
+ * deleted.
+ */
+ private char applyLinefeedTreatment(final char input, final LinefeedTreatment linefeedTreatment) {
+ if (input != '\n') {
+ return input;
+ }
+ switch (linefeedTreatment) {
+ case IGNORE: return WellKnownConstants.INVALID_UNICODE_CHARACTER;
+ case PRESERVE: return input;
+ case TREAT_AS_SPACE: return ' ';
+ case TREAT_AS_ZERO_WIDTH_SPACE: return General_Punctuation_Block.ZERO_WIDTH_SPACE;
+ default: throw new IllegalArgumentException();
+ }
+ }
+
+ /**
* Indicates whether white-space-collapse applies to a given character.
* @param rawChar The character being tested.
* @param whiteSpaceCollapse The value of the white-space-collapse trait.
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/WordSegment4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/WordSegment4a.java 2022-01-12 13:07:35 UTC (rev 12383)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/WordSegment4a.java 2022-01-12 16:30:02 UTC (rev 12384)
@@ -99,19 +99,65 @@
@Override
public int qtyKpLeaves() {
- return this.length();
+ return length();
}
+ /**
+ * Returns the number of refined chars in a given segment, using specific text modifiers.
+ * The {@link FoWordSegment} implementations tend to be in disparate class hierarchies, so this static method is
+ * intended to allow them to use common code.
+ * @param segment The segment whose refined characters are being examined.
+ * @param textModifiers The text modifiers needed to compute the refined text for this segment.
+ * @return The number of refined chars in {@code segment}.
+ */
+ public static int qtyRefinedChars(final FoWordSegment segment, final TextModifiers textModifiers) {
+ /* The linefeed-treatment trait does not affect words. */
+ /* The text-transform trait DOES affect words, but not the quantity of characters. */
+ /* The white-space-collapse trait does not affect words. */
+ return segment.length();
+ }
+
+ /**
+ * Returns the refined char at a given index in a given segment, using specific text modifiers.
+ * The {@link FoWordSegment} implementations tend to be in disparate class hierarchies, so this static method is
+ * intended to allow them to use common code.
+ * @param segment The segment whose refined characters are being examined.
+ * @param index The index into the refined text for {@code segment}.
+ * @param textModifiers The text modifiers needed to compute the refined text for {@code segment}.
+ * @return The refined char at index {@code index} for this {@code segment}.
+ */
+ public static char refinedCharAt(final FoWordSegment segment, final int index, final TextModifiers textModifiers) {
+ char refinedChar = segment.charAt(index);
+ /* The linefeed-treatment trait does not affect words. */
+
+ /* The text-transform trait DOES affect words. */
+ switch (textModifiers.traitTextTransform()) {
+ case NONE:
+ case CAPITALIZE:
+ /* Handle CAPITALIZE at the word level instead of here at the segment level. */
+ break;
+ case UPPERCASE:
+ refinedChar = Character.toUpperCase(refinedChar);
+ break;
+ case LOWERCASE:
+ refinedChar = Character.toLowerCase(refinedChar);
+ break;
+ default: throw new IllegalArgumentException();
+ }
+
+ /* The white-space-collapse trait does not affect words. */
+
+ return refinedChar;
+ }
+
@Override
public int qtyRefinedChars(final TextModifiers textModifiers) {
- // TODO Auto-generated method stub
- return 0;
+ return WordSegment4a.qtyRefinedChars(this, textModifiers);
}
@Override
public char refinedCharAt(final int index, final TextModifiers textModifiers) {
- // TODO Auto-generated method stub
- return 0;
+ return WordSegment4a.refinedCharAt(this, index, textModifiers);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-12 13:07:44
|
Revision: 12383
http://sourceforge.net/p/foray/code/12383
Author: victormote
Date: 2022-01-12 13:07:35 +0000 (Wed, 12 Jan 2022)
Log Message:
-----------
Add class to track progress through the content of a line.
Added Paths:
-----------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/MutableTokenFlowLocation.java
Added: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/MutableTokenFlowLocation.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/MutableTokenFlowLocation.java (rev 0)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/MutableTokenFlowLocation.java 2022-01-12 13:07:35 UTC (rev 12383)
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2017 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fotree;
+
+import org.axsl.orthography.TokenFlow;
+
+/**
+ * A mutable version of {@link TokenFlow.Location}, useful when iterating locations.
+ */
+public class MutableTokenFlowLocation implements TokenFlow.Location {
+
+ /** The token index. See {@link TokenFlow.Location#getTokenIndex()}. */
+ private int tokenIndex;
+
+ /** The segment index. See {@link TokenFlow.Location#getSegmentIndex()}. */
+ private byte segmentIndex;
+
+ /** The char index. See {@link TokenFlow.Location#getCharIndex()}. */
+ private byte charIndex;
+
+ public MutableTokenFlowLocation(final TokenFlow.Location location) {
+ this.tokenIndex = location.getTokenIndex();
+ this.segmentIndex = location.getSegmentIndex();
+ this.charIndex = location.getCharIndex();
+ }
+
+ @Override
+ public int getTokenIndex() {
+ return this.tokenIndex;
+ }
+
+ @Override
+ public byte getSegmentIndex() {
+ return this.segmentIndex;
+ }
+
+ @Override
+ public byte getCharIndex() {
+ return this.charIndex;
+ }
+
+ @Override
+ public int compareTo(final TokenFlow.Location o) {
+ if (this.tokenIndex == o.getTokenIndex()) {
+ if (this.segmentIndex == o.getSegmentIndex()) {
+ if (this.charIndex == o.getCharIndex()) {
+ return 0;
+ } else {
+ return this.charIndex - o.getCharIndex();
+ }
+ } else {
+ return this.segmentIndex - o.getSegmentIndex();
+ }
+ } else {
+ return this.tokenIndex - o.getTokenIndex();
+ }
+ }
+
+ /**
+ * Marks the current token complete by incrementing the token index and setting the segmentIndex and charIndex to
+ * zero.
+ */
+ public void markTokenComplete() {
+ this.tokenIndex ++;
+ this.segmentIndex = 0;
+ this.charIndex = 0;
+ }
+
+}
Property changes on: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/MutableTokenFlowLocation.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-12 13:05:12
|
Revision: 12382
http://sourceforge.net/p/foray/code/12382
Author: victormote
Date: 2022-01-12 13:05:10 +0000 (Wed, 12 Jan 2022)
Log Message:
-----------
Partially conform to aXSL changes: Add methods to FoToken and FoWordSegment to return refined values of their text.
Modified Paths:
--------------
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Punctuation4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentLatin1.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentUtf16.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Word4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/WordSegment4a.java
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Punctuation4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Punctuation4a.java 2022-01-11 18:23:42 UTC (rev 12381)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Punctuation4a.java 2022-01-12 13:05:10 UTC (rev 12382)
@@ -30,6 +30,7 @@
import org.foray.common.primitive.CharSequenceUtils;
+import org.axsl.common.TextModifiers;
import org.axsl.common.para.ParaBox;
import org.axsl.common.para.ParaBranch;
import org.axsl.common.para.ParaConfig;
@@ -117,7 +118,7 @@
/** Common punctuation item. */
public static final Punctuation4a ZERO_WIDTH_NO_BREAK_SPACE = new Punctuation4a("\uFEFF");
- /** The list of common interword items. */
+ /** The list of common punctuation items. */
private static final List<Punctuation4a> COMMON_PUNCTUATION = new ArrayList<Punctuation4a>(25);
static {
@@ -255,4 +256,21 @@
return this.content.length();
}
+ @Override
+ public int qtyRefinedChars(final TextModifiers textModifiers, final int codepointBefore, final int codepointAfter) {
+ /* The linefeed-treatment trait does not affect punctuation. */
+ /* The text-transform trait does not affect punctuation. */
+ /* The white-space-collapse trait does not affect punctuation. */
+ return this.content.length();
+ }
+
+ @Override
+ public char refinedCharAt(final int index, final TextModifiers textModifiers, final int codepointBefore,
+ final int codepointAfter) {
+ /* The linefeed-treatment trait does not affect punctuation. */
+ /* The text-transform trait does not affect punctuation. */
+ /* The white-space-collapse trait does not affect punctuation. */
+ return this.content.charAt(index);
+ }
+
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentLatin1.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentLatin1.java 2022-01-11 18:23:42 UTC (rev 12381)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentLatin1.java 2022-01-12 13:05:10 UTC (rev 12382)
@@ -30,6 +30,7 @@
import org.foray.common.primitive.StringLatin1;
+import org.axsl.common.TextModifiers;
import org.axsl.common.para.ParaBox;
import org.axsl.common.para.ParaBranch;
import org.axsl.common.para.ParaConfig;
@@ -124,4 +125,16 @@
return length();
}
+ @Override
+ public int qtyRefinedChars(final TextModifiers textModifiers) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public char refinedCharAt(final int index, final TextModifiers textModifiers) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentUtf16.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentUtf16.java 2022-01-11 18:23:42 UTC (rev 12381)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/StringWordSegmentUtf16.java 2022-01-12 13:05:10 UTC (rev 12382)
@@ -30,6 +30,7 @@
import org.foray.common.primitive.StringUtf16;
+import org.axsl.common.TextModifiers;
import org.axsl.common.para.ParaBox;
import org.axsl.common.para.ParaBranch;
import org.axsl.common.para.ParaConfig;
@@ -124,4 +125,16 @@
return length();
}
+ @Override
+ public int qtyRefinedChars(final TextModifiers textModifiers) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public char refinedCharAt(final int index, final TextModifiers textModifiers) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java 2022-01-11 18:23:42 UTC (rev 12381)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java 2022-01-12 13:05:10 UTC (rev 12382)
@@ -29,7 +29,9 @@
package org.foray.orthography;
import org.foray.common.primitive.CharSequenceUtils;
+import org.foray.common.primitive.XmlCharacterUtils;
+import org.axsl.common.TextModifiers;
import org.axsl.common.para.ParaBox;
import org.axsl.common.para.ParaBranch;
import org.axsl.common.para.ParaConfig;
@@ -36,7 +38,9 @@
import org.axsl.common.para.ParaGlue;
import org.axsl.common.para.ParaLeaf;
import org.axsl.common.para.ParaPenalty;
+import org.axsl.common.value.LinefeedTreatment;
import org.axsl.fotree.text.FoWhitespace;
+import org.axsl.unicode.block.General_Punctuation_Block;
import org.slf4j.LoggerFactory;
@@ -49,20 +53,22 @@
*/
public final class Whitespace4a implements FoWhitespace {
- /** Common whitespace item. */
- public static final Whitespace4a SPACE = new Whitespace4a(" ");
+ /** A space character. */
+ public static final Whitespace4a SPACE = new Whitespace4a(" ", ' ');
- /** Common whitespace item. */
- public static final Whitespace4a LINE_FEED = new Whitespace4a("\n");
+ /** A linefeed character. */
+ public static final Whitespace4a LINE_FEED = new Whitespace4a("\n", '\n');
- /** Common whitespace item. */
- public static final Whitespace4a CARRIAGE_RETURN_AND_LINE_FEED = new Whitespace4a("\r\n");
+ /** A carriage-return/linefeed combination. XML parsers are required to normalize this combination to a single
+ * linefeed, so this should never occur. If it does, we will treat it as if it were a single linefeed. */
+ public static final Whitespace4a CARRIAGE_RETURN_AND_LINE_FEED = new Whitespace4a("\r\n", '\n');
- /** Common whitespace item. */
- public static final Whitespace4a CARRIAGE_RETURN = new Whitespace4a("\r");
+ /** A carriage-return. XML parsers are required to normalize this combination to a single linefeed, so this should
+ * never occur. If it does, we will treat it as if it were a single linefeed. */
+ public static final Whitespace4a CARRIAGE_RETURN = new Whitespace4a("\r", '\n');
- /** Common whitespace item. */
- public static final Whitespace4a TAB = new Whitespace4a("\t");
+ /** A horizontal tab. */
+ public static final Whitespace4a TAB = new Whitespace4a("\t", '\t');
/** The list of common whitespace items. */
private static final List<Whitespace4a> COMMON_WHITESPACE = new ArrayList<Whitespace4a>(20);
@@ -77,12 +83,17 @@
/** The content of this whitespace item. */
private CharSequence content;
+ /** The raw char for this whitespace. */
+ private char nativeChar;
+
/**
* Private constructor. Use {@link #findInstance(CharSequence)} to obtain an instance of this class.
* @param content The content of this interword item.
+ * @param nativeChar The raw char for this whitespace.
*/
- private Whitespace4a(final CharSequence content) {
+ private Whitespace4a(final CharSequence content, final char nativeChar) {
this.content = content;
+ this.nativeChar = nativeChar;
}
/**
@@ -100,7 +111,7 @@
}
}
LoggerFactory.getLogger(Whitespace4a.class).warn("Standard interword not found: [" + content + "]");
- return new Whitespace4a(content);
+ return new Whitespace4a(content, content.charAt(0));
}
@Override
@@ -193,4 +204,81 @@
return this.content.length();
}
+ @Override
+ public int qtyRefinedChars(final TextModifiers textModifiers, final int codepointBefore, final int codepointAfter) {
+
+ /* Apply linefeed-treatment. */
+ if (this.nativeChar == '\n'
+ && textModifiers.traitLinefeedTreatment() == LinefeedTreatment.IGNORE) {
+ return 0;
+ }
+
+ /* The text-transform trait does not affect whitespace. */
+
+ /* Apply white-space-collapse. */
+ if (whiteSpaceCollapseApplies(this.nativeChar, textModifiers.traitWhiteSpaceCollapse(), codepointBefore,
+ codepointAfter)) {
+ /* This "character flow object ... shall not generate an area." */
+ return 0;
+ }
+
+ return 1;
+ }
+
+ @Override
+ public char refinedCharAt(final int index, final TextModifiers textModifiers, final int codepointBefore,
+ final int codepointAfter) {
+ char returnValue = this.nativeChar;
+
+ /* Apply linefeed-treatment. */
+ if (returnValue == '\n') {
+ switch (textModifiers.traitLinefeedTreatment()) {
+ case IGNORE: throw new IndexOutOfBoundsException();
+ case PRESERVE: break;
+ case TREAT_AS_SPACE: {
+ returnValue = ' ';
+ break;
+ }
+ case TREAT_AS_ZERO_WIDTH_SPACE: {
+ returnValue = General_Punctuation_Block.ZERO_WIDTH_SPACE;
+ break;
+ }
+ }
+ }
+
+ /* The text-transform trait does not affect whitespace. */
+
+ /* Apply white-space-collapse. */
+ if (whiteSpaceCollapseApplies(returnValue, textModifiers.traitWhiteSpaceCollapse(), codepointBefore,
+ codepointAfter)) {
+ /* This "character flow object ... shall not generate an area." */
+ throw new IndexOutOfBoundsException();
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Indicates whether white-space-collapse applies to a given character.
+ * @param rawChar The character being tested.
+ * @param whiteSpaceCollapse The value of the white-space-collapse trait.
+ * @param codepointBefore The Unicode codepoint, if any, immediately before this text in the paragraph.
+ * Setting this to -1 indicates that there is no such codepoint.
+ * @param codepointAfter The Unicode codepoint, if any, immediately after this text in the paragraph.
+ * This is needed to properly handle white-space-collapse.
+ * @return True if and only if this whitespace should be collapsed.
+ */
+ private boolean whiteSpaceCollapseApplies(final char rawChar, final boolean whiteSpaceCollapse,
+ final int codepointBefore, final int codepointAfter) {
+ if (whiteSpaceCollapse
+ && XmlCharacterUtils.isXMLWhitespace(rawChar)
+ && rawChar != '\n') {
+ if (XmlCharacterUtils.isXMLWhitespace(codepointBefore)
+ || codepointAfter == '\n') {
+ return true;
+ }
+ }
+ return false;
+ }
+
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Word4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Word4a.java 2022-01-11 18:23:42 UTC (rev 12381)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Word4a.java 2022-01-12 13:05:10 UTC (rev 12382)
@@ -31,6 +31,7 @@
import org.foray.common.primitive.CharSequenceUtils;
import org.foray.common.primitive.NumberUtils;
+import org.axsl.common.TextModifiers;
import org.axsl.common.para.ParaBranch;
import org.axsl.common.para.ParaLeaf;
import org.axsl.common.para.ParaNode;
@@ -269,4 +270,33 @@
return null;
}
+ @Override
+ public int qtyRefinedChars(final TextModifiers textModifiers, final int codepointBefore, final int codepointAfter) {
+ /* The linefeed-treatment trait does not affect words. */
+ /* The text-transform trait DOES affect words. However, it does not affect the count of chars. */
+ /* The white-space-collapse trait does not affect words. */
+ int count = 0;
+ for (int index = 0; index < qtyWordSegments(); index ++) {
+ final FoWordSegment segment = wordSegmentAt(index);
+ count += segment.qtyRefinedChars(textModifiers);
+ }
+ return count;
+ }
+
+ @Override
+ public char refinedCharAt(final int index, final TextModifiers textModifiers, final int codepointBefore,
+ final int codepointAfter) {
+ int count = 0;
+ for (int segmentIndex = 0; segmentIndex < this.qtyWordSegments(); segmentIndex ++) {
+ final FoWordSegment segment = wordSegmentAt(segmentIndex);
+ final int countThisSegment = segment.qtyRefinedChars(textModifiers);
+ if (count + countThisSegment > index) {
+ final int charIndex = index - count;
+ return segment.refinedCharAt(charIndex, textModifiers);
+ }
+ count += countThisSegment;
+ }
+ throw new IndexOutOfBoundsException();
+ }
+
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/WordSegment4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/WordSegment4a.java 2022-01-11 18:23:42 UTC (rev 12381)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/WordSegment4a.java 2022-01-12 13:05:10 UTC (rev 12382)
@@ -30,6 +30,7 @@
import org.foray.common.para.ParaLeaf4a;
+import org.axsl.common.TextModifiers;
import org.axsl.common.para.ParaBox;
import org.axsl.common.para.ParaConfig;
import org.axsl.common.para.ParaGlue;
@@ -101,4 +102,16 @@
return this.length();
}
+ @Override
+ public int qtyRefinedChars(final TextModifiers textModifiers) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public char refinedCharAt(final int index, final TextModifiers textModifiers) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-11 18:23:45
|
Revision: 12381
http://sourceforge.net/p/foray/code/12381
Author: victormote
Date: 2022-01-11 18:23:42 +0000 (Tue, 11 Jan 2022)
Log Message:
-----------
Add white-space-treatment handling to word-backed FO text.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoText4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
Added Paths:
-----------
trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/obj/FoText4aTests.java
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoText4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoText4a.java 2022-01-11 15:27:47 UTC (rev 12380)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoText4a.java 2022-01-11 18:23:42 UTC (rev 12381)
@@ -345,6 +345,46 @@
}
/**
+ * Applies white-space-treatment to the characters in a {@link StringBuilder}.
+ * @param builder The text to be (possibly) modifed.
+ * @param whiteSpaceTreatment The white-space-treatment trait.
+ * @param isStartOfLine Indicates whether {@code builder} is at the start of a line.
+ * @param isEndOfLine Indicates whether {@code builder} is at the end of a line.
+ */
+ public static void applyWhiteSpaceTreatmentToLine(final StringBuilder builder,
+ final WhiteSpaceTreatment whiteSpaceTreatment, final boolean isStartOfLine, final boolean isEndOfLine) {
+ /* Because suppress-at-line-break applies only to fo:character, and it cannot be inherited, there is no
+ * possibility that any character other than U+0020 can be affected by white-space-treatment. */
+ if (whiteSpaceTreatment == WhiteSpaceTreatment.PRESERVE) {
+ return;
+ }
+ if (isStartOfLine
+ && whiteSpaceTreatment.ignoreAtStartOfLine()) {
+ while (builder.length() > 0
+ && builder.charAt(0) == ' ') {
+ builder.deleteCharAt(0);
+ }
+ }
+ if (isEndOfLine
+ && whiteSpaceTreatment.ignoreAtEndOfLine()) {
+ while (builder.length() > 0
+ && builder.charAt(builder.length() - 1) == ' ') {
+ builder.deleteCharAt(builder.length() - 1);
+ }
+ }
+ if (whiteSpaceTreatment == WhiteSpaceTreatment.IGNORE) {
+ for (int index = 0; index < builder.length(); index ++) {
+ final char c = builder.charAt(index);
+ if (c == ' ') {
+ builder.deleteCharAt(index);
+ /* We need to decrement the index here to avoid skipping the next char. */
+ index --;
+ }
+ }
+ }
+ }
+
+ /**
* Applies the linefeed treatment to a specific character.
* @param c The character being processed, which should always be a linefeed character.
* @param linefeedTreatment The value of the linefeed-treatment trait.
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-11 15:27:47 UTC (rev 12380)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-11 18:23:42 UTC (rev 12381)
@@ -29,6 +29,7 @@
package org.foray.fotree.fo.obj;
import org.foray.fotree.FoObj;
+import org.foray.fotree.MutableTokenFlowLocation;
import org.axsl.common.TextModifiers;
import org.axsl.common.para.ParaBranch;
@@ -186,11 +187,14 @@
public CharSequence extract(final TokenFlow.Location startLocation, final TokenFlow.Location endLocation,
final TextModifiers textModifiers, final boolean isStartOfLine, final boolean isEndOfLine) {
final StringBuilder builder = new StringBuilder();
- /* TODO: Handle the segment and character indexes as well. */
- for (int tokenIndex = startLocation.getTokenIndex(); tokenIndex < endLocation.getTokenIndex(); tokenIndex ++) {
- final FoToken token = tokenAt(tokenIndex);
+ final MutableTokenFlowLocation currentLocation = new MutableTokenFlowLocation(startLocation);
+ while (currentLocation.compareTo(endLocation) < 0) {
+ final FoToken token = tokenAt(currentLocation.getTokenIndex());
builder.append(token.getText());
+ currentLocation.markTokenComplete();
}
+
+ applyWhiteSpaceTreatmentToLine(builder, textModifiers.traitWhiteSpaceTreatment(), isStartOfLine, isEndOfLine);
return builder.toString();
}
Added: trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/obj/FoText4aTests.java
===================================================================
--- trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/obj/FoText4aTests.java (rev 0)
+++ trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/obj/FoText4aTests.java 2022-01-11 18:23:42 UTC (rev 12381)
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2021 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fotree.fo.obj;
+
+import org.axsl.common.value.WhiteSpaceTreatment;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Tests of {@link FoText4a}.
+ */
+public class FoText4aTests {
+
+ /**
+ * Tests of {@link FoText4a#applyWhiteSpaceTreatmentToLine(StringBuilder, WhiteSpaceTreatment, boolean, boolean)}
+ * for a string with both leading and trailing spaces.
+ */
+ @Test
+ public void applyWhiteSpaceTreatmentToLine_Test_001() {
+ final String string1 = " A test string. ";
+
+ StringBuilder builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.PRESERVE, false, false);
+ Assert.assertEquals(string1, builder.toString());
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.PRESERVE, false, true);
+ Assert.assertEquals(string1, builder.toString());
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.PRESERVE, true, false);
+ Assert.assertEquals(string1, builder.toString());
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.PRESERVE, true, true);
+ Assert.assertEquals(string1, builder.toString());
+
+
+
+
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE, false, false);
+ Assert.assertEquals("Ateststring.", builder.toString());
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE, false, true);
+ Assert.assertEquals("Ateststring.", builder.toString());
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE, true, false);
+ Assert.assertEquals("Ateststring.", builder.toString());
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE, true, true);
+ Assert.assertEquals("Ateststring.", builder.toString());
+
+
+
+
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_BEFORE_LINEFEED, false, false);
+ Assert.assertEquals(string1, builder.toString());
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_BEFORE_LINEFEED, false, true);
+ Assert.assertEquals(" A test string.", builder.toString());
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_BEFORE_LINEFEED, true, false);
+ Assert.assertEquals(string1, builder.toString());
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_BEFORE_LINEFEED, true, true);
+ Assert.assertEquals(" A test string.", builder.toString());
+
+
+
+
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_AFTER_LINEFEED, false, false);
+ Assert.assertEquals(string1, builder.toString());
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_AFTER_LINEFEED, false, true);
+ Assert.assertEquals(string1, builder.toString());
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_AFTER_LINEFEED, true, false);
+ Assert.assertEquals("A test string. ", builder.toString());
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(builder, WhiteSpaceTreatment.IGNORE_IF_AFTER_LINEFEED, true, true);
+ Assert.assertEquals("A test string. ", builder.toString());
+
+
+
+
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(
+ builder, WhiteSpaceTreatment.IGNORE_IF_SURROUNDING_LINEFEED, false, false);
+ Assert.assertEquals(string1, builder.toString());
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(
+ builder, WhiteSpaceTreatment.IGNORE_IF_SURROUNDING_LINEFEED, false, true);
+ Assert.assertEquals(" A test string.", builder.toString());
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(
+ builder, WhiteSpaceTreatment.IGNORE_IF_SURROUNDING_LINEFEED, true, false);
+ Assert.assertEquals("A test string. ", builder.toString());
+
+ builder = new StringBuilder(string1);
+ FoText4a.applyWhiteSpaceTreatmentToLine(
+ builder, WhiteSpaceTreatment.IGNORE_IF_SURROUNDING_LINEFEED, true, true);
+ Assert.assertEquals("A test string.", builder.toString());
+
+ }
+
+}
Property changes on: trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/obj/FoText4aTests.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-11 15:27:50
|
Revision: 12380
http://sourceforge.net/p/foray/code/12380
Author: victormote
Date: 2022-01-11 15:27:47 +0000 (Tue, 11 Jan 2022)
Log Message:
-----------
Conform to aXSL changes: 1. Make TokenFlow.Location Comparable. 2. Add boolean values indicating first and last positions on the line when computing the text on a word-based line.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaWords.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaWords.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaWords.java 2022-01-11 13:32:51 UTC (rev 12379)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaWords.java 2022-01-11 15:27:47 UTC (rev 12380)
@@ -82,7 +82,10 @@
@Override
public CharSequence getText() {
final FoTextWords generator = this.foLink.getGenerator();
- return generator.extract(this.startLocation, this.endLocation, this);
+ final int whichChild = getParent().getOtnChildIndex(this);
+ final boolean isStartOfLine = whichChild == 0;
+ final boolean isEndOfLine = whichChild == getParent().getOtnChildCount() - 1;
+ return generator.extract(this.startLocation, this.endLocation, this, isStartOfLine, isEndOfLine);
}
@Override
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-11 13:32:51 UTC (rev 12379)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-11 15:27:47 UTC (rev 12380)
@@ -184,7 +184,7 @@
@Override
public CharSequence extract(final TokenFlow.Location startLocation, final TokenFlow.Location endLocation,
- final TextModifiers textModifiers) {
+ final TextModifiers textModifiers, final boolean isStartOfLine, final boolean isEndOfLine) {
final StringBuilder builder = new StringBuilder();
/* TODO: Handle the segment and character indexes as well. */
for (int tokenIndex = startLocation.getTokenIndex(); tokenIndex < endLocation.getTokenIndex(); tokenIndex ++) {
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java 2022-01-11 13:32:51 UTC (rev 12379)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java 2022-01-11 15:27:47 UTC (rev 12380)
@@ -48,9 +48,10 @@
public class TokenFlow4a implements FoTokenFlow {
/**
- * FOray implementation of {@link FoTokenFlow.Location}.
+ * FOray implementation of {@link TokenFlow.Location}.
+ * Instances of this class are immutable.
*/
- public class Location implements FoTokenFlow.Location {
+ public final class Location implements TokenFlow.Location {
/* TODO: If 16 bits is not enough for the token index, consider cramming the three parameters into one int,
* using the 32 bits as 20 bits for the token, 6 for the segment, and 6 for the char, adding 4 bits to the size
* of the token index. */
@@ -87,6 +88,23 @@
return this.charIndex;
}
+ @Override
+ public int compareTo(final TokenFlow.Location o) {
+ if (this.tokenIndex == o.getTokenIndex()) {
+ if (this.segmentIndex == o.getSegmentIndex()) {
+ if (this.charIndex == o.getCharIndex()) {
+ return 0;
+ } else {
+ return this.charIndex - o.getCharIndex();
+ }
+ } else {
+ return this.segmentIndex - o.getSegmentIndex();
+ }
+ } else {
+ return this.tokenIndex - o.getTokenIndex();
+ }
+ }
+
}
/** The tokens (children) of this text flow. */
@@ -166,8 +184,7 @@
}
@Override
- public org.axsl.orthography.TokenFlow.Location markLocation(final int tokenIndex, final byte segmentIndex,
- final byte charIndex) {
+ public TokenFlow.Location markLocation(final int tokenIndex, final byte segmentIndex, final byte charIndex) {
return new Location(tokenIndex, segmentIndex, charIndex);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-11 13:32:54
|
Revision: 12379
http://sourceforge.net/p/foray/code/12379
Author: victormote
Date: 2022-01-11 13:32:51 +0000 (Tue, 11 Jan 2022)
Log Message:
-----------
Conform to aXSL changes: For text areas backed by word-based Fo Text classes, use location scheme to mark the bounds of text on a given line.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractAncestralInlineArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaCharacters.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaWords.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractAncestralInlineArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractAncestralInlineArea.java 2022-01-10 22:11:20 UTC (rev 12378)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/AbstractAncestralInlineArea.java 2022-01-11 13:32:51 UTC (rev 12379)
@@ -92,8 +92,9 @@
}
@Override
- public GlyphAreaSequenceG5 makeGlyphAreaSequence(final FoTextWords paragraph, final int startLeaf,
- final int sizeInLeaves, final boolean hasFauxSmallCaps) {
+ public GlyphAreaSequenceG5 makeGlyphAreaSequence(final FoTextWords paragraph,
+ final FoTextWords.Location startLocation, final FoTextWords.Location endLocation,
+ final boolean hasFauxSmallCaps) {
throw new UnsupportedOperationException();
}
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2022-01-10 22:11:20 UTC (rev 12378)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2022-01-11 13:32:51 UTC (rev 12379)
@@ -1014,9 +1014,10 @@
}
@Override
- public GlyphAreaSequenceG5 makeGlyphAreaSequence(final FoTextWords paragraph, final int startLeaf,
- final int sizeInLeaves, final boolean hasFauxSmallCaps) {
- final TextAreaWords newTextArea = TextAreaWords.makeTextArea(paragraph, this, startLeaf, sizeInLeaves);
+ public GlyphAreaSequenceG5 makeGlyphAreaSequence(final FoTextWords paragraph,
+ final FoTextWords.Location startLocation, final FoTextWords.Location endLocation,
+ final boolean hasFauxSmallCaps) {
+ final TextAreaWords newTextArea = TextAreaWords.makeTextArea(paragraph, this, startLocation, endLocation);
this.children.add(newTextArea);
return newTextArea;
}
@@ -1127,12 +1128,13 @@
@Override
public void addParaBranch(final ParaBranch branch, final int offset, final int length) {
- if (branch instanceof FoTextWords) {
- final FoTextWords foTextWords = (FoTextWords) branch;
- makeGlyphAreaSequence(foTextWords, offset, length, false);
- return;
- }
- throw new IllegalArgumentException();
+// if (branch instanceof FoTextWords) {
+// final FoTextWords foTextWords = (FoTextWords) branch;
+// makeGlyphAreaSequence(foTextWords, offset, length, false);
+// return;
+// }
+// throw new IllegalArgumentException();
+ throw new UnsupportedOperationException();
}
/**
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java 2022-01-10 22:11:20 UTC (rev 12378)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java 2022-01-11 13:32:51 UTC (rev 12379)
@@ -329,53 +329,15 @@
* rendered as spaces in the output.
* @return The numbers of spaces in this text.
*/
- public int countSpaces() {
- int spaceCount = 0;
- final CharSequence text = this.getText();
- /* Cache the length to avoid recomputing it on every iteration. */
- final int length = text.length();
- for (int i = 0; i < length; i++) {
- final char c = text.charAt(i);
- if (wordSpacingApplies(c)) {
- spaceCount ++;
- }
- }
- return spaceCount;
- }
+ public abstract int countSpaces();
/**
- * Indicates whether word-spacing should be applied to a given character.
- * @param c The character to be tested.
- * @return True if and only if word-spacing should be added for this character.
- */
- private boolean wordSpacingApplies(final int c) {
- switch (c) {
- case ' ': {
- return true;
- }
- default: {
- return false;
- }
- }
- }
-
- /**
* Counts the number of characters in this text that will have
* letter-spacing applied to them.
* @return The numbers of characters in this text to which letter-spacing
* will be applied.
*/
- public int countLetterSpacingChars() {
- /* TODO: The theory here is that all characters except those that have
- * word-spacing applied should have letter-spacing applied, including
- * the last one. I'm not sure this is right. Needs to be tested. Also,
- * letter-spacing may need to be turned off for spaces with specific
- * widths, like the 1/3 em space, etc. */
- int letterCount = 0;
- letterCount += this.getText().length();
- letterCount -= this.countSpaces();
- return letterCount;
- }
+ public abstract int countLetterSpacingChars();
/**
* Returns the resolved letter-spacing, in millipoints.
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaCharacters.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaCharacters.java 2022-01-10 22:11:20 UTC (rev 12378)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaCharacters.java 2022-01-11 13:32:51 UTC (rev 12379)
@@ -446,4 +446,57 @@
return this.foLink.getGenerator();
}
+ /**
+ * Counts the number of space-like characters in this text that should be
+ * rendered as spaces in the output.
+ * @return The numbers of spaces in this text.
+ */
+ public int countSpaces() {
+ int spaceCount = 0;
+ final CharSequence text = this.getText();
+ /* Cache the length to avoid recomputing it on every iteration. */
+ final int length = text.length();
+ for (int i = 0; i < length; i++) {
+ final char c = text.charAt(i);
+ if (wordSpacingApplies(c)) {
+ spaceCount ++;
+ }
+ }
+ return spaceCount;
+ }
+
+ /**
+ * Indicates whether word-spacing should be applied to a given character.
+ * @param c The character to be tested.
+ * @return True if and only if word-spacing should be added for this character.
+ */
+ private boolean wordSpacingApplies(final int c) {
+ switch (c) {
+ case ' ': {
+ return true;
+ }
+ default: {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Counts the number of characters in this text that will have
+ * letter-spacing applied to them.
+ * @return The numbers of characters in this text to which letter-spacing
+ * will be applied.
+ */
+ public int countLetterSpacingChars() {
+ /* TODO: The theory here is that all characters except those that have
+ * word-spacing applied should have letter-spacing applied, including
+ * the last one. I'm not sure this is right. Needs to be tested. Also,
+ * letter-spacing may need to be turned off for spaces with specific
+ * widths, like the 1/3 em space, etc. */
+ int letterCount = 0;
+ letterCount += this.getText().length();
+ letterCount -= this.countSpaces();
+ return letterCount;
+ }
+
}
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaWords.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaWords.java 2022-01-10 22:11:20 UTC (rev 12378)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaWords.java 2022-01-11 13:32:51 UTC (rev 12379)
@@ -30,7 +30,6 @@
import org.foray.area.link.Link;
-import org.axsl.common.para.ParaLeaf;
import org.axsl.fotree.fo.FoTextWords;
public class TextAreaWords extends TextArea {
@@ -38,27 +37,25 @@
/** The link to the FO tree. */
private Link<FoTextWords> foLink;
- /** The first leaf index into the backing for {@link #foLink} that is part of this text area. */
- private int startingLeafIndex;
+ /** The starting location in {@link #foLink#traitGeneratedBy()} for the text in this area, inclusive. */
+ private FoTextWords.Location startLocation;
- /** The number of leaf indexes in the backing for {@link #foLink} that are part of this text area. */
- private int qtyLeaves;
+ /** The ending location in {@link #foLink#traitGeneratedBy()} for the text in this area, exclusive. */
+ private FoTextWords.Location endLocation;
/**
* Constructor.
* @param parentArea The parent area.
* @param generatedBy The FO tree linkage.
- * @param startingLeafIndex The first leaf index into the backing for {@code #generatedBy} that is part of this text
- * area.
- * @param qtyLeaves The number of leaf indexes in the backing for {@code #generatedBy} that are part of this text
- * area.
+ * @param startLocation The starting location in {@code generatedBy} for the text in this area, inclusive.
+ * @param endLocation The ending location in {@code generatedBy} for the text in this area, exclusive.
*/
- public TextAreaWords(final LineArea4a parentArea, final Link<FoTextWords> generatedBy, final int startingLeafIndex,
- final int qtyLeaves) {
+ public TextAreaWords(final LineArea4a parentArea, final Link<FoTextWords> generatedBy,
+ final FoTextWords.Location startLocation, final FoTextWords.Location endLocation) {
super(parentArea);
this.foLink = generatedBy;
- this.startingLeafIndex = startingLeafIndex;
- this.qtyLeaves = qtyLeaves;
+ this.startLocation = startLocation;
+ this.endLocation = endLocation;
}
/**
@@ -65,16 +62,14 @@
* Package-visible factory method.
* @param generatedBy The FO node generating this area.
* @param parentArea The parent area.
- * @param startingLeafIndex The first leaf index into the backing for {@code #generatedBy} that is part of this text
- * area.
- * @param qtyLeaves The number of leaf indexes in the backing for {@code #generatedBy} that are part of this text
- * area.
+ * @param startLocation The starting location in {@code generatedBy} for the text in this area, inclusive.
+ * @param endLocation The ending location in {@code generatedBy} for the text in this area, exclusive.
* @return The newly-created TextArea.
*/
static TextAreaWords makeTextArea(final FoTextWords generatedBy, final LineArea4a parentArea,
- final int startingLeafIndex, final int qtyLeaves) {
+ final FoTextWords.Location startLocation, final FoTextWords.Location endLocation) {
final Link<FoTextWords> linkage = parentArea.getLink(generatedBy);
- final TextAreaWords newTextArea = new TextAreaWords(parentArea, linkage, startingLeafIndex, qtyLeaves);
+ final TextAreaWords newTextArea = new TextAreaWords(parentArea, linkage, startLocation, endLocation);
newTextArea.registerLink(generatedBy);
return newTextArea;
}
@@ -86,13 +81,8 @@
@Override
public CharSequence getText() {
- final StringBuilder builder = new StringBuilder();
- final FoTextWords words = this.foLink.getGenerator();
- for (int index = this.startingLeafIndex; index < (this.startingLeafIndex + this.qtyLeaves); index ++) {
- final ParaLeaf leaf = words.paraLeafAt(index);
- builder.append(leaf.getText());
- }
- return builder.toString();
+ final FoTextWords generator = this.foLink.getGenerator();
+ return generator.extract(this.startLocation, this.endLocation, this);
}
@Override
@@ -112,4 +102,16 @@
return this.getFoLink().getGenerator();
}
+ @Override
+ public int countSpaces() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int countLetterSpacingChars() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-10 22:11:20 UTC (rev 12378)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-01-11 13:32:51 UTC (rev 12379)
@@ -185,8 +185,13 @@
@Override
public CharSequence extract(final TokenFlow.Location startLocation, final TokenFlow.Location endLocation,
final TextModifiers textModifiers) {
- // TODO Auto-generated method stub
- return null;
+ final StringBuilder builder = new StringBuilder();
+ /* TODO: Handle the segment and character indexes as well. */
+ for (int tokenIndex = startLocation.getTokenIndex(); tokenIndex < endLocation.getTokenIndex(); tokenIndex ++) {
+ final FoToken token = tokenAt(tokenIndex);
+ builder.append(token.getText());
+ }
+ return builder.toString();
}
@Override
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java 2022-01-10 22:11:20 UTC (rev 12378)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java 2022-01-11 13:32:51 UTC (rev 12379)
@@ -28,6 +28,8 @@
package org.foray.pioneer;
+import org.foray.common.para.ParaBranch4aIterator;
+
import org.axsl.area.AreaNode;
import org.axsl.area.AreaTreeException;
import org.axsl.area.LineArea;
@@ -73,12 +75,26 @@
final LineBreaker lb = areaNode.getAreaTree().getLineBreaker();
final LineBreakResult result = lb.breakIntoLines(this.node, (ParaConfig) this.node, paraContext);
- int lastLeafIndex = 0;
+ FoTextWords.Location startLocation = this.node.markLocation(0, (byte) -1, (byte) -1);
+ /* Run a leaf iterator alongside the iteration of the line-break results, so that we can conveniently retrieve
+ * the branch indexes. */
+ final ParaBranch4aIterator iterator = new ParaBranch4aIterator(this.node);
for (int index = 0; index < result.getQtyLines(); index ++) {
final int currentLeafIndex = result.getBreakPosition(index);
final LineArea lineArea = normalBlockArea.makeLineArea(true);
- lineArea.makeGlyphAreaSequence(this.node, lastLeafIndex, currentLeafIndex - lastLeafIndex, false);
- lastLeafIndex = currentLeafIndex;
+ while (iterator.nextIndex() < currentLeafIndex) {
+ if (iterator.hasNext()) {
+ iterator.next();
+ } else {
+ throw new IllegalStateException("Iterator cannot go past last element.");
+ }
+ }
+ /* Element 0 should be the token index. If there is an element 1, it should be the segment index. */
+ final int tokenIndex = iterator.branchIndexAt(0);
+ final byte segmentIndex = iterator.depth() > 1 ? (byte) iterator.branchIndexAt(1) : -1;
+ final FoTextWords.Location endLocation = this.node.markLocation(tokenIndex, segmentIndex, (byte) -1);
+ lineArea.makeGlyphAreaSequence(this.node, startLocation, endLocation, false);
+ startLocation = endLocation;
}
return Status.OK;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-01-10 22:11:22
|
Revision: 12378
http://sourceforge.net/p/foray/code/12378
Author: victormote
Date: 2022-01-10 22:11:20 +0000 (Mon, 10 Jan 2022)
Log Message:
-----------
Add methods to return the depth and content of the branch indexes.
Modified Paths:
--------------
trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4aIterator.java
trunk/foray/foray-common/src/test/java/org/foray/common/para/ParaBranch4aIteratorTests.java
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4aIterator.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4aIterator.java 2022-01-10 18:49:27 UTC (rev 12377)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4aIterator.java 2022-01-10 22:11:20 UTC (rev 12378)
@@ -189,4 +189,24 @@
this.branchIndexes.push(currentIndex);
}
+ /**
+ * Returns the number of items in the branch indexes stack.
+ * @return The number of items in the branch indexes stack.
+ */
+ public int depth() {
+ return this.branchIndexes.length();
+ }
+
+ /**
+ * Random read-only access to the branch indexes stack.
+ * Together with {@link #depth()}, provides access to the content of the branches stack.
+ * @param index The index into the branch indexes.
+ * Index 0 provides the value at the bottom of the stack, ... index {@code length() - 1} provides the value at the
+ * top of the stack.
+ * @return The content of the branches stack at index {@code index}.
+ */
+ public int branchIndexAt(final int index) {
+ return this.branchIndexes.intAt(0);
+ }
+
}
Modified: trunk/foray/foray-common/src/test/java/org/foray/common/para/ParaBranch4aIteratorTests.java
===================================================================
--- trunk/foray/foray-common/src/test/java/org/foray/common/para/ParaBranch4aIteratorTests.java 2022-01-10 18:49:27 UTC (rev 12377)
+++ trunk/foray/foray-common/src/test/java/org/foray/common/para/ParaBranch4aIteratorTests.java 2022-01-10 22:11:20 UTC (rev 12378)
@@ -45,13 +45,16 @@
* @param expectedHasPrevious The expected value for hasPrevious().
* @param expectedNextIndex The expected value for nextIndex().
* @param expectedPreviousIndex The expected value for previousIndex().
+ * @param expectedDepth The expected value for depth().
*/
private void iteratorAssertions(final ParaBranch4aIterator iterator, final boolean expectedHasNext,
- final boolean expectedHasPrevious, final int expectedNextIndex, final int expectedPreviousIndex) {
+ final boolean expectedHasPrevious, final int expectedNextIndex, final int expectedPreviousIndex,
+ final int expectedDepth) {
Assert.assertEquals(expectedHasNext, iterator.hasNext());
Assert.assertEquals(expectedHasPrevious, iterator.hasPrevious());
Assert.assertEquals(expectedNextIndex, iterator.nextIndex());
Assert.assertEquals(expectedPreviousIndex, iterator.previousIndex());
+ Assert.assertEquals(expectedDepth, iterator.depth());
}
/**
@@ -61,75 +64,75 @@
public void test_001() {
final ParaBranch4a para = ParaBranch4aTests.createTestPara();
final ParaBranch4aIterator out = new ParaBranch4aIterator(para);
- iteratorAssertions(out, true, false, 0, -1);
+ iteratorAssertions(out, true, false, 0, -1, 1);
/* Iterate forward. */
Assert.assertEquals("B", out.next().getText());
- iteratorAssertions(out, true, true, 1, 0);
+ iteratorAssertions(out, true, true, 1, 0, 2);
Assert.assertEquals("e", out.next().getText());
- iteratorAssertions(out, true, true, 2, 1);
+ iteratorAssertions(out, true, true, 2, 1, 2);
Assert.assertEquals(" ", out.next().getText());
- iteratorAssertions(out, true, true, 3, 2);
+ iteratorAssertions(out, true, true, 3, 2, 1);
Assert.assertEquals("not", out.next().getText());
- iteratorAssertions(out, true, true, 4, 3);
+ iteratorAssertions(out, true, true, 4, 3, 1);
Assert.assertEquals(" ", out.next().getText());
- iteratorAssertions(out, true, true, 5, 4);
+ iteratorAssertions(out, true, true, 5, 4, 1);
Assert.assertEquals("afraid", out.next().getText());
- iteratorAssertions(out, true, true, 6, 5);
+ iteratorAssertions(out, true, true, 6, 5, 1);
Assert.assertEquals(" ", out.next().getText());
- iteratorAssertions(out, true, true, 7, 6);
+ iteratorAssertions(out, true, true, 7, 6, 1);
Assert.assertEquals("of", out.next().getText());
- iteratorAssertions(out, true, true, 8, 7);
+ iteratorAssertions(out, true, true, 8, 7, 1);
Assert.assertEquals(" ", out.next().getText());
- iteratorAssertions(out, true, true, 9, 8);
+ iteratorAssertions(out, true, true, 9, 8, 1);
Assert.assertEquals("great", out.next().getText());
- iteratorAssertions(out, true, true, 10, 9);
+ iteratorAssertions(out, true, true, 10, 9, 2);
Assert.assertEquals("-", out.next().getText());
- iteratorAssertions(out, true, true, 11, 10);
+ iteratorAssertions(out, true, true, 11, 10, 2);
Assert.assertEquals("ness", out.next().getText());
- iteratorAssertions(out, true, true, 12, 11);
+ iteratorAssertions(out, true, true, 12, 11, 2);
Assert.assertEquals(".", out.next().getText());
- iteratorAssertions(out, true, true, 13, 12);
+ iteratorAssertions(out, true, true, 13, 12, 1);
/* Now iterate backward for awhile. */
Assert.assertEquals(".", out.previous().getText());
- iteratorAssertions(out, true, true, 12, 11);
+ iteratorAssertions(out, true, true, 12, 11, 1);
Assert.assertEquals("ness", out.previous().getText());
- iteratorAssertions(out, true, true, 11, 10);
+ iteratorAssertions(out, true, true, 11, 10, 2);
Assert.assertEquals("-", out.previous().getText());
- iteratorAssertions(out, true, true, 10, 9);
+ iteratorAssertions(out, true, true, 10, 9, 2);
Assert.assertEquals("great", out.previous().getText());
- iteratorAssertions(out, true, true, 9, 8);
+ iteratorAssertions(out, true, true, 9, 8, 2);
/* Reverse direction to forward again. */
Assert.assertEquals("great", out.next().getText());
- iteratorAssertions(out, true, true, 10, 9);
+ iteratorAssertions(out, true, true, 10, 9, 2);
Assert.assertEquals("-", out.next().getText());
- iteratorAssertions(out, true, true, 11, 10);
+ iteratorAssertions(out, true, true, 11, 10, 2);
/* Reverse direction to backward again. Read back to the beginning. */
Assert.assertEquals("-", out.previous().getText());
- iteratorAssertions(out, true, true, 10, 9);
+ iteratorAssertions(out, true, true, 10, 9, 2);
Assert.assertEquals("great", out.previous().getText());
- iteratorAssertions(out, true, true, 9, 8);
+ iteratorAssertions(out, true, true, 9, 8, 2);
Assert.assertEquals(" ", out.previous().getText());
- iteratorAssertions(out, true, true, 8, 7);
+ iteratorAssertions(out, true, true, 8, 7, 1);
Assert.assertEquals("of", out.previous().getText());
- iteratorAssertions(out, true, true, 7, 6);
+ iteratorAssertions(out, true, true, 7, 6, 1);
Assert.assertEquals(" ", out.previous().getText());
- iteratorAssertions(out, true, true, 6, 5);
+ iteratorAssertions(out, true, true, 6, 5, 1);
Assert.assertEquals("afraid", out.previous().getText());
- iteratorAssertions(out, true, true, 5, 4);
+ iteratorAssertions(out, true, true, 5, 4, 1);
Assert.assertEquals(" ", out.previous().getText());
- iteratorAssertions(out, true, true, 4, 3);
+ iteratorAssertions(out, true, true, 4, 3, 1);
Assert.assertEquals("not", out.previous().getText());
- iteratorAssertions(out, true, true, 3, 2);
+ iteratorAssertions(out, true, true, 3, 2, 1);
Assert.assertEquals(" ", out.previous().getText());
- iteratorAssertions(out, true, true, 2, 1);
+ iteratorAssertions(out, true, true, 2, 1, 1);
Assert.assertEquals("e", out.previous().getText());
- iteratorAssertions(out, true, true, 1, 0);
+ iteratorAssertions(out, true, true, 1, 0, 2);
Assert.assertEquals("B", out.previous().getText());
- iteratorAssertions(out, true, false, 0, -1);
+ iteratorAssertions(out, true, false, 0, -1, 2);
/* We just retrieved the first node using previous(). The cursor is sitting before index 0. Another previous()
* should throw an exception. */
@@ -149,7 +152,7 @@
public void test_002() {
final ParaBranch4a para = ParaBranch4aTests.createTestPara();
final ParaBranch4aIterator out = new ParaBranch4aIterator(para);
- iteratorAssertions(out, true, false, 0, -1);
+ iteratorAssertions(out, true, false, 0, -1, 1);
try {
out.previous();
@@ -167,7 +170,7 @@
public void test_003() {
final ParaBranch4a para = ParaBranch4aTests.createTestPara();
final ParaBranch4aIterator out = new ParaBranch4aIterator(para);
- iteratorAssertions(out, true, false, 0, -1);
+ iteratorAssertions(out, true, false, 0, -1, 1);
/* Iterate to the end of the branch. */
for (int leafIndex = 0; leafIndex < para.qtyParaLeaves(); leafIndex ++) {
@@ -175,7 +178,7 @@
}
/* Make sure we are where we think we are. */
- iteratorAssertions(out, false, true, 50, 49);
+ iteratorAssertions(out, false, true, 50, 49, 2);
try {
out.next();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|