org.foray.area
Class TextArea

java.lang.Object
  extended by org.foray.common.AbstractOrderedTreeNode
      extended by org.foray.area.AreaNode
          extended by org.foray.area.Area
              extended by org.foray.area.AreaFlexible
                  extended by org.foray.area.AbstractInlineArea
                      extended by org.foray.area.TextArea
All Implemented Interfaces:
Iterable<org.axsl.galley.AreaNode>, TreeNode, org.axsl.area.Area, org.axsl.area.AreaNode, org.axsl.area.GlyphAreaSequence, org.axsl.fo.FoContext, org.axsl.galley.GeneralInlineArea, org.axsl.galley.TextArea, OrderedTreeNode

public final class TextArea
extends AbstractInlineArea
implements org.axsl.galley.TextArea, org.axsl.area.GlyphAreaSequence

TextArea is a convenience class whose members represent contiguous glyph-areas that have identical text-related traits. With regard to the XSL-FO AreaTree, it is not a real area: essentially each character in the TextArea represents an XSL-FO glyph-area.

TextArea does not contain a copy of the text, but only keeps pointers to the text that is in the FOTree. Its generated-by is always an FObjMixed FO, and it is "backed" by exactly one of the nodes immediately under that FObjMixed item, usually an FOText node. TextArea stores a pointer to that node, as well a record of how much of that node's text actually belongs in this area. Please note that a given FOText node may have more than one TextArea that springs from it (they would have to be in different LineAreas or use different Fonts due to overriding). However , a TextSegment always springs from exactly one FOText node.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.foray.common.AbstractOrderedTreeNode
AbstractOrderedTreeNode.PostOrderDescendantIterator
 
Method Summary
 int countLetterSpacingChars()
          Counts the number of characters in this text that will have letter-spacing applied to them.
 int countSpaces()
          Counts the number of space-like characters in this text that should be rendered as spaces in the output.
 boolean endsWithLinefeed()
          Indicates whether this text-area ends with a linefeed.
 org.axsl.font.FontOptions fontOptions()
           
 String getAreaName()
           
 List<AreaNode> getChildren()
          Return the List of this node's children.
 FOLinkage getLinkage()
          Returns the raw "generated by" instance.
 Area getParent()
           
 org.axsl.font.FontUse getPrimaryFont()
           
 CharSequence getRawText()
          Returns the raw text for this area.
 int getResolvedLetterSpacing()
          Returns the resolved letter-spacing, in millipoints.
 org.axsl.font.FontUse getSecondaryFont(int codePoint)
           
 CharSequence getText()
          
static int ignoreAtEnd(CharSequence chars, int start, int size, boolean lastItemOnLine, org.axsl.common.value.WhiteSpaceTreatment whiteSpaceTreatment)
          Computes the number of characters that should be ignored at the end of this text-area.
static int ignoreAtStart(CharSequence chars, int start, int size, boolean firstItemOnLine, org.axsl.common.value.WhiteSpaceTreatment whiteSpaceTreatment)
          Computes the number of characters that should be ignored at the start of this text-area.
 int letterSpacing()
           
 int letterSpacingUsed()
          Computes the amount of space, in millipoints, that this area has already absorbed by adjusting word spacing.
 int maxLetterSpacingCapacity()
          Computes the total amount of space (including that already used), in millipoints, that the area can absorb by expanding each space to the maximum word space specified.
 int maxWordSpacingCapacity()
          Computes the amount of space, in millipoints, that the area can absorb by expanding each space to the maximum word space specified.
 int minLetterSpacingCapacity()
          Computes the amount of space, in millipoints, that the area can absorb by contracting each space to the minimum word space specified.
 int minWordSpacingCapacity()
          Computes the amount of space, in millipoints, that the area can absorb by contracting each space to the minimum word space specified.
protected  boolean optimize()
          This method should be run after layout is complete, allowing cleanup and adjustments that do not affect the placement of the areas to be computed before the page is rendered.
 org.axsl.common.i18n.Orthography orthography()
           
 void render(org.axsl.galley.RenderVisitor visitor)
           
 void setParent(AreaNode node)
          Sets the parent node.
 void setResolvedLetterSpacing(int resolvedLetterSpacing)
          Sets the resolved letter-spacing.
 void setResolvedWordSpacing(int resolvedWordSpacing)
          Sets the resolved word-spacing.
 int traitBorderAfterWidth()
          Returns the border-after-width trait for this area.
 int traitBorderBeforeWidth()
          Returns the border-before-width trait for this area.
 int traitBorderEndWidth()
          Returns the border-end-width trait for this area.
 int traitBorderStartWidth()
          Returns the border-start-width trait for this area.
 Color traitColor()
           
 int traitFontSize()
           Overrides the Area method because it needs to handle faux-small-caps.
 org.axsl.fo.fo.CharacterSequence traitGeneratedBy()
           
 int traitHyphenationCharacter()
          Returns the hyphenation-character trait for this area.
 int traitIPDimensionOpt()
          Return the optimum IP dimension for this area.
 int traitLetterSpacingMax()
          Returns the letter-spacing maximum trait.
 int traitLetterSpacingMin()
          Returns the letter-spacing minimum trait.
 int traitLetterSpacingOpt()
          Returns the letter-spacing optimum trait.
 boolean traitOverlineScore()
           
 Color traitOverlineScoreColor()
           
 int traitPaddingAfter()
          Returns the padding-after trait for this area.
 int traitPaddingBefore()
          Returns the padding-before trait for this area.
 int traitPaddingEnd()
          Returns the padding-end trait for this area.
 int traitPaddingStart()
          Returns the padding-start trait for this area.
 int traitSpaceEndOptimum()
          Returns the space-end optimum trait for this area.
 int traitSpaceStartOptimum()
          Returns the space-start optimum trait for this area.
 boolean traitThroughScore()
           
 Color traitThroughScoreColor()
           
 boolean traitUnderlineScore()
           
 Color traitUnderlineScoreColor()
           
 int traitWordSpacingMax()
          Returns the word-spacing maximum trait.
 int traitWordSpacingMin()
          Returns the word-spacing minimum trait.
 int traitWordSpacingOpt()
          Returns the word-spacing optimum trait.
 int wordSpacing()
           
 int wordSpacingUsed()
          Computes the amount of space, in millipoints, that this area has already absorbed by adjusting word spacing.
 
Methods inherited from class org.foray.area.AbstractInlineArea
baselineX, baselineY, contentStackingAxis, crBpd, crIpd, crOriginX, getLineArea, getOverflowArea, getProgressionDimension, incrementProgressionDimension, isAbsolutelyPositioned, isBlockArea, isFirstLeafOnLine, isLastLeafOnLine, setProgressionDimension, traitBaselineShift, traitEndIndent, traitSpaceAfterOptimum, traitSpaceBeforeOptimum, traitStartIndent, validateNewParent
 
Methods inherited from class org.foray.area.AreaFlexible
computeInitialPD, crIPDBlockArea, crOriginBPDOffset, crOriginIPDOffset, getAnteriorSpace, incrementAnteriorSpace, incrementParentPD, initializeAnteriorSpace, pdAvailable, pdUsedBySiblings, removeChild, setAnteriorSpace, setMinimumProgressionDimension, setParentPD, usedProgressionDimension, usedProgressionDimensionNormalFlow
 
Methods inherited from class org.foray.area.Area
brBpd, brIpd, brOriginBPDOffset, brOriginIPDOffset, brOriginX, brOriginY, brPoints, contentStackingAxisAbsolute, contentStackingDirectionAbsolute, crOriginY, crPoints, destinationName, generatedByExists, generatedByName, getAreaParent, getBPAxis, getFontWritingMode, getIPAxis, getNearestAncestorAreaContainer, getWritingMode, hasFenceFollowing, hasFencePreceding, isFirstChildOfParent, isInNormalFlow, isLastChildOfParent, isLinkRoot, larBPD, larIPD, larOriginX, larOriginY, linkDestination, linkType, narBPD, narIPD, narOriginX, narOriginY, nearestArea, parentAllocationWidth, prBpd, prIpd, prOriginBPDOffset, prOriginIPDOffset, prOriginX, prOriginY, referenceOrientationCumulative, shouldAdjustParentPD, traitAreaClass, traitId, traitIsFirst, traitIsLast, traitIsReferenceArea, traitWhiteSpaceTreatment
 
Methods inherited from class org.foray.area.AreaNode
ancestorArea, ancestorBlockAreaNotALineArea, ancestorBlockContentFactory, ancestorBlockOrRa, ancestorGeneratedByBlockLevelFO, ancestorLineArea, ancestorNormalBlockArea, ancestorPageCollection, ancestorReferenceArea, ancestorSpanRA, ancestorTableArea, bpdAncestorBlockOrRa, getAllowsChildren, getAreaTree, getChildAt, getColor, getContainingReferenceArea, getFirstAreaChild, getFirstChild, getGalley, getGraftingPoint, getLastAreaChild, getLastChild, getLogger, getNextChildOfGeneratedBy, getNextSiblingArea, getNormalLinkage, getNormalLinkage, getOrderedParent, getPage, getPreviousChildOfGeneratedBy, getPreviousSiblingArea, getSiblings, hasUnresolvedRefId, heightContainingBlock, ipdAncestorBlockArea, ipdAncestorBlockOrRa, ipdContainingRefArea, ipdParentArea, isFirst, isFirstChildOfGeneratedBy, isGeneratedByBlockLevelFo, isLast, isLastChildOfGeneratedBy, iterator, linkage, nearestBeforeFloatArea, nearestFootnoteArea, nearestGeneratedByBlockLevelFo, nearestNormalBlockArea, nearestTableArea, optimizeChildren, registerWithLinkage, remove, removeChild, tableWidth, widthContainingBlock
 
Methods inherited from class org.foray.common.AbstractOrderedTreeNode
children, getChildCount, getFirstLeaf, getIndex, getLastLeaf, getLevel, getNextLeaf, getNextSibling, getPreviousLeaf, getPreviousSibling, getSharedAncestor, hasChildren, isLeaf, isNodeAncestor, isNodeDescendant, nextPostOrderNode, nextPreOrderNode, postOrderDescendantIterator, siblingIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.axsl.galley.GeneralInlineArea
baselineX, baselineY, getLineArea
 
Methods inherited from interface org.axsl.galley.Area
brBpd, brIpd, brOriginX, brOriginY, crBpd, crIpd, crOriginX, crOriginY, destinationName, generatedByExists, generatedByName, isLinkRoot, linkDestination, linkType, traitId
 
Methods inherited from interface org.axsl.galley.AreaNode
getChildAt, getGalley
 
Methods inherited from interface javax.swing.tree.TreeNode
children, getAllowsChildren, getChildCount, getIndex, isLeaf
 
Methods inherited from interface java.lang.Iterable
iterator
 
Methods inherited from interface org.axsl.area.Area
crBpd, crIpd, pdAvailable
 
Methods inherited from interface org.axsl.area.AreaNode
ancestorArea, ancestorBlockContentFactory, ancestorNormalBlockArea, ancestorTableArea, getAreaTree, getPage, isFirstChildOfGeneratedBy, nearestArea, nearestGeneratedByBlockLevelFo, removeChild, siblingIndex
 
Methods inherited from interface org.axsl.fo.FoContext
bpdAncestorBlockOrRa, getGraftingPoint, heightContainingBlock, ipdAncestorBlockArea, ipdAncestorBlockOrRa, ipdContainingRefArea, ipdParentArea, isFirst, isLast, tableWidth, widthContainingBlock
 

Method Detail

getText

public CharSequence getText()

Computes and returns the text that should actually be used in the output document. Note that it may be different from the char array that backs this TextSegment for the following reasons:

Note that the following text changes occur elsewhere:

Specified by:
getText in interface org.axsl.galley.TextArea
Returns:
The text to be used in the output document.

getRawText

public CharSequence getRawText()
Returns the raw text for this area. This method is used primarily for testing purposes as it just dumps the text out without any final adjustments.

Returns:
The raw text from the FO Tree.

traitBorderBeforeWidth

public int traitBorderBeforeWidth()
Returns the border-before-width trait for this area. Overrides Area because line-areas have no borders or padding. See XSL-FO Standard 1.0, Section 4.5.

Specified by:
traitBorderBeforeWidth in class Area
Returns:
The border-before-width trait for this area.

traitBorderAfterWidth

public int traitBorderAfterWidth()
Returns the border-after-width trait for this area. Overrides Area because line-areas have no borders or padding. See XSL-FO Standard 1.0, Section 4.5.

Specified by:
traitBorderAfterWidth in class Area
Returns:
The border-after-width trait for this area.

traitBorderStartWidth

public int traitBorderStartWidth()
Returns the border-start-width trait for this area. Overrides Area because line-areas have no borders or padding. See XSL-FO Standard 1.0, Section 4.5.

Specified by:
traitBorderStartWidth in class Area
Returns:
The border-start-width trait for this area.

traitBorderEndWidth

public int traitBorderEndWidth()
Returns the border-end-width trait for this area. Overrides Area because line-areas have no borders or padding. See XSL-FO Standard 1.0, Section 4.5.

Specified by:
traitBorderEndWidth in class Area
Returns:
The border-end-width trait for this area.

traitPaddingBefore

public int traitPaddingBefore()
Returns the padding-before trait for this area. Overrides Area because line-areas have no borders or padding. See XSL-FO Standard 1.0, Section 4.5.

Specified by:
traitPaddingBefore in class Area
Returns:
The padding-before trait for this area.

traitPaddingAfter

public int traitPaddingAfter()
Returns the padding-after trait for this area. Overrides Area because line-areas have no borders or padding. See XSL-FO Standard 1.0, Section 4.5.

Specified by:
traitPaddingAfter in class Area
Returns:
The padding-after trait for this area.

traitPaddingStart

public int traitPaddingStart()
Returns the padding-start trait for this area. Overrides Area because line-areas have no borders or padding. See XSL-FO Standard 1.0, Section 4.5.

Specified by:
traitPaddingStart in class Area
Returns:
The padding-start trait for this area.

traitPaddingEnd

public int traitPaddingEnd()
Returns the padding-end trait for this area. Overrides Area because line-areas have no borders or padding. See XSL-FO Standard 1.0, Section 4.5.

Specified by:
traitPaddingEnd in class Area
Returns:
The padding-end trait for this area.

ignoreAtStart

public static int ignoreAtStart(CharSequence chars,
                                int start,
                                int size,
                                boolean firstItemOnLine,
                                org.axsl.common.value.WhiteSpaceTreatment whiteSpaceTreatment)
Computes the number of characters that should be ignored at the start of this text-area.

Parameters:
chars - The char array containing the text.
start - The first char that is part of the text.
size - The size of the the chars that are part of the text.
firstItemOnLine - Indicates whether this content will be the first item on the line.
whiteSpaceTreatment - The white-space treatment value.
Returns:
The number of characters that should be ignored.

ignoreAtEnd

public static int ignoreAtEnd(CharSequence chars,
                              int start,
                              int size,
                              boolean lastItemOnLine,
                              org.axsl.common.value.WhiteSpaceTreatment whiteSpaceTreatment)
Computes the number of characters that should be ignored at the end of this text-area.

Parameters:
chars - The char array containing the text.
start - The first char that is part of the text.
size - The size of the the chars that are part of the text.
lastItemOnLine - Indicates whether this content will be the last item on the line.
whiteSpaceTreatment - The white-space treatment value.
Returns:
The number of characters that should be ignored.

wordSpacingUsed

public int wordSpacingUsed()
Computes the amount of space, in millipoints, that this area has already absorbed by adjusting word spacing.

Returns:
The total actual word spacing adjustment for this area.

maxWordSpacingCapacity

public int maxWordSpacingCapacity()
Computes the amount of space, in millipoints, that the area can absorb by expanding each space to the maximum word space specified.

Returns:
The maximum total specified word space for this area.

minWordSpacingCapacity

public int minWordSpacingCapacity()
Computes the amount of space, in millipoints, that the area can absorb by contracting each space to the minimum word space specified.

Returns:
The minimum total specified word space for this area.

letterSpacingUsed

public int letterSpacingUsed()
Computes the amount of space, in millipoints, that this area has already absorbed by adjusting word spacing.

Returns:
The total actual word spacing adjustment for this area.

maxLetterSpacingCapacity

public int maxLetterSpacingCapacity()
Computes the total amount of space (including that already used), in millipoints, that the area can absorb by expanding each space to the maximum word space specified.

Returns:
The maximum total specified word space for this area.

minLetterSpacingCapacity

public int minLetterSpacingCapacity()
Computes the amount of space, in millipoints, that the area can absorb by contracting each space to the minimum word space specified.

Returns:
The minimum total specified word space for this area.

countSpaces

public int countSpaces()
Counts the number of space-like characters in this text that should be rendered as spaces in the output.

Returns:
The numbers of spaces in this text.

countLetterSpacingChars

public int countLetterSpacingChars()
Counts the number of characters in this text that will have letter-spacing applied to them.

Returns:
The numbers of characters in this text to which letter-spacing will be applied.

endsWithLinefeed

public boolean endsWithLinefeed()
Indicates whether this text-area ends with a linefeed.

Returns:
True iff this text-area ends with a linefeed.

getResolvedLetterSpacing

public int getResolvedLetterSpacing()
Returns the resolved letter-spacing, in millipoints.

Returns:
Returns the resolvedLetterSpacing.

letterSpacing

public int letterSpacing()
Specified by:
letterSpacing in interface org.axsl.galley.TextArea

setResolvedLetterSpacing

public void setResolvedLetterSpacing(int resolvedLetterSpacing)
Sets the resolved letter-spacing.

Parameters:
resolvedLetterSpacing - The resolvedLetterSpacing to set.

wordSpacing

public int wordSpacing()
Specified by:
wordSpacing in interface org.axsl.galley.TextArea

setResolvedWordSpacing

public void setResolvedWordSpacing(int resolvedWordSpacing)
Sets the resolved word-spacing.

Parameters:
resolvedWordSpacing - The resolvedWordSpacing to set.

traitFontSize

public int traitFontSize()
Overrides the Area method because it needs to handle faux-small-caps.

Specified by:
traitFontSize in interface org.axsl.galley.TextArea

getAreaName

public String getAreaName()
Specified by:
getAreaName in interface org.axsl.area.AreaNode

traitGeneratedBy

public org.axsl.fo.fo.CharacterSequence traitGeneratedBy()
Specified by:
traitGeneratedBy in interface org.axsl.area.AreaNode
Specified by:
traitGeneratedBy in class AreaNode

render

public void render(org.axsl.galley.RenderVisitor visitor)
            throws org.axsl.galley.GalleyVisitorException
Throws:
org.axsl.galley.GalleyVisitorException

getChildren

public List<AreaNode> getChildren()
Description copied from class: AbstractOrderedTreeNode
Return the List of this node's children.

Specified by:
getChildren in class AreaNode
Returns:
The List of this node's children.

optimize

protected boolean optimize()
Description copied from class: AreaNode
This method should be run after layout is complete, allowing cleanup and adjustments that do not affect the placement of the areas to be computed before the page is rendered. For example, empty areas should be removed. Also classes like LineArea can use this to adjust word-spacing and other variables. NOTE: This method is called recursively by each node. The process starts at PageRA.layoutComplete().

Specified by:
optimize in class AreaNode
Returns:
True iff the Area node thinks it should be removed.

getLinkage

public FOLinkage getLinkage()
Description copied from class: AreaNode
Returns the raw "generated by" instance.

Specified by:
getLinkage in class AreaNode
Returns:
The raw linkage item.

fontOptions

public org.axsl.font.FontOptions fontOptions()
Specified by:
fontOptions in interface org.axsl.galley.TextArea

orthography

public org.axsl.common.i18n.Orthography orthography()
Specified by:
orthography in interface org.axsl.galley.TextArea

getParent

public Area getParent()
Specified by:
getParent in interface TreeNode
Specified by:
getParent in class AreaNode

setParent

public void setParent(AreaNode node)
               throws org.axsl.area.AreaTreeException
Description copied from class: AreaNode
Sets the parent node.

Specified by:
setParent in class AreaNode
Parameters:
node - The new parent node.
Throws:
org.axsl.area.AreaTreeException - If the parent node is not compatible with the implementations specification for a parent node.

getPrimaryFont

public org.axsl.font.FontUse getPrimaryFont()
Specified by:
getPrimaryFont in interface org.axsl.galley.TextArea

getSecondaryFont

public org.axsl.font.FontUse getSecondaryFont(int codePoint)
Specified by:
getSecondaryFont in interface org.axsl.galley.TextArea

traitHyphenationCharacter

public int traitHyphenationCharacter()
Returns the hyphenation-character trait for this area.

Returns:
The hyphenation-character trait for this area.

traitSpaceStartOptimum

public int traitSpaceStartOptimum()
Description copied from class: Area
Returns the space-start optimum trait for this area.

Specified by:
traitSpaceStartOptimum in class Area
Returns:
The space-start optimum trait for this area.

traitSpaceEndOptimum

public int traitSpaceEndOptimum()
Description copied from class: Area
Returns the space-end optimum trait for this area.

Specified by:
traitSpaceEndOptimum in class Area
Returns:
The space-end optimum trait for this area.

traitWordSpacingOpt

public int traitWordSpacingOpt()
Returns the word-spacing optimum trait.

Returns:
The word-spacing optimum trait.

traitWordSpacingMax

public int traitWordSpacingMax()
Returns the word-spacing maximum trait.

Returns:
The word-spacing maximum trait.

traitWordSpacingMin

public int traitWordSpacingMin()
Returns the word-spacing minimum trait.

Returns:
The word-spacing minimum trait.

traitLetterSpacingOpt

public int traitLetterSpacingOpt()
Returns the letter-spacing optimum trait.

Returns:
The letter-spacing optimum trait.

traitLetterSpacingMax

public int traitLetterSpacingMax()
Returns the letter-spacing maximum trait.

Returns:
The letter-spacing maximum trait.

traitLetterSpacingMin

public int traitLetterSpacingMin()
Returns the letter-spacing minimum trait.

Returns:
The letter-spacing minimum trait.

traitUnderlineScore

public boolean traitUnderlineScore()
Specified by:
traitUnderlineScore in interface org.axsl.galley.GeneralInlineArea

traitOverlineScore

public boolean traitOverlineScore()
Specified by:
traitOverlineScore in interface org.axsl.galley.GeneralInlineArea

traitThroughScore

public boolean traitThroughScore()
Specified by:
traitThroughScore in interface org.axsl.galley.GeneralInlineArea

traitUnderlineScoreColor

public Color traitUnderlineScoreColor()
Specified by:
traitUnderlineScoreColor in interface org.axsl.galley.GeneralInlineArea

traitOverlineScoreColor

public Color traitOverlineScoreColor()
Specified by:
traitOverlineScoreColor in interface org.axsl.galley.GeneralInlineArea

traitThroughScoreColor

public Color traitThroughScoreColor()
Specified by:
traitThroughScoreColor in interface org.axsl.galley.GeneralInlineArea

traitIPDimensionOpt

public int traitIPDimensionOpt()
Description copied from class: AreaFlexible
Return the optimum IP dimension for this area.

Specified by:
traitIPDimensionOpt in class AreaFlexible
Returns:
The optimum IP dimension for this area, or -1 for "auto".

traitColor

public Color traitColor()
Specified by:
traitColor in interface org.axsl.galley.GeneralInlineArea


Copyright © 2017. All rights reserved.