foray-commit Mailing List for FOray (Page 52)
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
(2) |
Dec
|
|
From: <vic...@us...> - 2022-02-17 19:10:24
|
Revision: 12600
http://sourceforge.net/p/foray/code/12600
Author: victormote
Date: 2022-02-17 19:10:22 +0000 (Thu, 17 Feb 2022)
Log Message:
-----------
Doc change only.
Modified Paths:
--------------
trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeafIterator4a.java
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeafIterator4a.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeafIterator4a.java 2022-02-17 01:19:32 UTC (rev 12599)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeafIterator4a.java 2022-02-17 19:10:22 UTC (rev 12600)
@@ -47,15 +47,44 @@
* This means that node "n" returned by next(), will also be returned again if the next call is to previous(), and vice
* versa.</p>
*
- * <p>Although there is no "current" node, this class maintains the concept of a cursor, which always sits immediately
- * before the "next" node.
- * This cursor is made of of two elements: the {@link #branchStack} and the {@link #branchIndexes}, which together
- * efficiently track a path through the branches to a specific leaf.</p>
+ * <p>Internal to this class, there are really two cursor concepts.
+ * This deserves some explanation.
+ * We'll call the first cursor the "external cursor".
+ * It is the expected one, the one exposed through the following methods:</p>
+ * <ul>
+ * <li>{@link #hasNext()}</li>
+ * <li>{@link #hasPrevious()}</li>
+ * <li>{@link #next()}</li>
+ * <li>{@link #previous()}</li>
+ * <li>{@link #nextIndex()}</li>
+ * <li>{@link #previousIndex()}</li>
+ * <li>{@link #advanceToLeaf(int)}</li>
+ * </ul>
+ *
+ * <p>We'll call the second cursor the "internal cursor", which expose the state of the iterator at a
+ * particular node.
+ * Remember that bidirectional iterators really point to two nodes at the same time, a "next" and a "previous", so it is
+ * unnatural to try to point to a single node.
+ * However, the ability to do so is very valuable, as the state of the iterator can be used to efficiently mark a path
+ * to that node.
+ * Rather than trying to maintain both states (that of the next and that of the previous nodes), this "internal cursor"
+ * always points to the node <em>that was last accessed,</em> which is the natural way that one would want to use this
+ * state information.
+ * For this reason, these two cursors move in different patterns.
+ * Specifically, the "external cursor" always moves as part of a {@link #next()} or a {@link #previous()}.
+ * The "internal cursor" only moves as part of those methods if the direction of the method is the same as direction of
+ * the move immediately before.
+ * These are the methods that expose this internal iterator state:</p>
+ * <ul>
+ * <li>{@link #depth()}</li>
+ * <li>{@link #branchIndexAt(int)}</li>
+ * <li>{@link #getNearestContext()}</li>
+ * </ul>
*/
public class KpLeafIterator4a implements KpLeafIterator {
/**
- * Enumeration of directions.
+ * Enumeration of iterator directions.
*/
private enum Direction {
/** Iterator is reading in the forward direction. */
@@ -189,7 +218,7 @@
}
/**
- * Moves the cursor to the next leaf.
+ * Moves the "internal" cursor to the next leaf.
*/
private void cursorNextLeaf() {
if (isCursorPastEnd()) {
@@ -232,7 +261,7 @@
}
/**
- * Moves the cursor to the previous leaf.
+ * Moves the "internal" cursor to the previous leaf.
*/
private void cursorPreviousLeaf() {
if (isCursorBeforeBeginning()) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-17 01:19:35
|
Revision: 12599
http://sourceforge.net/p/foray/code/12599
Author: victormote
Date: 2022-02-17 01:19:32 +0000 (Thu, 17 Feb 2022)
Log Message:
-----------
Improvements to discrete block line-breaking.
Modified Paths:
--------------
trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeafIterator4a.java
trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.java
trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java
trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeafIterator4a.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeafIterator4a.java 2022-02-16 22:23:59 UTC (rev 12598)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeafIterator4a.java 2022-02-17 01:19:32 UTC (rev 12599)
@@ -353,7 +353,13 @@
if (newLeafIndex < this.leafIndex) {
throw new IllegalArgumentException("Iterator is already past requested leaf index: " + newLeafIndex);
}
- while (nextIndex() < newLeafIndex) {
+
+ if (isCursorBeforeBeginning()) {
+ /* The iterator has not yet been started. Fix that. */
+ next();
+ }
+
+ while (this.leafIndex < newLeafIndex) {
if (hasNext()) {
next();
} else {
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.java 2022-02-16 22:23:59 UTC (rev 12598)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.java 2022-02-17 01:19:32 UTC (rev 12599)
@@ -39,6 +39,7 @@
import org.axsl.fotree.fo.BlockDiscrete;
import org.axsl.fotree.fo.ExternalGraphic;
import org.axsl.fotree.fo.FoTextWords;
+import org.axsl.fotree.fo.InstreamForeignObject;
import org.axsl.kp.KpBranch;
import org.axsl.kp.KpContext;
import org.axsl.kp.KpLeaf;
@@ -97,6 +98,10 @@
final ExternalGraphic externalGraphic = (ExternalGraphic) fo;
this.children.add(new ScaledContent(externalGraphic, context));
return;
+ } else if (fo instanceof InstreamForeignObject) {
+ final InstreamForeignObject instreamForeign = (InstreamForeignObject) fo;
+ this.children.add(new ScaledContent(instreamForeign, context));
+ return;
}
throw new IllegalStateException("Don't know how to create content for: " + fo.getClass().getName());
}
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java 2022-02-16 22:23:59 UTC (rev 12598)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java 2022-02-17 01:19:32 UTC (rev 12599)
@@ -83,7 +83,7 @@
final ExternalGraphic externalGraphic = (ExternalGraphic) this.content;
lineArea.makeExternalGraphicArea(externalGraphic, -1);
}
- return iterator.nextIndex();
+ return iterator.nextIndex() + 1;
}
}
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java 2022-02-16 22:23:59 UTC (rev 12598)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java 2022-02-17 01:19:32 UTC (rev 12599)
@@ -161,7 +161,7 @@
final int contentIndex = iterator.branchIndexAt(0);
final FoTextTokenFlow foTextTokenFlow = this.content.getFoTokenFlow();
int tokenIndex = iterator.branchIndexAt(1);
- int segmentIndex = iterator.branchIndexAt(2);
+ int segmentIndex = iterator.depth() > 2 ? iterator.branchIndexAt(2) : 0;
final TextTokenFlowLocation start = foTextTokenFlow.markLocation(tokenIndex, segmentIndex, 0);
/* Keeping reading tokens until we are in a different content item, then create the area tree element. */
@@ -179,7 +179,7 @@
}
/* We are past the content that belongs on this line. */
tokenIndex = iterator.branchIndexAt(1);
- segmentIndex = iterator.branchIndexAt(2);
+ segmentIndex = iterator.depth() > 2 ? iterator.branchIndexAt(2) : 0;
final TextTokenFlowLocation end = foTextTokenFlow.markLocation(tokenIndex, segmentIndex, 0);
lineArea.makeGlyphAreaSequence(this.content, start, end, false);
return iterator.nextIndex();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-16 22:24:03
|
Revision: 12598
http://sourceforge.net/p/foray/code/12598
Author: victormote
Date: 2022-02-16 22:23:59 +0000 (Wed, 16 Feb 2022)
Log Message:
-----------
Let the cursor state lag the index-ish cursor so that it can be used by client code.
Modified Paths:
--------------
trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeafIterator4a.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/kp/KpLeafIterator4a.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeafIterator4a.java 2022-02-16 18:21:30 UTC (rev 12597)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeafIterator4a.java 2022-02-16 22:23:59 UTC (rev 12598)
@@ -54,6 +54,17 @@
*/
public class KpLeafIterator4a implements KpLeafIterator {
+ /**
+ * Enumeration of directions.
+ */
+ private enum Direction {
+ /** Iterator is reading in the forward direction. */
+ FORWARD,
+
+ /** Iterator is reading the backward direction. */
+ BACKWARD;
+ }
+
/** The total number of leaf descendants of the root branch that is being iterated. */
private int qtyLeaves;
@@ -74,6 +85,9 @@
* (except if the last item was just returned). All other elements point to branches. */
private IntArrayBuilder branchIndexes = new IntArrayBuilder();
+ /** The last direction that was fulfilled by this iterator. */
+ private Direction lastDirection;
+
/**
* Constructor.
* @param branch The branch to be iterated.
@@ -85,8 +99,9 @@
branchIndexes.push(-1);
/* Advance the cursor to the first leaf node. */
- cursorNextLeaf();
+// cursorNextLeaf();
this.leafIndex = 0;
+ this.lastDirection = Direction.FORWARD;
}
/**
@@ -126,9 +141,13 @@
if (! hasNext()) {
throw new NoSuchElementException("There is no \"next\" leaf.");
}
+
+ if (this.lastDirection == Direction.FORWARD) {
+ cursorNextLeaf();
+ }
+ this.lastDirection = Direction.FORWARD;
+ this.leafIndex ++;
final KpNode next = nodeAtCursor();
- this.leafIndex ++;
- cursorNextLeaf();
return KpNode.Type.asLeaf(next);
}
@@ -140,10 +159,12 @@
/* The cursor sits on the "next" node. Therefore to find the previous node, we must first move the cursor
* backwards. */
- cursorPreviousLeaf();
+ if (this.lastDirection == Direction.BACKWARD) {
+ cursorPreviousLeaf();
+ }
+ this.lastDirection = Direction.BACKWARD;
+ this.leafIndex --;
final KpNode previous = nodeAtCursor();
- this.leafIndex --;
-
return KpNode.Type.asLeaf(previous);
}
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-02-16 18:21:30 UTC (rev 12597)
+++ trunk/foray/foray-common/src/test/java/org/foray/common/para/ParaBranch4aIteratorTests.java 2022-02-16 22:23:59 UTC (rev 12598)
@@ -67,13 +67,13 @@
public void test_001() {
final KpBranch4a para = ParaBranch4aTests.createTestPara();
final KpLeafIterator4a out = new KpLeafIterator4a(para);
- iteratorAssertions(out, true, false, 0, -1, 2);
+ iteratorAssertions(out, true, false, 0, -1, 1);
/* Iterate forward. */
Assert.assertEquals("B", out.next().getText());
iteratorAssertions(out, true, true, 1, 0, 2);
Assert.assertEquals("e", out.next().getText());
- iteratorAssertions(out, true, true, 2, 1, 1);
+ iteratorAssertions(out, true, true, 2, 1, 2);
Assert.assertEquals(" ", out.next().getText());
iteratorAssertions(out, true, true, 3, 2, 1);
Assert.assertEquals("not", out.next().getText());
@@ -87,13 +87,13 @@
Assert.assertEquals("of", out.next().getText());
iteratorAssertions(out, true, true, 8, 7, 1);
Assert.assertEquals(" ", out.next().getText());
- iteratorAssertions(out, true, true, 9, 8, 2);
+ iteratorAssertions(out, true, true, 9, 8, 1);
Assert.assertEquals("great", out.next().getText());
iteratorAssertions(out, true, true, 10, 9, 2);
Assert.assertEquals("-", out.next().getText());
iteratorAssertions(out, true, true, 11, 10, 2);
Assert.assertEquals("ness", out.next().getText());
- iteratorAssertions(out, true, true, 12, 11, 1);
+ iteratorAssertions(out, true, true, 12, 11, 2);
Assert.assertEquals(".", out.next().getText());
iteratorAssertions(out, true, true, 13, 12, 1);
@@ -155,7 +155,7 @@
public void test_002() {
final KpBranch4a para = ParaBranch4aTests.createTestPara();
final KpLeafIterator4a out = new KpLeafIterator4a(para);
- iteratorAssertions(out, true, false, 0, -1, 2);
+ iteratorAssertions(out, true, false, 0, -1, 1);
try {
out.previous();
@@ -173,7 +173,7 @@
public void test_003() {
final KpBranch4a para = ParaBranch4aTests.createTestPara();
final KpLeafIterator4a out = new KpLeafIterator4a(para);
- iteratorAssertions(out, true, false, 0, -1, 2);
+ iteratorAssertions(out, true, false, 0, -1, 1);
/* Iterate to the end of the branch. */
for (int leafIndex = 0; leafIndex < para.qtyParaLeaves(); leafIndex ++) {
@@ -181,7 +181,7 @@
}
/* Make sure we are where we think we are. */
- iteratorAssertions(out, false, true, 50, 49, 1);
+ 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.
|
|
From: <vic...@us...> - 2022-02-16 18:21:35
|
Revision: 12597
http://sourceforge.net/p/foray/code/12597
Author: victormote
Date: 2022-02-16 18:21:30 +0000 (Wed, 16 Feb 2022)
Log Message:
-----------
Rename Knuth-Plass package and classes, for consistency.
Modified Paths:
--------------
trunk/foray/foray-common/src/main/java/org/foray/common/kp/package-info.java
trunk/foray/foray-common/src/test/java/org/foray/common/para/ParaBranch4aIteratorTests.java
trunk/foray/foray-common/src/test/java/org/foray/common/para/ParaBranch4aTests.java
trunk/foray/foray-content/src/main/java/org/foray/content/CharContent4a.java
trunk/foray/foray-content/src/main/java/org/foray/content/Content4a.java
trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.java
trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java
trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java
trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java
trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Block4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/BlockDiscrete4a.java
trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/TotalFitLb.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/ParaBranch4aTestFixture.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/ParaContentIteratorTests.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/TokenFlow4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/WordSegment4a.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
Added Paths:
-----------
trunk/foray/foray-common/src/main/java/org/foray/common/kp/
trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpBox4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpBoxChars4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpBranch4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpContext4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpGlue4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpGlueChars4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeaf4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeafIterator4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpPenalty4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpPenaltyChars4a.java
Removed Paths:
-------------
trunk/foray/foray-common/src/main/java/org/foray/common/kp/ParaBox4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/ParaBoxChars.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/ParaBranch4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/ParaBranch4aIterator.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/ParaConfig4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/ParaGlue4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/ParaGlueChars.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/ParaLeaf4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/ParaPenalty4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/kp/ParaPenaltyChars.java
trunk/foray/foray-common/src/main/java/org/foray/common/para/
Copied: trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpBox4a.java (from rev 12569, trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBox4a.java)
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpBox4a.java (rev 0)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpBox4a.java 2022-02-16 18:21:30 UTC (rev 12597)
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2010 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.kp;
+
+import org.foray.common.primitive.StringUtils;
+
+import org.axsl.kp.KpBox;
+import org.axsl.kp.KpContext;
+import org.axsl.kp.KpLeaf;
+
+/**
+ * A hard-wired implementation of a Knuth-Plass box.
+ * Instances of this class are immutable.
+ */
+public final class KpBox4a extends KpLeaf4a implements KpBox {
+
+ /** Format used in {@link #toString()}. */
+ private static final String TO_STRING_FORMAT = "Box (w = %1$d)";
+
+ /** The width of this box, in millipoints. */
+ private int width;
+
+ /**
+ * Constructor.
+ * @param width The width of this box, in millipoints.
+ */
+ public KpBox4a(final int width) {
+ this.width = width;
+ }
+
+ @Override
+ public KpLeaf.Type getParaLeafType() {
+ return KpLeaf.Type.BOX;
+ }
+
+ @Override
+ public int getIdealWidth(final KpContext config) {
+ return this.width;
+ }
+
+ @Override
+ public int getStretchability(final KpContext config) {
+ return 0;
+ }
+
+ @Override
+ public int getShrinkability(final KpContext config) {
+ return 0;
+ }
+
+ @Override
+ public CharSequence getText() {
+ return StringUtils.EMPTY_STRING;
+ }
+
+ @Override
+ public int qtyKpLeaves() {
+ return 1;
+ }
+
+ @Override
+ public String toString() {
+ return String.format(TO_STRING_FORMAT, this.width);
+ }
+
+}
Copied: trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpBoxChars4a.java (from rev 12569, trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBoxChars.java)
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpBoxChars4a.java (rev 0)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpBoxChars4a.java 2022-02-16 18:21:30 UTC (rev 12597)
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2019 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.kp;
+
+import org.axsl.kp.KpBox;
+import org.axsl.kp.KpContext;
+import org.axsl.kp.KpLeaf;
+
+/**
+ * An implementation of Knuth-Plass penalty that wraps text content.
+ * Instances of this class are immutable.
+ */
+public final class KpBoxChars4a extends KpLeaf4a implements KpBox {
+
+ /** The char(s) for this box. */
+ private String chars;
+
+ /**
+ * Constructor.
+ * @param chars The chars in this box item.
+ */
+ public KpBoxChars4a(final CharSequence chars) {
+ this.chars = chars.toString();
+ }
+
+ @Override
+ public String toString() {
+ return this.chars;
+ }
+
+ @Override
+ public KpLeaf.Type getParaLeafType() {
+ return KpLeaf.Type.BOX;
+ }
+
+ @Override
+ public int getIdealWidth(final KpContext config) {
+ return config.getIdealWidth(this);
+ }
+
+ @Override
+ public int getStretchability(final KpContext config) {
+ return 0;
+ }
+
+ @Override
+ public int getShrinkability(final KpContext config) {
+ return 0;
+ }
+
+ @Override
+ public CharSequence getText() {
+ return this.chars;
+ }
+
+ @Override
+ public int qtyKpLeaves() {
+ return this.chars.length();
+ }
+
+}
Copied: trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpBranch4a.java (from rev 12589, trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4a.java)
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpBranch4a.java (rev 0)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpBranch4a.java 2022-02-16 18:21:30 UTC (rev 12597)
@@ -0,0 +1,193 @@
+/*
+ * Copyright 2019 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.kp;
+
+import org.axsl.kp.KpBranch;
+import org.axsl.kp.KpContext;
+import org.axsl.kp.KpLeaf;
+import org.axsl.kp.KpLeafIterator;
+import org.axsl.kp.KpNode;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * FOray implementation of {@link KpBranch}.
+ */
+public class KpBranch4a implements KpBranch {
+
+ /** The list of child nodes. */
+ private List<KpNode> nodes = new ArrayList<KpNode>();
+
+ /** The context for descendant leaves. */
+ private KpContext kpContext;
+
+ /**
+ * No-args constructor.
+ * @param kpContext The context for descendant leaves.
+ */
+ public KpBranch4a(final KpContext kpContext) {
+ this.kpContext = kpContext;
+ }
+
+ @Override
+ public Type getParaNodeType() {
+ return KpNode.Type.BRANCH;
+ }
+
+ @Override
+ public int qtyParaNodes() {
+ return this.nodes.size();
+ }
+
+ @Override
+ public KpNode paraNodeAt(final int nodeIndex) {
+ return this.nodes.get(nodeIndex);
+ }
+
+ @Override
+ public int qtyParaLeaves() {
+ int returnValue = 0;
+ for (int nodeIndex = 0; nodeIndex < qtyParaNodes(); nodeIndex ++) {
+ final KpNode node = paraNodeAt(nodeIndex);
+ final KpBranch childBranch = KpNode.Type.asBranch(node);
+ if (childBranch == null) {
+ /* Child node is a leaf. */
+ returnValue ++;
+ } else {
+ /* Child node is a branch. */
+ returnValue += childBranch.qtyParaLeaves();
+ }
+ }
+ return returnValue;
+ }
+
+ /**
+ * Returns the leaf node at a given index in a given branch.
+ * @param branch The branch whose leaf nodes are being searched.
+ * @param leafIndex The index to the leaf of {@code branch} to be returned.
+ * @return The leaf of {@code branch} at index {@code leafIndex}.
+ * @see KpBranch#paraLeafAt(int)
+ */
+ public static KpLeaf paraLeafAt(final KpBranch branch, final int leafIndex) {
+ int runningLeafIndex = 0;
+ for (int nodeIndex = 0; nodeIndex < branch.qtyParaNodes(); nodeIndex ++) {
+ final KpNode node = branch.paraNodeAt(nodeIndex);
+ final KpBranch childBranch = KpNode.Type.asBranch(node);
+
+ if (runningLeafIndex == leafIndex) {
+ final KpLeaf leaf = KpNode.Type.asLeaf(node);
+ if (leaf != null) {
+ return leaf;
+ } else {
+ return childBranch.paraLeafAt(0);
+ }
+ }
+
+ final int additionalLeaves = childBranch == null ? 1 : childBranch.qtyParaLeaves();
+ final int newRunningLeafIndex = runningLeafIndex + additionalLeaves;
+
+ if (newRunningLeafIndex > leafIndex) {
+ /* The leafIndex is a descendant of this node. */
+ final int relativeLeafIndex = leafIndex - runningLeafIndex;
+ return childBranch.paraLeafAt(relativeLeafIndex);
+ }
+
+ runningLeafIndex = newRunningLeafIndex;
+ }
+ throw new IndexOutOfBoundsException("Leaf index out of bounds: " + leafIndex);
+ }
+
+ @Override
+ public KpLeaf paraLeafAt(final int leafIndex) {
+ return paraLeafAt(this, leafIndex);
+ }
+
+ @Override
+ public int qtyKpLeaves() {
+ int returnValue = 0;
+ for (int nodeIndex = 0; nodeIndex < qtyParaNodes(); nodeIndex ++) {
+ final KpNode node = paraNodeAt(nodeIndex);
+ final KpBranch childBranch = KpNode.Type.asBranch(node);
+ if (childBranch == null) {
+ /* Child node is a leaf. */
+ final KpLeaf leaf = (KpLeaf) node;
+ returnValue += leaf.qtyKpLeaves();
+ } else {
+ /* Child node is a branch. */
+ returnValue += childBranch.qtyKpLeaves();
+ }
+ }
+ return returnValue;
+ }
+
+ /**
+ * Replaces a node in a branch with a different node. This is useful mostly for testing.
+ * @param index The index at which the new node should be placed.
+ * @param newNode The node to replace the node at {@code index}.
+ */
+ public void setParaNodeChild(final int index, final KpNode newNode) {
+ if (newNode == null) {
+ throw new NullPointerException("Node cannot be null");
+ }
+ this.nodes.set(index, newNode);
+ }
+
+ @Override
+ public KpLeafIterator leafIterator() {
+ return new KpLeafIterator4a(this);
+ }
+
+ @Override
+ public CharSequence getText() {
+ final StringBuilder builder = new StringBuilder();
+ for (int leafIndex = 0; leafIndex < qtyParaLeaves(); leafIndex ++) {
+ final KpLeaf leaf = paraLeafAt(leafIndex);
+ builder.append(leaf.getText());
+ }
+ return builder.toString();
+ }
+
+ /**
+ * Add a node.
+ * @param node The node to be added.
+ */
+ public void addNode(final KpNode node) {
+ if (node == null) {
+ throw new IllegalArgumentException(this.getClass().getName() + " content cannot be null.");
+ }
+ this.nodes.add(node);
+ }
+
+ @Override
+ public KpContext getKpContext() {
+ return this.kpContext;
+ }
+
+}
Copied: trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpContext4a.java (from rev 12569, trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaConfig4a.java)
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpContext4a.java (rev 0)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpContext4a.java 2022-02-16 18:21:30 UTC (rev 12597)
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2019 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.kp;
+
+import org.axsl.font.FontContext;
+import org.axsl.font.FontUse;
+import org.axsl.kp.KpContext;
+import org.axsl.kp.KpLeaf;
+import org.axsl.orthography.Orthography;
+
+/**
+ * Hard-wired implementation of {@link KpContext}.
+ */
+public class KpContext4a implements KpContext {
+
+ /** The font. */
+ private FontUse fontUse;
+
+ /** The size, in milliponts, of the font. */
+ private int fontSize;
+
+ /** Context indicating how the font should use its features. */
+ private FontContext fontContext;
+
+ /** The size, in millipoints, of any stretchability. */
+ private int stretchability;
+
+ /** The size, in millipoints, of any shrinkability. */
+ private int shrinkability;
+
+ /** The character (Unicode code point) to use for hyphenation. */
+ private int hyphenationCharacter = '-';
+
+ /** The orthography that should be used when applying locale-sensitive font features. */
+ private Orthography orthography;
+
+ /**
+ * Constructor.
+ * @param fontUse The font.
+ * @param fontSize The size, in millipoints, of the font.
+ * @param orthography The orthography that should be used when applying locale-sensitive font features.
+ * @param stretchability The size, in millipoints, of any stretchability.
+ * @param shrinkability The size, in millipoints, of any shrinkability.
+ */
+ public KpContext4a(final FontUse fontUse, final int fontSize, final Orthography orthography,
+ final int stretchability, final int shrinkability) {
+ this.fontUse = fontUse;
+ this.fontSize = fontSize;
+ this.orthography = orthography;
+ this.stretchability = stretchability;
+ this.shrinkability = shrinkability;
+ }
+
+ @Override
+ public int getIdealWidth(final KpLeaf leaf) {
+ return this.fontUse.width(leaf.getText(), 0, leaf.getText().length(), fontSize, 0, 0, fontContext,
+ orthography);
+ }
+
+ @Override
+ public int getStretchability(final KpLeaf leaf) {
+ return this.stretchability;
+ }
+
+ @Override
+ public int getShrinkability(final KpLeaf leaf) {
+ return this.shrinkability;
+ }
+
+ @Override
+ public int getHyphenCharacterWidth() {
+ return this.fontUse.width(this.hyphenationCharacter, this.fontSize);
+ }
+
+}
Copied: trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpGlue4a.java (from rev 12569, trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaGlue4a.java)
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpGlue4a.java (rev 0)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpGlue4a.java 2022-02-16 18:21:30 UTC (rev 12597)
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2010 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.kp;
+
+import org.foray.common.primitive.StringUtils;
+
+import org.axsl.kp.KpContext;
+import org.axsl.kp.KpGlue;
+import org.axsl.kp.KpLeaf;
+
+/**
+ * A hard-wired implementation of a Knuth-Plass glue item.
+ * Instances of this class are immutable.
+ */
+public final class KpGlue4a extends KpLeaf4a implements KpGlue {
+
+ /** A glue instance used near the end of a paragraphy for finishing purposes. */
+ public static final KpGlue4a FINISHING_GLUE = new KpGlue4a(0, KpGlue.INFINITE_STRETCHABILITY, 0);
+
+ /** Format used in {@link #toString()}. */
+ private static final String TO_STRING_FORMAT = "Box (w = %1$d, y = %2$d, z = %3$d)";
+
+ /** The ideal width of this glue, in millipoints. */
+ private int idealWidth;
+
+ /** The stretchability of this glue, in millipoints. */
+ private int stretchability;
+
+ /** The shrinkability of this glue, in millipoints. */
+ private int shrinkability;
+
+ /**
+ * Constructor.
+ * @param idealWidth The ideal width of this glue, in millipoints.
+ * @param stretchability The stretchability of this glue, in millipoints.
+ * @param shrinkability The shrinkability of this glue, in millipoints.
+ */
+ public KpGlue4a(final int idealWidth, final int stretchability, final int shrinkability) {
+ this.idealWidth = idealWidth;
+ this.stretchability = stretchability;
+ this.shrinkability = shrinkability;
+ }
+
+ @Override
+ public KpLeaf.Type getParaLeafType() {
+ return KpLeaf.Type.GLUE;
+ }
+
+ @Override
+ public int getIdealWidth(final KpContext config) {
+ return this.idealWidth;
+ }
+
+ @Override
+ public int getStretchability(final KpContext config) {
+ return this.stretchability;
+ }
+
+ @Override
+ public int getShrinkability(final KpContext config) {
+ return this.shrinkability;
+ }
+
+ @Override
+ public CharSequence getText() {
+ return StringUtils.EMPTY_STRING;
+ }
+
+ @Override
+ public int qtyKpLeaves() {
+ return 1;
+ }
+
+ @Override
+ public String toString() {
+ return String.format(TO_STRING_FORMAT, this.idealWidth, this.stretchability, this.shrinkability);
+ }
+
+}
Copied: trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpGlueChars4a.java (from rev 12569, trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaGlueChars.java)
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpGlueChars4a.java (rev 0)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpGlueChars4a.java 2022-02-16 18:21:30 UTC (rev 12597)
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2019 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.kp;
+
+import org.axsl.kp.KpContext;
+import org.axsl.kp.KpGlue;
+import org.axsl.kp.KpLeaf;
+
+/**
+ * An implementation of Knuth-Plass glue that wraps text content.
+ * Instances of this class are immutable.
+ */
+public final class KpGlueChars4a extends KpLeaf4a implements KpGlue {
+
+ /** Reusable glue item representing a single space character. */
+ public static final KpGlueChars4a SPACE = new KpGlueChars4a(" ");
+
+ /** The char(s) for this glue. */
+ private String chars;
+
+ /**
+ * Constructor.
+ * @param chars The chars in this box item.
+ */
+ public KpGlueChars4a(final CharSequence chars) {
+ this.chars = chars.toString();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("<");
+ builder.append(this.chars);
+ builder.append(">");
+ return builder.toString();
+ }
+
+ @Override
+ public KpLeaf.Type getParaLeafType() {
+ return KpLeaf.Type.GLUE;
+ }
+
+ @Override
+ public int getIdealWidth(final KpContext config) {
+ return config.getIdealWidth(this);
+ }
+
+ @Override
+ public CharSequence getText() {
+ return this.chars;
+ }
+
+ @Override
+ public int getStretchability(final KpContext config) {
+ return config.getStretchability(this);
+ }
+
+ @Override
+ public int getShrinkability(final KpContext config) {
+ return config.getShrinkability(this);
+ }
+
+ @Override
+ public int qtyKpLeaves() {
+ return this.chars.length();
+ }
+
+}
Copied: trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeaf4a.java (from rev 12561, trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaLeaf4a.java)
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeaf4a.java (rev 0)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeaf4a.java 2022-02-16 18:21:30 UTC (rev 12597)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2019 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.kp;
+
+import org.axsl.kp.KpLeaf;
+import org.axsl.kp.KpNode;
+
+/**
+ * Abstract superclass for FOray implementations of {@link KpLeaf}.
+ */
+public abstract class KpLeaf4a implements KpLeaf {
+
+ @Override
+ public KpNode.Type getParaNodeType() {
+ return KpNode.Type.LEAF;
+ }
+
+ @Override
+ public int qtyParaNodes() {
+ return 0;
+ }
+
+ @Override
+ public int qtyParaLeaves() {
+ return 1;
+ }
+
+}
Copied: trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeafIterator4a.java (from rev 12596, trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4aIterator.java)
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeafIterator4a.java (rev 0)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpLeafIterator4a.java 2022-02-16 18:21:30 UTC (rev 12597)
@@ -0,0 +1,362 @@
+/*
+ * 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.common.kp;
+
+import org.foray.common.MarkedIndexOutOfBoundsException;
+import org.foray.common.sequence.IntArrayBuilder;
+
+import org.axsl.kp.KpBranch;
+import org.axsl.kp.KpContext;
+import org.axsl.kp.KpLeaf;
+import org.axsl.kp.KpLeafIterator;
+import org.axsl.kp.KpNode;
+
+import java.util.NoSuchElementException;
+import java.util.Stack;
+
+/**
+ * <p>Depth-first bidirectional iterator over the Leaf nodes of a {@link KpBranch} instance.
+ * Note that because this iterator is bidirectional, there is no concept of a "current" node, but rather "previous" and
+ * "next" which can be found at {@link #nextIndex()} and {@link #previousIndex()} respectively.
+ * This means that node "n" returned by next(), will also be returned again if the next call is to previous(), and vice
+ * versa.</p>
+ *
+ * <p>Although there is no "current" node, this class maintains the concept of a cursor, which always sits immediately
+ * before the "next" node.
+ * This cursor is made of of two elements: the {@link #branchStack} and the {@link #branchIndexes}, which together
+ * efficiently track a path through the branches to a specific leaf.</p>
+ */
+public class KpLeafIterator4a implements KpLeafIterator {
+
+ /** The total number of leaf descendants of the root branch that is being iterated. */
+ private int qtyLeaves;
+
+ /** The current location of the iterator within {@link qtyLeaves}. The iterator conceptually sits immediately
+ * after ({@link leafIndex} - 1) and immediately before ({@link leafIndex}). */
+ private int leafIndex = 0;
+
+ /** The stack of branches being iterated. The root branch being iterated (i.e. the one passed in the constructor)
+ * is at the bottom of the stack, and the one currently being iterated is at the top. Each item on the stack must
+ * be a child of the item immediately below it in the stack. Together with {@link #branchIndexes}, which should
+ * always be of the same size, this defines the current location of the iterator as it traverses the content of
+ * the root. */
+ private Stack<KpBranch> branchStack = new Stack<KpBranch>();
+
+ /** The stack of descendant branch indexes. Together with {@link #branchStack}, which should always be of the same
+ * size, this defines the current location of the iterator as it traverses the content of the root. The index
+ * stored is conceptually the "next" index to be iterated. The top element in the stack always points to a leaf node
+ * (except if the last item was just returned). All other elements point to branches. */
+ private IntArrayBuilder branchIndexes = new IntArrayBuilder();
+
+ /**
+ * Constructor.
+ * @param branch The branch to be iterated.
+ */
+ public KpLeafIterator4a(final KpBranch branch) {
+ this.qtyLeaves = branch.qtyParaLeaves();
+
+ this.branchStack.push(branch);
+ branchIndexes.push(-1);
+
+ /* Advance the cursor to the first leaf node. */
+ cursorNextLeaf();
+ this.leafIndex = 0;
+ }
+
+ /**
+ * Returns the node at which the cursor currently sits.
+ * While the cursor is being moved, this can point to any node, but when the movement is complete, it should always
+ * point to a leaf node.
+ * The "cursor" is the combination of {@link #branchStack} and {@link #branchIndexes}, which together should always
+ * point to a leaf index (except for the special case of having iterated past the last item).
+ * @return The leaf currently pointed at by the "cursor".
+ */
+ private KpNode nodeAtCursor() {
+ KpBranch branch = this.branchStack.get(0);
+ int index = 0;
+ while (index < this.branchIndexes.length() - 1) {
+ final int branchIndex = this.branchIndexes.intAt(index);
+ branch = (KpBranch) branch.paraNodeAt(branchIndex);
+ index ++;
+ }
+ /* Variable "index" should now be pointed at the top of the stack, which should be the index to the leaf node
+ * that we want. */
+ final int branchIndex = this.branchIndexes.intAt(index);
+ return branch.paraNodeAt(branchIndex);
+ }
+
+ @Override
+ public boolean hasNext() {
+ return this.leafIndex < this.qtyLeaves;
+ }
+
+ @Override
+ public boolean hasPrevious() {
+ return this.leafIndex > 0;
+ }
+
+ @Override
+ public KpLeaf next() {
+ if (! hasNext()) {
+ throw new NoSuchElementException("There is no \"next\" leaf.");
+ }
+ final KpNode next = nodeAtCursor();
+ this.leafIndex ++;
+ cursorNextLeaf();
+ return KpNode.Type.asLeaf(next);
+ }
+
+ @Override
+ public KpLeaf previous() {
+ if (! hasPrevious()) {
+ throw new NoSuchElementException("There is no \"previous\" leaf.");
+ }
+
+ /* The cursor sits on the "next" node. Therefore to find the previous node, we must first move the cursor
+ * backwards. */
+ cursorPreviousLeaf();
+ final KpNode previous = nodeAtCursor();
+ this.leafIndex --;
+
+ return KpNode.Type.asLeaf(previous);
+ }
+
+ /**
+ * Indicates whether the cursor is sitting at the unique spot that is immediately past the end of the leaves
+ * being iterated.
+ * @return True if and only if the cursor is immediately past the end of the leaves being iterated.
+ */
+ public boolean isCursorBeforeBeginning() {
+ return this.branchIndexes.length() == 1
+ && this.branchIndexes.peek() < 0;
+ }
+
+ /**
+ * Indicates whether the cursor is sitting at the unique spot that is immediately past the end of the leaves
+ * being iterated.
+ * @return True if and only if the cursor is immediately past the end of the leaves being iterated.
+ */
+ public boolean isCursorPastEnd() {
+ return this.branchIndexes.length() == 1
+ && this.branchIndexes.peek() >= this.branchStack.peek().qtyParaNodes();
+ }
+
+ /**
+ * Moves the cursor to the next leaf.
+ */
+ private void cursorNextLeaf() {
+ if (isCursorPastEnd()) {
+ throw new NoSuchElementException("There is no \"next\" leaf.");
+ }
+
+ incrementBranchIndex();
+
+ KpBranch currentBranch = this.branchStack.peek();
+ int nextIndex = this.branchIndexes.peek();
+ while (nextIndex >= currentBranch.qtyParaNodes()) {
+ if (this.branchStack.size() == 1) {
+ /* We are at the bottom of the stack. Do NOT pop the bottom element, but do mark its index and
+ * bail out. This is a valid state for the cursor, not any error condition. */
+ this.branchIndexes.pop();
+ this.branchIndexes.push(currentBranch.qtyParaNodes());
+ return;
+ } else {
+ this.branchStack.pop();
+ this.branchIndexes.pop();
+ incrementBranchIndex();
+ currentBranch = this.branchStack.peek();
+ nextIndex = this.branchIndexes.peek();
+ }
+ }
+
+ /* The cursor is sitting at a valid node. */
+ final KpNode node = this.nodeAtCursor();
+ if (node.getParaNodeType() == KpNode.Type.LEAF) {
+ /* The node is a leaf node. The cursor is where we want it. */
+ return;
+ }
+
+ /* The node is a branch node. We push it onto the stack and recursively call this method until we land on a
+ * leaf node. */
+ final KpBranch branch = (KpBranch) node;
+ this.branchStack.push(branch);
+ this.branchIndexes.push(-1);
+ cursorNextLeaf();
+ }
+
+ /**
+ * Moves the cursor to the previous leaf.
+ */
+ private void cursorPreviousLeaf() {
+ if (isCursorBeforeBeginning()) {
+ throw new NoSuchElementException("There is no \"previous\" leaf.");
+ }
+
+ decrementBranchIndex();
+
+ int previousIndex = this.branchIndexes.peek();
+
+ while (previousIndex < 0) {
+ if (this.branchStack.size() == 1) {
+ /* We are at the bottom of the stack, with an index < 0. This is an error. */
+ throw new NoSuchElementException("There is no \"previous\" leaf.");
+ } else {
+ this.branchStack.pop();
+ this.branchIndexes.pop();
+ decrementBranchIndex();
+ previousIndex = this.branchIndexes.peek();
+ }
+ }
+
+ /* The cursor is sitting at a valid node. */
+ final KpNode node = this.nodeAtCursor();
+ if (node.getParaNodeType() == KpNode.Type.LEAF) {
+ /* The node is a leaf node. The cursor is where we want it. */
+ return;
+ }
+
+ /* The node is a branch node. We push it onto the stack and recursively call this method until we land on a
+ * leaf node. */
+ final KpBranch branch = (KpBranch) node;
+ this.branchStack.push(branch);
+ this.branchIndexes.push(branch.qtyParaNodes());
+ cursorPreviousLeaf();
+ }
+
+ @Override
+ public int nextIndex() {
+ return this.leafIndex;
+ }
+
+ @Override
+ public int previousIndex() {
+ return this.leafIndex - 1;
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException("This iterator is read-only.");
+ }
+
+ @Override
+ public void set(final KpLeaf e) {
+ throw new UnsupportedOperationException("This iterator is read-only.");
+ }
+
+ @Override
+ public void add(final KpLeaf e) {
+ throw new UnsupportedOperationException("This iterator is read-only.");
+ }
+
+ /**
+ * Increments the top item on the branch index stack.
+ */
+ private void incrementBranchIndex() {
+ if (this.branchIndexes.empty()) {
+ return;
+ }
+ int currentIndex = this.branchIndexes.pop();
+ currentIndex ++;
+ this.branchIndexes.push(currentIndex);
+ }
+
+ /**
+ * Decrements the top item on the branch index stack.
+ */
+ private void decrementBranchIndex() {
+ if (this.branchIndexes.empty()) {
+ return;
+ }
+ int currentIndex = this.branchIndexes.pop();
+ currentIndex --;
+ 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 branch indexes stack at index {@code index}.
+ */
+ public int branchIndexAt(final int index) {
+ 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.qtyLeaves) {
+ throw new MarkedIndexOutOfBoundsException(newLeafIndex, this.qtyLeaves);
+ }
+ 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.");
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ * This implementation returns the {@link KpBranch} that is nearest to the top of the {@link KpBranch} stack that is
+ * also a {@link KpContext}.
+ */
+ @Override
+ public KpContext getNearestContext() {
+ /* Iterate the stack in reverse order. */
+ for (int index = this.branchStack.size() - 1; index > -1; index --) {
+ final KpBranch branch = branchStack.get(index);
+ final KpContext context = branch.getKpContext();
+ if (context != null) {
+ return context;
+ }
+ }
+ return null;
+ }
+
+}
Copied: trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpPenalty4a.java (from rev 12569, trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaPenalty4a.java)
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpPenalty4a.java (rev 0)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpPenalty4a.java 2022-02-16 18:21:30 UTC (rev 12597)
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2010 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.kp;
+
+import org.foray.common.primitive.StringUtils;
+
+import org.axsl.kp.KpContext;
+import org.axsl.kp.KpLeaf;
+import org.axsl.kp.KpPenalty;
+import org.axsl.kp.KpUserAgent;
+
+/**
+ * A hard-wired implementation of Knuth-Plass penalty.
+ * Instances of this class are immutable.
+ */
+public final class KpPenalty4a extends KpLeaf4a implements KpPenalty {
+
+ /** The default penalty for a discretionary hyphen using the Knuth-Plass model. Derived from [KP-03], p. 74, Table
+ * 1.*/
+ public static final int DEFAULT_PENALTY = 50;
+
+ /** A penalty instance indicating that a break cannot be taken here under any circumstances. */
+ public static final KpPenalty4a DISALLOWED_BREAK =
+ new KpPenalty4a(0, KpPenalty.Quality.INFINITE_PENALTY.getNumericValue(), false);
+
+ /** A penalty instance indicating that a break must be taken here always. */
+ public static final KpPenalty4a FORCED_BREAK =
+ new KpPenalty4a(0, KpPenalty.Quality.FORCED_BREAK.getNumericValue(), true);
+
+ /** String format used in {@link #toString()}. */
+ private static final String TO_STRING_FORMAT = "Penalty (w = %1$d, p = %2$d, f = %3$b)";
+
+ /** The width of this penalty, in millipoints. */
+ private int width;
+
+ /** The penalty value. */
+ private int cost;
+
+ /** Indicates whether this is a "flagged" penalty. */
+ private boolean flagged;
+
+ /**
+ * Constructor.
+ * @param width The width of this box, in millipoints.
+ * @param cost The penalty value.
+ * @param flagged Indicates whether this is a "flagged" penalty.
+ */
+ public KpPenalty4a(final int width, final int cost, final boolean flagged) {
+ this.width = width;
+ this.cost = cost;
+ this.flagged = flagged;
+ }
+
+ @Override
+ public KpLeaf.Type getParaLeafType() {
+ return KpLeaf.Type.PENALTY;
+ }
+
+ @Override
+ public int getIdealWidth(final KpContext config) {
+ return 0;
+ }
+
+ @Override
+ public int getStretchability(final KpContext config) {
+ return 0;
+ }
+
+ @Override
+ public int getShrinkability(final KpContext config) {
+ return 0;
+ }
+
+ @Override
+ public int getPenaltyWidth(final KpContext config) {
+ return this.width;
+ }
+
+ @Override
+ public int getCost(final KpUserAgent paraContext) {
+ return this.cost;
+ }
+
+ @Override
+ public boolean isFlagged() {
+ return this.flagged;
+ }
+
+ @Override
+ public CharSequence getText() {
+ return StringUtils.EMPTY_STRING;
+ }
+
+ @Override
+ public int qtyKpLeaves() {
+ return 1;
+ }
+
+ @Override
+ public String toString() {
+ return String.format(TO_STRING_FORMAT, this.width, this.cost, this.flagged);
+ }
+
+}
Copied: trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpPenaltyChars4a.java (from rev 12569, trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaPenaltyChars.java)
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpPenaltyChars4a.java (rev 0)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/kp/KpPenaltyChars4a.java 2022-02-16 18:21:30 UTC (rev 12597)
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2019 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.kp;
+
+import org.axsl.kp.KpContext;
+import org.axsl.kp.KpLeaf;
+import org.axsl.kp.KpPenalty;
+import org.axsl.kp.KpUserAgent;
+
+/**
+ * An implementation of Knuth-Plass penalty that wraps text content.
+ * Instances of this class are immutable.
+ */
+public final class KpPenaltyChars4a extends KpLeaf4a implements KpPenalty {
+
+ /** The char(s) for this penalty. */
+ private String chars;
+
+ /** The width of this penalty, in millipoints. */
+ private int width;
+
+ /** The penalty value. */
+ private int cost;
+
+ /** Indicates whether this is a "flagged" penalty. */
+ private boolean flagged;
+
+ /**
+ * Constructor.
+ * @param chars The chars for this penalty item.
+ * @param cost The penalty value.
+ * @param flagged Indicates whether this is a "flagged" penalty.
+ */
+ public KpPenaltyChars4a(final CharSequence chars, final int cost, final boolean flagged) {
+ this.chars = chars.toString();
+ this.cost = cost;
+ this.flagged = flagged;
+ }
+
+ @Override
+ public KpLeaf.Type getParaLeafType() {
+ return KpLeaf.Type.PENALTY;
+ }
+
+ @Override
+ public int getIdealWidth(final KpContext config) {
+ return 0;
+ }
+
+ @Override
+ public int getStretchability(final KpContext config) {
+ return 0;
+ }
+
+ @Override
+ public int getShrinkability(final KpContext config) {
+ return 0;
+ }
+
+ @Override
+ public int getPenaltyWidth(final KpContext config) {
+ return this.width;
+ }
+
+ @Override
+ public int getCost(final KpUserAgent paraContext) {
+ return this.cost;
+ }
+
+ @Override
+ public boolean isFlagged() {
+ return this.flagged;
+ }
+
+ @Override
+ public CharSequence getText() {
+ return this.chars;
+ }
+
+ @Override
+ public int qtyKpLeaves() {
+ return this.chars.length();
+ }
+
+}
Deleted: trunk/foray/foray-common/src/main/java/org/foray/common/kp/ParaBox4a.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBox4a.java 2022-02-03 20:09:49 UTC (rev 12552)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/kp/ParaBox4a.java 2022-02-16 18:21:30 UTC (rev 12597)
@@ -1,97 +0,0 @@
-/*
- * Copyright 2010 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.para;
-
-import org.foray.common.primitive.StringUtils;
-
-import org.axsl.kpModel.ParaBox;
-import org.axsl.kpModel.ParaConfig;
-import org.axsl.kpModel.ParaLeaf;
-
-/**
- * A hard-wired implementation of a Knuth-Plass box.
- * Instances of this class are immutable.
- */
-public final class ParaBox4a extends ParaLeaf4a implements ParaBox {
-
- /** Format used in {@link #toString()}. */
- private static final String TO_STRING_FORMAT = "Box (w = %1$d)";
-
- /** The width of this box, in millipoints. */
- private int width;
-
- /**
- * Constructor.
- * @param width The width of this box, in millipoints.
- */
- public ParaBox4a(final int width) {
- this.width = width;
- }
-
- @Override
- public ParaLeaf.Type getParaLeafType() {
- return ParaLeaf.Type.BOX;
- }
-
- @Override
- public ParaBox4a asParaBox() {
- return this;
- }
-
- @Override
- public ParaGlue4a asParaGlue() {
- return null;
- }
-
- @Override
- public ParaPenalty4a asParaPenalty() {
- return null;
- }
-
- @Override
- public int getWidth(final ParaConfig config) {
- return this.width;
- }
-
- @Override
- public CharSequence getText() {
- return StringUtils.EMPTY_STRING;
- }
-
- @Override
- public int qtyKpLeaves() {
- return 1;
- }
-
- @Override
- public String toString() {
- return String.format(TO_STRING_FORMAT, this.width);
- }
-
-}
Deleted: trunk/foray/foray-common/src/main/java/org/foray/common/kp/ParaBoxChars.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBoxChars.java 2022-02-03 20:09:49 UTC (rev 12552)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/kp/ParaBoxChars.java 2022-02-16 18:21:30 UTC (rev 12597)
@@ -1,94 +0,0 @@
-/*
- * Copyright 2019 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.para;
-
-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.
- * Instances of this class are immutable.
- */
-public final class ParaBoxChars extends ParaLeaf4a implements ParaBox {
-
- /** The char(s) for this box. */
- private String chars;
-
- /**
- * Constructor.
- * @param chars The chars in this box item.
- */
- public ParaBoxChars(final CharSequence chars) {
- this.chars = chars.toString();
- }
-
- @Override
- public String toString() {
- return this.chars;
- }
-
- @Override
- public ParaLeaf.Type getParaLeafType() {
- return ParaLeaf.Type.BOX;
- }
-
- @Override
- public ParaBox asParaBox() {
- return this;
- }
-
- @Override
- public ParaGlue asParaGlue() {
- return null;
- }
-
- @Override
- public ParaPenalty asParaPenalty() {
- return null;
- }
-
- @Override
- public int getWidth(final ParaConfig config) {
- return config.getWidth(this);
- }
-
- @Override
- public CharSequence getText() {
- return this.chars;
- }
-
- @Override
- public int qtyKpLeaves() {
- return this.chars.length();
- }
-
-}
Deleted: trunk/foray/foray-common/src/main/java/org/foray/common/kp/ParaBranch4a.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4a.java 2022-02-03 20:09:49 UTC (rev 12552)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/kp/ParaBranch4a.java 2022-02-16 18:21:30 UTC (rev 12597)
@@ -1,190 +0,0 @@
-/*
- * Copyright 2019 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.para;
-
-import org.axsl.kpModel.ParaBranch;
-import org.axsl.kpModel.ParaLeaf;
-import org.axsl.kpModel.ParaNode;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ListIterator;
-
-/**
- * FOray implementation of {@link ParaBranch}.
- */
-public class ParaBranch4a implements ParaBranch {
-
- /** The list of child nodes. */
- private List<ParaNode> nodes = new ArrayList<ParaNode>();
-
- /**
- * No-args constructor.
- */
- public ParaBranch4a() { }
-
- @Override
- public Type getParaNodeType() {
- return ParaNode.Type.BRANCH;
- }
-
- @Override
- public ParaLeaf asParaLeaf() {
- return null;
- }
-
- @Override
- public ParaBranch asParaBranch() {
- return this;
- }
-
- @Override
- public int qtyParaNodes() {
- return this.nodes.size();
- }
-
- @Override
- public ParaNode paraNodeAt(final int nodeIndex) {
- return this.nodes.get(nodeIndex);
- }
-
- @Override
- public int qtyParaLeaves() {
- int returnValue = 0;
- for (int nodeIndex = 0; nodeIndex < qtyParaNodes(); nodeIndex ++) {
- final ParaBranch childBranch = paraNodeAt(nodeIndex).asParaBranch();
- if (childBranch == null) {
- /* Child node is a leaf. */
- returnValue ++;
- } else {
- /* Child node is a branch. */
- returnValue += childBranch.qtyParaLeaves();
- }
- }
- return returnValue;
- }
-
- /**
- * Returns the leaf node at a given index in a given branch.
- * @param branch The branch whose leaf nodes are being searched.
- * @param leafIndex The index to the leaf of {@code branch} to be returned.
- * @return The leaf of {@code branch} at index {@code leafIndex}.
- * @see ParaBranch#paraLeafAt(int)
- */
- public static ParaLeaf paraLeafAt(final ParaBranch branch, final int leafIndex) {
- int runningLeafIndex = 0;
- for (int nodeIndex = 0; nodeIndex < branch.qtyParaNodes(); nodeIndex ++) {
- final ParaNode node = branch.paraNodeAt(nodeIndex);
- final ParaBranch childBranch = node.asParaBranch();
- final ParaLeaf leaf = node.asParaLeaf();
-
- if (runningLeafIndex == leafIndex) {
- if (leaf != null) {
- return leaf;
- } else {
- return childBranch.paraLeafAt(0);
- }
- }
-
- final int additionalLeaves = childBranch == null ? 1 : childBranch.qtyParaLeaves();
- final int newRunningLeafIndex = runningLeafIndex + additionalLeaves;
-
- if (newRunningLeafIndex > leafIndex) {
- /* The leafIndex is a descendant of this node. */
- final int relativeLeafIndex = leafIndex - runningLeafIndex;
- return childBranch.paraLeafAt(relativeLeafIndex);
- }
-
- runningLeafIndex = newRunningLeafIndex;
- }
- throw new IndexOutOfBoundsException("Leaf index out of bounds: " + leafIn...
[truncated message content] |
|
From: <vic...@us...> - 2022-02-16 18:02:07
|
Revision: 12596
http://sourceforge.net/p/foray/code/12596
Author: victormote
Date: 2022-02-16 18:02:04 +0000 (Wed, 16 Feb 2022)
Log Message:
-----------
Improvements to ParaBranch4aIterator so that it is always pointed to a leaf node.
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
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.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-02-15 21:26:56 UTC (rev 12595)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4aIterator.java 2022-02-16 18:02:04 UTC (rev 12596)
@@ -41,20 +41,26 @@
import java.util.Stack;
/**
- * Depth-first bidirectional iterator over the Leaf nodes of a {@link KpBranch} instance.
+ * <p>Depth-first bidirectional iterator over the Leaf nodes of a {@link KpBranch} instance.
* Note that because this iterator is bidirectional, there is no concept of a "current" node, but rather "previous" and
* "next" which can be found at {@link #nextIndex()} and {@link #previousIndex()} respectively.
* This means that node "n" returned by next(), will also be returned again if the next call is to previous(), and vice
- * versa.
+ * versa.</p>
+ *
+ * <p>Although there is no "current" node, this class maintains the concept of a cursor, which always sits immediately
+ * before the "next" node.
+ * This cursor is made of of two elements: the {@link #branchStack} and the {@link #branchIndexes}, which together
+ * efficiently track a path through the branches to a specific leaf.</p>
*/
public class ParaBranch4aIterator implements KpLeafIterator {
- /** The iterator conceptually sits immediately after (index - 1) and immediately before (index). */
+ /** The total number of leaf descendants of the root branch that is being iterated. */
+ private int qtyLeaves;
+
+ /** The current location of the iterator within {@link qtyLeaves}. The iterator conceptually sits immediately
+ * after ({@link leafIndex} - 1) and immediately before ({@link leafIndex}). */
private int leafIndex = 0;
- /** The number of leaves in the branch. */
- private int paraLeafSize;
-
/** The stack of branches being iterated. The root branch being iterated (i.e. the one passed in the constructor)
* is at the bottom of the stack, and the one currently being iterated is at the top. Each item on the stack must
* be a child of the item immediately below it in the stack. Together with {@link #branchIndexes}, which should
@@ -64,7 +70,8 @@
/** The stack of descendant branch indexes. Together with {@link #branchStack}, which should always be of the same
* size, this defines the current location of the iterator as it traverses the content of the root. The index
- * stored is conceptually the "next" index to be iterated. */
+ * stored is conceptually the "next" index to be iterated. The top element in the stack always points to a leaf node
+ * (except if the last item was just returned). All other elements point to branches. */
private IntArrayBuilder branchIndexes = new IntArrayBuilder();
/**
@@ -72,89 +79,174 @@
* @param branch The branch to be iterated.
*/
public ParaBranch4aIterator(final KpBranch branch) {
+ this.qtyLeaves = branch.qtyParaLeaves();
+
this.branchStack.push(branch);
- this.paraLeafSize = branch.qtyParaLeaves();
- branchIndexes.push(0);
+ branchIndexes.push(-1);
+
+ /* Advance the cursor to the first leaf node. */
+ cursorNextLeaf();
+ this.leafIndex = 0;
}
+ /**
+ * Returns the node at which the cursor currently sits.
+ * While the cursor is being moved, this can point to any node, but when the movement is complete, it should always
+ * point to a leaf node.
+ * The "cursor" is the combination of {@link #branchStack} and {@link #branchIndexes}, which together should always
+ * point to a leaf index (except for the special case of having iterated past the last item).
+ * @return The leaf currently pointed at by the "cursor".
+ */
+ private KpNode nodeAtCursor() {
+ KpBranch branch = this.branchStack.get(0);
+ int index = 0;
+ while (index < this.branchIndexes.length() - 1) {
+ final int branchIndex = this.branchIndexes.intAt(index);
+ branch = (KpBranch) branch.paraNodeAt(branchIndex);
+ index ++;
+ }
+ /* Variable "index" should now be pointed at the top of the stack, which should be the index to the leaf node
+ * that we want. */
+ final int branchIndex = this.branchIndexes.intAt(index);
+ return branch.paraNodeAt(branchIndex);
+ }
+
@Override
public boolean hasNext() {
- return this.leafIndex < this.paraLeafSize;
+ return this.leafIndex < this.qtyLeaves;
}
@Override
+ public boolean hasPrevious() {
+ return this.leafIndex > 0;
+ }
+
+ @Override
public KpLeaf next() {
- final KpLeaf next = internalNext();
+ if (! hasNext()) {
+ throw new NoSuchElementException("There is no \"next\" leaf.");
+ }
+ final KpNode next = nodeAtCursor();
this.leafIndex ++;
- return next;
+ cursorNextLeaf();
+ return KpNode.Type.asLeaf(next);
}
+ @Override
+ public KpLeaf previous() {
+ if (! hasPrevious()) {
+ throw new NoSuchElementException("There is no \"previous\" leaf.");
+ }
+
+ /* The cursor sits on the "next" node. Therefore to find the previous node, we must first move the cursor
+ * backwards. */
+ cursorPreviousLeaf();
+ final KpNode previous = nodeAtCursor();
+ this.leafIndex --;
+
+ return KpNode.Type.asLeaf(previous);
+ }
+
/**
- * Internal computation of the next leaf.
- * @return The next leaf, or null if there is none.
+ * Indicates whether the cursor is sitting at the unique spot that is immediately past the end of the leaves
+ * being iterated.
+ * @return True if and only if the cursor is immediately past the end of the leaves being iterated.
*/
- private KpLeaf internalNext() {
- if (this.branchStack.isEmpty()) {
- throw new NoSuchElementException("There is no \"next\" element.");
+ public boolean isCursorBeforeBeginning() {
+ return this.branchIndexes.length() == 1
+ && this.branchIndexes.peek() < 0;
+ }
+
+ /**
+ * Indicates whether the cursor is sitting at the unique spot that is immediately past the end of the leaves
+ * being iterated.
+ * @return True if and only if the cursor is immediately past the end of the leaves being iterated.
+ */
+ public boolean isCursorPastEnd() {
+ return this.branchIndexes.length() == 1
+ && this.branchIndexes.peek() >= this.branchStack.peek().qtyParaNodes();
+ }
+
+ /**
+ * Moves the cursor to the next leaf.
+ */
+ private void cursorNextLeaf() {
+ if (isCursorPastEnd()) {
+ throw new NoSuchElementException("There is no \"next\" leaf.");
}
- final KpBranch currentBranch = this.branchStack.peek();
- final int nextIndex = this.branchIndexes.peek();
- if (nextIndex >= currentBranch.qtyParaNodes()) {
- this.branchStack.pop();
- this.branchIndexes.pop();
- incrementBranchIndex();
- return internalNext();
+
+ incrementBranchIndex();
+
+ KpBranch currentBranch = this.branchStack.peek();
+ int nextIndex = this.branchIndexes.peek();
+ while (nextIndex >= currentBranch.qtyParaNodes()) {
+ if (this.branchStack.size() == 1) {
+ /* We are at the bottom of the stack. Do NOT pop the bottom element, but do mark its index and
+ * bail out. This is a valid state for the cursor, not any error condition. */
+ this.branchIndexes.pop();
+ this.branchIndexes.push(currentBranch.qtyParaNodes());
+ return;
+ } else {
+ this.branchStack.pop();
+ this.branchIndexes.pop();
+ incrementBranchIndex();
+ currentBranch = this.branchStack.peek();
+ nextIndex = this.branchIndexes.peek();
+ }
}
- final KpNode node = currentBranch.paraNodeAt(nextIndex);
- final KpLeaf leaf = KpNode.Type.asLeaf(node);
- if (leaf != null) {
- incrementBranchIndex();
- return leaf;
+
+ /* The cursor is sitting at a valid node. */
+ final KpNode node = this.nodeAtCursor();
+ if (node.getParaNodeType() == KpNode.Type.LEAF) {
+ /* The node is a leaf node. The cursor is where we want it. */
+ return;
}
+
+ /* The node is a branch node. We push it onto the stack and recursively call this method until we land on a
+ * leaf node. */
final KpBranch branch = (KpBranch) node;
this.branchStack.push(branch);
- this.branchIndexes.push(0);
- return internalNext();
+ this.branchIndexes.push(-1);
+ cursorNextLeaf();
}
- @Override
- public boolean hasPrevious() {
- return this.leafIndex > 0;
- }
-
- @Override
- public KpLeaf previous() {
- final KpLeaf previous = internalPrevious();
- this.leafIndex --;
- return previous;
- }
-
/**
- * Internal computation of the previous leaf.
- * @return The previous leaf, or null if there is none.
+ * Moves the cursor to the previous leaf.
*/
- private KpLeaf internalPrevious() {
- if (this.branchStack.isEmpty()) {
- throw new NoSuchElementException("There is no \"previous\" element.");
+ private void cursorPreviousLeaf() {
+ if (isCursorBeforeBeginning()) {
+ throw new NoSuchElementException("There is no \"previous\" leaf.");
}
- final KpBranch currentBranch = this.branchStack.peek();
- final int previousIndex = this.branchIndexes.peek() - 1;
- if (previousIndex < 0) {
- this.branchStack.pop();
- this.branchIndexes.pop();
- decrementBranchIndex();
- return internalPrevious();
+
+ decrementBranchIndex();
+
+ int previousIndex = this.branchIndexes.peek();
+
+ while (previousIndex < 0) {
+ if (this.branchStack.size() == 1) {
+ /* We are at the bottom of the stack, with an index < 0. This is an error. */
+ throw new NoSuchElementException("There is no \"previous\" leaf.");
+ } else {
+ this.branchStack.pop();
+ this.branchIndexes.pop();
+ decrementBranchIndex();
+ previousIndex = this.branchIndexes.peek();
+ }
}
- final KpNode node = currentBranch.paraNodeAt(previousIndex);
- final KpLeaf leaf = KpNode.Type.asLeaf(node);
- if (leaf != null) {
- decrementBranchIndex();
- return leaf;
+
+ /* The cursor is sitting at a valid node. */
+ final KpNode node = this.nodeAtCursor();
+ if (node.getParaNodeType() == KpNode.Type.LEAF) {
+ /* The node is a leaf node. The cursor is where we want it. */
+ return;
}
+
+ /* The node is a branch node. We push it onto the stack and recursively call this method until we land on a
+ * leaf node. */
final KpBranch branch = (KpBranch) node;
this.branchStack.push(branch);
this.branchIndexes.push(branch.qtyParaNodes());
- return internalPrevious();
+ cursorPreviousLeaf();
}
@Override
@@ -220,7 +312,7 @@
* @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}.
+ * @return The content of the branch indexes stack at index {@code index}.
*/
public int branchIndexAt(final int index) {
return this.branchIndexes.intAt(index);
@@ -234,8 +326,8 @@
*/
public void advanceToLeaf(final int newLeafIndex) {
if (newLeafIndex < 0
- || newLeafIndex > this.paraLeafSize) {
- throw new MarkedIndexOutOfBoundsException(newLeafIndex, this.paraLeafSize);
+ || newLeafIndex > this.qtyLeaves) {
+ throw new MarkedIndexOutOfBoundsException(newLeafIndex, this.qtyLeaves);
}
if (newLeafIndex < this.leafIndex) {
throw new IllegalArgumentException("Iterator is already past requested leaf index: " + newLeafIndex);
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-02-15 21:26:56 UTC (rev 12595)
+++ trunk/foray/foray-common/src/test/java/org/foray/common/para/ParaBranch4aIteratorTests.java 2022-02-16 18:02:04 UTC (rev 12596)
@@ -64,13 +64,13 @@
public void test_001() {
final ParaBranch4a para = ParaBranch4aTests.createTestPara();
final ParaBranch4aIterator out = new ParaBranch4aIterator(para);
- iteratorAssertions(out, true, false, 0, -1, 1);
+ iteratorAssertions(out, true, false, 0, -1, 2);
/* Iterate forward. */
Assert.assertEquals("B", out.next().getText());
iteratorAssertions(out, true, true, 1, 0, 2);
Assert.assertEquals("e", out.next().getText());
- iteratorAssertions(out, true, true, 2, 1, 2);
+ iteratorAssertions(out, true, true, 2, 1, 1);
Assert.assertEquals(" ", out.next().getText());
iteratorAssertions(out, true, true, 3, 2, 1);
Assert.assertEquals("not", out.next().getText());
@@ -84,13 +84,13 @@
Assert.assertEquals("of", out.next().getText());
iteratorAssertions(out, true, true, 8, 7, 1);
Assert.assertEquals(" ", out.next().getText());
- iteratorAssertions(out, true, true, 9, 8, 1);
+ iteratorAssertions(out, true, true, 9, 8, 2);
Assert.assertEquals("great", out.next().getText());
iteratorAssertions(out, true, true, 10, 9, 2);
Assert.assertEquals("-", out.next().getText());
iteratorAssertions(out, true, true, 11, 10, 2);
Assert.assertEquals("ness", out.next().getText());
- iteratorAssertions(out, true, true, 12, 11, 2);
+ iteratorAssertions(out, true, true, 12, 11, 1);
Assert.assertEquals(".", out.next().getText());
iteratorAssertions(out, true, true, 13, 12, 1);
@@ -141,7 +141,7 @@
Assert.fail("Exception expected here.");
} catch (final NoSuchElementException e) {
/* This is the expected case. */
- Assert.assertEquals("There is no \"previous\" element.", e.getMessage());
+ Assert.assertEquals("There is no \"previous\" leaf.", e.getMessage());
}
}
@@ -152,7 +152,7 @@
public void test_002() {
final ParaBranch4a para = ParaBranch4aTests.createTestPara();
final ParaBranch4aIterator out = new ParaBranch4aIterator(para);
- iteratorAssertions(out, true, false, 0, -1, 1);
+ iteratorAssertions(out, true, false, 0, -1, 2);
try {
out.previous();
@@ -159,7 +159,7 @@
Assert.fail("Exception expected here.");
} catch (final NoSuchElementException e) {
/* This is the expected case. */
- Assert.assertEquals("There is no \"previous\" element.", e.getMessage());
+ Assert.assertEquals("There is no \"previous\" leaf.", e.getMessage());
}
}
@@ -170,7 +170,7 @@
public void test_003() {
final ParaBranch4a para = ParaBranch4aTests.createTestPara();
final ParaBranch4aIterator out = new ParaBranch4aIterator(para);
- iteratorAssertions(out, true, false, 0, -1, 1);
+ iteratorAssertions(out, true, false, 0, -1, 2);
/* Iterate to the end of the branch. */
for (int leafIndex = 0; leafIndex < para.qtyParaLeaves(); leafIndex ++) {
@@ -178,7 +178,7 @@
}
/* Make sure we are where we think we are. */
- iteratorAssertions(out, false, true, 50, 49, 2);
+ iteratorAssertions(out, false, true, 50, 49, 1);
try {
out.next();
@@ -185,7 +185,7 @@
Assert.fail("Exception expected here.");
} catch (final NoSuchElementException e) {
/* This is the expected case. */
- Assert.assertEquals("There is no \"next\" element.", e.getMessage());
+ Assert.assertEquals("There is no \"next\" leaf.", e.getMessage());
}
}
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-02-15 21:26:56 UTC (rev 12595)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java 2022-02-16 18:02:04 UTC (rev 12596)
@@ -104,6 +104,9 @@
}
iterator.advanceToLeaf(currentLeafIndex);
+ if (iterator.isCursorPastEnd()) {
+ iterator.previous();
+ }
/* 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 int segmentIndex = iterator.depth() > 1 ? iterator.branchIndexAt(1) : 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-15 21:26:59
|
Revision: 12595
http://sourceforge.net/p/foray/code/12595
Author: victormote
Date: 2022-02-15 21:26:56 +0000 (Tue, 15 Feb 2022)
Log Message:
-----------
1. Conform to aXSL change: Add methods for iterating over the content in a ContentTree. 2. Improvements to post-line-break handling.
Modified Paths:
--------------
trunk/foray/foray-areatree/build.gradle
trunk/foray/foray-content/build.gradle
trunk/foray/foray-content/src/main/java/org/foray/content/CharContent4a.java
trunk/foray/foray-content/src/main/java/org/foray/content/Content4a.java
trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.java
trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java
trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java
trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java
trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/BlockDiscretePnr.java
Modified: trunk/foray/foray-areatree/build.gradle
===================================================================
--- trunk/foray/foray-areatree/build.gradle 2022-02-14 12:21:57 UTC (rev 12594)
+++ trunk/foray/foray-areatree/build.gradle 2022-02-15 21:26:56 UTC (rev 12595)
@@ -1,18 +1,17 @@
description = 'foray-areatree'
dependencies {
+ api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
/* Do *** NOT *** add a dependency on axsl-galley, as axsl-areatree should be a superset of axsl-galley. If not, fix
that instead. */
+ api group: 'org.axsl', name: 'axsl-areatree', version: axslVersion
- api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
- api group: 'org.axsl', name: 'axsl-areatree', 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/foray-content/build.gradle
===================================================================
--- trunk/foray/foray-content/build.gradle 2022-02-14 12:21:57 UTC (rev 12594)
+++ trunk/foray/foray-content/build.gradle 2022-02-15 21:26:56 UTC (rev 12595)
@@ -11,6 +11,10 @@
api (group: 'org.axsl', name: 'axsl-value', version: axslVersion) { transitive = false }
api (group: 'org.axsl', name: 'axsl-orthography', version: axslVersion) { transitive = false }
api (group: 'org.axsl', name: 'axsl-kp-model', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-areatree', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-galley', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-context', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-linebreak', version: axslVersion) { transitive = false }
api (project(':foray-common')) { transitive = false }
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/CharContent4a.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/CharContent4a.java 2022-02-14 12:21:57 UTC (rev 12594)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/CharContent4a.java 2022-02-15 21:26:56 UTC (rev 12595)
@@ -28,6 +28,9 @@
package org.foray.content;
+import org.foray.common.para.ParaBranch4aIterator;
+
+import org.axsl.area.LineArea;
import org.axsl.content.CharContent;
import org.axsl.fotree.FoContext;
import org.axsl.fotree.fo.FoTextCharacters;
@@ -69,4 +72,9 @@
return false;
}
+ @Override
+ public int addToLine(final LineArea lineArea, final ParaBranch4aIterator iterator, final int endLeafIndex) {
+ return iterator.nextIndex();
+ }
+
}
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/Content4a.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/Content4a.java 2022-02-14 12:21:57 UTC (rev 12594)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/Content4a.java 2022-02-15 21:26:56 UTC (rev 12595)
@@ -28,6 +28,9 @@
package org.foray.content;
+import org.foray.common.para.ParaBranch4aIterator;
+
+import org.axsl.area.LineArea;
import org.axsl.content.Content;
import org.axsl.fotree.FoContext;
@@ -55,4 +58,14 @@
return this.context;
}
+ /**
+ * Add this content, or part of it, to a given line.
+ * @param lineArea The line to which this content item should be added.
+ * @param iterator The iterator over the paragraph content.
+ * @param endLeafIndex The index to the first leaf node that should <em>not</em> be processed by this method, i.e.
+ * the first item on the next line.
+ * @return The index to the next leaf in {@code iterator} that is now unprocessed.
+ */
+ public abstract int addToLine(LineArea lineArea, ParaBranch4aIterator iterator, int endLeafIndex);
+
}
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.java 2022-02-14 12:21:57 UTC (rev 12594)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.java 2022-02-15 21:26:56 UTC (rev 12595)
@@ -31,8 +31,14 @@
import org.foray.common.MarkedIndexOutOfBoundsException;
import org.foray.common.para.ParaBranch4aIterator;
+import org.axsl.area.Area;
+import org.axsl.area.NormalBlockArea;
import org.axsl.content.Content;
import org.axsl.content.ContentTree;
+import org.axsl.fotree.Fo;
+import org.axsl.fotree.fo.BlockDiscrete;
+import org.axsl.fotree.fo.ExternalGraphic;
+import org.axsl.fotree.fo.FoTextWords;
import org.axsl.kp.KpBranch;
import org.axsl.kp.KpContext;
import org.axsl.kp.KpLeaf;
@@ -48,8 +54,53 @@
public class ContentTree4a implements ContentTree {
/** The content item children of this tree. */
- private List<Content> children = new ArrayList<Content>();
+ private List<Content4a> children = new ArrayList<Content4a>();
+ /**
+ * Constructor that creates a content tree from the content of a {@link BlockDiscrete}.
+ * @param nba The block whose content should be wrapped in a content tree.
+ */
+ public ContentTree4a(final NormalBlockArea nba) {
+ final Fo generatedBy = nba.traitGeneratedBy();
+ processChildren(generatedBy, nba);
+ }
+
+ /**
+ * Recursively traverses the {@link Fo} node being wrapped in this content tree, adding children to this tree as
+ * needed.
+ * @param fo The {@link Fo} instance whose children are being traversed and wrapped.
+ * @param context The area-tree context for {@code fo} and descendants.
+ */
+ private void processChildren(final Fo fo, final Area context) {
+ for (int index = 0; index < fo.qtyFormattingObjectChildren(); index ++) {
+ final Fo child = fo.formattingObjectChildAt(index);
+ processChild(child, context);
+ }
+ }
+
+ /**
+ * Processes an {@link Fo} either by wrapping it and adding it to the content, or by traversing its children.
+ * @param fo The {@link Fo} to be processed.
+ * @param context The area-tree context for {@code fo} and descendants.
+ */
+ private void processChild(final Fo fo, final Area context) {
+ if (fo instanceof BlockDiscrete) {
+ processChildren(fo, context);
+ return;
+ }
+ if (fo instanceof FoTextWords) {
+ final FoTextWords foTextWords = (FoTextWords) fo;
+ final TextTokensContent4a tokensContent = new TextTokensContent4a(foTextWords, null);
+ this.children.add(tokensContent);
+ return;
+ } else if (fo instanceof ExternalGraphic) {
+ final ExternalGraphic externalGraphic = (ExternalGraphic) fo;
+ this.children.add(new ScaledContent(externalGraphic, context));
+ return;
+ }
+ throw new IllegalStateException("Don't know how to create content for: " + fo.getClass().getName());
+ }
+
@Override
public Type getParaNodeType() {
return Type.BRANCH;
@@ -153,4 +204,14 @@
return null;
}
+ @Override
+ public int qtyContent() {
+ return this.children.size();
+ }
+
+ @Override
+ public Content4a contentAt(final int index) {
+ return this.children.get(index);
+ }
+
}
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java 2022-02-14 12:21:57 UTC (rev 12594)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java 2022-02-15 21:26:56 UTC (rev 12595)
@@ -28,6 +28,9 @@
package org.foray.content;
+import org.foray.common.para.ParaBranch4aIterator;
+
+import org.axsl.area.LineArea;
import org.axsl.content.IndivisibleContent;
import org.axsl.fotree.FoContext;
import org.axsl.fotree.fo.Leader;
@@ -70,4 +73,9 @@
return this.content.traitLeaderLengthMax(null);
}
+ @Override
+ public int addToLine(final LineArea lineArea, final ParaBranch4aIterator iterator, final int endLeafIndex) {
+ return iterator.nextIndex();
+ }
+
}
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java 2022-02-14 12:21:57 UTC (rev 12594)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java 2022-02-15 21:26:56 UTC (rev 12595)
@@ -28,6 +28,9 @@
package org.foray.content;
+import org.foray.common.para.ParaBranch4aIterator;
+
+import org.axsl.area.LineArea;
import org.axsl.content.IndivisibleContent;
import org.axsl.font.FontUse;
import org.axsl.fotree.Fo;
@@ -84,4 +87,9 @@
return inlineSizeOptimum(lineLength);
}
+ @Override
+ public int addToLine(final LineArea lineArea, final ParaBranch4aIterator iterator, final int endLeafIndex) {
+ return iterator.nextIndex();
+ }
+
}
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java 2022-02-14 12:21:57 UTC (rev 12594)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java 2022-02-15 21:26:56 UTC (rev 12595)
@@ -28,9 +28,13 @@
package org.foray.content;
+import org.foray.common.para.ParaBranch4aIterator;
+
+import org.axsl.area.LineArea;
import org.axsl.content.IndivisibleContent;
import org.axsl.fotree.FoContext;
import org.axsl.fotree.FoScaled;
+import org.axsl.fotree.fo.ExternalGraphic;
/**
* Content wrapper for {FoScaled}.
@@ -73,4 +77,13 @@
return inlineSizeOptimum(lineLength);
}
+ @Override
+ public int addToLine(final LineArea lineArea, final ParaBranch4aIterator iterator, final int endLeafIndex) {
+ if (this.content instanceof ExternalGraphic) {
+ final ExternalGraphic externalGraphic = (ExternalGraphic) this.content;
+ lineArea.makeExternalGraphicArea(externalGraphic, -1);
+ }
+ return iterator.nextIndex();
+ }
+
}
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java 2022-02-14 12:21:57 UTC (rev 12594)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java 2022-02-15 21:26:56 UTC (rev 12595)
@@ -31,6 +31,7 @@
import org.foray.common.FontContext4a;
import org.foray.common.para.ParaBranch4aIterator;
+import org.axsl.area.LineArea;
import org.axsl.content.TextTokensContent;
import org.axsl.font.FontUse;
import org.axsl.fotree.FoContext;
@@ -41,6 +42,7 @@
import org.axsl.kp.KpLeafIterator;
import org.axsl.kp.KpNode;
import org.axsl.orthography.Orthography;
+import org.axsl.orthography.TextTokenFlowLocation;
/**
* Content wrapper for {@link FoTextWords}.
@@ -149,4 +151,42 @@
return this;
}
+ @Override
+ public int addToLine(final LineArea lineArea, final ParaBranch4aIterator iterator, final int endLeafIndex) {
+ /* The iterator branch stack tells us where we are. Element 0 is the index into the children of
+ * contentTree. If there is an element 1, it is because the element in contentTree is a text element,
+ * and element 1 is the index into its child tokens. If there is an element 2, it is the index into
+ * the char children of the token specified by element 1. */
+
+ final int contentIndex = iterator.branchIndexAt(0);
+ final FoTextTokenFlow foTextTokenFlow = this.content.getFoTokenFlow();
+ int tokenIndex = iterator.branchIndexAt(1);
+ int segmentIndex = iterator.branchIndexAt(2);
+ final TextTokenFlowLocation start = foTextTokenFlow.markLocation(tokenIndex, segmentIndex, 0);
+
+ /* Keeping reading tokens until we are in a different content item, then create the area tree element. */
+ while (iterator.hasNext()) {
+ while (iterator.nextIndex() < endLeafIndex) {
+ iterator.next();
+ if (iterator.branchIndexAt(0) == contentIndex) {
+ /* The current node is also part of the text item being created. Continue looping. */
+ } else {
+ /* We are now sitting on a different content element. That means that all of the previous
+ * content item belongs on this line. */
+ lineArea.makeGlyphAreaSequence(this.content, start, null, false);
+ return iterator.nextIndex();
+ }
+ }
+ /* We are past the content that belongs on this line. */
+ tokenIndex = iterator.branchIndexAt(1);
+ segmentIndex = iterator.branchIndexAt(2);
+ final TextTokenFlowLocation end = foTextTokenFlow.markLocation(tokenIndex, segmentIndex, 0);
+ lineArea.makeGlyphAreaSequence(this.content, start, end, false);
+ return iterator.nextIndex();
+ }
+ /* The iterator is out of content. All of this content item goes on this line. */
+ lineArea.makeGlyphAreaSequence(this.content, start, null, false);
+ return iterator.nextIndex();
+ }
+
}
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-02-14 12:21:57 UTC (rev 12594)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/BlockDiscretePnr.java 2022-02-15 21:26:56 UTC (rev 12595)
@@ -28,7 +28,9 @@
package org.foray.pioneer;
-import org.foray.common.primitive.ObjectUtils;
+import org.foray.common.para.ParaBranch4aIterator;
+import org.foray.content.Content4a;
+import org.foray.content.ContentTree4a;
import org.axsl.area.AreaNode;
import org.axsl.area.AreaTreeException;
@@ -36,8 +38,6 @@
import org.axsl.area.NormalBlockArea;
import org.axsl.area.factory.BlockLevelAreaFactory;
import org.axsl.fotree.fo.BlockDiscrete;
-import org.axsl.kp.KpBranch;
-import org.axsl.kp.KpNode;
import org.axsl.kp.KpResult;
import org.axsl.kp.KpUserAgent;
import org.axsl.linebreak.LineBreaker;
@@ -50,6 +50,15 @@
/** The real FONode which this proxy represents. */
private BlockDiscrete blockDiscrete;
+ /** The content tree for this block. */
+ private ContentTree4a contentTree;
+
+ /** The results of line-breaking for {@link #node}. */
+ private KpResult result;
+
+ /** Index to the next line in {@link #result} to be placed on a line. */
+ private int nextResultLine = 0;
+
/**
* Constructor.
* @param realFObj The FO Tree object which is being laid out.
@@ -73,60 +82,41 @@
}
final BlockLevelAreaFactory bcArea = (BlockLevelAreaFactory) areaNode;
- final NormalBlockArea blockArea = bcArea.makeNormalBlockArea(this.blockDiscrete);
+ final NormalBlockArea normalBlockArea = bcArea.makeNormalBlockArea(this.blockDiscrete);
- final LineBreaker breaker = getLayout().getLineBreaker();
- final KpUserAgent paraContext = this.blockDiscrete.ancestorBlock(blockArea).getParaContext();
- final KpResult result = breaker.breakIntoLines(this.blockDiscrete, paraContext, blockArea);
+ if (this.result == null) {
+ final LineBreaker lb = getLayout().getLineBreaker();
+ final KpUserAgent paraContext = this.blockDiscrete.ancestorBlock(normalBlockArea).getParaContext();
+ this.contentTree = new ContentTree4a(normalBlockArea);
+ this.result = lb.breakIntoLines(contentTree, paraContext, normalBlockArea);
+ }
- int lastBreakPosition = 0;
- for (int lineIndex = 0; lineIndex < result.getQtyLines(); lineIndex ++) {
- final int breakPosition = result.getBreakPosition(lineIndex);
- final int qtyLineNodes = breakPosition - lastBreakPosition;
- final LineArea lineArea = blockArea.makeLineArea(true);
- /* TODO: Remove following line after logic to fill line area is added. */
- ObjectUtils.noOperation(lineArea);
- int lineNodesConsumed = 0;
- KpBranch currentBranch = null;
- int branchNodesConsumed = 0;
- for (int contentIndex = lastBreakPosition; contentIndex < breakPosition; contentIndex ++) {
- final KpNode paraNode = this.blockDiscrete.paraNodeAt(contentIndex);
- final KpNode.Type nodeType = paraNode.getParaNodeType();
- switch (paraNode.getParaNodeType()) {
- case LEAF: {
- currentBranch = null;
- branchNodesConsumed = 0;
-
-
- /* TODO: Convert the leaf node to an AreaTree concept and add it. */
-
-
- lineNodesConsumed ++;
- break;
+ /* 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(contentTree);
+ for (int lineIndex = this.nextResultLine; lineIndex < result.getQtyLines(); lineIndex ++) {
+ final LineArea lineArea = normalBlockArea.makeLineArea(false);
+ if (lineArea == null) {
+ /* Unable to create another line on the current page. */
+ this.nextResultLine = lineIndex;
+ if (lineIndex == 0) {
+ return Status.AREA_FULL_NONE;
+ } else {
+ return Status.AREA_FULL_SOME;
}
- case BRANCH: {
- final KpBranch branch = nodeType == KpNode.Type.BRANCH ? (KpBranch) paraNode : null;
- if (currentBranch == null
- /* This is deliberately an identity test, not an equality test. */
- || currentBranch != branch) {
- currentBranch = branch;
- branchNodesConsumed = 0;
- }
- final int branchNodesRemaining = branch.qtyParaNodes() - branchNodesConsumed;
- final int lineNodesRemaining = qtyLineNodes - lineNodesConsumed;
- final int length = Math.min(lineNodesRemaining, branchNodesRemaining);
+ }
+ int leafIndex = lineIndex < 1 ? 0 : result.getBreakPosition(lineIndex - 1);
+ final int endLeafIndex = result.getBreakPosition(lineIndex);
+ while (leafIndex < endLeafIndex) {
+ iterator.advanceToLeaf(leafIndex);
- /* TODO: Convert the branch node to AreaTree concept(s) and add it/them. */
-
-
- lineNodesConsumed += length;
- break;
- }
- default: throw new IllegalStateException();
- }
+ /* Retrieve the same element two ways, first as Content, second as a KpLeaf. This duality will help
+ * us convert the line-breaking KP results into something that the Area Tree understands. */
+ final int contentIndex = iterator.branchIndexAt(0);
+ final Content4a content = this.contentTree.contentAt(contentIndex);
+ leafIndex = content.addToLine(lineArea, iterator, endLeafIndex);
}
- lastBreakPosition = breakPosition;
}
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-02-14 12:22:00
|
Revision: 12594
http://sourceforge.net/p/foray/code/12594
Author: victormote
Date: 2022-02-14 12:21:57 +0000 (Mon, 14 Feb 2022)
Log Message:
-----------
Remove duplicate context variable.
Modified Paths:
--------------
trunk/foray/foray-content/src/main/java/org/foray/content/TextContent4a.java
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/TextContent4a.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/TextContent4a.java 2022-02-13 12:18:24 UTC (rev 12593)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/TextContent4a.java 2022-02-14 12:21:57 UTC (rev 12594)
@@ -46,9 +46,6 @@
*/
public abstract class TextContent4a extends Content4a implements TextContent {
- /** The FO context. */
- private FoContext context = null;
-
/**
* Constructor.
* @param context The FO context.
@@ -69,12 +66,12 @@
@Override
public FontUse inlinePrimaryFont() {
- return effectiveParent().getPrimaryFont(this.context);
+ return effectiveParent().getPrimaryFont(getContext());
}
@Override
public FontUse inlineSecondaryFont(final int codePoint) {
- return effectiveParent().getSecondaryFont(this.context, codePoint);
+ return effectiveParent().getSecondaryFont(getContext(), codePoint);
}
@Override
@@ -85,17 +82,17 @@
@Override
public int inlineFontSize() {
- return effectiveParent().traitFontSize(this.context);
+ return effectiveParent().traitFontSize(getContext());
}
@Override
public int inlineLetterSpacingOptimum() {
- return effectiveParent().traitLetterSpacingOpt(this.context);
+ return effectiveParent().traitLetterSpacingOpt(getContext());
}
@Override
public int inlineWordSpacingOptimum() {
- return effectiveParent().traitWordSpacingOpt(this.context);
+ return effectiveParent().traitWordSpacingOpt(getContext());
}
@Override
@@ -104,7 +101,7 @@
final Fo effectiveParent = getContent().getParent();
if (effectiveParent instanceof WrapOptionPa) {
final WrapOptionPa wrapOption = (WrapOptionPa) effectiveParent;
- return wrapOption.traitWrapOption(this.context) == WrapOption.WRAP;
+ return wrapOption.traitWrapOption(getContext()) == WrapOption.WRAP;
}
/* The initial value. */
return true;
@@ -112,27 +109,27 @@
@Override
public boolean inlineHyphenate() {
- return effectiveParent().traitHyphenate(this.context);
+ return effectiveParent().traitHyphenate(getContext());
}
@Override
public int inlineHyphenationRemainCount() {
- return effectiveParent().traitHyphenationRemainCharacterCount(this.context);
+ return effectiveParent().traitHyphenationRemainCharacterCount(getContext());
}
@Override
public int inlineHyphenationPushCount() {
- return effectiveParent().traitHyphenationPushCharacterCount(this.context);
+ return effectiveParent().traitHyphenationPushCharacterCount(getContext());
}
@Override
public int inlineHyphenationCharacter() {
- return effectiveParent().traitHyphenationCharacter(this.context);
+ return effectiveParent().traitHyphenationCharacter(getContext());
}
@Override
public boolean inlineIsFauxSmallCaps() {
- if (effectiveParent().traitFontVariant(context) != Font.Variant.SMALL_CAPS) {
+ if (effectiveParent().traitFontVariant(getContext()) != Font.Variant.SMALL_CAPS) {
/* If we are not doing small-caps at all, we certainly should not be simulating it. */
return false;
}
@@ -142,7 +139,7 @@
* Right now we rely on the user to configure the font correctly to avoid this. */
/* Has the font been configured to simulate small-caps? */
- final FontUse fontUse = effectiveParent().getPrimaryFont(context);
+ final FontUse fontUse = effectiveParent().getPrimaryFont(getContext());
if (fontUse.simulateSmallCaps() == FontServer.SMALL_CAP_SIMULATION_INVALID) {
return false;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-13 12:18:27
|
Revision: 12593
http://sourceforge.net/p/foray/code/12593
Author: victormote
Date: 2022-02-13 12:18:24 +0000 (Sun, 13 Feb 2022)
Log Message:
-----------
Conform to aXSL change: Remove extraneous method.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/EagerLineBreaker.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/SolitaryLineBreaker.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-02-13 12:04:25 UTC (rev 12592)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2022-02-13 12:18:24 UTC (rev 12593)
@@ -947,11 +947,6 @@
return lineContentLengthUsed();
}
- @Override
- public int capacityRemaining() {
- return capacityTotal() - capacityUsed();
- }
-
/**
* Indicates whether a text area should be created for a given piece of
* text.
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/EagerLineBreaker.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/EagerLineBreaker.java 2022-02-13 12:04:25 UTC (rev 12592)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/EagerLineBreaker.java 2022-02-13 12:18:24 UTC (rev 12593)
@@ -132,7 +132,8 @@
protected int processLineNonText(final IndivisibleContent nonTextItem) throws TextException {
final int lineLength = lineReceivingContent().capacityTotal();
final int itemSize = nonTextItem.inlineSizeMinimum(lineLength);
- if (itemSize > lineReceivingContent().capacityRemaining()) {
+ final int capacityRemaining = lineReceivingContent().capacityTotal() - lineReceivingContent().capacityUsed();
+ if (itemSize > capacityRemaining) {
// It doesn't fit on the current line.
if (lineReceivingContent().capacityUsed() == 0) {
// There is nothing on the line. Therefore it won't fit any
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/SolitaryLineBreaker.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/SolitaryLineBreaker.java 2022-02-13 12:04:25 UTC (rev 12592)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/SolitaryLineBreaker.java 2022-02-13 12:18:24 UTC (rev 12593)
@@ -149,8 +149,8 @@
whitespaceWidth);
processTextChar(lineText.inlineOrthography(), thisCharStarts, charWidth);
- if ((this.finalWidth + this.spaceWidth + this.wordWidth)
- <= lineReceivingContent().capacityRemaining()) {
+ int capacityRemaining = lineReceivingContent().capacityTotal() - lineReceivingContent().capacityUsed();
+ if ((this.finalWidth + this.spaceWidth + this.wordWidth) <= capacityRemaining) {
// Content fits on the current line. We are done with this char.
continue;
}
@@ -169,8 +169,10 @@
return ret;
}
}
+
+ capacityRemaining = getCurrentLine().capacityTotal() - getCurrentLine().capacityUsed();
if (this.wordStart == start
- && getCurrentLine().capacityTotal() == getCurrentLine().capacityRemaining()) {
+ && getCurrentLine().capacityTotal() == capacityRemaining) {
/* This is the first word on this line. It doesn't fit on this
* line, which means that it won't fit on any line, unless
* subsequent pages are wider. We will break the line anyway. */
@@ -195,9 +197,10 @@
}
/* Otherwise the word may continue into the next text. See if the
* entire word fits. */
+ final int capacityRemaining = lineReceivingContent().capacityTotal() - lineReceivingContent().capacityUsed();
if (this.finalWidth + this.spaceWidth + this.wordWidth
+ sizeFirstWordNextText(lineText, textModifiers, startIndex, endIndex)
- <= lineReceivingContent().capacityRemaining()) {
+ <= capacityRemaining) {
return remainingContentOnThisLine(textModifiers, startIndex, endIndex);
}
@@ -414,10 +417,15 @@
* @throws TextException For errors during break selection.
*/
private int selectDiscretionaryHyphenationPoint(final CharContent lineText, final Word hyph) throws TextException {
+ final int capacityRemaining = lineReceivingContent().capacityTotal() - lineReceivingContent().capacityUsed();
+
+
+
final int remainingWidth
- = this.lineReceivingContent().capacityRemaining()
+ = capacityRemaining
- this.finalWidth
- - this.spaceWidth - getHyphenWidth(this.currentLineText);
+ - this.spaceWidth
+ - getHyphenWidth(this.currentLineText);
int index = -1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-13 12:04:29
|
Revision: 12592
http://sourceforge.net/p/foray/code/12592
Author: victormote
Date: 2022-02-13 12:04:25 +0000 (Sun, 13 Feb 2022)
Log Message:
-----------
Conform to aXSL change by moving Exception class to foray-pioneer: Remove no-longer-needed Exception subclass.
Modified Paths:
--------------
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PioneerLayoutStrategy.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/EagerLineBreaker.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/LineBreakHandler.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/SolitaryLineBreaker.java
Added Paths:
-----------
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/TextException.java
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java 2022-02-13 11:49:40 UTC (rev 12591)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java 2022-02-13 12:04:25 UTC (rev 12592)
@@ -30,6 +30,7 @@
import org.foray.content.CharContent4a;
import org.foray.pioneer.lb.EagerLineBreaker;
+import org.foray.pioneer.lb.TextException;
import org.foray.pioneer.lb.TextServer4a;
import org.axsl.area.AreaNode;
@@ -45,7 +46,6 @@
import org.axsl.fotree.FoContext;
import org.axsl.fotree.fo.FoTextCharacters;
import org.axsl.fotree.fo.TableCell;
-import org.axsl.text.TextException;
import org.slf4j.LoggerFactory;
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PioneerLayoutStrategy.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PioneerLayoutStrategy.java 2022-02-13 11:49:40 UTC (rev 12591)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PioneerLayoutStrategy.java 2022-02-13 12:04:25 UTC (rev 12592)
@@ -32,6 +32,7 @@
import org.foray.layout.LayoutStrategy;
import org.foray.pioneer.lb.EagerLineBreaker;
import org.foray.pioneer.lb.LineBreakHandler;
+import org.foray.pioneer.lb.TextException;
import org.foray.pioneer.lb.TextServer4a;
import org.axsl.area.Area;
@@ -110,7 +111,6 @@
import org.axsl.linebreak.LineBreaker;
import org.axsl.linebreak.LineBreakerFactory;
import org.axsl.linebreak.OutputLine;
-import org.axsl.text.TextException;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/EagerLineBreaker.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/EagerLineBreaker.java 2022-02-13 11:49:40 UTC (rev 12591)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/EagerLineBreaker.java 2022-02-13 12:04:25 UTC (rev 12592)
@@ -34,7 +34,6 @@
import org.axsl.font.FontConsumer;
import org.axsl.kp.KpUserAgent;
import org.axsl.linebreak.OutputLine;
-import org.axsl.text.TextException;
import org.axsl.value.group.TextModifiers;
import org.slf4j.LoggerFactory;
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/LineBreakHandler.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/LineBreakHandler.java 2022-02-13 11:49:40 UTC (rev 12591)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/LineBreakHandler.java 2022-02-13 12:04:25 UTC (rev 12592)
@@ -31,7 +31,6 @@
import org.axsl.content.CharContent;
import org.axsl.content.IndivisibleContent;
import org.axsl.linebreak.OutputLine;
-import org.axsl.text.TextException;
/**
* Defines an interface that can be used by client applications to handle the
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/SolitaryLineBreaker.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/SolitaryLineBreaker.java 2022-02-13 11:49:40 UTC (rev 12591)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/SolitaryLineBreaker.java 2022-02-13 12:04:25 UTC (rev 12592)
@@ -33,7 +33,6 @@
import org.axsl.kp.KpUserAgent;
import org.axsl.orthography.Orthography;
import org.axsl.orthography.Word;
-import org.axsl.text.TextException;
import org.axsl.unicode.block.General_Punctuation_Block;
import org.axsl.value.group.TextModifiers;
Added: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/TextException.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/TextException.java (rev 0)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/TextException.java 2022-02-13 12:04:25 UTC (rev 12592)
@@ -0,0 +1,74 @@
+/*
+ * 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.pioneer.lb;
+
+/**
+ * Exception thrown when an axslText implementation has a problem.
+ */
+public class TextException extends Exception {
+
+ /** Constant for serialization. */
+ private static final long serialVersionUID = 844043692256461582L;
+
+ /**
+ * Create a new TextException.
+ * Identical to {@link Exception#Exception(java.lang.String)}
+ * @param message The detail message. The detail message is saved for later retrieval by the {@link #getMessage()}
+ * method.
+ * @see Exception#Exception(java.lang.String)
+ */
+ public TextException(final String message) {
+ super(message);
+ }
+
+ /**
+ * Create a new TextException.
+ * Identical to {@link Exception#Exception(java.lang.Throwable)}
+ * @param cause The cause (which is saved for later retrieval by the {@link #getCause()} method).
+ * (A @code(null) value is permitted, and indicates that the cause is nonexistent or unknown.)
+ * @see Exception#Exception(java.lang.Throwable)
+ */
+ public TextException(final Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Create a new TextException.
+ * Identical to {@link Exception#Exception(java.lang.String, java.lang.Throwable)}
+ * @param message The detail message. The detail message is saved for later retrieval by the {@link #getMessage()}
+ * method.
+ * @param cause The cause (which is saved for later retrieval by the {@link #getCause()} method).
+ * (A @code(null) value is permitted, and indicates that the cause is nonexistent or unknown.)
+ * @see Exception#Exception(java.lang.String, java.lang.Throwable)
+ */
+ public TextException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+}
Property changes on: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/TextException.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-02-13 11:49:43
|
Revision: 12591
http://sourceforge.net/p/foray/code/12591
Author: victormote
Date: 2022-02-13 11:49:40 +0000 (Sun, 13 Feb 2022)
Log Message:
-----------
Conform to aXSL change, by moving the interface to FOray: Remove another legacy line-breaking interface.
Modified Paths:
--------------
trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PioneerLayoutStrategy.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/EagerLineBreaker.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/LineBreaker.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/SolitaryLineBreaker.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/TextServer4a.java
Added Paths:
-----------
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/LineBreakHandler.java
Modified: trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java
===================================================================
--- trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java 2022-02-12 22:13:52 UTC (rev 12590)
+++ trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java 2022-02-13 11:49:40 UTC (rev 12591)
@@ -28,30 +28,16 @@
package org.foray.layout;
-import org.foray.content.CharContent4a;
-
import org.axsl.area.AreaTree;
import org.axsl.area.AreaTreeException;
-import org.axsl.area.LineArea;
import org.axsl.area.PageCollection;
import org.axsl.area.PageRa;
import org.axsl.area.RegionOuterRa;
import org.axsl.area.factory.LineContentFactory;
-import org.axsl.content.CharContent;
-import org.axsl.content.IndivisibleContent;
-import org.axsl.fotree.fo.ExternalGraphic;
-import org.axsl.fotree.fo.FoTextCharacters;
-import org.axsl.fotree.fo.InstreamForeignObject;
-import org.axsl.fotree.fo.Leader;
-import org.axsl.fotree.fo.PageNumber;
-import org.axsl.fotree.fo.PageNumberCitation;
import org.axsl.fotree.fo.PageSequence;
import org.axsl.fotree.fo.Region;
import org.axsl.fotree.fo.SimplePageMaster;
import org.axsl.layout.Layout;
-import org.axsl.linebreak.OutputLine;
-import org.axsl.text.TextException;
-import org.axsl.text.line.LineBreakHandler;
import java.util.Stack;
@@ -58,7 +44,7 @@
/**
* Abstract base class for all Layout systems.
*/
-public abstract class LayoutStrategy implements LineBreakHandler, Layout {
+public abstract class LayoutStrategy implements Layout {
/** The AreaTree instance that this layout system is processing. */
private AreaTree areaTree;
@@ -106,91 +92,7 @@
public abstract void layoutStaticContent(PageSequence pageSequence, Region region, RegionOuterRa area)
throws AreaTreeException;
- @Override
- public void handleLineBreakText(final OutputLine lineOutput,
- final CharContent text, final int startOffset, final int sizeInChars,
- final int sizeInline, final boolean hasDiscretionaryHyphen,
- final boolean hasFauxSmallCaps, final boolean isLastItemOnLine)
- throws TextException {
- checkLayoutTarget(lineOutput);
- final LineArea lineArea = (LineArea) lineOutput;
-
- CharContent textToUse = text;
- if (textToUse instanceof FoTextCharacters) {
- final FoTextCharacters foLineText = (FoTextCharacters) textToUse;
- textToUse = new CharContent4a(foLineText, lineArea);
- }
- LineContentFactory factory = lineArea;
- if (this.areaStack.size() > 0) {
- factory = this.areaStack.peek();
- }
- if (textToUse instanceof FoTextCharacters) {
- final FoTextCharacters foText = (FoTextCharacters) textToUse;
- factory.makeGlyphAreaSequence(foText, startOffset, sizeInChars, sizeInline, hasDiscretionaryHyphen,
- hasFauxSmallCaps, isLastItemOnLine);
- } else {
- throw new TextException("Returned LineText is an unknown type.");
- }
- }
-
- @Override
- public void handleLineBreakNonText(final OutputLine lineOutput, final IndivisibleContent nonText,
- final int sizeInline) throws TextException {
- checkLayoutTarget(lineOutput);
- final LineArea lineArea = (LineArea) lineOutput;
-
-// IndivisibleContent nonTextToUse = nonText;
-// if (nonTextToUse instanceof IndivisibleContent) {
-// final IndivisibleContent foLineNonText = (IndivisibleContent) nonTextToUse;
-// nonTextToUse = foLineNonText; //.getWrapped();
-// }
-
- LineContentFactory factory = lineArea;
- if (this.areaStack.size() > 0) {
- factory = this.areaStack.peek();
- }
-
- final Object nonTextToUse = nonText.getContent();
-
- if (nonTextToUse instanceof InstreamForeignObject) {
- final InstreamForeignObject ifo = (InstreamForeignObject) nonTextToUse;
- factory.makeForeignObjectArea(ifo, sizeInline);
- } else if (nonTextToUse instanceof ExternalGraphic) {
- final ExternalGraphic graphic = (ExternalGraphic) nonTextToUse;
- factory.makeExternalGraphicArea(graphic, sizeInline);
- } else if (nonTextToUse instanceof Leader) {
- final Leader leader = (Leader) nonTextToUse;
- try {
- factory.makeLeaderArea(leader, sizeInline);
- } catch (final AreaTreeException e) {
- throw new TextException(e);
- }
- } else if (nonTextToUse instanceof PageNumberCitation) {
- final PageNumberCitation citation = (PageNumberCitation)
- nonTextToUse;
- factory.makePageNumberCitationArea(citation, sizeInline);
- } else if (nonTextToUse instanceof PageNumber) {
- final PageNumber pageNumber = (PageNumber) nonTextToUse;
- factory.makePageNumberArea(pageNumber, sizeInline);
- }
- }
-
/**
- * Ensures that a given {@link LineOutput} instance is an instance of
- * {@link LineArea}, throwing an exception if it is not.
- * @param lineOutput The instance to be tested.
- * @throws TextException If {@code lineOutput} is not an instance of
- * {@link LineArea}.
- */
- private void checkLayoutTarget(final OutputLine lineOutput)
- throws TextException {
- if (! (lineOutput instanceof LineArea)) {
- throw new TextException("Line-breaking layout target must be "
- + "a LineArea.");
- }
- }
-
- /**
* Formats the static content of the current page.
* @param pageArea The page area whose static content should be laid out.
* @throws AreaTreeException For errors during layout.
@@ -230,4 +132,12 @@
return this.areaStack.pop();
}
+ /**
+ * Returns the area stack.
+ * @return The area stack.
+ */
+ public Stack<LineContentFactory> getAreaStack() {
+ return this.areaStack;
+ }
+
}
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PioneerLayoutStrategy.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PioneerLayoutStrategy.java 2022-02-12 22:13:52 UTC (rev 12590)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PioneerLayoutStrategy.java 2022-02-13 11:49:40 UTC (rev 12591)
@@ -28,12 +28,15 @@
package org.foray.pioneer;
+import org.foray.content.CharContent4a;
import org.foray.layout.LayoutStrategy;
import org.foray.pioneer.lb.EagerLineBreaker;
+import org.foray.pioneer.lb.LineBreakHandler;
import org.foray.pioneer.lb.TextServer4a;
import org.axsl.area.Area;
import org.axsl.area.AreaTreeException;
+import org.axsl.area.LineArea;
import org.axsl.area.NormalBlockArea;
import org.axsl.area.NormalFlowRa;
import org.axsl.area.PageCollection;
@@ -40,6 +43,9 @@
import org.axsl.area.PageRa;
import org.axsl.area.RegionBodyRa;
import org.axsl.area.RegionOuterRa;
+import org.axsl.area.factory.LineContentFactory;
+import org.axsl.content.CharContent;
+import org.axsl.content.IndivisibleContent;
import org.axsl.fotree.Fo;
import org.axsl.fotree.FoVisitor;
import org.axsl.fotree.fo.BasicLink;
@@ -103,6 +109,8 @@
import org.axsl.fotree.foreign.SvgElement;
import org.axsl.linebreak.LineBreaker;
import org.axsl.linebreak.LineBreakerFactory;
+import org.axsl.linebreak.OutputLine;
+import org.axsl.text.TextException;
import java.util.ArrayList;
import java.util.List;
@@ -128,7 +136,7 @@
* place where it previously left off.</li>
* </ul>
*/
-public class PioneerLayoutStrategy extends LayoutStrategy implements FoVisitor<FoNodePnr> {
+public class PioneerLayoutStrategy extends LayoutStrategy implements LineBreakHandler, FoVisitor<FoNodePnr> {
/** The initial size at which the linkage map should be created. */
private static final short INITIAL_PROXY_MAP_SIZE = 200;
@@ -733,4 +741,88 @@
return this.textServer;
}
+ @Override
+ public void handleLineBreakText(final OutputLine lineOutput,
+ final CharContent text, final int startOffset, final int sizeInChars,
+ final int sizeInline, final boolean hasDiscretionaryHyphen,
+ final boolean hasFauxSmallCaps, final boolean isLastItemOnLine)
+ throws TextException {
+ checkLayoutTarget(lineOutput);
+ final LineArea lineArea = (LineArea) lineOutput;
+
+ CharContent textToUse = text;
+ if (textToUse instanceof FoTextCharacters) {
+ final FoTextCharacters foLineText = (FoTextCharacters) textToUse;
+ textToUse = new CharContent4a(foLineText, lineArea);
+ }
+ LineContentFactory factory = lineArea;
+ if (getAreaStack().size() > 0) {
+ factory = getAreaStack().peek();
+ }
+ if (textToUse instanceof FoTextCharacters) {
+ final FoTextCharacters foText = (FoTextCharacters) textToUse;
+ factory.makeGlyphAreaSequence(foText, startOffset, sizeInChars, sizeInline, hasDiscretionaryHyphen,
+ hasFauxSmallCaps, isLastItemOnLine);
+ } else {
+ throw new TextException("Returned LineText is an unknown type.");
+ }
+ }
+
+ @Override
+ public void handleLineBreakNonText(final OutputLine lineOutput, final IndivisibleContent nonText,
+ final int sizeInline) throws TextException {
+ checkLayoutTarget(lineOutput);
+ final LineArea lineArea = (LineArea) lineOutput;
+
+// IndivisibleContent nonTextToUse = nonText;
+// if (nonTextToUse instanceof IndivisibleContent) {
+// final IndivisibleContent foLineNonText = (IndivisibleContent) nonTextToUse;
+// nonTextToUse = foLineNonText; //.getWrapped();
+// }
+
+ LineContentFactory factory = lineArea;
+ if (getAreaStack().size() > 0) {
+ factory = getAreaStack().peek();
+ }
+
+ final Object nonTextToUse = nonText.getContent();
+
+ if (nonTextToUse instanceof InstreamForeignObject) {
+ final InstreamForeignObject ifo = (InstreamForeignObject) nonTextToUse;
+ factory.makeForeignObjectArea(ifo, sizeInline);
+ } else if (nonTextToUse instanceof ExternalGraphic) {
+ final ExternalGraphic graphic = (ExternalGraphic) nonTextToUse;
+ factory.makeExternalGraphicArea(graphic, sizeInline);
+ } else if (nonTextToUse instanceof Leader) {
+ final Leader leader = (Leader) nonTextToUse;
+ try {
+ factory.makeLeaderArea(leader, sizeInline);
+ } catch (final AreaTreeException e) {
+ throw new TextException(e);
+ }
+ } else if (nonTextToUse instanceof PageNumberCitation) {
+ final PageNumberCitation citation = (PageNumberCitation)
+ nonTextToUse;
+ factory.makePageNumberCitationArea(citation, sizeInline);
+ } else if (nonTextToUse instanceof PageNumber) {
+ final PageNumber pageNumber = (PageNumber) nonTextToUse;
+ factory.makePageNumberArea(pageNumber, sizeInline);
+ }
+ }
+
+ /**
+ * Ensures that a given {@link LineOutput} instance is an instance of
+ * {@link LineArea}, throwing an exception if it is not.
+ * @param lineOutput The instance to be tested.
+ * @throws TextException If {@code lineOutput} is not an instance of
+ * {@link LineArea}.
+ */
+ private void checkLayoutTarget(final OutputLine lineOutput)
+ throws TextException {
+ if (! (lineOutput instanceof LineArea)) {
+ throw new TextException("Line-breaking layout target must be "
+ + "a LineArea.");
+ }
+ }
+
}
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/EagerLineBreaker.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/EagerLineBreaker.java 2022-02-12 22:13:52 UTC (rev 12590)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/EagerLineBreaker.java 2022-02-13 11:49:40 UTC (rev 12591)
@@ -35,7 +35,6 @@
import org.axsl.kp.KpUserAgent;
import org.axsl.linebreak.OutputLine;
import org.axsl.text.TextException;
-import org.axsl.text.line.LineBreakHandler;
import org.axsl.value.group.TextModifiers;
import org.slf4j.LoggerFactory;
Added: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/LineBreakHandler.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/LineBreakHandler.java (rev 0)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/LineBreakHandler.java 2022-02-13 11:49:40 UTC (rev 12591)
@@ -0,0 +1,80 @@
+/*
+ * 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.pioneer.lb;
+
+import org.axsl.content.CharContent;
+import org.axsl.content.IndivisibleContent;
+import org.axsl.linebreak.OutputLine;
+import org.axsl.text.TextException;
+
+/**
+ * Defines an interface that can be used by client applications to handle the
+ * results of the line-breaking process.
+ * LineBreakHandler is where the LineBreaker implementations throw the results
+ * of their work.
+ */
+public interface LineBreakHandler {
+
+ /**
+ * Handle the results of the line-breaking by placing the specified text
+ * on the specified line.
+ * @param lineOutput The line on which the text should be added.
+ * @param text The item containing the text to be added.
+ * @param startOffset The index to the first character in the text item
+ * that should be included on the line.
+ * @param sizeInChars The size, in characters, of the text in the text item
+ * that should be included on the line.
+ * @param sizeInline The size, in millipoints, that this result occupies
+ * on the line.
+ * @param hasDiscretionaryHyphen Indicates whether a discretionary hyphen
+ * should be added to the text being added.
+ * @param hasFauxSmallCaps Indicates whether faux small-caps should be
+ * applied to the text being added.
+ * @param isLastItemOnLine Indicates whether this text item is the last
+ * item on this line.
+ * @throws TextException For errors handling the output.
+ */
+ void handleLineBreakText(OutputLine lineOutput, CharContent text,
+ int startOffset, int sizeInChars, int sizeInline,
+ boolean hasDiscretionaryHyphen, boolean hasFauxSmallCaps,
+ boolean isLastItemOnLine) throws TextException;
+
+ /**
+ * Handle the results of the line-breaking by placing the specified text
+ * on the specified line.
+ * @param lineOutput The line on which the text should be added.
+ * @param nonText The non-text item that should be added to the line.
+ * @param sizeInline The size, in millipoints, that this result occupies
+ * on the line.
+ * @throws TextException For errors handling the output.
+ */
+ void handleLineBreakNonText(OutputLine lineOutput, IndivisibleContent nonText,
+ int sizeInline) throws TextException;
+
+}
Property changes on: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/LineBreakHandler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/LineBreaker.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/LineBreaker.java 2022-02-12 22:13:52 UTC (rev 12590)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/LineBreaker.java 2022-02-13 11:49:40 UTC (rev 12591)
@@ -32,7 +32,6 @@
import org.axsl.font.FontConsumer;
import org.axsl.font.FontUse;
import org.axsl.kp.KpUserAgent;
-import org.axsl.text.line.LineBreakHandler;
/**
* Abstract superclass for all line breakers.
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/SolitaryLineBreaker.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/SolitaryLineBreaker.java 2022-02-12 22:13:52 UTC (rev 12590)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/SolitaryLineBreaker.java 2022-02-13 11:49:40 UTC (rev 12591)
@@ -34,7 +34,6 @@
import org.axsl.orthography.Orthography;
import org.axsl.orthography.Word;
import org.axsl.text.TextException;
-import org.axsl.text.line.LineBreakHandler;
import org.axsl.unicode.block.General_Punctuation_Block;
import org.axsl.value.group.TextModifiers;
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/TextServer4a.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/TextServer4a.java 2022-02-12 22:13:52 UTC (rev 12590)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/TextServer4a.java 2022-02-13 11:49:40 UTC (rev 12591)
@@ -30,7 +30,6 @@
import org.axsl.font.FontConsumer;
import org.axsl.kp.KpUserAgent;
-import org.axsl.text.line.LineBreakHandler;
/**
* This class encapsulates the various text processing functions.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-12 22:13:55
|
Revision: 12590
http://sourceforge.net/p/foray/code/12590
Author: victormote
Date: 2022-02-12 22:13:52 +0000 (Sat, 12 Feb 2022)
Log Message:
-----------
Conform to aXSL change: Remove dependency on KpContext at the paragraph level.
Modified Paths:
--------------
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/TotalFitLb.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/TotalFitLbTests.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-linebreak/src/main/java/org/foray/linebreak/BestFitLb.java
===================================================================
--- trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/BestFitLb.java 2022-02-12 21:53:10 UTC (rev 12589)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/BestFitLb.java 2022-02-12 22:13:52 UTC (rev 12590)
@@ -30,7 +30,6 @@
import org.axsl.context.LineBreakContext;
import org.axsl.kp.KpBranch;
-import org.axsl.kp.KpContext;
import org.axsl.kp.KpUserAgent;
/**
@@ -40,8 +39,8 @@
public class BestFitLb extends LineBreaker4a {
@Override
- public LineBreakResult4a breakIntoLines(final KpBranch paragraph, final KpContext paraConfig,
- final KpUserAgent paraContext, final LineBreakContext lbContext) {
+ public LineBreakResult4a breakIntoLines(final KpBranch paragraph, final KpUserAgent paraContext,
+ final LineBreakContext lbContext) {
return new LineBreakResult4a(null, null);
}
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-02-12 21:53:10 UTC (rev 12589)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java 2022-02-12 22:13:52 UTC (rev 12590)
@@ -125,11 +125,10 @@
/**
* Constructor.
- * @param paraConfig The configuration of the paragraph being processed.
* @param paraContext The paragraph context instance.
* @param lbContext The line-break target.
*/
- private State(final KpContext paraConfig, final KpUserAgent paraContext, final LineBreakContext lbContext) {
+ private State(final KpUserAgent paraContext, final LineBreakContext lbContext) {
this.paraContext = paraContext;
this.lineBreakTarget = lbContext;
this.currentLineNumber = 1;
@@ -276,8 +275,8 @@
}
@Override
- public LineBreakResult4a breakIntoLines(final KpBranch paragraph, final KpContext paraConfig,
- final KpUserAgent paraContext, final LineBreakContext lbContext) {
+ public LineBreakResult4a breakIntoLines(final KpBranch paragraph, final KpUserAgent paraContext,
+ final LineBreakContext lbContext) {
/* For purposes of this algorithm, "word" means the content between glue items, or, really, if (a) is non-glue,
* (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. */
@@ -286,7 +285,7 @@
return LineBreakResult4a.EMPTY_RESULT;
}
- final State state = new State(paraConfig, paraContext, lbContext);
+ final State state = new State(paraContext, lbContext);
state.leafIterator = paragraph.leafIterator();
while (state.leafIterator.hasNext()) {
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-02-12 21:53:10 UTC (rev 12589)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/TotalFitLb.java 2022-02-12 22:13:52 UTC (rev 12590)
@@ -99,15 +99,19 @@
private LineBreakContext lbContext;
@Override
- public LineBreakResult4a breakIntoLines(final KpBranch paragraph, final KpContext paraConfig,
- final KpUserAgent paraContext, final LineBreakContext lbContext) {
+ public LineBreakResult4a breakIntoLines(final KpBranch paragraph, final KpUserAgent paraContext,
+ final LineBreakContext lbContext) {
+ if (paragraph == null) {
+ return new LineBreakResult4a(new int[0], new int[0]);
+ }
+
+ /* TODO: KpContext used to be passed in as a parameter to this method, but the API changed. This class needs to
+ * use the iterator that FirstFitLb used, which will allow it to remove this dependency. */
+ final KpContext kpContext = paragraph.getKpContext();
this.paragraph = paragraph;
this.paraContext = paraContext;
this.lbContext = lbContext;
final IntArrayBuilder returnValue = new IntArrayBuilder();
- if (paragraph == null) {
- return new LineBreakResult4a(new int[0], new int[0]);
- }
/* Initialize the data structures. */
this.branchStack = new Stack<KpBranch>();
@@ -119,11 +123,11 @@
for (int index = 0; index < this.paragraph.qtyParaNodes(); index ++) {
final KpNode node = this.paragraph.paraNodeAt(index);
currentPath.push(index);
- flatten(node, currentPath, paraConfig);
+ flatten(node, currentPath, kpContext);
currentPath.pop();
}
/* Add the paragraph terminator penalty item. */
- final LbNodeWrapper wrapper = new LbNodeWrapper(ParaPenalty4a.FORCED_BREAK, paraConfig,
+ final LbNodeWrapper wrapper = new LbNodeWrapper(ParaPenalty4a.FORCED_BREAK, kpContext,
this.contentNodes.size(), null);
this.contentNodes.add(wrapper);
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-02-12 21:53:10 UTC (rev 12589)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java 2022-02-12 22:13:52 UTC (rev 12590)
@@ -54,7 +54,7 @@
final KpUserAgent paraContext = createUserAgent();
final LineBreakContext lineBreakTarget = createLineBreakTarget(-1);
final FirstFitLb out = new FirstFitLb();
- final LineBreakResult4a actual = out.breakIntoLines(para, kpContext, paraContext, lineBreakTarget);
+ final LineBreakResult4a actual = out.breakIntoLines(para, paraContext, lineBreakTarget);
Assert.assertEquals(1, actual.getQtyLines());
Assert.assertEquals(468000, actual.getLineLength(0));
Assert.assertEquals(2, actual.getBreakPosition(0));
@@ -73,7 +73,7 @@
final LineBreakContext lbContext = createLineBreakTarget(lineWidth);
final FirstFitLb out = new FirstFitLb();
- final LineBreakResult4a actual = out.breakIntoLines(para, kpContext, paraContext, lbContext);
+ final LineBreakResult4a actual = out.breakIntoLines(para, paraContext, lbContext);
Assert.assertEquals(12, actual.getQtyLines());
Assert.assertEquals(390, actual.getLineLength(0));
Assert.assertEquals(390, actual.getLineLength(1));
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-02-12 21:53:10 UTC (rev 12589)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/TotalFitLbTests.java 2022-02-12 22:13:52 UTC (rev 12590)
@@ -58,7 +58,7 @@
final LineBreakContext lineBreakTarget = createLineBreakTarget(390_000);
final TotalFitLb out = new TotalFitLb();
- final LineBreakResult4a actual = out.breakIntoLines(para, kpContext, paraContext, lineBreakTarget);
+ final LineBreakResult4a actual = out.breakIntoLines(para, paraContext, lineBreakTarget);
final int[] expected = new int[0];
Assert.assertEquals(expected, actual);
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-02-12 21:53:10 UTC (rev 12589)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/BlockDiscretePnr.java 2022-02-12 22:13:52 UTC (rev 12590)
@@ -37,7 +37,6 @@
import org.axsl.area.factory.BlockLevelAreaFactory;
import org.axsl.fotree.fo.BlockDiscrete;
import org.axsl.kp.KpBranch;
-import org.axsl.kp.KpContext;
import org.axsl.kp.KpNode;
import org.axsl.kp.KpResult;
import org.axsl.kp.KpUserAgent;
@@ -78,8 +77,7 @@
final LineBreaker breaker = getLayout().getLineBreaker();
final KpUserAgent paraContext = this.blockDiscrete.ancestorBlock(blockArea).getParaContext();
- final KpResult result = breaker.breakIntoLines(
- this.blockDiscrete, (KpContext) this.blockDiscrete, paraContext, blockArea);
+ final KpResult result = breaker.breakIntoLines(this.blockDiscrete, paraContext, blockArea);
int lastBreakPosition = 0;
for (int lineIndex = 0; lineIndex < result.getQtyLines(); lineIndex ++) {
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-02-12 21:53:10 UTC (rev 12589)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java 2022-02-12 22:13:52 UTC (rev 12590)
@@ -37,7 +37,6 @@
import org.axsl.area.NormalBlockArea;
import org.axsl.content.TextTokensContent;
import org.axsl.fotree.fo.FoTextWords;
-import org.axsl.kp.KpContext;
import org.axsl.kp.KpResult;
import org.axsl.kp.KpUserAgent;
import org.axsl.linebreak.LineBreaker;
@@ -84,7 +83,7 @@
if (this.result == null) {
final LineBreaker lb = getLayout().getLineBreaker();
final TextTokensContent content = new TextTokensContent4a(this.node, normalBlockArea);
- this.result = lb.breakIntoLines(content, (KpContext) this.node, paraContext, normalBlockArea);
+ this.result = lb.breakIntoLines(content, paraContext, normalBlockArea);
}
TextTokenFlowLocation startLocation = this.node.getFoTokenFlow().markLocation(0, 0, 0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-12 21:53:13
|
Revision: 12589
http://sourceforge.net/p/foray/code/12589
Author: victormote
Date: 2022-02-12 21:53:10 +0000 (Sat, 12 Feb 2022)
Log Message:
-----------
Conform to aXSL changes: 1. Make TextTokensContent implement KpContext. 2. Use the leaf iterator to get the nearest context in the stack of branches.
Modified Paths:
--------------
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/test/java/org/foray/common/para/ParaBranch4aTests.java
trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.java
trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.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/FirstFitLb.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/ParaBranch4aTestFixture.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/ParaContentIteratorTests.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/TokenFlow4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Word4a.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.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 2022-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4a.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -29,12 +29,13 @@
package org.foray.common.para;
import org.axsl.kp.KpBranch;
+import org.axsl.kp.KpContext;
import org.axsl.kp.KpLeaf;
+import org.axsl.kp.KpLeafIterator;
import org.axsl.kp.KpNode;
import java.util.ArrayList;
import java.util.List;
-import java.util.ListIterator;
/**
* FOray implementation of {@link KpBranch}.
@@ -44,10 +45,16 @@
/** The list of child nodes. */
private List<KpNode> nodes = new ArrayList<KpNode>();
+ /** The context for descendant leaves. */
+ private KpContext kpContext;
+
/**
* No-args constructor.
+ * @param kpContext The context for descendant leaves.
*/
- public ParaBranch4a() { }
+ public ParaBranch4a(final KpContext kpContext) {
+ this.kpContext = kpContext;
+ }
@Override
public Type getParaNodeType() {
@@ -153,7 +160,7 @@
}
@Override
- public ListIterator<KpLeaf> leafIterator() {
+ public KpLeafIterator leafIterator() {
return new ParaBranch4aIterator(this);
}
@@ -178,4 +185,9 @@
this.nodes.add(node);
}
+ @Override
+ public KpContext getKpContext() {
+ return this.kpContext;
+ }
+
}
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-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/para/ParaBranch4aIterator.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -32,10 +32,11 @@
import org.foray.common.sequence.IntArrayBuilder;
import org.axsl.kp.KpBranch;
+import org.axsl.kp.KpContext;
import org.axsl.kp.KpLeaf;
+import org.axsl.kp.KpLeafIterator;
import org.axsl.kp.KpNode;
-import java.util.ListIterator;
import java.util.NoSuchElementException;
import java.util.Stack;
@@ -46,7 +47,7 @@
* This means that node "n" returned by next(), will also be returned again if the next call is to previous(), and vice
* versa.
*/
-public class ParaBranch4aIterator implements ListIterator<KpLeaf> {
+public class ParaBranch4aIterator implements KpLeafIterator {
/** The iterator conceptually sits immediately after (index - 1) and immediately before (index). */
private int leafIndex = 0;
@@ -248,4 +249,22 @@
}
}
+ /**
+ * {@inheritDoc}
+ * This implementation returns the {@link KpBranch} that is nearest to the top of the {@link KpBranch} stack that is
+ * also a {@link KpContext}.
+ */
+ @Override
+ public KpContext getNearestContext() {
+ /* Iterate the stack in reverse order. */
+ for (int index = this.branchStack.size() - 1; index > -1; index --) {
+ final KpBranch branch = branchStack.get(index);
+ final KpContext context = branch.getKpContext();
+ if (context != null) {
+ return context;
+ }
+ }
+ return null;
+ }
+
}
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-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-common/src/test/java/org/foray/common/para/ParaBranch4aTests.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -51,8 +51,8 @@
final KpPenalty discretionaryHyphen = new ParaPenaltyChars("-", 0, false);
- final ParaBranch4a out = new ParaBranch4a();
- final ParaBranch4a nodeGreatness = new ParaBranch4a();
+ final ParaBranch4a out = new ParaBranch4a(null);
+ final ParaBranch4a nodeGreatness = new ParaBranch4a(null);
nodeGreatness.addNode(new ParaBoxChars("great"));
nodeGreatness.addNode(discretionaryHyphen);
@@ -59,7 +59,7 @@
nodeGreatness.addNode(new ParaBoxChars("ness"));
/* Putting "Be" in a branch is unnecessary, but we wish to test a branch as the first node. */
- final ParaBranch4a nodeBe = new ParaBranch4a();
+ final ParaBranch4a nodeBe = new ParaBranch4a(null);
nodeBe.addNode(new ParaBoxChars("B"));
nodeBe.addNode(new ParaBoxChars("e"));
out.addNode(nodeBe); // Node 0, Leaf 0 - 1
@@ -102,7 +102,7 @@
out.addNode(ParaGlueChars.SPACE); // Node 37, Leaf 44
/* Putting "them." in a branch is unnecessary, but we with to test a branch as the last node. */
- final ParaBranch4a nodeThem = new ParaBranch4a();
+ final ParaBranch4a nodeThem = new ParaBranch4a(null);
nodeThem.addNode(new ParaBoxChars("t"));
nodeThem.addNode(new ParaBoxChars("h"));
nodeThem.addNode(new ParaBoxChars("e"));
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.java 2022-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -34,12 +34,13 @@
import org.axsl.content.Content;
import org.axsl.content.ContentTree;
import org.axsl.kp.KpBranch;
+import org.axsl.kp.KpContext;
import org.axsl.kp.KpLeaf;
+import org.axsl.kp.KpLeafIterator;
import org.axsl.kp.KpNode;
import java.util.ArrayList;
import java.util.List;
-import java.util.ListIterator;
/**
* FOray implementation of {@link ContentTree}.
@@ -130,7 +131,7 @@
}
@Override
- public ListIterator<KpLeaf> leafIterator() {
+ public KpLeafIterator leafIterator() {
return new ParaBranch4aIterator(this);
}
@@ -147,4 +148,9 @@
return builder.toString();
}
+ @Override
+ public KpContext getKpContext() {
+ return null;
+ }
+
}
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java 2022-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -28,15 +28,20 @@
package org.foray.content;
+import org.foray.common.FontContext4a;
+import org.foray.common.para.ParaBranch4aIterator;
+
import org.axsl.content.TextTokensContent;
+import org.axsl.font.FontUse;
import org.axsl.fotree.FoContext;
import org.axsl.fotree.fo.FoTextWords;
import org.axsl.fotree.text.FoTextTokenFlow;
+import org.axsl.kp.KpContext;
import org.axsl.kp.KpLeaf;
+import org.axsl.kp.KpLeafIterator;
import org.axsl.kp.KpNode;
+import org.axsl.orthography.Orthography;
-import java.util.ListIterator;
-
/**
* Content wrapper for {@link FoTextWords}.
*/
@@ -95,9 +100,10 @@
}
@Override
- public ListIterator<KpLeaf> leafIterator() {
- /* Pass-through. */
- return getTokenFlow().leafIterator();
+ public KpLeafIterator leafIterator() {
+ /* Do NOT pass-through. This wrapper needs to go onto the stack of branches so that the descendant words and
+ * word segments have {@link KpContext}. */
+ return new ParaBranch4aIterator(this);
}
@Override
@@ -112,4 +118,35 @@
return getTokenFlow().getText();
}
+ @Override
+ public int getIdealWidth(final KpLeaf leaf) {
+ final FontUse fontUse = this.content.getPrimaryFont(getContext());
+ final int fontSize = this.content.traitFontSize(getContext());
+ final Orthography orthography = this.content.getOrthography();
+ return fontUse.width(leaf.getText(), fontSize, FontContext4a.DEFAULT, orthography);
+ }
+
+ @Override
+ public int getStretchability(final KpLeaf leaf) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getShrinkability(final KpLeaf leaf) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getHyphenCharacterWidth() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public KpContext getKpContext() {
+ return this;
+ }
+
}
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-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/BlockDiscrete4a.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -41,12 +41,13 @@
import org.axsl.fotree.FoVisitor;
import org.axsl.fotree.fo.BlockDiscrete;
import org.axsl.kp.KpBranch;
+import org.axsl.kp.KpContext;
import org.axsl.kp.KpLeaf;
+import org.axsl.kp.KpLeafIterator;
import org.axsl.kp.KpNode;
import java.util.ArrayList;
import java.util.List;
-import java.util.ListIterator;
/**
* A container for only text and inline items.
@@ -262,7 +263,7 @@
}
@Override
- public ListIterator<KpLeaf> leafIterator() {
+ public KpLeafIterator leafIterator() {
return new ParaBranch4aIterator(this);
}
@@ -283,4 +284,9 @@
throw new UnsupportedOperationException();
}
+ @Override
+ public KpContext getKpContext() {
+ return null;
+ }
+
}
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-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoTextWords4a.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -38,13 +38,13 @@
import org.axsl.fotree.text.FoTextToken;
import org.axsl.fotree.text.FoTextTokenFlow;
import org.axsl.kp.KpBranch;
+import org.axsl.kp.KpContext;
import org.axsl.kp.KpLeaf;
+import org.axsl.kp.KpLeafIterator;
import org.axsl.kp.KpNode;
import org.axsl.orthography.OrthographyException;
import org.axsl.orthography.Whitespace;
-import java.util.ListIterator;
-
/**
* Text in an FO document that has been tokenized into words.
* This is a thin wrapper around an instance of {@link FoTextTokenFlow} that allows that token flow to live in an FO
@@ -155,8 +155,13 @@
}
@Override
- public ListIterator<KpLeaf> leafIterator() {
+ public KpLeafIterator leafIterator() {
return this.tokenFlow.leafIterator();
}
+ @Override
+ public KpContext getKpContext() {
+ return null;
+ }
+
}
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-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-linebreak/src/main/java/org/foray/linebreak/FirstFitLb.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -35,12 +35,12 @@
import org.axsl.kp.KpContext;
import org.axsl.kp.KpGlue;
import org.axsl.kp.KpLeaf;
+import org.axsl.kp.KpLeafIterator;
import org.axsl.kp.KpPenalty;
import org.axsl.kp.KpUserAgent;
import java.util.ArrayList;
import java.util.List;
-import java.util.ListIterator;
/**
* <p>Implementation of the Knuth-Plass "first-fit" linebreaking algorithm.
@@ -114,9 +114,6 @@
/** The accumulated total of the ideal width of the non-glue items in the current provisional word. */
private int provisionalNonGlueIdealWidth = 0;
- /** The configuration of the paragraph being processed. */
- private KpContext paraConfig;
-
/** The paragraph context. */
private KpUserAgent paraContext;
@@ -123,6 +120,9 @@
/** The target of the line-breaker. */
private LineBreakContext lineBreakTarget;
+ /** The iterator being used to traverse the nodes in the paragraph. */
+ private KpLeafIterator leafIterator;
+
/**
* Constructor.
* @param paraConfig The configuration of the paragraph being processed.
@@ -130,7 +130,6 @@
* @param lbContext The line-break target.
*/
private State(final KpContext paraConfig, final KpUserAgent paraContext, final LineBreakContext lbContext) {
- this.paraConfig = paraConfig;
this.paraContext = paraContext;
this.lineBreakTarget = lbContext;
this.currentLineNumber = 1;
@@ -145,7 +144,7 @@
provisionalNonGlue.add(leaf);
/* Do not include the width of penalty items. */
if (leaf.getParaLeafType() == KpLeaf.Type.BOX) {
- final int leafWidth = leaf.getIdealWidth(paraConfig);
+ final int leafWidth = leaf.getIdealWidth(this.leafIterator.getNearestContext());
provisionalNonGlueIdealWidth += leafWidth;
}
}
@@ -156,9 +155,10 @@
*/
private void addProvisionalGlue(final KpGlue glue) {
provisionalGlue.add(glue);
- provisionalGlueIdealWidth += glue.getIdealWidth(paraConfig);
- provisionalGlueShrinkability += glue.getShrinkability(paraConfig);
- provisionalGlueStretchability += glue.getStretchability(paraConfig);
+ final KpContext context = this.leafIterator.getNearestContext();
+ provisionalGlueIdealWidth += glue.getIdealWidth(context);
+ provisionalGlueShrinkability += glue.getShrinkability(context);
+ provisionalGlueStretchability += glue.getStretchability(context);
}
/**
@@ -287,10 +287,10 @@
}
final State state = new State(paraConfig, paraContext, lbContext);
+ state.leafIterator = paragraph.leafIterator();
- final ListIterator<KpLeaf> leafIterator = paragraph.leafIterator();
- while (leafIterator.hasNext()) {
- final KpLeaf leaf = leafIterator.next();
+ while (state.leafIterator.hasNext()) {
+ final KpLeaf leaf = state.leafIterator.next();
final KpPenalty penalty = KpLeaf.Type.asPenalty(leaf);
if (penalty != null
&& penalty.getCost(paraContext) <= KpPenalty.Quality.FORCED_BREAK.getNumericValue()) {
@@ -380,7 +380,7 @@
final KpPenalty penalty = KpLeaf.Type.asPenalty(leaf);
if (penalty == null) {
/* This is block content might get pushed to the next line. */
- idealWidthToNextLine += leaf.getIdealWidth(state.paraConfig);
+ idealWidthToNextLine += leaf.getIdealWidth(state.leafIterator.getNearestContext());
} else {
/* This is a penalty item. */
/* Are we allowed to break here. */
@@ -387,7 +387,8 @@
if (penalty.getCost(state.paraContext) >= KpPenalty.Quality.INFINITE_PENALTY.getNumericValue()) {
}
- if (state.minProvisionalLineWidth() - idealWidthToNextLine + penalty.getPenaltyWidth(state.paraConfig)
+ if (state.minProvisionalLineWidth() - idealWidthToNextLine +
+ penalty.getPenaltyWidth(state.leafIterator.getNearestContext())
<= lineCapacity) {
/* This is the breakpoint we want. However, we need to break after this breakpoint. */
state.markEndOfLine(index + 1);
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-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/FirstFitLbTests.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -47,14 +47,14 @@
*/
@Test
public void firstFitTestSingleLine() {
- final ParaBranch4aTestFixture para = new ParaBranch4aTestFixture('-');
+ final KpContext kpContext = createGrimmParaConfig();
+ final ParaBranch4aTestFixture para = new ParaBranch4aTestFixture(kpContext, '-');
para.addWord("Hello World!");
para.addSpace();
- final KpContext paraConfig = createGrimmParaConfig();
final KpUserAgent paraContext = createUserAgent();
final LineBreakContext lineBreakTarget = createLineBreakTarget(-1);
final FirstFitLb out = new FirstFitLb();
- final LineBreakResult4a actual = out.breakIntoLines(para, paraConfig, paraContext, lineBreakTarget);
+ final LineBreakResult4a actual = out.breakIntoLines(para, kpContext, paraContext, lineBreakTarget);
Assert.assertEquals(1, actual.getQtyLines());
Assert.assertEquals(468000, actual.getLineLength(0));
Assert.assertEquals(2, actual.getBreakPosition(0));
@@ -65,8 +65,8 @@
*/
@Test
public void firstFitTestGrimm() {
- final ParaBranch4a para = this.createPara();
- final KpContext paraConfig = createGrimmParaConfig();
+ final KpContext kpContext = createGrimmParaConfig();
+ final ParaBranch4a para = this.createPara(kpContext);
/* Line width obtained from "Digital Typography," p. 73. We leave it expressed here in Monotype "units". */
final int lineWidth = 390;
final KpUserAgent paraContext = createUserAgent();
@@ -73,7 +73,7 @@
final LineBreakContext lbContext = createLineBreakTarget(lineWidth);
final FirstFitLb out = new FirstFitLb();
- final LineBreakResult4a actual = out.breakIntoLines(para, paraConfig, paraContext, lbContext);
+ final LineBreakResult4a actual = out.breakIntoLines(para, kpContext, paraContext, lbContext);
Assert.assertEquals(12, actual.getQtyLines());
Assert.assertEquals(390, actual.getLineLength(0));
Assert.assertEquals(390, actual.getLineLength(1));
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-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/LineBreaker4aTests.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -38,6 +38,7 @@
import org.foray.orthography.Punctuation4a;
import org.axsl.context.LineBreakContext;
+import org.axsl.kp.KpContext;
import org.axsl.kp.KpPenalty;
import org.axsl.kp.KpUserAgent;
@@ -88,10 +89,11 @@
* manually build it in this method.
* Where effort has been expended to manually compute indexes and widths, that work is shown, as it may be useful
* for testing or debugging in the future.
+ * @param kpContext The context to be used by descendant leaves.
* @return The tokenized content of {@link #TEST_STRING_01}.
*/
- public ParaBranch4a createPara() {
- final ParaBranch4aTestFixture para = new ParaBranch4aTestFixture('-');
+ public ParaBranch4a createPara(final KpContext kpContext) {
+ final ParaBranch4aTestFixture para = new ParaBranch4aTestFixture(kpContext, '-');
// ----Leaf--- Ideal Cumul
// Index Qty Width Width
// ------ --- ----- -----
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/ParaBranch4aTestFixture.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/ParaBranch4aTestFixture.java 2022-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/ParaBranch4aTestFixture.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -32,6 +32,8 @@
import org.foray.orthography.StringWord;
import org.foray.orthography.Whitespace4a;
+import org.axsl.kp.KpContext;
+
import java.util.regex.Pattern;
/**
@@ -44,9 +46,11 @@
/**
* Constructor.
+ * @param kpContext The context to be used by descendant leaves.
* @param softHyphenChar The character used to mark syllable breaks.
*/
- public ParaBranch4aTestFixture(final char softHyphenChar) {
+ public ParaBranch4aTestFixture(final KpContext kpContext, final char softHyphenChar) {
+ super(kpContext);
this.wordBreaker = Pattern.compile(Character.toString(softHyphenChar));
}
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/ParaContentIteratorTests.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/ParaContentIteratorTests.java 2022-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/ParaContentIteratorTests.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -48,11 +48,11 @@
*/
@Test
public void test01() {
- final ParaBranch4a root = new ParaBranch4a();
+ final ParaBranch4a root = new ParaBranch4a(null);
final ParaBox4a a = new ParaBox4a(0);
- final ParaBranch4a b = new ParaBranch4a();
- final ParaBranch4a c = new ParaBranch4a();
- final ParaBranch4a d = new ParaBranch4a();
+ final ParaBranch4a b = new ParaBranch4a(null);
+ final ParaBranch4a c = new ParaBranch4a(null);
+ final ParaBranch4a d = new ParaBranch4a(null);
final ParaBox4a e = new ParaBox4a(0);
final ParaBox4a f = new ParaBox4a(0);
final ParaBox4a g = new ParaBox4a(0);
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-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/TotalFitLbTests.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -51,14 +51,14 @@
public void totalFitTest1() {
/* TODO: THE CLASS BEING TESTED IS VERY INCOMPLETE, AND SO IS THIS TEST !!!!!! */
- final ParaBranch4a para = this.createPara();
- final KpContext paraConfig = createGrimmParaConfig();
+ final KpContext kpContext = createGrimmParaConfig();
+ final ParaBranch4a para = this.createPara(kpContext);
final KpUserAgent paraContext = createUserAgent();
/* Line width obtained from "Digital Typography," p. 73.*/
final LineBreakContext lineBreakTarget = createLineBreakTarget(390_000);
final TotalFitLb out = new TotalFitLb();
- final LineBreakResult4a actual = out.breakIntoLines(para, paraConfig, paraContext, lineBreakTarget);
+ final LineBreakResult4a actual = out.breakIntoLines(para, kpContext, paraContext, lineBreakTarget);
final int[] expected = new int[0];
Assert.assertEquals(expected, actual);
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-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/util/DumpLayout.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -81,7 +81,7 @@
final String arrayAsString = args[0];
final IntArray intArray = new IntArray(arrayAsString);
final FirstFitLbTests lb = new FirstFitLbTests();
- final ParaBranch4a branch = lb.createPara();
+ final ParaBranch4a branch = lb.createPara(null);
new DumpLayout(branch, intArray.toArray());
}
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-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/util/DumpParaBranch.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -80,7 +80,7 @@
*/
public static void main(final String[] args) {
final FirstFitLbTests lb = new FirstFitLbTests();
- final ParaBranch4a branch = lb.createPara();
+ final ParaBranch4a branch = lb.createPara(null);
new DumpParaBranch(branch);
}
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-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/TokenFlow4a.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -36,7 +36,9 @@
import org.axsl.fotree.text.FoTextTokenFlow;
import org.axsl.fotree.text.FoWord;
import org.axsl.fotree.text.FoWordSegment;
+import org.axsl.kp.KpContext;
import org.axsl.kp.KpLeaf;
+import org.axsl.kp.KpLeafIterator;
import org.axsl.kp.KpNode;
import org.axsl.orthography.TextTokenFlowLocation;
import org.axsl.orthography.Whitespace;
@@ -45,7 +47,6 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.ListIterator;
/**
* FOray implementation of {@link FoTextTokenFlow}.
@@ -171,7 +172,7 @@
}
@Override
- public ListIterator<KpLeaf> leafIterator() {
+ public KpLeafIterator leafIterator() {
return new ParaBranch4aIterator(this);
}
@@ -375,4 +376,9 @@
}
}
+ @Override
+ public KpContext getKpContext() {
+ return null;
+ }
+
}
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-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Word4a.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -35,7 +35,8 @@
import org.axsl.fotree.text.FoWord;
import org.axsl.fotree.text.FoWordComponent;
import org.axsl.fotree.text.FoWordSegment;
-import org.axsl.kp.KpLeaf;
+import org.axsl.kp.KpContext;
+import org.axsl.kp.KpLeafIterator;
import org.axsl.kp.KpNode;
import org.axsl.kp.KpPenalty;
import org.axsl.orthography.Word;
@@ -45,7 +46,6 @@
import org.axsl.value.group.TextModifiers;
import java.io.Serializable;
-import java.util.ListIterator;
/**
* <p>Abstract superclass for FOray implementations of {@link Word}, providing some default implementation.</p>
@@ -255,7 +255,7 @@
}
@Override
- public ListIterator<KpLeaf> leafIterator() {
+ public KpLeafIterator leafIterator() {
// TODO Auto-generated method stub
return null;
}
@@ -296,4 +296,9 @@
throw new IndexOutOfBoundsException();
}
+ @Override
+ public KpContext getKpContext() {
+ return null;
+ }
+
}
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-02-12 13:41:38 UTC (rev 12588)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextWordsPnr.java 2022-02-12 21:53:10 UTC (rev 12589)
@@ -29,11 +29,13 @@
package org.foray.pioneer;
import org.foray.common.para.ParaBranch4aIterator;
+import org.foray.content.TextTokensContent4a;
import org.axsl.area.AreaNode;
import org.axsl.area.AreaTreeException;
import org.axsl.area.LineArea;
import org.axsl.area.NormalBlockArea;
+import org.axsl.content.TextTokensContent;
import org.axsl.fotree.fo.FoTextWords;
import org.axsl.kp.KpContext;
import org.axsl.kp.KpResult;
@@ -81,8 +83,8 @@
if (this.result == null) {
final LineBreaker lb = getLayout().getLineBreaker();
- this.result = lb.breakIntoLines(
- this.node.getFoTokenFlow(), (KpContext) this.node, paraContext, normalBlockArea);
+ final TextTokensContent content = new TextTokensContent4a(this.node, normalBlockArea);
+ this.result = lb.breakIntoLines(content, (KpContext) this.node, paraContext, normalBlockArea);
}
TextTokenFlowLocation startLocation = this.node.getFoTokenFlow().markLocation(0, 0, 0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-12 13:41:41
|
Revision: 12588
http://sourceforge.net/p/foray/code/12588
Author: victormote
Date: 2022-02-12 13:41:38 +0000 (Sat, 12 Feb 2022)
Log Message:
-----------
Add a ContentTree implementation.
Modified Paths:
--------------
trunk/foray/foray-content/build.gradle
Added Paths:
-----------
trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.java
Modified: trunk/foray/foray-content/build.gradle
===================================================================
--- trunk/foray/foray-content/build.gradle 2022-02-12 13:07:48 UTC (rev 12587)
+++ trunk/foray/foray-content/build.gradle 2022-02-12 13:41:38 UTC (rev 12588)
@@ -12,6 +12,8 @@
api (group: 'org.axsl', name: 'axsl-orthography', version: axslVersion) { transitive = false }
api (group: 'org.axsl', name: 'axsl-kp-model', version: axslVersion) { transitive = false }
+ api (project(':foray-common')) { transitive = false }
+
implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
testImplementation group: 'junit', name: 'junit', version: junitVersion
Added: trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.java (rev 0)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.java 2022-02-12 13:41:38 UTC (rev 12588)
@@ -0,0 +1,150 @@
+/*
+ * 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.content;
+
+import org.foray.common.MarkedIndexOutOfBoundsException;
+import org.foray.common.para.ParaBranch4aIterator;
+
+import org.axsl.content.Content;
+import org.axsl.content.ContentTree;
+import org.axsl.kp.KpBranch;
+import org.axsl.kp.KpLeaf;
+import org.axsl.kp.KpNode;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+
+/**
+ * FOray implementation of {@link ContentTree}.
+ */
+public class ContentTree4a implements ContentTree {
+
+ /** The content item children of this tree. */
+ private List<Content> children = new ArrayList<Content>();
+
+ @Override
+ public Type getParaNodeType() {
+ return Type.BRANCH;
+ }
+
+ @Override
+ public int qtyParaNodes() {
+ int count = 0;
+ for (int index = 0; index < this.children.size(); index ++) {
+ final Content content = this.children.get(index);
+ if (content instanceof KpNode) {
+ count ++;
+ }
+ }
+ return count;
+ }
+
+ @Override
+ public KpNode paraNodeAt(final int nodeIndex) {
+ int count = 0;
+ for (int index = 0; index < this.children.size(); index ++) {
+ final Content content = this.children.get(index);
+ if (content instanceof KpNode) {
+ final KpNode node = (KpNode) content;
+ if (count == nodeIndex) {
+ return node;
+ }
+ count ++;
+ }
+ }
+ throw new MarkedIndexOutOfBoundsException(nodeIndex, qtyParaNodes());
+ }
+
+ @Override
+ public int qtyParaLeaves() {
+ int count = 0;
+ for (int index = 0; index < this.children.size(); index ++) {
+ final Content content = this.children.get(index);
+ if (content instanceof KpNode) {
+ final KpNode node = (KpNode) content;
+ count += node.qtyParaLeaves();
+ }
+ }
+ return count;
+ }
+
+ @Override
+ public KpLeaf paraLeafAt(final int leafIndex) {
+ int leafCount = 0;
+ for (int index = 0; index < this.children.size(); index ++) {
+ final Content content = this.children.get(index);
+ if (content instanceof KpNode) {
+ final KpNode node = (KpNode) content;
+ leafCount += node.qtyParaLeaves();
+ if (leafCount >= leafIndex) {
+ if (node instanceof KpLeaf) {
+ return (KpLeaf) node;
+ }
+ final KpBranch branch = (KpBranch) node;
+ final int localIndex = leafCount - leafIndex;
+ return branch.paraLeafAt(localIndex);
+ }
+ }
+ }
+ throw new MarkedIndexOutOfBoundsException(leafIndex, qtyParaLeaves());
+ }
+
+ @Override
+ public int qtyKpLeaves() {
+ int count = 0;
+ for (int index = 0; index < this.children.size(); index ++) {
+ final Content content = this.children.get(index);
+ if (content instanceof KpNode) {
+ final KpNode node = (KpNode) content;
+ count += node.qtyKpLeaves();
+ }
+ }
+ return count;
+ }
+
+ @Override
+ public ListIterator<KpLeaf> leafIterator() {
+ return new ParaBranch4aIterator(this);
+ }
+
+ @Override
+ public CharSequence getText() {
+ final StringBuilder builder = new StringBuilder();
+ for (int index = 0; index < this.children.size(); index ++) {
+ final Content content = this.children.get(index);
+ if (content instanceof KpNode) {
+ final KpNode node = (KpNode) content;
+ builder.append(node.getText());
+ }
+ }
+ return builder.toString();
+ }
+
+}
Property changes on: trunk/foray/foray-content/src/main/java/org/foray/content/ContentTree4a.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-02-12 13:07:50
|
Revision: 12587
http://sourceforge.net/p/foray/code/12587
Author: victormote
Date: 2022-02-12 13:07:48 +0000 (Sat, 12 Feb 2022)
Log Message:
-----------
Conform to aXSL change: Add implementation of axsl-kp-model interfaces to axsl-content types.
Modified Paths:
--------------
trunk/foray/foray-content/build.gradle
trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java
trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java
trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java
trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java
Added Paths:
-----------
trunk/foray/foray-content/src/main/java/org/foray/content/IndivisibleContent4a.java
Modified: trunk/foray/foray-content/build.gradle
===================================================================
--- trunk/foray/foray-content/build.gradle 2022-02-11 16:11:06 UTC (rev 12586)
+++ trunk/foray/foray-content/build.gradle 2022-02-12 13:07:48 UTC (rev 12587)
@@ -10,6 +10,7 @@
api (group: 'org.axsl', name: 'axsl-font', version: axslVersion) { transitive = false }
api (group: 'org.axsl', name: 'axsl-value', version: axslVersion) { transitive = false }
api (group: 'org.axsl', name: 'axsl-orthography', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-kp-model', version: axslVersion) { transitive = false }
implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
Added: trunk/foray/foray-content/src/main/java/org/foray/content/IndivisibleContent4a.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/IndivisibleContent4a.java (rev 0)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/IndivisibleContent4a.java 2022-02-12 13:07:48 UTC (rev 12587)
@@ -0,0 +1,98 @@
+/*
+ * 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.content;
+
+import org.axsl.content.IndivisibleContent;
+import org.axsl.fotree.FoContext;
+import org.axsl.kp.KpContext;
+import org.axsl.kp.KpLeaf;
+
+/**
+ * Abstract superclass for FOray implementations of {@link IndivisibleContent}.
+ */
+public abstract class IndivisibleContent4a extends Content4a implements IndivisibleContent {
+
+ /**
+ * Constructor.
+ * @param context The FO context for this content.
+ */
+ public IndivisibleContent4a(final FoContext context) {
+ super(context);
+ }
+
+ @Override
+ public Type getParaLeafType() {
+ return KpLeaf.Type.BOX;
+ }
+
+ @Override
+ public int getIdealWidth(final KpContext config) {
+ return inlineSizeOptimum(getContext().ipdParentArea());
+ }
+
+ @Override
+ public int getStretchability(final KpContext config) {
+ final int max = inlineSizeMaximum(getContext().ipdParentArea());
+ final int opt = inlineSizeOptimum(getContext().ipdParentArea());
+ return max - opt;
+ }
+
+ @Override
+ public int getShrinkability(final KpContext config) {
+ final int opt = inlineSizeOptimum(getContext().ipdParentArea());
+ final int min = inlineSizeMinimum(getContext().ipdParentArea());
+ return opt - min;
+ }
+
+ @Override
+ public org.axsl.kp.KpNode.Type getParaNodeType() {
+ return org.axsl.kp.KpNode.Type.LEAF;
+ }
+
+ @Override
+ public int qtyParaNodes() {
+ return 0;
+ }
+
+ @Override
+ public int qtyParaLeaves() {
+ return 0;
+ }
+
+ @Override
+ public int qtyKpLeaves() {
+ return 0;
+ }
+
+ @Override
+ public CharSequence getText() {
+ return "";
+ }
+
+}
Property changes on: trunk/foray/foray-content/src/main/java/org/foray/content/IndivisibleContent4a.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java 2022-02-11 16:11:06 UTC (rev 12586)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java 2022-02-12 13:07:48 UTC (rev 12587)
@@ -35,7 +35,7 @@
/**
* Content wrapper for {@link Leader}.
*/
-public class LeaderContent extends Content4a implements IndivisibleContent {
+public class LeaderContent extends IndivisibleContent4a implements IndivisibleContent {
/** The wrapped content. */
private Leader content;
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java 2022-02-11 16:11:06 UTC (rev 12586)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java 2022-02-12 13:07:48 UTC (rev 12587)
@@ -38,7 +38,7 @@
* Content wrapper for {@link org.axsl.fotree.fo.PageNumber}, {@link org.axsl.fotree.fo.PageNumberCitation}, and
* {@link org.axsl.fotree.fo.PageNumberCitationLast}.
*/
-public class PageReferenceContent extends Content4a implements IndivisibleContent {
+public class PageReferenceContent extends IndivisibleContent4a implements IndivisibleContent {
/** The number of placeholder digits that should be used when we do not yet know what the actual page-number is. */
private static final byte QTY_PLACEHOLDER_DIGITS = 3;
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java 2022-02-11 16:11:06 UTC (rev 12586)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java 2022-02-12 13:07:48 UTC (rev 12587)
@@ -35,7 +35,7 @@
/**
* Content wrapper for {FoScaled}.
*/
-public class ScaledContent extends Content4a implements IndivisibleContent {
+public class ScaledContent extends IndivisibleContent4a implements IndivisibleContent {
/** The wrapped content. */
private FoScaled content;
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java 2022-02-11 16:11:06 UTC (rev 12586)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java 2022-02-12 13:07:48 UTC (rev 12587)
@@ -31,9 +31,12 @@
import org.axsl.content.TextTokensContent;
import org.axsl.fotree.FoContext;
import org.axsl.fotree.fo.FoTextWords;
-import org.axsl.orthography.TextToken;
-import org.axsl.orthography.TextTokenFlow;
+import org.axsl.fotree.text.FoTextTokenFlow;
+import org.axsl.kp.KpLeaf;
+import org.axsl.kp.KpNode;
+import java.util.ListIterator;
+
/**
* Content wrapper for {@link FoTextWords}.
*/
@@ -58,9 +61,55 @@
}
@Override
- public TextTokenFlow<TextToken> getTokenFlow() {
- // TODO Auto-generated method stub
- return null;
+ public FoTextTokenFlow getTokenFlow() {
+ return this.content.getFoTokenFlow();
}
+ @Override
+ public Type getParaNodeType() {
+ return KpNode.Type.BRANCH;
+ }
+
+ @Override
+ public int qtyParaNodes() {
+ /* Pass-through. */
+ return getTokenFlow().qtyParaNodes();
+ }
+
+ @Override
+ public KpNode paraNodeAt(final int nodeIndex) {
+ /* Pass-through. */
+ return getTokenFlow().paraNodeAt(nodeIndex);
+ }
+
+ @Override
+ public int qtyParaLeaves() {
+ /* Pass-through. */
+ return getTokenFlow().qtyParaLeaves();
+ }
+
+ @Override
+ public KpLeaf paraLeafAt(final int leafIndex) {
+ /* Pass-through. */
+ return getTokenFlow().paraLeafAt(leafIndex);
+ }
+
+ @Override
+ public ListIterator<KpLeaf> leafIterator() {
+ /* Pass-through. */
+ return getTokenFlow().leafIterator();
+ }
+
+ @Override
+ public int qtyKpLeaves() {
+ /* Pass-through. */
+ return getTokenFlow().qtyKpLeaves();
+ }
+
+ @Override
+ public CharSequence getText() {
+ /* Pass-through. */
+ return getTokenFlow().getText();
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-11 16:11:09
|
Revision: 12586
http://sourceforge.net/p/foray/code/12586
Author: victormote
Date: 2022-02-11 16:11:06 +0000 (Fri, 11 Feb 2022)
Log Message:
-----------
Conform to aXSL changes: Remove dependency of axsl-fotree on axsl-content. Add dependency of axsl-content on axsl-fotree, making axsl-content classes wrappers around axsl-fotree classes.
Modified Paths:
--------------
trunk/foray/foray-content/build.gradle
trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java
trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java
trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.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/AbstractCharacterSequence.java
trunk/foray/foray-layout/build.gradle
trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/ExternalGraphicPnr.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextPnr.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/InstreamForeignObjectPnr.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/LeaderPnr.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PageNumberCitationPnr.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PageNumberPnr.java
Added Paths:
-----------
trunk/foray/foray-content/src/main/java/org/foray/content/CharContent4a.java
trunk/foray/foray-content/src/main/java/org/foray/content/Content4a.java
trunk/foray/foray-content/src/main/java/org/foray/content/TextContent4a.java
trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java
Modified: trunk/foray/foray-content/build.gradle
===================================================================
--- trunk/foray/foray-content/build.gradle 2022-02-10 18:04:43 UTC (rev 12585)
+++ trunk/foray/foray-content/build.gradle 2022-02-11 16:11:06 UTC (rev 12586)
@@ -9,6 +9,7 @@
api (group: 'org.axsl', name: 'axsl-fotree', version: axslVersion) { transitive = false }
api (group: 'org.axsl', name: 'axsl-font', version: axslVersion) { transitive = false }
api (group: 'org.axsl', name: 'axsl-value', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-orthography', version: axslVersion) { transitive = false }
implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
Added: trunk/foray/foray-content/src/main/java/org/foray/content/CharContent4a.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/CharContent4a.java (rev 0)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/CharContent4a.java 2022-02-11 16:11:06 UTC (rev 12586)
@@ -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.content;
+
+import org.axsl.content.CharContent;
+import org.axsl.fotree.FoContext;
+import org.axsl.fotree.fo.FoTextCharacters;
+import org.axsl.value.group.TextModifiers;
+
+/**
+ * Content wrapper for {@link FoTextCharacters}.
+ */
+public class CharContent4a extends TextContent4a implements CharContent {
+
+ /** The wrapped content. */
+ private FoTextCharacters content;
+
+ /**
+ * Constructor.
+ * @param content The wrapped content.
+ * @param context The FO context for this content.
+ */
+ public CharContent4a(final FoTextCharacters content, final FoContext context) {
+ super(context);
+ this.content = content;
+ }
+
+ @Override
+ public FoTextCharacters getContent() {
+ return this.content;
+ }
+
+ @Override
+ public CharSequence inlineText(final TextModifiers textModifiers) {
+ return this.content.getRefinedText(getContext());
+ }
+
+ @Override
+ public boolean isLastItemInBlock() {
+ /* TODO: Remove this method from the interface. */
+// return getNextSibling() == null; <-- from AbstractOrderedTreeNode
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
Property changes on: trunk/foray/foray-content/src/main/java/org/foray/content/CharContent4a.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-content/src/main/java/org/foray/content/Content4a.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/Content4a.java (rev 0)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/Content4a.java 2022-02-11 16:11:06 UTC (rev 12586)
@@ -0,0 +1,58 @@
+/*
+ * 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.content;
+
+import org.axsl.content.Content;
+import org.axsl.fotree.FoContext;
+
+/**
+ * Abstract superclass for all FOray implementations of {@link Content}.
+ */
+public abstract class Content4a implements Content {
+
+ /** The FO context for this content. */
+ private FoContext context;
+
+ /**
+ * Constructor.
+ * @param context The FO context for this content.
+ */
+ public Content4a(final FoContext context) {
+ this.context = context;
+ }
+
+ /**
+ * Returns the FO context for this content.
+ * @return The FO context for this content.
+ */
+ public FoContext getContext() {
+ return this.context;
+ }
+
+}
Property changes on: trunk/foray/foray-content/src/main/java/org/foray/content/Content4a.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java 2022-02-10 18:04:43 UTC (rev 12585)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java 2022-02-11 16:11:06 UTC (rev 12586)
@@ -29,12 +29,13 @@
package org.foray.content;
import org.axsl.content.IndivisibleContent;
+import org.axsl.fotree.FoContext;
import org.axsl.fotree.fo.Leader;
/**
- * Content wrapper for {@link org.axsl.fotree.fo.Leader}.
+ * Content wrapper for {@link Leader}.
*/
-public class LeaderContent implements IndivisibleContent {
+public class LeaderContent extends Content4a implements IndivisibleContent {
/** The wrapped content. */
private Leader content;
@@ -42,8 +43,10 @@
/**
* Constructor.
* @param content The wrapped content.
+ * @param context The FO context for this content.
*/
- public LeaderContent(final Leader content) {
+ public LeaderContent(final Leader content, final FoContext context) {
+ super(context);
this.content = content;
}
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java 2022-02-10 18:04:43 UTC (rev 12585)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java 2022-02-11 16:11:06 UTC (rev 12586)
@@ -30,6 +30,8 @@
import org.axsl.content.IndivisibleContent;
import org.axsl.font.FontUse;
+import org.axsl.fotree.Fo;
+import org.axsl.fotree.FoContext;
import org.axsl.fotree.fo.prop.CommonFontPa;
/**
@@ -36,7 +38,7 @@
* Content wrapper for {@link org.axsl.fotree.fo.PageNumber}, {@link org.axsl.fotree.fo.PageNumberCitation}, and
* {@link org.axsl.fotree.fo.PageNumberCitationLast}.
*/
-public class PageReferenceContent implements IndivisibleContent {
+public class PageReferenceContent extends Content4a implements IndivisibleContent {
/** The number of placeholder digits that should be used when we do not yet know what the actual page-number is. */
private static final byte QTY_PLACEHOLDER_DIGITS = 3;
@@ -47,14 +49,16 @@
/**
* Constructor.
* @param content The wrapped content.
+ * @param context The FO context for this content.
*/
- public PageReferenceContent(final CommonFontPa content) {
+ public PageReferenceContent(final CommonFontPa content, final FoContext context) {
+ super(context);
this.content = content;
}
@Override
- public CommonFontPa getContent() {
- return this.content;
+ public Fo getContent() {
+ return (Fo) this.content;
}
@Override
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java 2022-02-10 18:04:43 UTC (rev 12585)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java 2022-02-11 16:11:06 UTC (rev 12586)
@@ -29,12 +29,13 @@
package org.foray.content;
import org.axsl.content.IndivisibleContent;
+import org.axsl.fotree.FoContext;
import org.axsl.fotree.FoScaled;
/**
- * Content wrapper for {@link org.axsl.fotree.FoScaled}.
+ * Content wrapper for {FoScaled}.
*/
-public class ScaledContent implements IndivisibleContent {
+public class ScaledContent extends Content4a implements IndivisibleContent {
/** The wrapped content. */
private FoScaled content;
@@ -42,8 +43,10 @@
/**
* Constructor.
* @param content The wrapped content.
+ * @param context The FO context for this content.
*/
- public ScaledContent(final FoScaled content) {
+ public ScaledContent(final FoScaled content, final FoContext context) {
+ super(context);
this.content = content;
}
Added: trunk/foray/foray-content/src/main/java/org/foray/content/TextContent4a.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/TextContent4a.java (rev 0)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/TextContent4a.java 2022-02-11 16:11:06 UTC (rev 12586)
@@ -0,0 +1,179 @@
+/*
+ * 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.content;
+
+import org.axsl.content.CharContent;
+import org.axsl.content.TextContent;
+import org.axsl.font.Font;
+import org.axsl.font.FontContext;
+import org.axsl.font.FontServer;
+import org.axsl.font.FontUse;
+import org.axsl.fotree.Fo;
+import org.axsl.fotree.FoContext;
+import org.axsl.fotree.fo.FoText;
+import org.axsl.fotree.fo.prop.WrapOptionPa;
+import org.axsl.orthography.Orthography;
+import org.axsl.value.WrapOption;
+
+/**
+ * Abstract superclass for text content wrappers.
+ */
+public abstract class TextContent4a extends Content4a implements TextContent {
+
+ /** The FO context. */
+ private FoContext context = null;
+
+ /**
+ * Constructor.
+ * @param context The FO context.
+ */
+ public TextContent4a(final FoContext context) {
+ super(context);
+ }
+
+ /**
+ * Returns the effective parent of the content item.
+ * @return The effective parent of the content item.
+ */
+ private FoText effectiveParent() {
+ /* TODO: Do we need this method? */
+// final Fo effectiveParent = getContent().effectiveParent(context);
+ return getContent();
+ }
+
+ @Override
+ public FontUse inlinePrimaryFont() {
+ return effectiveParent().getPrimaryFont(this.context);
+ }
+
+ @Override
+ public FontUse inlineSecondaryFont(final int codePoint) {
+ return effectiveParent().getSecondaryFont(this.context, codePoint);
+ }
+
+ @Override
+ public FontContext inlineFontContext() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int inlineFontSize() {
+ return effectiveParent().traitFontSize(this.context);
+ }
+
+ @Override
+ public int inlineLetterSpacingOptimum() {
+ return effectiveParent().traitLetterSpacingOpt(this.context);
+ }
+
+ @Override
+ public int inlineWordSpacingOptimum() {
+ return effectiveParent().traitWordSpacingOpt(this.context);
+ }
+
+ @Override
+ public boolean inlineWrapOption() {
+ /* TODO: Fix this. Need to find the ancestor that is a WrapOptionPa. */
+ final Fo effectiveParent = getContent().getParent();
+ if (effectiveParent instanceof WrapOptionPa) {
+ final WrapOptionPa wrapOption = (WrapOptionPa) effectiveParent;
+ return wrapOption.traitWrapOption(this.context) == WrapOption.WRAP;
+ }
+ /* The initial value. */
+ return true;
+ }
+
+ @Override
+ public boolean inlineHyphenate() {
+ return effectiveParent().traitHyphenate(this.context);
+ }
+
+ @Override
+ public int inlineHyphenationRemainCount() {
+ return effectiveParent().traitHyphenationRemainCharacterCount(this.context);
+ }
+
+ @Override
+ public int inlineHyphenationPushCount() {
+ return effectiveParent().traitHyphenationPushCharacterCount(this.context);
+ }
+
+ @Override
+ public int inlineHyphenationCharacter() {
+ return effectiveParent().traitHyphenationCharacter(this.context);
+ }
+
+ @Override
+ public boolean inlineIsFauxSmallCaps() {
+ if (effectiveParent().traitFontVariant(context) != Font.Variant.SMALL_CAPS) {
+ /* If we are not doing small-caps at all, we certainly should not be simulating it. */
+ return false;
+ }
+
+ /* TODO: If the font handles small-caps natively, that is, they do not need to be simulated,
+ * return false, regardless of whether it has also been configured to simulate small caps.
+ * Right now we rely on the user to configure the font correctly to avoid this. */
+
+ /* Has the font been configured to simulate small-caps? */
+ final FontUse fontUse = effectiveParent().getPrimaryFont(context);
+ if (fontUse.simulateSmallCaps() == FontServer.SMALL_CAP_SIMULATION_INVALID) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int inlineFauxSmallCapsFontSize() {
+ /* TODO: Fix this. It should be a percentage, and should come from the font. */
+// return effectiveParent().getFauxSmallCapFontSize(this.context);
+ return 0;
+ }
+
+ @Override
+ public CharContent nextContiguousLineText() {
+ /* TODO: Fix this. This method should be removed. */
+// return getNextContiguousTextInBlock(); <-- from FoObj
+
+ return null;
+ }
+
+ @Override
+ public CharContent previousContiguousLineText() {
+ /* TODO: Fix this. This method should be removed. */
+// return getPreviousContiguousTextInBlock(); <-- from FoObj
+ return null;
+ }
+
+ @Override
+ public Orthography inlineOrthography() {
+ return effectiveParent().getOrthography();
+ }
+
+}
Property changes on: trunk/foray/foray-content/src/main/java/org/foray/content/TextContent4a.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java (rev 0)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.java 2022-02-11 16:11:06 UTC (rev 12586)
@@ -0,0 +1,66 @@
+/*
+ * 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.content;
+
+import org.axsl.content.TextTokensContent;
+import org.axsl.fotree.FoContext;
+import org.axsl.fotree.fo.FoTextWords;
+import org.axsl.orthography.TextToken;
+import org.axsl.orthography.TextTokenFlow;
+
+/**
+ * Content wrapper for {@link FoTextWords}.
+ */
+public class TextTokensContent4a extends TextContent4a implements TextTokensContent {
+
+ /** The wrapped content. */
+ private FoTextWords content;
+
+ /**
+ * Constructor.
+ * @param content The wrapped content.
+ * @param context The FO context.
+ */
+ public TextTokensContent4a(final FoTextWords content, final FoContext context) {
+ super(context);
+ this.content = content;
+ }
+
+ @Override
+ public FoTextWords getContent() {
+ return this.content;
+ }
+
+ @Override
+ public TextTokenFlow<TextToken> getTokenFlow() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on: trunk/foray/foray-content/src/main/java/org/foray/content/TextTokensContent4a.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/FoObj.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java 2022-02-10 18:04:43 UTC (rev 12585)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java 2022-02-11 16:11:06 UTC (rev 12586)
@@ -66,7 +66,6 @@
import org.axsl.fotree.FoAllProperties;
import org.axsl.fotree.FoContext;
import org.axsl.fotree.FoInlineContext;
-import org.axsl.fotree.FoLineText;
import org.axsl.fotree.FoTreeException;
import org.axsl.fotree.fo.FoTextCharacters;
import org.axsl.fotree.fo.Marker;
@@ -3157,7 +3156,7 @@
* @return The underlying text of the first descendant text item.
*/
public CharSequence firstTextSegment(final FoContext context) {
- final FoLineText firstLineText = firstLineText();
+ final FoTextCharacters firstLineText = firstLineText();
if (firstLineText == null) {
return null;
}
@@ -3168,16 +3167,16 @@
* Recursively searched the descendants of this object looking for and returning the first descendant text item.
* @return The first descendant text item.
*/
- public FoLineText firstLineText() {
+ public FoTextCharacters firstLineText() {
if (this.getChildren() == null) {
return null;
}
for (int i = 0; i < qtyFormattingObjectChildren(); i++) {
final Object child = this.getChildren().get(i);
- if (child instanceof FoLineText) {
- return (FoLineText) child;
+ if (child instanceof FoTextCharacters) {
+ return (FoTextCharacters) child;
}
- FoLineText firstDescendant = null;
+ FoTextCharacters firstDescendant = null;
if (child instanceof FoObj) {
firstDescendant = ((FoObj) child).firstLineText();
}
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-02-10 18:04:43 UTC (rev 12585)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractCharacterSequence.java 2022-02-11 16:11:06 UTC (rev 12586)
@@ -32,17 +32,9 @@
import org.foray.common.i18n.Language4a;
import org.foray.fotree.FoObj;
-import org.axsl.content.CharContent;
-import org.axsl.font.Font;
-import org.axsl.font.FontContext;
-import org.axsl.font.FontServer;
-import org.axsl.font.FontUse;
import org.axsl.fotree.FoContext;
import org.axsl.fotree.fo.FoTextCharacters;
import org.axsl.fotree.fo.GraftingPoint;
-import org.axsl.orthography.Orthography;
-import org.axsl.value.WrapOption;
-import org.axsl.value.group.TextModifiers;
/**
* Abstract superclass for representations of characters.
@@ -58,91 +50,10 @@
}
@Override
- public CharSequence inlineText(final TextModifiers textModifers) {
- return inlineText(null);
- }
-
- @Override
public CharSequence inlineText(final FoContext context) {
return getRefinedText(context);
}
- @Override
- public FontUse inlinePrimaryFont() {
- return inlinePrimaryFont(null);
- }
-
- @Override
- public FontUse inlinePrimaryFont(final FoContext context) {
- return getPrimaryFont(context);
- }
-
- @Override
- public FontUse inlineSecondaryFont(final char c) {
- return inlineSecondaryFont(null, c);
- }
-
- @Override
- public FontUse inlineSecondaryFont(final FoContext context, final char c) {
- final FoObj effectiveParent = effectiveParent(context);
- return effectiveParent.getSecondaryFont(context, c);
- }
-
- @Override
- public int inlineFontSize() {
- return inlineFontSize(null);
- }
-
- @Override
- public int inlineFontSize(final FoContext context) {
- final FoObj effectiveParent = effectiveParent(context);
- return effectiveParent.traitFontSize(context);
- }
-
- @Override
- public int inlineLetterSpacingOptimum() {
- return inlineLetterSpacingOptimum(null);
- }
-
- @Override
- public int inlineLetterSpacingOptimum(final FoContext context) {
- final FoObj effectiveParent = effectiveParent(context);
- return effectiveParent.traitLetterSpacingOpt(context);
- }
-
- @Override
- public int inlineWordSpacingOptimum() {
- return inlineWordSpacingOptimum(null);
- }
-
- @Override
- public int inlineWordSpacingOptimum(final FoContext context) {
- final FoObj effectiveParent = effectiveParent(context);
- return effectiveParent.traitWordSpacingOpt(context);
- }
-
- @Override
- public boolean inlineWrapOption() {
- return inlineWrapOption(null);
- }
-
- @Override
- public boolean inlineWrapOption(final FoContext context) {
- final FoObj effectiveParent = effectiveParent(context);
- return effectiveParent.traitWrapOption(context) == WrapOption.WRAP;
- }
-
- @Override
- public boolean inlineHyphenate() {
- return inlineHyphenate(null);
- }
-
- @Override
- public boolean inlineHyphenate(final FoContext context) {
- final FoObj effectiveParent = effectiveParent(context);
- return effectiveParent.traitHyphenate(context);
- }
-
/**
* Returns the language code for this node.
* @return The language code for this node.
@@ -162,94 +73,6 @@
}
@Override
- public Orthography inlineOrthography() {
- return getOrthography();
- }
-
- @Override
- public int inlineHyphenationRemainCount() {
- return inlineHyphenationRemainCount(null);
- }
-
- @Override
- public int inlineHyphenationRemainCount(final FoContext context) {
- final FoObj effectiveParent = effectiveParent(context);
- return effectiveParent.traitHyphenationRemainCharacterCount(context);
- }
-
- @Override
- public int inlineHyphenationPushCount() {
- return inlineHyphenationPushCount(null);
- }
-
- @Override
- public int inlineHyphenationPushCount(final FoContext context) {
- final FoObj effectiveParent = effectiveParent(context);
- return effectiveParent.traitHyphenationPushCharacterCount(context);
- }
-
- @Override
- public int inlineHyphenationCharacter() {
- return inlineHyphenationCharacter(null);
- }
-
- @Override
- public int inlineHyphenationCharacter(final FoContext context) {
- final FoObj effectiveParent = effectiveParent(context);
- return effectiveParent.traitHyphenationCharacter(context);
- }
-
- @Override
- public boolean inlineIsFauxSmallCaps() {
- return inlineIsFauxSmallCaps(null);
- }
-
- @Override
- public boolean inlineIsFauxSmallCaps(final FoContext context) {
- if (traitFontVariant(context) != Font.Variant.SMALL_CAPS) {
- /* If we are not doing small-caps at all, we certainly should not be simulating it. */
- return false;
- }
-
- /* TODO: If the font handles small-caps natively, that is, they do not need to be simulated,
- * return false, regardless of whether it has also been configured to simulate small caps.
- * Right now we rely on the user to configure the font correctly to avoid this. */
-
- /* Has the font been configured to simulate small-caps? */
- final FontUse fontUse = getPrimaryFont(context);
- if (fontUse.simulateSmallCaps() == FontServer.SMALL_CAP_SIMULATION_INVALID) {
- return false;
- }
- return true;
- }
-
- @Override
- public int inlineFauxSmallCapsFontSize() {
- return inlineFauxSmallCapsFontSize(null);
- }
-
- @Override
- public int inlineFauxSmallCapsFontSize(final FoContext context) {
- final FoObj effectiveParent = effectiveParent(context);
- return effectiveParent.getFauxSmallCapFontSize(context);
- }
-
- @Override
- public CharContent nextContiguousLineText() {
- return getNextContiguousTextInBlock();
- }
-
- @Override
- public CharContent previousContiguousLineText() {
- return getPreviousContiguousTextInBlock();
- }
-
- @Override
- public boolean isLastItemInBlock() {
- return getNextSibling() == null;
- }
-
- @Override
public String getSystemId() {
return this.getParent().getSystemId();
}
@@ -287,10 +110,4 @@
return null;
}
- @Override
- public FontContext inlineFontContext() {
- // TODO Auto-generated method stub
- return null;
- }
-
}
Modified: trunk/foray/foray-layout/build.gradle
===================================================================
--- trunk/foray/foray-layout/build.gradle 2022-02-10 18:04:43 UTC (rev 12585)
+++ trunk/foray/foray-layout/build.gradle 2022-02-11 16:11:06 UTC (rev 12586)
@@ -10,6 +10,8 @@
api group: 'org.axsl', name: 'axsl-linebreak', version: axslVersion
api project(':foray-common')
+ /* TODO: We should be able to eliminate the dependency on foray-content. */
+ api project(':foray-content')
implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
}
Modified: trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java
===================================================================
--- trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java 2022-02-10 18:04:43 UTC (rev 12585)
+++ trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java 2022-02-11 16:11:06 UTC (rev 12586)
@@ -28,6 +28,8 @@
package org.foray.layout;
+import org.foray.content.CharContent4a;
+
import org.axsl.area.AreaTree;
import org.axsl.area.AreaTreeException;
import org.axsl.area.LineArea;
@@ -37,7 +39,6 @@
import org.axsl.area.factory.LineContentFactory;
import org.axsl.content.CharContent;
import org.axsl.content.IndivisibleContent;
-import org.axsl.fotree.FoLineText;
import org.axsl.fotree.fo.ExternalGraphic;
import org.axsl.fotree.fo.FoTextCharacters;
import org.axsl.fotree.fo.InstreamForeignObject;
@@ -115,9 +116,9 @@
final LineArea lineArea = (LineArea) lineOutput;
CharContent textToUse = text;
- if (textToUse instanceof org.axsl.fotree.FoLineText) {
- final FoLineText foLineText = (FoLineText) textToUse;
- textToUse = foLineText;
+ if (textToUse instanceof FoTextCharacters) {
+ final FoTextCharacters foLineText = (FoTextCharacters) textToUse;
+ textToUse = new CharContent4a(foLineText, lineArea);
}
LineContentFactory factory = lineArea;
if (this.areaStack.size() > 0) {
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/ExternalGraphicPnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/ExternalGraphicPnr.java 2022-02-10 18:04:43 UTC (rev 12585)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/ExternalGraphicPnr.java 2022-02-11 16:11:06 UTC (rev 12586)
@@ -77,7 +77,7 @@
// Not enough room on the page for this.
return Status.AREA_FULL_NONE;
}
- return addNonTextContent(lineArea, new ScaledContent(this.realFONode));
+ return addNonTextContent(lineArea, new ScaledContent(this.realFONode, lineArea));
}
@Override
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java 2022-02-10 18:04:43 UTC (rev 12585)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java 2022-02-11 16:11:06 UTC (rev 12586)
@@ -28,6 +28,7 @@
package org.foray.pioneer;
+import org.foray.content.CharContent4a;
import org.foray.pioneer.lb.EagerLineBreaker;
import org.foray.pioneer.lb.TextServer4a;
@@ -42,7 +43,7 @@
import org.axsl.font.FontConsumer;
import org.axsl.fotree.Fo;
import org.axsl.fotree.FoContext;
-import org.axsl.fotree.FoLineText;
+import org.axsl.fotree.fo.FoTextCharacters;
import org.axsl.fotree.fo.TableCell;
import org.axsl.text.TextException;
@@ -188,8 +189,8 @@
* line.
* @throws AreaTreeException For errors during layout.
*/
- protected int addTextItemToLine(final LineArea lineArea, final FoLineText lineText, final int start, final int end)
- throws AreaTreeException {
+ protected int addTextItemToLine(final LineArea lineArea, final FoTextCharacters lineText, final int start,
+ final int end) throws AreaTreeException {
final FoContext foContext = lineArea;
EagerLineBreaker lb = this.layout.getEagerLineBreaker();
if (lb == null) {
@@ -201,7 +202,8 @@
}
int status = 0;
try {
- status = lb.processLineContent(lineText, foContext, start, end, lineArea);
+ final CharContent4a charContent = new CharContent4a(lineText, lineArea);
+ status = lb.processLineContent(charContent, foContext, start, end, lineArea);
} catch (final TextException e) {
final Fo generatedBy = lineArea.traitGeneratedBy();
throw new AreaTreeException("Error in text layout:\n"
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextPnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextPnr.java 2022-02-10 18:04:43 UTC (rev 12585)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoTextPnr.java 2022-02-11 16:11:06 UTC (rev 12586)
@@ -31,7 +31,6 @@
import org.axsl.area.AreaNode;
import org.axsl.area.AreaTreeException;
import org.axsl.area.LineArea;
-import org.axsl.fotree.FoLineText;
import org.axsl.fotree.fo.FoTextCharacters;
/**
@@ -79,7 +78,7 @@
* If the first six characters have been laid out (indices 0-5), then 6 should be returned.
* @throws AreaTreeException For errors during layout.
*/
- private int addText(final FoLineText lineText, final AreaNode areaNode, final int start)
+ private int addText(final FoTextCharacters lineText, final AreaNode areaNode, final int start)
throws AreaTreeException {
final int end = lineText.inlineText(areaNode).length();
final LineArea la = this.activeLineArea(areaNode);
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/InstreamForeignObjectPnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/InstreamForeignObjectPnr.java 2022-02-10 18:04:43 UTC (rev 12585)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/InstreamForeignObjectPnr.java 2022-02-11 16:11:06 UTC (rev 12586)
@@ -61,7 +61,7 @@
// Not enough room on the page for this.
return Status.AREA_FULL_NONE;
}
- return addNonTextContent(lineArea, new ScaledContent(this.node));
+ return addNonTextContent(lineArea, new ScaledContent(this.node, lineArea));
}
@Override
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/LeaderPnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/LeaderPnr.java 2022-02-10 18:04:43 UTC (rev 12585)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/LeaderPnr.java 2022-02-11 16:11:06 UTC (rev 12586)
@@ -60,7 +60,7 @@
// Not enough room on the page for this.
return Status.AREA_FULL_NONE;
}
- return addNonTextContent(lineArea, new LeaderContent(this.node));
+ return addNonTextContent(lineArea, new LeaderContent(this.node, lineArea));
}
@Override
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PageNumberCitationPnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PageNumberCitationPnr.java 2022-02-10 18:04:43 UTC (rev 12585)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PageNumberCitationPnr.java 2022-02-11 16:11:06 UTC (rev 12586)
@@ -61,7 +61,7 @@
// Not enough room on the page for this.
return Status.AREA_FULL_NONE;
}
- return addNonTextContent(lineArea, new PageReferenceContent(this.node));
+ return addNonTextContent(lineArea, new PageReferenceContent(this.node, lineArea));
}
@Override
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PageNumberPnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PageNumberPnr.java 2022-02-10 18:04:43 UTC (rev 12585)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PageNumberPnr.java 2022-02-11 16:11:06 UTC (rev 12586)
@@ -60,7 +60,7 @@
// Not enough room on the page for this.
return Status.AREA_FULL_NONE;
}
- return addNonTextContent(lineArea, new PageReferenceContent(this.node));
+ return addNonTextContent(lineArea, new PageReferenceContent(this.node, lineArea));
}
@Override
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-10 18:04:45
|
Revision: 12585
http://sourceforge.net/p/foray/code/12585
Author: victormote
Date: 2022-02-10 18:04:43 +0000 (Thu, 10 Feb 2022)
Log Message:
-----------
Conform to aXSL change: Narrow scope of isLastItemInBlock() method.
Modified Paths:
--------------
trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java
trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java
trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java 2022-02-10 17:43:14 UTC (rev 12584)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java 2022-02-10 18:04:43 UTC (rev 12585)
@@ -29,7 +29,6 @@
package org.foray.content;
import org.axsl.content.IndivisibleContent;
-import org.axsl.fotree.Fo;
import org.axsl.fotree.fo.Leader;
/**
@@ -68,13 +67,4 @@
return this.content.traitLeaderLengthMax(null);
}
- @Override
- public boolean isLastItemInBlock() {
- /* TODO: This is not right. */
- final Fo parent = this.content.getParent();
- final int qtySiblings = parent.qtyFormattingObjectChildren();
- final int myIndex = parent.getIndex(this.content);
- return myIndex >= qtySiblings - 1;
- }
-
}
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java 2022-02-10 17:43:14 UTC (rev 12584)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java 2022-02-10 18:04:43 UTC (rev 12585)
@@ -80,10 +80,4 @@
return inlineSizeOptimum(lineLength);
}
- @Override
- public boolean isLastItemInBlock() {
- /* TODO: This is not right. */
- return false;
- }
-
}
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java 2022-02-10 17:43:14 UTC (rev 12584)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java 2022-02-10 18:04:43 UTC (rev 12585)
@@ -29,7 +29,6 @@
package org.foray.content;
import org.axsl.content.IndivisibleContent;
-import org.axsl.fotree.Fo;
import org.axsl.fotree.FoScaled;
/**
@@ -71,13 +70,4 @@
return inlineSizeOptimum(lineLength);
}
- @Override
- public boolean isLastItemInBlock() {
- /* TODO: This is not right. */
- final Fo parent = this.content.getParent();
- final int qtySiblings = parent.qtyFormattingObjectChildren();
- final int myIndex = parent.getIndex(this.content);
- return myIndex >= qtySiblings - 1;
- }
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-10 17:43:17
|
Revision: 12584
http://sourceforge.net/p/foray/code/12584
Author: victormote
Date: 2022-02-10 17:43:14 +0000 (Thu, 10 Feb 2022)
Log Message:
-----------
1. Conform to aXSL change: For non-text line content, remove implementation of IndivisibleContent, which will now be used by wrappers. 2. Add foray-content project to hold those new wrappers.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractPageReference.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Leader4a.java
trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java
trunk/foray/foray-pioneer/build.gradle
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/ExternalGraphicPnr.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/InstreamForeignObjectPnr.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/LeaderPnr.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PageNumberCitationPnr.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PageNumberPnr.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/EagerLineBreaker.java
trunk/foray/settings.gradle
Added Paths:
-----------
trunk/foray/foray-content/
trunk/foray/foray-content/build.gradle
trunk/foray/foray-content/src/
trunk/foray/foray-content/src/main/
trunk/foray/foray-content/src/main/java/
trunk/foray/foray-content/src/main/java/org/
trunk/foray/foray-content/src/main/java/org/foray/
trunk/foray/foray-content/src/main/java/org/foray/content/
trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java
trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java
trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java
trunk/foray/foray-content/src/main/java/org/foray/content/package-info.java
Added: trunk/foray/foray-content/build.gradle
===================================================================
--- trunk/foray/foray-content/build.gradle (rev 0)
+++ trunk/foray/foray-content/build.gradle 2022-02-10 17:43:14 UTC (rev 12584)
@@ -0,0 +1,25 @@
+description = 'foray-content'
+
+dependencies {
+ api group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
+
+ /* Turn transitive resolution OFF for both aXSL and FOray modules, for greater design visibility. */
+
+ api (group: 'org.axsl', name: 'axsl-content', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-fotree', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-font', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-value', version: axslVersion) { 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
+}
+
+javadoc {
+ options.windowTitle = "FOray Content API"
+ options.docTitle = "FOray Content API"
+ options.header = "FOray Content API ${version}"
+}
+
+/* Last line of script. */
Property changes on: trunk/foray/foray-content/build.gradle
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java (rev 0)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java 2022-02-10 17:43:14 UTC (rev 12584)
@@ -0,0 +1,80 @@
+/*
+ * 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.content;
+
+import org.axsl.content.IndivisibleContent;
+import org.axsl.fotree.Fo;
+import org.axsl.fotree.fo.Leader;
+
+/**
+ * Content wrapper for {@link org.axsl.fotree.fo.Leader}.
+ */
+public class LeaderContent implements IndivisibleContent {
+
+ /** The wrapped content. */
+ private Leader content;
+
+ /**
+ * Constructor.
+ * @param content The wrapped content.
+ */
+ public LeaderContent(final Leader content) {
+ this.content = content;
+ }
+
+ @Override
+ public Leader getContent() {
+ return this.content;
+ }
+
+ @Override
+ public int inlineSizeOptimum(final int lineLength) {
+ return this.content.traitLeaderLengthOpt(null);
+ }
+
+ @Override
+ public int inlineSizeMinimum(final int lineLength) {
+ return this.content.traitLeaderLengthMin(null);
+ }
+
+ @Override
+ public int inlineSizeMaximum(final int lineLength) {
+ return this.content.traitLeaderLengthMax(null);
+ }
+
+ @Override
+ public boolean isLastItemInBlock() {
+ /* TODO: This is not right. */
+ final Fo parent = this.content.getParent();
+ final int qtySiblings = parent.qtyFormattingObjectChildren();
+ final int myIndex = parent.getIndex(this.content);
+ return myIndex >= qtySiblings - 1;
+ }
+
+}
Property changes on: trunk/foray/foray-content/src/main/java/org/foray/content/LeaderContent.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java (rev 0)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java 2022-02-10 17:43:14 UTC (rev 12584)
@@ -0,0 +1,89 @@
+/*
+ * 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.content;
+
+import org.axsl.content.IndivisibleContent;
+import org.axsl.font.FontUse;
+import org.axsl.fotree.fo.prop.CommonFontPa;
+
+/**
+ * Content wrapper for {@link org.axsl.fotree.fo.PageNumber}, {@link org.axsl.fotree.fo.PageNumberCitation}, and
+ * {@link org.axsl.fotree.fo.PageNumberCitationLast}.
+ */
+public class PageReferenceContent implements IndivisibleContent {
+
+ /** The number of placeholder digits that should be used when we do not yet know what the actual page-number is. */
+ private static final byte QTY_PLACEHOLDER_DIGITS = 3;
+
+ /** The wrapped content. */
+ private CommonFontPa content;
+
+ /**
+ * Constructor.
+ * @param content The wrapped content.
+ */
+ public PageReferenceContent(final CommonFontPa content) {
+ this.content = content;
+ }
+
+ @Override
+ public CommonFontPa getContent() {
+ return this.content;
+ }
+
+ @Override
+ public int inlineSizeOptimum(final int lineLength) {
+ /* TODO: Fix this method after we add the context to this class. */
+ final CommonFontPa asText = (CommonFontPa) this.content;
+ final FontUse fontUse = asText.getPrimaryFont(null);
+ final int fontSize = asText.traitFontSize(null);
+ final int zeroWidth = fontUse.width('0', fontSize);
+ // This is an estimate for purposes of layout.
+ return zeroWidth * QTY_PLACEHOLDER_DIGITS;
+ }
+
+ @Override
+ public int inlineSizeMinimum(final int lineLength) {
+ /* TODO: Fix this method after we add the context to this class. */
+ return inlineSizeOptimum(lineLength);
+ }
+
+ @Override
+ public int inlineSizeMaximum(final int lineLength) {
+ /* TODO: Fix this method after we add the context to this class. */
+ return inlineSizeOptimum(lineLength);
+ }
+
+ @Override
+ public boolean isLastItemInBlock() {
+ /* TODO: This is not right. */
+ return false;
+ }
+
+}
Property changes on: trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java (rev 0)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java 2022-02-10 17:43:14 UTC (rev 12584)
@@ -0,0 +1,83 @@
+/*
+ * 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.content;
+
+import org.axsl.content.IndivisibleContent;
+import org.axsl.fotree.Fo;
+import org.axsl.fotree.FoScaled;
+
+/**
+ * Content wrapper for {@link org.axsl.fotree.FoScaled}.
+ */
+public class ScaledContent implements IndivisibleContent {
+
+ /** The wrapped content. */
+ private FoScaled content;
+
+ /**
+ * Constructor.
+ * @param content The wrapped content.
+ */
+ public ScaledContent(final FoScaled content) {
+ this.content = content;
+ }
+
+ @Override
+ public FoScaled getContent() {
+ return this.content;
+ }
+
+ @Override
+ public int inlineSizeOptimum(final int lineLength) {
+ /* TODO: Fix this method after we add the context to this class. */
+ return this.content.viewportIpd(null);
+ }
+
+ @Override
+ public int inlineSizeMinimum(final int lineLength) {
+ /* TODO: Fix this method after we add the context to this class. */
+ return inlineSizeOptimum(lineLength);
+ }
+
+ @Override
+ public int inlineSizeMaximum(final int lineLength) {
+ /* TODO: Fix this method after we add the context to this class. */
+ return inlineSizeOptimum(lineLength);
+ }
+
+ @Override
+ public boolean isLastItemInBlock() {
+ /* TODO: This is not right. */
+ final Fo parent = this.content.getParent();
+ final int qtySiblings = parent.qtyFormattingObjectChildren();
+ final int myIndex = parent.getIndex(this.content);
+ return myIndex >= qtySiblings - 1;
+ }
+
+}
Property changes on: trunk/foray/foray-content/src/main/java/org/foray/content/ScaledContent.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-content/src/main/java/org/foray/content/package-info.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/package-info.java (rev 0)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/package-info.java 2022-02-10 17:43:14 UTC (rev 12584)
@@ -0,0 +1,33 @@
+/*
+ * 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$
+ */
+
+/**
+ * <p>Classes that wrap content for purposes of line-breaking.</p>
+ */
+
+package org.foray.content;
Property changes on: trunk/foray/foray-content/src/main/java/org/foray/content/package-info.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/AbstractPageReference.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractPageReference.java 2022-02-09 18:03:04 UTC (rev 12583)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractPageReference.java 2022-02-10 17:43:14 UTC (rev 12584)
@@ -32,7 +32,6 @@
import org.foray.fotree.Namespace;
import org.foray.fotree.PropertyList;
-import org.axsl.content.IndivisibleContent;
import org.axsl.fotree.FoTreeException;
import java.util.List;
@@ -41,12 +40,8 @@
* Abstract superclass for page-number, page-number-citation, and
* page-number-citation-last.
*/
-public abstract class AbstractPageReference extends FoObj implements IndivisibleContent {
+public abstract class AbstractPageReference extends FoObj {
- /** The number of placeholder digits that should be used when we do not yet
- * know what the actual page-number is. */
- protected static final byte QTY_PLACEHOLDER_DIGITS = 3;
-
/** The property list for this object. */
private PropertyList propertyList;
@@ -112,29 +107,6 @@
}
@Override
- public int inlineSizeOptimum(final int lineLength) {
- final int zeroWidth = getPrimaryFont(null).width('0', traitFontSize(null));
- // This is an estimate for purposes of layout.
- return (zeroWidth + traitLetterSpacingOpt(null))
- * AbstractPageReference.QTY_PLACEHOLDER_DIGITS;
- }
-
- @Override
- public int inlineSizeMinimum(final int lineLength) {
- return inlineSizeOptimum(lineLength);
- }
-
- @Override
- public int inlineSizeMaximum(final int lineLength) {
- return inlineSizeOptimum(lineLength);
- }
-
- @Override
- public boolean isLastItemInBlock() {
- return this.getNextSibling() == null;
- }
-
- @Override
public PropertyList getPropertyList() {
return this.propertyList;
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java 2022-02-09 18:03:04 UTC (rev 12583)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java 2022-02-10 17:43:14 UTC (rev 12584)
@@ -175,26 +175,6 @@
}
@Override
- public int inlineSizeOptimum(final int lineLength) {
- return this.viewportIpd(null);
- }
-
- @Override
- public int inlineSizeMinimum(final int lineLength) {
- return this.viewportIpd(null);
- }
-
- @Override
- public int inlineSizeMaximum(final int lineLength) {
- return this.viewportIpd(null);
- }
-
- @Override
- public boolean isLastItemInBlock() {
- return this.getNextSibling() == null;
- }
-
- @Override
public FoObj getParent() {
return this.parent;
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java 2022-02-09 18:03:04 UTC (rev 12583)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java 2022-02-10 17:43:14 UTC (rev 12584)
@@ -123,26 +123,6 @@
}
@Override
- public int inlineSizeOptimum(final int lineLength) {
- return this.viewportIpd(null);
- }
-
- @Override
- public int inlineSizeMinimum(final int lineLength) {
- return this.viewportIpd(null);
- }
-
- @Override
- public int inlineSizeMaximum(final int lineLength) {
- return this.viewportIpd(null);
- }
-
- @Override
- public boolean isLastItemInBlock() {
- return this.getNextSibling() == null;
- }
-
- @Override
public FoObj getParent() {
return this.parent;
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Leader4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Leader4a.java 2022-02-09 18:03:04 UTC (rev 12583)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Leader4a.java 2022-02-10 17:43:14 UTC (rev 12584)
@@ -102,21 +102,6 @@
return this.getFoTree().getFONamespace();
}
- @Override
- public int inlineSizeOptimum(final int lineLength) {
- return traitLeaderLengthOpt(null);
- }
-
- @Override
- public int inlineSizeMinimum(final int lineLength) {
- return traitLeaderLengthMin(null);
- }
-
- @Override
- public int inlineSizeMaximum(final int lineLength) {
- return traitLeaderLengthMax(null);
- }
-
/**
* {@inheritDoc}
* Overrides FoObj method, because this is the Leader being sought.
@@ -127,11 +112,6 @@
}
@Override
- public boolean isLastItemInBlock() {
- return this.getNextSibling() == null;
- }
-
- @Override
public <T> T acceptVisitor(final FoVisitor<T> visitor) {
return visitor.visit(this);
}
Modified: trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java
===================================================================
--- trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java 2022-02-09 18:03:04 UTC (rev 12583)
+++ trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java 2022-02-10 17:43:14 UTC (rev 12584)
@@ -133,25 +133,26 @@
}
@Override
- public void handleLineBreakNonText(final OutputLine lineOutput,
- final IndivisibleContent nonText, final int sizeInline)
- throws TextException {
+ public void handleLineBreakNonText(final OutputLine lineOutput, final IndivisibleContent nonText,
+ final int sizeInline) throws TextException {
checkLayoutTarget(lineOutput);
final LineArea lineArea = (LineArea) lineOutput;
- IndivisibleContent nonTextToUse = nonText;
- if (nonTextToUse instanceof IndivisibleContent) {
- final IndivisibleContent foLineNonText = (IndivisibleContent) nonTextToUse;
- nonTextToUse = foLineNonText; //.getWrapped();
- }
+// IndivisibleContent nonTextToUse = nonText;
+// if (nonTextToUse instanceof IndivisibleContent) {
+// final IndivisibleContent foLineNonText = (IndivisibleContent) nonTextToUse;
+// nonTextToUse = foLineNonText; //.getWrapped();
+// }
LineContentFactory factory = lineArea;
if (this.areaStack.size() > 0) {
factory = this.areaStack.peek();
}
+
+ final Object nonTextToUse = nonText.getContent();
+
if (nonTextToUse instanceof InstreamForeignObject) {
- final InstreamForeignObject ifo = (InstreamForeignObject)
- nonTextToUse;
+ final InstreamForeignObject ifo = (InstreamForeignObject) nonTextToUse;
factory.makeForeignObjectArea(ifo, sizeInline);
} else if (nonTextToUse instanceof ExternalGraphic) {
final ExternalGraphic graphic = (ExternalGraphic) nonTextToUse;
Modified: trunk/foray/foray-pioneer/build.gradle
===================================================================
--- trunk/foray/foray-pioneer/build.gradle 2022-02-09 18:03:04 UTC (rev 12583)
+++ trunk/foray/foray-pioneer/build.gradle 2022-02-10 17:43:14 UTC (rev 12584)
@@ -16,6 +16,7 @@
api project(':foray-common')
api project(':foray-layout')
+ api project(':foray-content')
implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackClassicVersion
}
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/ExternalGraphicPnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/ExternalGraphicPnr.java 2022-02-09 18:03:04 UTC (rev 12583)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/ExternalGraphicPnr.java 2022-02-10 17:43:14 UTC (rev 12584)
@@ -28,6 +28,8 @@
package org.foray.pioneer;
+import org.foray.content.ScaledContent;
+
import org.axsl.area.AreaNode;
import org.axsl.area.AreaTreeException;
import org.axsl.area.LineArea;
@@ -66,8 +68,7 @@
return Status.OK;
}
final int height = this.realFONode.viewportBpd(areaNode);
- if (areaNode.nearestArea().pdAvailable()
- < height) {
+ if (areaNode.nearestArea().pdAvailable() < height) {
return Status.AREA_FULL_NONE;
}
@@ -76,7 +77,7 @@
// Not enough room on the page for this.
return Status.AREA_FULL_NONE;
}
- return addNonTextContent(lineArea);
+ return addNonTextContent(lineArea, new ScaledContent(this.realFONode));
}
@Override
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java 2022-02-09 18:03:04 UTC (rev 12583)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java 2022-02-10 17:43:14 UTC (rev 12584)
@@ -224,16 +224,14 @@
* not fit onto the current line.
* @throws AreaTreeException For errors during layout.
*/
- protected int addNonTextItemToLine(final LineArea lineArea,
- final IndivisibleContent nonText, final FoContext foContext)
- throws AreaTreeException {
+ protected int addNonTextItemToLine(final LineArea lineArea, final IndivisibleContent nonText,
+ final FoContext foContext) throws AreaTreeException {
EagerLineBreaker lb = this.layout.getEagerLineBreaker();
if (lb == null) {
final AreaTree areaTree = lineArea.getAreaTree();
final TextServer4a textServer = getLayout().getTextServer();
final FontConsumer fontConsumer = areaTree.getFontConsumer();
- lb = textServer.provideEagerLineBreaker(null,
- this.layout, fontConsumer);
+ lb = textServer.provideEagerLineBreaker(null, this.layout, fontConsumer);
}
int status = 0;
final IndivisibleContent contextAware = nonText;
@@ -251,17 +249,20 @@
/**
* Add this object's non-text line content to a line.
* @param inputLineArea The line to which the content should be added.
+ * @param content The content item to be added to {@code inputLineArea}.
* @return The status of the layout attempt.
* @throws AreaTreeException For errors during layout.
*/
- protected Status addNonTextContent(final LineArea inputLineArea) throws AreaTreeException {
+ protected Status addNonTextContent(final LineArea inputLineArea, final IndivisibleContent content)
+ throws AreaTreeException {
final FoContext foContext = inputLineArea;
final Fo node = this.getFONode();
LineArea lineArea = inputLineArea;
- if (! (node instanceof IndivisibleContent)) {
- return Status.UNKNOWN;
- }
- final IndivisibleContent nonText = (IndivisibleContent) node;
+// if (! (node instanceof IndivisibleContent)) {
+// return Status.UNKNOWN;
+// }
+// final IndivisibleContent nonText = (IndivisibleContent) node;
+ final IndivisibleContent nonText = content;
// this should start a new page
if (lineArea == null) {
return Status.AREA_FULL_SOME;
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/InstreamForeignObjectPnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/InstreamForeignObjectPnr.java 2022-02-09 18:03:04 UTC (rev 12583)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/InstreamForeignObjectPnr.java 2022-02-10 17:43:14 UTC (rev 12584)
@@ -28,6 +28,8 @@
package org.foray.pioneer;
+import org.foray.content.ScaledContent;
+
import org.axsl.area.AreaNode;
import org.axsl.area.AreaTreeException;
import org.axsl.area.LineArea;
@@ -59,7 +61,7 @@
// Not enough room on the page for this.
return Status.AREA_FULL_NONE;
}
- return addNonTextContent(lineArea);
+ return addNonTextContent(lineArea, new ScaledContent(this.node));
}
@Override
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/LeaderPnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/LeaderPnr.java 2022-02-09 18:03:04 UTC (rev 12583)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/LeaderPnr.java 2022-02-10 17:43:14 UTC (rev 12584)
@@ -28,6 +28,8 @@
package org.foray.pioneer;
+import org.foray.content.LeaderContent;
+
import org.axsl.area.AreaNode;
import org.axsl.area.AreaTreeException;
import org.axsl.area.LineArea;
@@ -58,7 +60,7 @@
// Not enough room on the page for this.
return Status.AREA_FULL_NONE;
}
- return addNonTextContent(lineArea);
+ return addNonTextContent(lineArea, new LeaderContent(this.node));
}
@Override
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PageNumberCitationPnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PageNumberCitationPnr.java 2022-02-09 18:03:04 UTC (rev 12583)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PageNumberCitationPnr.java 2022-02-10 17:43:14 UTC (rev 12584)
@@ -28,6 +28,8 @@
package org.foray.pioneer;
+import org.foray.content.PageReferenceContent;
+
import org.axsl.area.AreaNode;
import org.axsl.area.AreaTreeException;
import org.axsl.area.LineArea;
@@ -59,7 +61,7 @@
// Not enough room on the page for this.
return Status.AREA_FULL_NONE;
}
- return addNonTextContent(lineArea);
+ return addNonTextContent(lineArea, new PageReferenceContent(this.node));
}
@Override
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PageNumberPnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PageNumberPnr.java 2022-02-09 18:03:04 UTC (rev 12583)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/PageNumberPnr.java 2022-02-10 17:43:14 UTC (rev 12584)
@@ -28,6 +28,8 @@
package org.foray.pioneer;
+import org.foray.content.PageReferenceContent;
+
import org.axsl.area.AreaNode;
import org.axsl.area.AreaTreeException;
import org.axsl.area.LineArea;
@@ -58,7 +60,7 @@
// Not enough room on the page for this.
return Status.AREA_FULL_NONE;
}
- return addNonTextContent(lineArea);
+ return addNonTextContent(lineArea, new PageReferenceContent(this.node));
}
@Override
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/EagerLineBreaker.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/EagerLineBreaker.java 2022-02-09 18:03:04 UTC (rev 12583)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/EagerLineBreaker.java 2022-02-10 17:43:14 UTC (rev 12584)
@@ -126,14 +126,12 @@
/**
* Standard processing of non-text items for eager line breaking systems.
- * @param nonTextItem The non-text item that should be added to the current
- * line.
- * @return If the item was successfully added to the current line, returns
- * 1, or returns 0 if there is not enough room on the line for it.
+ * @param nonTextItem The non-text item that should be added to the current line.
+ * @return If the item was successfully added to the current line, returns 1, or returns 0 if there is not enough
+ * room on the line for it.
* @throws TextException For errors during processing.
*/
- protected int processLineNonText(final IndivisibleContent nonTextItem)
- throws TextException {
+ protected int processLineNonText(final IndivisibleContent nonTextItem) throws TextException {
final int lineLength = lineReceivingContent().capacityTotal();
final int itemSize = nonTextItem.inlineSizeMinimum(lineLength);
if (itemSize > lineReceivingContent().capacityRemaining()) {
Modified: trunk/foray/settings.gradle
===================================================================
--- trunk/foray/settings.gradle 2022-02-09 18:03:04 UTC (rev 12583)
+++ trunk/foray/settings.gradle 2022-02-10 17:43:14 UTC (rev 12584)
@@ -3,6 +3,7 @@
include 'foray-app'
include 'foray-areatree'
include 'foray-common'
+include 'foray-content'
include 'foray-core'
include 'foray-font'
include 'foray-fotree'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-09 18:03:07
|
Revision: 12583
http://sourceforge.net/p/foray/code/12583
Author: victormote
Date: 2022-02-09 18:03:04 +0000 (Wed, 09 Feb 2022)
Log Message:
-----------
Conform to aXSL change: Remove no-longer-needed FoLineNonText interface.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractPageReference.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Leader4a.java
trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractPageReference.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractPageReference.java 2022-02-09 17:43:15 UTC (rev 12582)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractPageReference.java 2022-02-09 18:03:04 UTC (rev 12583)
@@ -32,8 +32,7 @@
import org.foray.fotree.Namespace;
import org.foray.fotree.PropertyList;
-import org.axsl.fotree.FoContext;
-import org.axsl.fotree.FoLineNonText;
+import org.axsl.content.IndivisibleContent;
import org.axsl.fotree.FoTreeException;
import java.util.List;
@@ -42,7 +41,7 @@
* Abstract superclass for page-number, page-number-citation, and
* page-number-citation-last.
*/
-public abstract class AbstractPageReference extends FoObj implements FoLineNonText {
+public abstract class AbstractPageReference extends FoObj implements IndivisibleContent {
/** The number of placeholder digits that should be used when we do not yet
* know what the actual page-number is. */
@@ -114,37 +113,19 @@
@Override
public int inlineSizeOptimum(final int lineLength) {
- return inlineSizeOptimum(null, lineLength);
- }
-
- @Override
- public int inlineSizeOptimum(final FoContext context,
- final int lineLength) {
- final int zeroWidth = getPrimaryFont(context).width('0', traitFontSize(context));
+ final int zeroWidth = getPrimaryFont(null).width('0', traitFontSize(null));
// This is an estimate for purposes of layout.
- return (zeroWidth + traitLetterSpacingOpt(context))
+ return (zeroWidth + traitLetterSpacingOpt(null))
* AbstractPageReference.QTY_PLACEHOLDER_DIGITS;
}
@Override
public int inlineSizeMinimum(final int lineLength) {
- return inlineSizeMinimum(null, lineLength);
- }
-
- @Override
- public int inlineSizeMinimum(final FoContext context,
- final int lineLength) {
return inlineSizeOptimum(lineLength);
}
@Override
public int inlineSizeMaximum(final int lineLength) {
- return inlineSizeMaximum(null, lineLength);
- }
-
- @Override
- public int inlineSizeMaximum(final FoContext context,
- final int lineLength) {
return inlineSizeOptimum(lineLength);
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java 2022-02-09 17:43:15 UTC (rev 12582)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java 2022-02-09 18:03:04 UTC (rev 12583)
@@ -176,38 +176,20 @@
@Override
public int inlineSizeOptimum(final int lineLength) {
- return inlineSizeOptimum(null, lineLength);
+ return this.viewportIpd(null);
}
@Override
- public int inlineSizeOptimum(final FoContext context,
- final int lineLength) {
- return this.viewportIpd(context);
- }
-
- @Override
public int inlineSizeMinimum(final int lineLength) {
- return inlineSizeMinimum(null, lineLength);
+ return this.viewportIpd(null);
}
@Override
- public int inlineSizeMinimum(final FoContext context,
- final int lineLength) {
- return this.viewportIpd(context);
- }
-
- @Override
public int inlineSizeMaximum(final int lineLength) {
- return inlineSizeMaximum(null, lineLength);
+ return this.viewportIpd(null);
}
@Override
- public int inlineSizeMaximum(final FoContext context,
- final int lineLength) {
- return this.viewportIpd(context);
- }
-
- @Override
public boolean isLastItemInBlock() {
return this.getNextSibling() == null;
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java 2022-02-09 17:43:15 UTC (rev 12582)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java 2022-02-09 18:03:04 UTC (rev 12583)
@@ -124,38 +124,20 @@
@Override
public int inlineSizeOptimum(final int lineLength) {
- return inlineSizeOptimum(null, lineLength);
+ return this.viewportIpd(null);
}
@Override
- public int inlineSizeOptimum(final FoContext context,
- final int lineLength) {
- return this.viewportIpd(context);
- }
-
- @Override
public int inlineSizeMinimum(final int lineLength) {
- return inlineSizeMinimum(null, lineLength);
+ return this.viewportIpd(null);
}
@Override
- public int inlineSizeMinimum(final FoContext context,
- final int lineLength) {
- return this.viewportIpd(context);
- }
-
- @Override
public int inlineSizeMaximum(final int lineLength) {
- return inlineSizeMaximum(null, lineLength);
+ return this.viewportIpd(null);
}
@Override
- public int inlineSizeMaximum(final FoContext context,
- final int lineLength) {
- return this.viewportIpd(context);
- }
-
- @Override
public boolean isLastItemInBlock() {
return this.getNextSibling() == null;
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Leader4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Leader4a.java 2022-02-09 17:43:15 UTC (rev 12582)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Leader4a.java 2022-02-09 18:03:04 UTC (rev 12583)
@@ -108,33 +108,15 @@
}
@Override
- public int inlineSizeOptimum(final FoContext context,
- final int lineLength) {
- return traitLeaderLengthOpt(context);
- }
-
- @Override
public int inlineSizeMinimum(final int lineLength) {
return traitLeaderLengthMin(null);
}
@Override
- public int inlineSizeMinimum(final FoContext context,
- final int lineLength) {
- return traitLeaderLengthMin(context);
- }
-
- @Override
public int inlineSizeMaximum(final int lineLength) {
return traitLeaderLengthMax(null);
}
- @Override
- public int inlineSizeMaximum(final FoContext context,
- final int lineLength) {
- return traitLeaderLengthMax(context);
- }
-
/**
* {@inheritDoc}
* Overrides FoObj method, because this is the Leader being sought.
Modified: trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java
===================================================================
--- trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java 2022-02-09 17:43:15 UTC (rev 12582)
+++ trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java 2022-02-09 18:03:04 UTC (rev 12583)
@@ -37,7 +37,6 @@
import org.axsl.area.factory.LineContentFactory;
import org.axsl.content.CharContent;
import org.axsl.content.IndivisibleContent;
-import org.axsl.fotree.FoLineNonText;
import org.axsl.fotree.FoLineText;
import org.axsl.fotree.fo.ExternalGraphic;
import org.axsl.fotree.fo.FoTextCharacters;
@@ -141,8 +140,8 @@
final LineArea lineArea = (LineArea) lineOutput;
IndivisibleContent nonTextToUse = nonText;
- if (nonTextToUse instanceof org.axsl.fotree.FoLineNonText) {
- final FoLineNonText foLineNonText = (FoLineNonText) nonTextToUse;
+ if (nonTextToUse instanceof IndivisibleContent) {
+ final IndivisibleContent foLineNonText = (IndivisibleContent) nonTextToUse;
nonTextToUse = foLineNonText; //.getWrapped();
}
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java 2022-02-09 17:43:15 UTC (rev 12582)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java 2022-02-09 18:03:04 UTC (rev 12583)
@@ -38,10 +38,10 @@
import org.axsl.area.NormalBlockArea;
import org.axsl.area.TableCellArea;
import org.axsl.area.TableRowContainer;
+import org.axsl.content.IndivisibleContent;
import org.axsl.font.FontConsumer;
import org.axsl.fotree.Fo;
import org.axsl.fotree.FoContext;
-import org.axsl.fotree.FoLineNonText;
import org.axsl.fotree.FoLineText;
import org.axsl.fotree.fo.TableCell;
import org.axsl.text.TextException;
@@ -225,7 +225,7 @@
* @throws AreaTreeException For errors during layout.
*/
protected int addNonTextItemToLine(final LineArea lineArea,
- final FoLineNonText nonText, final FoContext foContext)
+ final IndivisibleContent nonText, final FoContext foContext)
throws AreaTreeException {
EagerLineBreaker lb = this.layout.getEagerLineBreaker();
if (lb == null) {
@@ -236,7 +236,7 @@
this.layout, fontConsumer);
}
int status = 0;
- final FoLineNonText contextAware = nonText; //.getContextWrapper(foContext);
+ final IndivisibleContent contextAware = nonText;
try {
status = lb.processLineContent(contextAware, foContext, -1, -1, lineArea);
} catch (final TextException e) {
@@ -258,10 +258,10 @@
final FoContext foContext = inputLineArea;
final Fo node = this.getFONode();
LineArea lineArea = inputLineArea;
- if (! (node instanceof FoLineNonText)) {
+ if (! (node instanceof IndivisibleContent)) {
return Status.UNKNOWN;
}
- final FoLineNonText nonText = (FoLineNonText) node;
+ final IndivisibleContent nonText = (IndivisibleContent) node;
// this should start a new page
if (lineArea == null) {
return Status.AREA_FULL_SOME;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-09 17:43:18
|
Revision: 12582
http://sourceforge.net/p/foray/code/12582
Author: victormote
Date: 2022-02-09 17:43:15 +0000 (Wed, 09 Feb 2022)
Log Message:
-----------
Conform to aXSL changes: Remove context-wrapping features of non-text line content.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractPageReference.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Leader4a.java
trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java
Removed Paths:
-------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoLineNonText.java
Deleted: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoLineNonText.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoLineNonText.java 2022-02-09 13:51:14 UTC (rev 12581)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoLineNonText.java 2022-02-09 17:43:15 UTC (rev 12582)
@@ -1,105 +0,0 @@
-/*
- * Copyright 2006 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.fotree;
-
-import org.axsl.fotree.FoContext;
-
-/**
- * Wraps an underlying "real" FoLineNonText along with the context to be used by
- * that item for trait resolution.
- */
-public class FoLineNonText implements org.axsl.fotree.FoLineNonText {
-
- /** The wrapped non-text item. */
- private org.axsl.fotree.FoLineNonText realLineNonText;
-
- /** The FO context for this non-text item. */
- private FoContext context;
-
- /**
- * Constructor.
- * @param realLineNonText The wrapped non-text item.
- * @param context The FO context for this non-text item.
- */
- public FoLineNonText(final org.axsl.fotree.FoLineNonText realLineNonText, final FoContext context) {
- this.realLineNonText = realLineNonText;
- this.context = context;
- }
-
- @Override
- public int inlineSizeOptimum(final int lineLength) {
- return this.realLineNonText.inlineSizeOptimum(this.context, lineLength);
- }
-
- @Override
- public int inlineSizeOptimum(final FoContext context,
- final int lineLength) {
- return this.realLineNonText.inlineSizeOptimum(context, lineLength);
- }
-
- @Override
- public int inlineSizeMinimum(final int lineLength) {
- return this.realLineNonText.inlineSizeMinimum(this.context, lineLength);
- }
-
- @Override
- public int inlineSizeMinimum(final FoContext context,
- final int lineLength) {
- return this.realLineNonText.inlineSizeMinimum(context, lineLength);
- }
-
- @Override
- public int inlineSizeMaximum(final int lineLength) {
- return this.realLineNonText.inlineSizeMaximum(this.context, lineLength);
- }
-
- @Override
- public int inlineSizeMaximum(final FoContext context,
- final int lineLength) {
- return this.realLineNonText.inlineSizeMaximum(context, lineLength);
- }
-
- @Override
- public boolean isLastItemInBlock() {
- return this.realLineNonText.isLastItemInBlock();
- }
-
- @Override
- public org.axsl.fotree.FoLineNonText getContextWrapper(
- final FoContext context) {
- /* This *is* the wrapper. */
- return this;
- }
-
- @Override
- public org.axsl.fotree.FoLineNonText getWrapped() {
- return this.realLineNonText;
- }
-
-}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractPageReference.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractPageReference.java 2022-02-09 13:51:14 UTC (rev 12581)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/AbstractPageReference.java 2022-02-09 17:43:15 UTC (rev 12582)
@@ -113,17 +113,6 @@
}
@Override
- public FoLineNonText getContextWrapper(final FoContext context) {
- return new org.foray.fotree.FoLineNonText(this, context);
- }
-
- @Override
- public FoLineNonText getWrapped() {
- /* This is the wrapped item. */
- return this;
- }
-
- @Override
public int inlineSizeOptimum(final int lineLength) {
return inlineSizeOptimum(null, lineLength);
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java 2022-02-09 13:51:14 UTC (rev 12581)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java 2022-02-09 17:43:15 UTC (rev 12582)
@@ -35,7 +35,6 @@
import org.foray.fotree.PropertyList;
import org.axsl.fotree.FoContext;
-import org.axsl.fotree.FoLineNonText;
import org.axsl.fotree.FoTreeException;
import org.axsl.fotree.FoVisitor;
import org.axsl.fotree.fo.ExternalGraphic;
@@ -176,17 +175,6 @@
}
@Override
- public FoLineNonText getContextWrapper(final FoContext context) {
- return new org.foray.fotree.FoLineNonText(this, context);
- }
-
- @Override
- public FoLineNonText getWrapped() {
- /* This is the wrapped item. */
- return this;
- }
-
- @Override
public int inlineSizeOptimum(final int lineLength) {
return inlineSizeOptimum(null, lineLength);
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java 2022-02-09 13:51:14 UTC (rev 12581)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java 2022-02-09 17:43:15 UTC (rev 12582)
@@ -34,7 +34,6 @@
import org.foray.fotree.PropertyList;
import org.axsl.fotree.FoContext;
-import org.axsl.fotree.FoLineNonText;
import org.axsl.fotree.FoTreeException;
import org.axsl.fotree.FoVisitor;
import org.axsl.fotree.fo.InstreamForeignObject;
@@ -124,17 +123,6 @@
}
@Override
- public FoLineNonText getContextWrapper(final FoContext context) {
- return new org.foray.fotree.FoLineNonText(this, context);
- }
-
- @Override
- public FoLineNonText getWrapped() {
- /* This is the wrapped item. */
- return this;
- }
-
- @Override
public int inlineSizeOptimum(final int lineLength) {
return inlineSizeOptimum(null, lineLength);
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Leader4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Leader4a.java 2022-02-09 13:51:14 UTC (rev 12581)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Leader4a.java 2022-02-09 17:43:15 UTC (rev 12582)
@@ -34,7 +34,6 @@
import org.foray.fotree.PropertyList;
import org.axsl.fotree.FoContext;
-import org.axsl.fotree.FoLineNonText;
import org.axsl.fotree.FoTreeException;
import org.axsl.fotree.FoVisitor;
import org.axsl.fotree.fo.Leader;
@@ -104,17 +103,6 @@
}
@Override
- public FoLineNonText getContextWrapper(final FoContext context) {
- return new org.foray.fotree.FoLineNonText(this, context);
- }
-
- @Override
- public FoLineNonText getWrapped() {
- /* This is the wrapped item. */
- return this;
- }
-
- @Override
public int inlineSizeOptimum(final int lineLength) {
return traitLeaderLengthOpt(null);
}
Modified: trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java
===================================================================
--- trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java 2022-02-09 13:51:14 UTC (rev 12581)
+++ trunk/foray/foray-layout/src/main/java/org/foray/layout/LayoutStrategy.java 2022-02-09 17:43:15 UTC (rev 12582)
@@ -143,7 +143,7 @@
IndivisibleContent nonTextToUse = nonText;
if (nonTextToUse instanceof org.axsl.fotree.FoLineNonText) {
final FoLineNonText foLineNonText = (FoLineNonText) nonTextToUse;
- nonTextToUse = foLineNonText.getWrapped();
+ nonTextToUse = foLineNonText; //.getWrapped();
}
LineContentFactory factory = lineArea;
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java 2022-02-09 13:51:14 UTC (rev 12581)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/FoNodePnr.java 2022-02-09 17:43:15 UTC (rev 12582)
@@ -236,7 +236,7 @@
this.layout, fontConsumer);
}
int status = 0;
- final FoLineNonText contextAware = nonText.getContextWrapper(foContext);
+ final FoLineNonText contextAware = nonText; //.getContextWrapper(foContext);
try {
status = lb.processLineContent(contextAware, foContext, -1, -1, lineArea);
} catch (final TextException e) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-09 13:51:17
|
Revision: 12581
http://sourceforge.net/p/foray/code/12581
Author: victormote
Date: 2022-02-09 13:51:14 +0000 (Wed, 09 Feb 2022)
Log Message:
-----------
When processing a ForayTarget, allow it to start its Renderer(s).
Modified Paths:
--------------
trunk/foray/foray-core/src/main/java/org/foray/core/ForayDocument.java
trunk/foray/foray-core/src/main/java/org/foray/core/ForaySession.java
trunk/foray/foray-core/src/main/java/org/foray/core/ForayTarget.java
Modified: trunk/foray/foray-core/src/main/java/org/foray/core/ForayDocument.java
===================================================================
--- trunk/foray/foray-core/src/main/java/org/foray/core/ForayDocument.java 2022-02-09 03:52:05 UTC (rev 12580)
+++ trunk/foray/foray-core/src/main/java/org/foray/core/ForayDocument.java 2022-02-09 13:51:14 UTC (rev 12581)
@@ -265,9 +265,9 @@
* @param target The target to be processed.
* @throws ForayException For errors during processing.
*/
- public synchronized void processTarget(final ForayTarget target)
- throws ForayException {
+ public synchronized void processTarget(final ForayTarget target) throws ForayException {
this.setTarget(target);
+ target.startRenderer();
try {
if (this.jaxpTransformer == null) {
// Regular SAX Input
Modified: trunk/foray/foray-core/src/main/java/org/foray/core/ForaySession.java
===================================================================
--- trunk/foray/foray-core/src/main/java/org/foray/core/ForaySession.java 2022-02-09 03:52:05 UTC (rev 12580)
+++ trunk/foray/foray-core/src/main/java/org/foray/core/ForaySession.java 2022-02-09 13:51:14 UTC (rev 12581)
@@ -45,22 +45,11 @@
import java.util.List;
/**
- * The ancestor class for all FOray processing. All classes that start
- * FOray processing need to create a ForaySession, one or more ForayDocument
- * instances, and one or more ForayTarget instances for each ForayDocument,
- * then run the ForaySession process() method.
- * This process is illustrated and documented in the source code for
- * the CommandLineStarter.run() method.
- *
- * After instantiating ForaySession, additional Namespace instances can
- * be registered with the session through the addNamespace method. Custom
- * Namespaces can also be added to the system resources, and these are
- * automatically registered at runtime.
- *
- * The input document is identified to the ForayDocument as it is instantiated.
- * There are two constructors, one for SAX input, and the other for DOM input.
- * The Renderer, LayoutStrategy, and output document are identified to the
- * ForayTarget as it is instantiated.
+ * <p>The ancestor class for all FOray processing.
+ * All classes that start FOray processing need to create a {@link ForaySession}, one or more {@link ForayDocument}
+ * instances, and one or more {@link ForayTarget} instances for each {@link ForayDocument}, then run
+ * {@link ForaySession#process()}.
+ * This process is illustrated and documented in the source code for the CommandLineStarter.run() method.</p>
*/
public class ForaySession {
Modified: trunk/foray/foray-core/src/main/java/org/foray/core/ForayTarget.java
===================================================================
--- trunk/foray/foray-core/src/main/java/org/foray/core/ForayTarget.java 2022-02-09 03:52:05 UTC (rev 12580)
+++ trunk/foray/foray-core/src/main/java/org/foray/core/ForayTarget.java 2022-02-09 13:51:14 UTC (rev 12581)
@@ -94,7 +94,7 @@
private OutputStream outputStream;
/** The renderer being used. */
- private List<OutputTarget> outputTargets = new ArrayList<OutputTarget>();;
+ private List<OutputTarget> outputTargets = new ArrayList<OutputTarget>();
/**
* Keeps track of how many page-sequence objects have been processed.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-09 03:52:08
|
Revision: 12580
http://sourceforge.net/p/foray/code/12580
Author: victormote
Date: 2022-02-09 03:52:05 +0000 (Wed, 09 Feb 2022)
Log Message:
-----------
Conform to aXSL changes: Move more trait methods to standard location.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/Area4a.java
trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/Area4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/Area4a.java 2022-02-09 03:21:47 UTC (rev 12579)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/Area4a.java 2022-02-09 03:52:05 UTC (rev 12580)
@@ -719,7 +719,12 @@
@Override
public String destinationName() {
- final String id = traitId();
+ String id = null;
+ final Fo generatedBy = this.traitGeneratedBy();
+ if (generatedBy instanceof IdPa) {
+ id = ((IdPa) generatedBy).traitId();
+ }
+
if (id == null || id.equals("")) {
return null;
}
@@ -909,15 +914,6 @@
return this;
}
- @Override
- public String traitId() {
- final Fo generatedBy = this.traitGeneratedBy();
- if (generatedBy instanceof IdPa) {
- return ((IdPa) generatedBy).traitId();
- }
- return null;
- }
-
/**
* Returns the border-start-width trait for this area.
* @return The border-start-width trait for this area.
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java 2022-02-09 03:21:47 UTC (rev 12579)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java 2022-02-09 03:52:05 UTC (rev 12580)
@@ -505,8 +505,8 @@
final AreaOriginDescriptor proxy = area.traitGeneratedByProxy();
if (proxy != null) {
String idString = "";
- if (area.traitId() != null && ! area.traitId().equals("")) {
- idString = "(id " + area.traitId() + ")";
+ if (proxy.traitId() != null && ! proxy.traitId().equals("")) {
+ idString = "(id " + proxy.traitId() + ")";
}
outputAttribute(buffer, "generated-by", proxy.getName() + idString);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-09 03:21:50
|
Revision: 12579
http://sourceforge.net/p/foray/code/12579
Author: victormote
Date: 2022-02-09 03:21:47 +0000 (Wed, 09 Feb 2022)
Log Message:
-----------
Conform to aXSL changes: Move more trait methods to standard location. Add proxy trait for generated-by in axsl-galley.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/Area4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/RegionOuterRa4a.java
trunk/foray/foray-output/build.gradle
trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/Area4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/Area4a.java 2022-02-09 00:01:34 UTC (rev 12578)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/Area4a.java 2022-02-09 03:21:47 UTC (rev 12579)
@@ -43,6 +43,7 @@
import org.axsl.graphic.Graphic;
import org.axsl.value.AbsoluteAxis;
import org.axsl.value.AbsoluteDirection;
+import org.axsl.value.AreaOriginDescriptor;
import org.axsl.value.BackgroundAttachment;
import org.axsl.value.BackgroundRepeat;
import org.axsl.value.BorderStyle;
@@ -81,15 +82,11 @@
}
@Override
- public boolean generatedByExists() {
- return getFoLink() != null;
+ public AreaOriginDescriptor traitGeneratedByProxy() {
+ // TODO Auto-generated method stub
+ return null;
}
- @Override
- public String generatedByName() {
- return traitGeneratedBy().getName();
- }
-
/**
* Returns the end-indent trait.
* @return The end-indent trait.
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/RegionOuterRa4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/RegionOuterRa4a.java 2022-02-09 00:01:34 UTC (rev 12578)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/RegionOuterRa4a.java 2022-02-09 03:21:47 UTC (rev 12579)
@@ -29,6 +29,7 @@
package org.foray.area;
import org.foray.area.link.Link;
+import org.foray.common.primitive.StringUtils;
import org.axsl.area.AreaTreeException;
import org.axsl.area.RegionOuterRa;
@@ -169,8 +170,8 @@
}
@Override
- public String getAreaName() {
- return this.generatedByName();
+ public CharSequence getAreaName() {
+ return traitGeneratedBy() == null ? StringUtils.EMPTY_STRING : traitGeneratedBy().getName();
}
@Override
Modified: trunk/foray/foray-output/build.gradle
===================================================================
--- trunk/foray/foray-output/build.gradle 2022-02-09 00:01:34 UTC (rev 12578)
+++ trunk/foray/foray-output/build.gradle 2022-02-09 03:21:47 UTC (rev 12579)
@@ -9,6 +9,7 @@
api (group: 'org.axsl', name: 'axsl-output', version: axslVersion) { transitive = false }
api (group: 'org.axsl', name: 'axsl-mif', version: axslVersion) { transitive = false }
api (group: 'org.axsl', name: 'axsl-fotree', version: axslVersion) { transitive = false }
+ api (group: 'org.axsl', name: 'axsl-value', version: axslVersion) { transitive = false }
api (project(':foray-common')) { transitive = false }
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java 2022-02-09 00:01:34 UTC (rev 12578)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java 2022-02-09 03:21:47 UTC (rev 12579)
@@ -64,6 +64,7 @@
import org.axsl.galley.render.GalleyVisitorException;
import org.axsl.graphic.Graphic;
import org.axsl.output.DocumentAreaConfiguration;
+import org.axsl.value.AreaOriginDescriptor;
import org.axsl.value.RuleStyle;
import java.awt.Color;
@@ -156,7 +157,7 @@
final StringBuilder attributes, final String content) {
writeIndent();
this.writer.write("<");
- this.writer.write(area.getAreaName());
+ this.writer.write(area.getAreaName().toString());
if (attributes != null) {
this.writer.write(attributes.toString());
}
@@ -170,8 +171,7 @@
* @param area The area for whom element is written.
* @param attributes Text of the attributes to be written.
*/
- protected void writeEmptyElement(final AreaG5 area,
- final StringBuilder attributes) {
+ protected void writeEmptyElement(final AreaG5 area, final StringBuilder attributes) {
this.writeEmptyElement(area.getAreaName(), attributes);
}
@@ -180,11 +180,10 @@
* @param elementName The name of the element to be written.
* @param attributes Text of the attributes to be written.
*/
- protected void writeEmptyElement(final String elementName,
- final StringBuilder attributes) {
+ protected void writeEmptyElement(final CharSequence elementName, final StringBuilder attributes) {
writeIndent();
this.writer.write("<");
- this.writer.write(elementName);
+ this.writer.write(elementName.toString());
if (attributes != null) {
this.writer.write(attributes.toString());
}
@@ -200,7 +199,7 @@
writeIndent();
this.indent++;
this.writer.write("<");
- this.writer.write(node.getAreaName());
+ this.writer.write(node.getAreaName().toString());
if (attributes != null) {
this.writer.write(attributes.toString());
}
@@ -503,12 +502,13 @@
* @param buffer StringBuilder instance in which to append the output.
*/
private void outputCommonAttributes(final AreaG5 area, final StringBuilder buffer) {
- if (area.generatedByExists()) {
+ final AreaOriginDescriptor proxy = area.traitGeneratedByProxy();
+ if (proxy != null) {
String idString = "";
if (area.traitId() != null && ! area.traitId().equals("")) {
idString = "(id " + area.traitId() + ")";
}
- outputAttribute(buffer, "generated-by", area.generatedByName() + idString);
+ outputAttribute(buffer, "generated-by", proxy.getName() + idString);
}
if (area.destinationName() != null) {
@@ -593,8 +593,8 @@
* @param attributeName The name of the attribute.
* @param attributeValue The value of the attribute.
*/
- public void outputAttribute(final StringBuilder buffer,
- final String attributeName, final CharSequence attributeValue) {
+ public void outputAttribute(final StringBuilder buffer, final CharSequence attributeName,
+ final CharSequence attributeValue) {
buffer.append(" " + attributeName + "=");
buffer.append(XmlRenderer.DOUBLE_QUOTE);
buffer.append(attributeValue);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-09 00:01:37
|
Revision: 12578
http://sourceforge.net/p/foray/code/12578
Author: victormote
Date: 2022-02-09 00:01:34 +0000 (Wed, 09 Feb 2022)
Log Message:
-----------
Conform to aXSL changes: Move more trait methods to standard location.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/Area4a.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/Area4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/Area4a.java 2022-02-08 20:18:58 UTC (rev 12577)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/Area4a.java 2022-02-09 00:01:34 UTC (rev 12578)
@@ -31,7 +31,6 @@
import org.foray.common.WellKnownConstants;
import org.axsl.area.Area;
-import org.axsl.area.AreaClass;
import org.axsl.area.AreaTreeException;
import org.axsl.area.BlockLevelRa;
import org.axsl.font.Font;
@@ -40,6 +39,7 @@
import org.axsl.fotree.fo.BasicLink;
import org.axsl.fotree.fo.prop.IdPa;
import org.axsl.fotree.fo.prop.WritingModePa;
+import org.axsl.galley.value.AreaClass;
import org.axsl.graphic.Graphic;
import org.axsl.value.AbsoluteAxis;
import org.axsl.value.AbsoluteDirection;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-08 20:19:03
|
Revision: 12577
http://sourceforge.net/p/foray/code/12577
Author: victormote
Date: 2022-02-08 20:18:58 +0000 (Tue, 08 Feb 2022)
Log Message:
-----------
Conform to aXSL changes: Move more trait methods to standard location.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/BlockContainerRa.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/InlineArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/NormalBlockArea4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TableCellRa.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TableRa.java
trunk/foray/foray-render/src/main/java/org/foray/render/PrintRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/svg/SvgRenderer.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/BlockContainerRa.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/BlockContainerRa.java 2022-02-08 19:57:17 UTC (rev 12576)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/BlockContainerRa.java 2022-02-08 20:18:58 UTC (rev 12577)
@@ -317,22 +317,22 @@
}
@Override
- public Color traitBorderBeforeColor() {
+ public Color traitBorderColorBefore() {
return traitGeneratedBy().traitBorderBeforeColor(this);
}
@Override
- public Color traitBorderStartColor() {
+ public Color traitBorderColorStart() {
return traitGeneratedBy().traitBorderStartColor(this);
}
@Override
- public Color traitBorderEndColor() {
+ public Color traitBorderColorEnd() {
return traitGeneratedBy().traitBorderEndColor(this);
}
@Override
- public Color traitBorderAfterColor() {
+ public Color traitBorderColorAfter() {
return traitGeneratedBy().traitBorderAfterColor(this);
}
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/InlineArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/InlineArea.java 2022-02-08 19:57:17 UTC (rev 12576)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/InlineArea.java 2022-02-08 20:18:58 UTC (rev 12577)
@@ -162,22 +162,22 @@
}
@Override
- public Color traitBorderBeforeColor() {
+ public Color traitBorderColorBefore() {
return traitGeneratedBy().traitBorderBeforeColor(this);
}
@Override
- public Color traitBorderStartColor() {
+ public Color traitBorderColorStart() {
return traitGeneratedBy().traitBorderStartColor(this);
}
@Override
- public Color traitBorderEndColor() {
+ public Color traitBorderColorEnd() {
return traitGeneratedBy().traitBorderEndColor(this);
}
@Override
- public Color traitBorderAfterColor() {
+ public Color traitBorderColorAfter() {
return traitGeneratedBy().traitBorderAfterColor(this);
}
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-02-08 19:57:17 UTC (rev 12576)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/NormalBlockArea4a.java 2022-02-08 20:18:58 UTC (rev 12577)
@@ -340,22 +340,22 @@
}
@Override
- public Color traitBorderBeforeColor() {
+ public Color traitBorderColorBefore() {
return traitGeneratedBy().traitBorderBeforeColor(this);
}
@Override
- public Color traitBorderStartColor() {
+ public Color traitBorderColorStart() {
return traitGeneratedBy().traitBorderStartColor(this);
}
@Override
- public Color traitBorderEndColor() {
+ public Color traitBorderColorEnd() {
return traitGeneratedBy().traitBorderEndColor(this);
}
@Override
- public Color traitBorderAfterColor() {
+ public Color traitBorderColorAfter() {
return traitGeneratedBy().traitBorderAfterColor(this);
}
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TableCellRa.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TableCellRa.java 2022-02-08 19:57:17 UTC (rev 12576)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TableCellRa.java 2022-02-08 20:18:58 UTC (rev 12577)
@@ -518,22 +518,22 @@
}
@Override
- public Color traitBorderBeforeColor() {
+ public Color traitBorderColorBefore() {
return traitGeneratedBy().traitBorderBeforeColor(this);
}
@Override
- public Color traitBorderStartColor() {
+ public Color traitBorderColorStart() {
return traitGeneratedBy().traitBorderStartColor(this);
}
@Override
- public Color traitBorderEndColor() {
+ public Color traitBorderColorEnd() {
return traitGeneratedBy().traitBorderEndColor(this);
}
@Override
- public Color traitBorderAfterColor() {
+ public Color traitBorderColorAfter() {
return traitGeneratedBy().traitBorderAfterColor(this);
}
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TableRa.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TableRa.java 2022-02-08 19:57:17 UTC (rev 12576)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TableRa.java 2022-02-08 20:18:58 UTC (rev 12577)
@@ -643,22 +643,22 @@
}
@Override
- public Color traitBorderBeforeColor() {
+ public Color traitBorderColorBefore() {
return traitGeneratedBy().traitBorderBeforeColor(this);
}
@Override
- public Color traitBorderStartColor() {
+ public Color traitBorderColorStart() {
return traitGeneratedBy().traitBorderStartColor(this);
}
@Override
- public Color traitBorderEndColor() {
+ public Color traitBorderColorEnd() {
return traitGeneratedBy().traitBorderEndColor(this);
}
@Override
- public Color traitBorderAfterColor() {
+ public Color traitBorderColorAfter() {
return traitGeneratedBy().traitBorderAfterColor(this);
}
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/PrintRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/PrintRenderer.java 2022-02-08 19:57:17 UTC (rev 12576)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/PrintRenderer.java 2022-02-08 20:18:58 UTC (rev 12577)
@@ -72,10 +72,10 @@
/* TODO: This all needs to become writing-mode aware. Right now we
* assume left-to-right, top-to-bottom. */
- final int startWidth = area.traitBorderStartWidth();
- final int endWidth = area.traitBorderEndWidth();
- final int beforeWidth = area.traitBorderBeforeWidth();
- final int afterWidth = area.traitBorderAfterWidth();
+ final int startWidth = area.traitBorderWidthStart();
+ final int endWidth = area.traitBorderWidthEnd();
+ final int beforeWidth = area.traitBorderWidthBefore();
+ final int afterWidth = area.traitBorderWidthAfter();
final int rx = area.brOriginX() + Math.round(startWidth / 2);
final int ry = area.brOriginY() - Math.round(beforeWidth / 2);
@@ -85,23 +85,23 @@
if (beforeWidth != 0) {
drawLine(rx, ry, rx + w, ry, beforeWidth,
- area.traitBorderBeforeStyle().getEquivalentRuleStyle(),
- area.traitBorderBeforeColor());
+ area.traitBorderStyleBefore().getEquivalentRuleStyle(),
+ area.traitBorderColorBefore());
}
if (startWidth != 0) {
drawLine(rx, ry, rx, ry - h, startWidth,
- area.traitBorderStartStyle().getEquivalentRuleStyle(),
- area.traitBorderStartColor());
+ area.traitBorderStyleStart().getEquivalentRuleStyle(),
+ area.traitBorderColorStart());
}
if (endWidth != 0) {
drawLine(rx + w, ry, rx + w, ry - h, endWidth,
- area.traitBorderEndStyle().getEquivalentRuleStyle(),
- area.traitBorderEndColor());
+ area.traitBorderStyleEnd().getEquivalentRuleStyle(),
+ area.traitBorderColorEnd());
}
if (afterWidth != 0) {
drawLine(rx, ry - h, rx + w, ry - h, afterWidth,
- area.traitBorderAfterStyle().getEquivalentRuleStyle(),
- area.traitBorderAfterColor());
+ area.traitBorderStyleAfter().getEquivalentRuleStyle(),
+ area.traitBorderColorAfter());
}
}
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java 2022-02-08 19:57:17 UTC (rev 12576)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java 2022-02-08 20:18:58 UTC (rev 12577)
@@ -444,24 +444,24 @@
final int w = area.brIpd();
final int h = area.brBpd();
- if (area.traitBorderBeforeWidth() != 0) {
- drawLine(rx, ry, rx + w, ry, -area.traitBorderBeforeWidth(),
- RuleStyle.SOLID, area.traitBorderBeforeColor());
+ if (area.traitBorderWidthBefore() != 0) {
+ drawLine(rx, ry, rx + w, ry, -area.traitBorderWidthBefore(),
+ RuleStyle.SOLID, area.traitBorderColorBefore());
}
- if (area.traitBorderStartWidth() != 0) {
- drawLine(rx, ry, rx, ry - h, area.traitBorderStartWidth(),
- RuleStyle.SOLID, area.traitBorderStartColor());
+ if (area.traitBorderWidthStart() != 0) {
+ drawLine(rx, ry, rx, ry - h, area.traitBorderWidthStart(),
+ RuleStyle.SOLID, area.traitBorderColorStart());
}
- if (area.traitBorderEndWidth() != 0) {
- drawLine(rx + w, ry, rx + w, ry - h, -area.traitBorderEndWidth(),
- RuleStyle.SOLID, area.traitBorderEndColor());
+ if (area.traitBorderWidthEnd() != 0) {
+ drawLine(rx + w, ry, rx + w, ry - h, -area.traitBorderWidthEnd(),
+ RuleStyle.SOLID, area.traitBorderColorEnd());
}
- if (area.traitBorderAfterWidth() != 0) {
- drawLine(rx, ry - h, rx + w, ry - h, area.traitBorderAfterWidth(),
- RuleStyle.SOLID, area.traitBorderAfterColor());
+ if (area.traitBorderWidthAfter() != 0) {
+ drawLine(rx, ry - h, rx + w, ry - h, area.traitBorderWidthAfter(),
+ RuleStyle.SOLID, area.traitBorderColorAfter());
}
}
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2022-02-08 19:57:17 UTC (rev 12576)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2022-02-08 20:18:58 UTC (rev 12577)
@@ -1135,40 +1135,40 @@
final int w = area.crIpd();
final int h = area.crBpd();
- if (area.traitBorderBeforeWidth() != 0) {
+ if (area.traitBorderWidthBefore() != 0) {
write("newpath");
write(rx + " " + ry + " M");
write(w + " 0 rlineto");
- write(area.traitBorderBeforeWidth() + " setlinewidth");
+ write(area.traitBorderWidthBefore() + " setlinewidth");
write("0 setlinecap");
- useColor(area.traitBorderBeforeColor());
+ useColor(area.traitBorderColorBefore());
write("stroke");
}
- if (area.traitBorderStartWidth() != 0) {
+ if (area.traitBorderWidthStart() != 0) {
write("newpath");
write(rx + " " + ry + " M");
write("0 " + (-h) + " rlineto");
- write(area.traitBorderStartWidth() + " setlinewidth");
+ write(area.traitBorderWidthStart() + " setlinewidth");
write("0 setlinecap");
- useColor(area.traitBorderStartColor());
+ useColor(area.traitBorderColorStart());
write("stroke");
}
- if (area.traitBorderEndWidth() != 0) {
+ if (area.traitBorderWidthEnd() != 0) {
write("newpath");
write((rx + w) + " " + ry + " M");
write("0 " + (-h) + " rlineto");
- write(area.traitBorderEndWidth() + " setlinewidth");
+ write(area.traitBorderWidthEnd() + " setlinewidth");
write("0 setlinecap");
- useColor(area.traitBorderEndColor());
+ useColor(area.traitBorderColorEnd());
write("stroke");
}
- if (area.traitBorderAfterWidth() != 0) {
+ if (area.traitBorderWidthAfter() != 0) {
write("newpath");
write(rx + " " + (ry - h) + " M");
write(w + " 0 rlineto");
- write(area.traitBorderAfterWidth() + " setlinewidth");
+ write(area.traitBorderWidthAfter() + " setlinewidth");
write("0 setlinecap");
- useColor(area.traitBorderAfterColor());
+ useColor(area.traitBorderColorAfter());
write("stroke");
}
}
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/svg/SvgRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/svg/SvgRenderer.java 2022-02-08 19:57:17 UTC (rev 12576)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/svg/SvgRenderer.java 2022-02-08 20:18:58 UTC (rev 12577)
@@ -340,24 +340,24 @@
final int w = area.crIpd();
final int h = area.crBpd();
- if (area.traitBorderBeforeWidth() != 0) {
- drawLine(rx, ry, rx + w, ry, area.traitBorderBeforeWidth(),
- RuleStyle.SOLID, area.traitBorderBeforeColor());
+ if (area.traitBorderWidthBefore() != 0) {
+ drawLine(rx, ry, rx + w, ry, area.traitBorderWidthBefore(),
+ RuleStyle.SOLID, area.traitBorderColorBefore());
}
- if (area.traitBorderStartWidth() != 0) {
- drawLine(rx, ry, rx, ry - h, area.traitBorderStartWidth(),
- RuleStyle.DASHED, area.traitBorderStartColor());
+ if (area.traitBorderWidthStart() != 0) {
+ drawLine(rx, ry, rx, ry - h, area.traitBorderWidthStart(),
+ RuleStyle.DASHED, area.traitBorderColorStart());
}
- if (area.traitBorderEndWidth() != 0) {
- drawLine(rx + w, ry, rx + w, ry - h, area.traitBorderEndWidth(),
- RuleStyle.DASHED, area.traitBorderEndColor());
+ if (area.traitBorderWidthEnd() != 0) {
+ drawLine(rx + w, ry, rx + w, ry - h, area.traitBorderWidthEnd(),
+ RuleStyle.DASHED, area.traitBorderColorEnd());
}
- if (area.traitBorderAfterWidth() != 0) {
- drawLine(rx, ry - h, rx + w, ry - h, area.traitBorderAfterWidth(),
- RuleStyle.DASHED, area.traitBorderAfterColor());
+ if (area.traitBorderWidthAfter() != 0) {
+ drawLine(rx, ry - h, rx + w, ry - h, area.traitBorderWidthAfter(),
+ RuleStyle.DASHED, area.traitBorderColorAfter());
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-08 19:57:20
|
Revision: 12576
http://sourceforge.net/p/foray/code/12576
Author: victormote
Date: 2022-02-08 19:57:17 +0000 (Tue, 08 Feb 2022)
Log Message:
-----------
Conform to aXSL changes: Move more trait methods to standard location.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/LeaderArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberCitationArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberCitationLastArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/ScalingValueCitationArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java
trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/LeaderArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/LeaderArea.java 2022-02-08 19:39:43 UTC (rev 12575)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/LeaderArea.java 2022-02-08 19:57:17 UTC (rev 12576)
@@ -259,12 +259,12 @@
}
@Override
- public int wordSpacing() {
+ public int traitWordSpacing() {
return actualWordSpacing();
}
@Override
- public int letterSpacing() {
+ public int traitLetterSpacing() {
/* Letter-spacing is not applicable for this inline element. */
return 0;
}
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-02-08 19:39:43 UTC (rev 12575)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2022-02-08 19:57:17 UTC (rev 12576)
@@ -533,7 +533,7 @@
final float share = (float) numerator / (float) totalDenominator
* unusedSpace;
final int adjustment = Math.round(share / numSpaces);
- final int previousWordSpacing = text.wordSpacing();
+ final int previousWordSpacing = text.traitWordSpacing();
text.setResolvedWordSpacing(previousWordSpacing + adjustment);
}
}
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberArea.java 2022-02-08 19:39:43 UTC (rev 12575)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberArea.java 2022-02-08 19:57:17 UTC (rev 12576)
@@ -149,13 +149,13 @@
}
@Override
- public int letterSpacing() {
+ public int traitLetterSpacing() {
/* TODO: Implement this. */
return 0;
}
@Override
- public int wordSpacing() {
+ public int traitWordSpacing() {
/* TODO: Implement this. */
return 0;
}
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberCitationArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberCitationArea.java 2022-02-08 19:39:43 UTC (rev 12575)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberCitationArea.java 2022-02-08 19:57:17 UTC (rev 12576)
@@ -162,13 +162,13 @@
}
@Override
- public int letterSpacing() {
+ public int traitLetterSpacing() {
/* TODO: Implement this. */
return 0;
}
@Override
- public int wordSpacing() {
+ public int traitWordSpacing() {
/* TODO: Implement this. */
return 0;
}
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberCitationLastArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberCitationLastArea.java 2022-02-08 19:39:43 UTC (rev 12575)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/PageNumberCitationLastArea.java 2022-02-08 19:57:17 UTC (rev 12576)
@@ -162,13 +162,13 @@
}
@Override
- public int letterSpacing() {
+ public int traitLetterSpacing() {
/* TODO: Implement this. */
return 0;
}
@Override
- public int wordSpacing() {
+ public int traitWordSpacing() {
/* TODO: Implement this. */
return 0;
}
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/ScalingValueCitationArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/ScalingValueCitationArea.java 2022-02-08 19:39:43 UTC (rev 12575)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/ScalingValueCitationArea.java 2022-02-08 19:57:17 UTC (rev 12576)
@@ -156,13 +156,13 @@
}
@Override
- public int letterSpacing() {
+ public int traitLetterSpacing() {
/* TODO: Implement this. */
return 0;
}
@Override
- public int wordSpacing() {
+ public int traitWordSpacing() {
/* TODO: Implement this. */
return 0;
}
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-02-08 19:39:43 UTC (rev 12575)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java 2022-02-08 19:57:17 UTC (rev 12576)
@@ -348,8 +348,8 @@
}
@Override
- public int letterSpacing() {
- return this.getResolvedLetterSpacing();
+ public int traitLetterSpacing() {
+ return getResolvedLetterSpacing();
}
/**
@@ -362,7 +362,7 @@
}
@Override
- public int wordSpacing() {
+ public int traitWordSpacing() {
return this.resolvedWordSpacing;
}
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2022-02-08 19:39:43 UTC (rev 12575)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2022-02-08 19:57:17 UTC (rev 12576)
@@ -414,9 +414,9 @@
getContentStream().setFillColor(fillColor);
/* Set the word-spacing and letter-spacing. */
- final float wordSpacing = toPoints(area.wordSpacing());
+ final float wordSpacing = toPoints(area.traitWordSpacing());
getContentStream().setWordSpacing(wordSpacing);
- final float letterspacing = toPoints(area.letterSpacing());
+ final float letterspacing = toPoints(area.traitLetterSpacing());
getContentStream().setCharacterSpacing(letterspacing);
/* Position the cursor. */
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2022-02-08 19:39:43 UTC (rev 12575)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2022-02-08 19:57:17 UTC (rev 12576)
@@ -915,8 +915,8 @@
}
String psString = null;
- if (area.letterSpacing() > 0) {
- final float f = area.letterSpacing();
+ if (area.traitLetterSpacing() > 0) {
+ final float f = area.traitLetterSpacing();
psString = (new StringBuilder().append(f).append(" 0.0 (")
.append(sb.toString()).append(") A")).toString();
} else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|