FOray

FOray Users
Module Users
Developers
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

FOray Modules: FOTree

Contents

Introduction

FOTree is essentially a data structure. The processing that it does is essentially validating the data as it goes into the structure, and the mechanics of retrieving the data when it is called for by the client application. The following is a list of notable features in FOrayFOTree:

Eager vs. Patient Processing

FOray FOTree uses a SAX-like event system to make the client application aware that data is ready. Currently, events are fired when a page-sequence is complete and when the whole document is complete. Clients can use or ignore these events as they see fit. A client can also request to have events fired when each FO object is complete. This gives the client the opportunity to manage the processing in a more “eager” manner if it wishes to. It is kind of like having the SAX concept and the DOM concept rolled into one package. If you want the view-one-piece-at-a-time approach (like SAX), request events for each FO object. If you want the let-me-see-the-whole-thing approach (like DOM), then simply respond to the end-of-document event. If you want something in between, respond to the end-of-page-sequence event.

API

The API for FOray FOTree is intended to be very straightforward. As expected, all of the FO objects are organized in a tree. Each parent in the tree knows all of its children (through the getChildren() method, and each child in the tree knows its parent (through the getParent() method.

In general, the FOTree is designed to be independent of the other document-processing modules, such as Layout, AreaTree, and Renderers. It is also designed to be independent of any particular implementation (i.e. it can be used by applications other than FOray), and to be reusable (i.e. it can be used by LayoutStrategy A, then used again by LayoutStrategy B). This means that, in general, FOTree clients can read data all they want from the FOTree, but should not write data to it. The one current exception to this rule is that each FObj encapsulates one Object instance called “shadow”, which can be used by an FOTree client to hold whatever data it likes. In general, this approach is deprecated, but we have made it available to handle some legacy code. We may discontinue this “feature” in the future. If this capability is critically important to your application for some reason, please let us know.

Please note that, although the “shadow” concept was added to handle layout-specific data, the current Pioneer layout strategy used by FORay still writes to some other fields within the FOray FOTree. This is a legacy issue, and these fields will be systematically removed in the future. In general, your application should not write to any field in the FOTree except for the shadow.

If you wish to reuse an already-built FOTree, and you are using shadow instances to cache data, you can use the FOTreeBuilder.resetShadow() method to set all of the shadow instances in the FOTree to null.

The API for properties and traits requires more explanation. For the most part, FOray does not expose property values to FOTree clients, instead exposing, where possible, the computed, refined “trait” values, which are suitable for creating an AreaTree. Methods for obtaining trait values start with the word “trait”. Virtually any trait can be requested from any FO object, although only some of them make sense. As the spec mentions, many trait names are derived directly from the name of the property which is its source. So, for example, to get the value of the column-width property, use the traitColumnWidth method(). Because some traits depend on actual Area Tree dimensions, those properties require parameters to be passed to them that provide that information.

If it seems unnatural to have FO Objects with “trait” properties, understand that the methods are really returning the applicable trait values that apply to areas generated by the FO Object.

The following are exceptions to the above trait method naming convetion:

  • Abbreviated trait names. Abbreviations currently used include “IP” (inline-progression), “BP” (block-progression), “Min” (Minimum), “Opt” (Optimum), “Max” (Maximum) names.
  • Traits stemming from compound properties, like inline-progression-dimension, have methods for each of their components, e.g. has traitIPDimensionMin(), traitIPDimensionOpt, and traitIPDimensionMax() methods.
  • Traits stemming from Complex Property-to-Trait Mapping (as defined in Section 5.5 of the XSL-FO Standard 1.0). For example, the property text-decoration maps to the traits underline-score, underline-score-color, overline-score, overline-score-color, through-score, through-score-color, and blink. Trait values for these traits are obtained from traitUnderlineScore(), traitUnderlineScoreColor(), etc. There is no method for obtaining the raw text-decoration value.
  • Some properties require more than one method to get the data. This is because we have (so far anyway) been able to find a way to return only one value, usually because of the complexity of the types of data stored in the property. Some of these may intrinsically need to be this way. Others may be this way for historical reasons, and can be changed in the future. In most cases, it probably means that we do not yet understand well enough all of the dependencies for this item:
    • alignment-adjust. First run traitAlignmentAdjust(). If the return value is PropertyKeyword.NOT_A_KEYWORD, then run traitAlignmentAdjustAmount() to get the alignment adjustment in millipoints.
    • text-align. First run traitTextAlign(). If the return value is PropertyKeyword.NOT_A_KEYWORD, then run traitTextAlignString() to get the alignment string.
    • play-during. There are four methods required to get the entire picture: traitPlayDuring() returns a String containing the URL; traitPlayDuringMix(), traitPlayDuringRepeat() and traitPlayDuringAuto() all return boolean values.

List of Traits

The following is intended to eventually be a comprehensive list of traits and the properties from which they are derived. Rows in the butterscotch color are those which do not have a one-to-one relationship between the two. Please note that this list is not currently complete or correct. It is being currently being used as a checklist by the developers.

Trait From Property(s) Citations
absolute-position same, position
active-state same
actual-baseline-table ??? 4.1
alignment-adjust same, vertical-align 7.13.1, 7.29.22
alignment-baseline same, vertical-align 4.1, 7.13.2, 7.29.22
alignment-point ??? 4.1
area-class Derived mostly from the area ancestry. Affected by “float” property in some cases. 4.1 (last para), 4.2.5, 6.4.5, 6.4.13, 6.10.1.3, 6.10.2, 6.10.3, 6.10.4, 7.18.2
auto-restore same
azimuth same
background
background-attachment same, background 4.2.2
background-color same, background 4.2.2
background-image same, background 4.2.2
background-position 4.2.2
background-position-horizontal same, background-position, background
background-position-vertical same, background-position, background
background-repeat same, background 4.2.2
baseline-shift same, vertical-align 4.1, 7.13.3, 7.29.22
blank-or-not-blank same
blink text-decoration 4.1
block-progression-dimension same (also affected by height, width, max-height, max-width, min-height, min-width). 4.2.2, 5.3.3, 7.14.4, 7.14.5, 7.14.6, 7.14.7, 7.14.8, 7.14.9
block-progression-direction writing-mode, reference-orientation 4.1, 4.2.2, A.1
border same
border-after-color same 4.2.2
border-after-precedence same
border-after-style same 4.2.2
border-after-width same 4.2.2
border-before-color same 4.2.2
border-before-precedence same
border-before-style same 4.2.2
border-before-width same 4.2.2
border-bottom same
border-bottom-color same
border-bottom-style same
border-bottom-width same
border-collapse same
border-color same
border-end-color same 4.2.2
border-end-precedence same
border-end-style same 4.2.2
border-end-width same 4.2.2
border-left same
border-left-color same
border-left-style same
border-left-width same
border-right same
border-right-color same
border-right-style same
border-right-width same
border-separation same
n/a (shorthand for border-separation) border-spacing
border-start-color same 4.2.2
border-start-precedence same
border-start-style same 4.2.2
border-start-width same 4.2.2
border-style same
border-top same
border-top-color same
border-top-style same
border-top-width same
border-width same
bottom same
bottom-position ??? 4.1, 4.2.2
break-after same, page-break-after
break-before same, page-break-before
caption-side same
case-name same
case-title same
character same
clear same
clip same
color same
color-profile-name same
column-count same
column-gap same
column-number same
column-width same
content-height same
content-type same
content-width same
country same
cue
cue-after same, cue
cue-before same, cue
destination-placement-offset same
direction same
display-align same
dominant-baseline same, vertical-align 7.13.5, 7.29.22
dominant-baseline-identifier ??? 4.1
elevation same
empty-cells same
end-indent same, margin- (top, bottom, left, right), padding- (top, bottom, left, right), border- (top, bottom, left, right) -width.
end-intrusion-adjustment ??? 4.1, 4.4.1, 4.4.2, 4.5, 6.10.1.1
ends-row same
extent same
external-destination same
float same
flow-name same
font same
font-family same
font-selection-strategy same
font-size same
font-size-adjust same
font-stretch same
font-style same
font-variant same
font-weight same
force-page-count same
format same
generated-by Indicates which FO generated the area. 4.1, 6.1.1
glyph-orientation ??? 4.1, 4.2.2
glyph-orientation-horizontal same
glyph-orientation-vertical same
grouping-separator same
grouping-size same
half-leading-conditionality line-height 6.5.2
half-leading-maximum line-height, text-altitude, text-depth 6.5.2
half-leading-minimum line-height, text-altitude, text-depth 6.5.2
half-leading-optimum line-height, text-altitude, text-depth 6.5.2
half-leading-precedence line-height 6.5.2
n/a height (used in computation of inline-progression-dimension or block-progression-dimension). 5.3.3, 7.14.4
hyphenate same
hyphenation-character same
hyphenation-keep same
hyphenation-ladder-count same
hyphenation-push-character-count same
hyphenation-remain-character-count same
id same
indicate-destination same
initial-page-number same
inline-progression-dimension same (also affected by height, width, max-height, max-width, min-height, min-width). 4.2.2, 5.3.3, 7.14.4, 7.14.5, 7.14.6, 7.14.7, 7.14.8, 7.14.9
inline-progression-direction writing-mode, reference-orientation 4.1, 4.2.2, A.1
inline-progression-direction-even writing-mode, reference-orientation Implied at A.1
inline-progression-direction-odd writing-mode, reference-orientation Implied at A.1
internal-destination same
intrusion-displace same
is-first N/A 4.1, 4.2.2
is-last N/A 4.1, 4.2.2
is-reference-area ??? 4.1, 4.2.2
is-viewport-area ??? 4.1, 4.2.2
keep-together same, page-break-inside
keep-with-next same, page-break-after
keep-with-previous same, page-break-before
language same
last-line-end-indent same
leader-alignment same
leader-length same
leader-pattern same
leader-pattern-width same
left same
left-offset ??? 4.1, 4.2.2
left-position ??? 4.1, 4.2.2
letter-spacing same
letter-value same
linefeed-treatment same, white-space
line-height same 4.4
line-height-shift-adjustment same
line-stacking-strategy same
n/a margin (used in computation of space-before, space-after, space-start, space-end, start-indent, end-indent). 5.3.2
n/a margin-bottom (used in computation of space-before, space-after, space-start, space-end, start-indent, end-indent). 5.3.2
n/a margin-left (used in computation of space-before, space-after, space-start, space-end, start-indent, end-indent). 5.3.2
n/a margin-right (used in computation of space-before, space-after, space-start, space-end, start-indent, end-indent). 5.3.2
n/a margin-top (used in computation of space-before, space-after, space-start, space-end, start-indent, end-indent). 5.3.2
marker-class-name same
master-name same
master-reference same
n/a max-height (used in computation of inline-progression-dimension or block-progression-dimension). 5.3.3, 7.14.6
n/a max-width (used in computation of inline-progression-dimension or block-progression-dimension). 5.3.3, 7.14.7
maximum-repeats same
media-usage same
n/a min-height (used in computation of inline-progression-dimension or block-progression-dimension). 5.3.3, 7.14.8
n/a min-width (used in computation of inline-progression-dimension or block-progression-dimension). 5.3.3, 7.14.9
nominal-font ??? 4.1, 4.2.2
number-columns-repeated same
number-columns-spanned same
number-rows-spanned same
odd-or-even same
orphans same
overflow same
overline-score text-decoration 4.1
overline-score-color color attribute of fo object for which text-decoration property was set 4.1, 7.16.4
padding same
padding-after same 4.2.2
padding-before same 4.2.2
padding-bottom same
padding-end same 4.2.2
padding-start same 4.2.2
padding-top same
page-break-after
page-break-before
page-break-inside
page-height same, size
page-number ??? 4.1
page-position same
page-width same, size
pause
pause-after same, pause
pause-before same, pause
pitch same
pitch-range same
play-during same
position
precedence same
provisional-distance-between-starts same
provisional-label-separation same
reference-orientation same
ref-id same
region-name same
relative-align same
relative-position same, position
rendering-intent same
retrieve-boundary same
retrieve-class-name same
retrieve-position same
returned-by Derived from ancestry. 4.1, 6.1.1
richness same
right same
right-position ??? 4.1, 4.2.2
role same
rule-style same
rule-thickness same
scaling same
scaling-method same
score-spaces same
script script, ??? 4.1
shift-direction writing-mode 4.1, 4.2.2, A.1
shift-direction-even writing-mode implied at A.1
shift-direction-odd writing-mode implied at A.1
show-destination same
size
source-document same
space-after same, margin-top, margin-bottom, margin-left, margin-right 4.2.2, 5.3.2
space-before same, margin-top, margin-bottom, margin-left, margin-right 4.2.2, 5.3.2
space-end same, margin-top, margin-bottom, margin-left, margin-right 4.2.2, 5.3.2
space-start same, margin-top, margin-bottom, margin-left, margin-right 4.2.2, 5.3.2
span same
speak same
speak-header same
speak-numeral same
speak-punctuation same
speech-rate same
src same
start-indent same, margin- (top, bottom, left, right), padding- (top, bottom, left, right), border- (top, bottom, left, right) -width.
start-intrusion-adjustment ??? 4.1, 4.4.1, 4.4.2, 4.5, 6.10.1.1
starting-state same
starts-row same
stress same
suppress-at-line-break same
switch-to same
table-layout same
table-omit-footer-at-break same
table-omit-header-at-break same
target-presentation-context same
target-processing-context same
target-stylesheet same
text-align same
text-align-last same
text-altitude same
n/a text-decoration
text-depth same
text-indent same
text-shadow same
text-transform same
through-score text-decoration 4.1
through-score-color color attribute of fo object for which text-decoration property was set 4.1, 7.16.4
top same
top-offset ??? 4.1, 4.2.2
top-position ??? 4.1, 4.2.2
treat-as-word-space same
underline-score text-decoration 4.1
underline-score-color color attribute of fo object for which text-decoration property was set 4.1, 7.16.4
unicode-bidi same
n/a (shorthand) vertical-align
visibility same
voice-family same
volume same
white-space
white-space-collapse same, white-space
white-space-treatment same, white-space
widows same
n/a width (used in computation of inline-progression-dimension or block-progression-dimension). 5.3.3, 7.14.12
word-spacing same
wrap-option same, white-space
n/a writing-mode
xml:lang same
z-index same

Note: Although “width” and “height” do not have “trait” methods, they do have convenience “get” methods which map to the appropriate inline-progression-dimension or block-progression-dimension trait, depending on the writing mode. The same is true for margin-top, margin-bottom, margin-left, and margin-right, which map to one of space-before, space-after, start-indent, or end-indent, depending on the writing-mode.

Possible Future Enhancements

  • Consider detecting and storing patterns (i.e. templates or styles) that are indentical between different objects of the same type. For example, if two fo:block items have identical traits, they could share the same “style”. (This is an example of the GoF Flyweight pattern.)
  • Consider replacing the FontState class with appropriate FObj trait methods. Alternatively, this effort could be part of the “style” initiative, i.e. rather than replace FontState, fix it so that multiple FObj instances can share the same FontState instance.
  • Consider developing a scheme for explicitly supporting the concept of styles within the fo document itself. This would be a small step toward the idea of a replacement for XSLT as the intermediary between the semantic XML and the FO document.
  • We need to systematically remove all non-shadow layout-related fields from FObj subclasses.