[FOray-commit] SF.net SVN: foray:[12053] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2021-11-13 13:41:51
|
Revision: 12053
http://sourceforge.net/p/foray/code/12053
Author: victormote
Date: 2021-11-13 13:41:48 +0000 (Sat, 13 Nov 2021)
Log Message:
-----------
Conform to aXSL changes: Move management of the paragraph config, a layout issue, out of Orthography.
Modified Paths:
--------------
trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWordSequence.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/TotalFitLbTests.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Interword4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Orthography4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Punctuation4a.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/test/java/org/foray/orthography/HyphenationConsumer4aTests.java
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 2021-11-13 12:37:41 UTC (rev 12052)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4a.java 2021-11-13 13:41:48 UTC (rev 12053)
@@ -108,4 +108,9 @@
this.nodes.set(index, newNode);
}
+ @Override
+ public void setParaConfig(final ParaConfig config) {
+ this.config = config;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWordSequence.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWordSequence.java 2021-11-13 12:37:41 UTC (rev 12052)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoWordSequence.java 2021-11-13 13:41:48 UTC (rev 12053)
@@ -59,11 +59,12 @@
public FoWordSequence(final FoObj parent, final CharSequence content) {
super(parent);
final OrthographyServer orthographyServer = getOrthographyServer();
+ final Orthography orthography = orthographyServer.getOrthography(getWritingSystem());
+ final ParaBranch wordSequence =
+ orthography.tokenizeWordSequence(content, 0, content.length());
final ParaConfig4a config = new ParaConfig4a(getPrimaryFont(null), inlineFontSize(), inlineWritingSystem(),
parent.traitWordSpacingMax(null), parent.traitWordSpacingMin(null));
- final Orthography orthography = orthographyServer.getOrthography(getWritingSystem());
- final ParaBranch wordSequence =
- orthography.parseWordSequence(content, 0, content.length(), config);
+ wordSequence.setParaConfig(config);
this.content = new ArrayList<FoWordSequenceContent>(wordSequence.getQtyParaNodeChildren());
for (int index = 0; index < wordSequence.getQtyParaNodeChildren(); index ++) {
final ParaNode wordSequenceContent = wordSequence.getParaNodeChild(index);
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 2021-11-13 12:37:41 UTC (rev 12052)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/TotalFitLbTests.java 2021-11-13 13:41:48 UTC (rev 12053)
@@ -60,7 +60,9 @@
*/
public class TotalFitLbTests {
- /** A string used for testing line-breaking. */
+ /** A string used for testing line-breaking. This example is used in Knuth, "Digital Typography," 1999, Chapter 3,
+ * "Breaking Paragraphs into Lines," p. 74 et seq. Knuth cites his source as "Grimm's Fairy Tales." By using an
+ * example directly from the book, we hope to get some independent expected results. */
public static final String TEST_STRING_01 =
"In olden times when wishing still helped one, there lived a king " +
"whose daughters were all beautiful; and the youngest was so beautiful that the sun itself, which has " +
@@ -101,7 +103,8 @@
final Orthography4a orthography = this.orthographyServer.getOrthography(WritingSystem4a.USA);
final ParaBranch4a paragraph =
- orthography.parseWordSequence(TEST_STRING_01, 0, TEST_STRING_01.length(), paraConfig);
+ orthography.tokenizeWordSequence(TEST_STRING_01, 0, TEST_STRING_01.length());
+ paragraph.setParaConfig(paraConfig);
/* Make manual changes to get the paragraph features identical to our baseline paragraph, as documented
* in the Knuth-Plass article. These are all cases where the native hyphenation opportunies violate the
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Interword4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Interword4a.java 2021-11-13 12:37:41 UTC (rev 12052)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Interword4a.java 2021-11-13 13:41:48 UTC (rev 12053)
@@ -303,6 +303,11 @@
}
@Override
+ public void setParaConfig(final ParaConfig config) {
+ /* Nothing to do here. */
+ }
+
+ @Override
public Type getParaNodeType() {
return ParaNode.Type.BRANCH;
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Orthography4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Orthography4a.java 2021-11-13 12:37:41 UTC (rev 12052)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Orthography4a.java 2021-11-13 13:41:48 UTC (rev 12053)
@@ -37,7 +37,6 @@
import org.foray.orthography.wrapper.ExactWord;
import org.foray.orthography.wrapper.UppercaseWord;
-import org.axsl.common.para.ParaConfig;
import org.axsl.orthography.Orthography;
import org.axsl.orthography.Word;
import org.axsl.orthography.optional.Dictionary;
@@ -407,9 +406,8 @@
}
@Override
- public ParaBranch4a parseWordSequence(final CharSequence characters, final int startIndex, final int length,
- final ParaConfig paraConfig) {
- final ParaBranch4a wordSequence = new ParaBranch4a(paraConfig);
+ public ParaBranch4a tokenizeWordSequence(final CharSequence characters, final int startIndex, final int length) {
+ final ParaBranch4a wordSequence = new ParaBranch4a(null);
final CharSequence sequence = characters.subSequence(startIndex, startIndex + length);
final List<CharSequence> chunks = this.lexer.tokenize(sequence);
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 2021-11-13 12:37:41 UTC (rev 12052)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Punctuation4a.java 2021-11-13 13:41:48 UTC (rev 12053)
@@ -234,6 +234,11 @@
}
@Override
+ public void setParaConfig(final ParaConfig config) {
+ /* Nothing to do here. */
+ }
+
+ @Override
public int length() {
return this.content.length();
}
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 2021-11-13 12:37:41 UTC (rev 12052)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java 2021-11-13 13:41:48 UTC (rev 12053)
@@ -180,6 +180,11 @@
}
@Override
+ public void setParaConfig(final ParaConfig config) {
+ /* Nothing to do here. */
+ }
+
+ @Override
public int length() {
return this.content.length();
}
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 2021-11-13 12:37:41 UTC (rev 12052)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Word4a.java 2021-11-13 13:41:48 UTC (rev 12053)
@@ -221,6 +221,11 @@
return null;
}
+ @Override
+ public void setParaConfig(final ParaConfig config) {
+ /* Nothing to do here. */
+ }
+
/**
* Returns the index (from a {@link CharSequence} standpoint) to the first character of a given segment.
* For example, for the word phi-los-o-phy, getSegmentStart(1) should return the index to the second segment
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 2021-11-13 12:37:41 UTC (rev 12052)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/HyphenationConsumer4aTests.java 2021-11-13 13:41:48 UTC (rev 12053)
@@ -30,7 +30,6 @@
import org.foray.common.i18n.WritingSystem4a;
import org.foray.common.para.ParaBranch4a;
-import org.foray.common.para.ParaConfig4a;
import org.axsl.common.para.ParaConfig;
import org.axsl.orthography.OrthographyException;
@@ -51,9 +50,6 @@
/** The hyphenation server used in these tests. */
private static OrthographyServer4a server;
- /** The paragraph configuration that should be used in these tests. */
- private static ParaConfig paraConfig = new ParaConfig4a(null, 0, WritingSystem4a.USA, 0, 0);
-
/** The object under test. */
private Orthography4a consumer;
@@ -86,7 +82,7 @@
/* Spoken by Henry, Henry V, Act III Scene 1. */
final String testString = "Once more unto the breach, dear friends, once more;";
final ParaBranch4a wordSequence =
- this.consumer.parseWordSequence(testString, 0, testString.length(), paraConfig);
+ this.consumer.tokenizeWordSequence(testString, 0, testString.length());
Assert.assertEquals(20, wordSequence.getQtyParaNodeChildren());
Assert.assertEquals("Once", wordSequence.getParaNodeChild(0).toString());
Assert.assertEquals(" ", wordSequence.getParaNodeChild(1).toString());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|