Revision: 12230
http://sourceforge.net/p/foray/code/12230
Author: victormote
Date: 2021-12-16 14:17:44 +0000 (Thu, 16 Dec 2021)
Log Message:
-----------
Add implementation of FoTextWords.
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 2021-12-16 13:56:36 UTC (rev 12229)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2021-12-16 14:17:44 UTC (rev 12230)
@@ -33,6 +33,8 @@
import org.foray.fotree.FoObj;
import org.axsl.common.para.ParaBranch;
+import org.axsl.common.para.ParaConfig;
+import org.axsl.common.para.ParaLeaf;
import org.axsl.common.para.ParaNode;
import org.axsl.common.value.LinefeedTreatment;
import org.axsl.common.value.TextTransform;
@@ -39,6 +41,7 @@
import org.axsl.common.value.WhiteSpaceTreatment;
import org.axsl.fotree.FoContext;
import org.axsl.fotree.ProxyFactory;
+import org.axsl.fotree.fo.FoTextWords;
import org.axsl.orthography.Orthography;
import org.axsl.orthography.OrthographyException;
import org.axsl.orthography.OrthographyServer;
@@ -45,11 +48,12 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.ListIterator;
/**
* Text in an FO document that is already broken into words.
*/
-public class FoTextWords4a extends AbstractCharacterSequence {
+public class FoTextWords4a extends AbstractCharacterSequence implements FoTextWords {
/** The parent of this node. */
private FoObj parent;
@@ -57,6 +61,9 @@
/** The parsed words. */
private List<FoWordSequenceContent> content;
+ /** The parsed words. */
+ private ParaBranch paraBranch;
+
/**
* Constructor.
* @param parent The FoObj parent of this text.
@@ -68,14 +75,13 @@
this.parent = parent;
final OrthographyServer orthographyServer = getOrthographyServer();
final Orthography orthography = orthographyServer.getOrthography(getWritingSystem());
- final ParaBranch wordSequence =
- orthography.tokenizeWordSequence(ParaBranch4a.getFactory(), content, 0, content.length());
- final ParaConfig4a config = new ParaConfig4a(getPrimaryFont(null), inlineFontSize(), inlineOrthography(),
+ this.paraBranch = orthography.tokenizeWordSequence(ParaBranch4a.getFactory(), content, 0, content.length());
+ final ParaConfig4a config = new ParaConfig4a(getPrimaryFont(null), parent.traitFontSize(null), orthography,
parent.traitWordSpacingMax(null), parent.traitWordSpacingMin(null));
- wordSequence.setParaConfig(config);
- this.content = new ArrayList<FoWordSequenceContent>(wordSequence.paraNodeSize());
- for (int index = 0; index < wordSequence.paraNodeSize(); index ++) {
- final ParaNode wordSequenceContent = wordSequence.paraNodeAt(index);
+ this.paraBranch.setParaConfig(config);
+ this.content = new ArrayList<FoWordSequenceContent>(this.paraBranch.paraNodeSize());
+ for (int index = 0; index < this.paraBranch.paraNodeSize(); index ++) {
+ final ParaNode wordSequenceContent = this.paraBranch.paraNodeAt(index);
final FoWordSequenceContent contentElement = FoWordSequenceContent.create(wordSequenceContent);
this.content.add(contentElement);
}
@@ -87,6 +93,71 @@
}
@Override
+ public int paraNodeSize() {
+ return this.paraBranch.paraNodeSize();
+ }
+
+ @Override
+ public ParaNode paraNodeAt(final int nodeIndex) {
+ return this.paraBranch.paraNodeAt(nodeIndex);
+ }
+
+ @Override
+ public void addNode(final ParaNode node) {
+ this.paraBranch.addNode(node);
+ }
+
+ @Override
+ public int paraLeafSize() {
+ return this.paraBranch.paraLeafSize();
+ }
+
+ @Override
+ public ParaLeaf paraLeafAt(final int leafIndex) {
+ return this.paraBranch.paraLeafAt(leafIndex);
+ }
+
+ @Override
+ public ListIterator<ParaLeaf> leafIterator() {
+ return this.paraBranch.leafIterator();
+ }
+
+ @Override
+ public ParaConfig getParaConfig() {
+ return this.paraBranch.getParaConfig();
+ }
+
+ @Override
+ public void setParaConfig(final ParaConfig config) {
+ this.paraBranch.setParaConfig(config);
+ }
+
+ @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 paraKpLeafSize() {
+ return this.paraBranch.paraKpLeafSize();
+ }
+
+ @Override
+ public CharSequence getText() {
+ return this.paraBranch.getText();
+ }
+
+ @Override
public CharSequence getAreaTreeText(final FoContext context) {
final FoObj effectiveParent = this.effectiveParent(context);
final WhiteSpaceTreatment whiteSpaceTreatment = effectiveParent.traitWhiteSpaceTreatment(context);
@@ -122,26 +193,6 @@
}
@Override
- public boolean canHaveMarkerChildren() {
- return false;
- }
-
- @Override
- public boolean canHavePcdataChildren() {
- return false;
- }
-
- @Override
- public boolean canHaveInlineChildren() {
- return false;
- }
-
- @Override
- public boolean canHaveBlockChildren() {
- return false;
- }
-
- @Override
public int length() {
int totalLength = 0;
for (int index = 0; index < this.content.size(); index ++) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|