org.foray.area
Class LeaderArea

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.AbstractAncestralInlineArea
                          extended by org.foray.area.LeaderArea
All Implemented Interfaces:
Iterable<org.axsl.galley.AreaNode>, TreeNode, org.axsl.area.AncestralNormalInlineArea, org.axsl.area.Area, org.axsl.area.AreaNode, org.axsl.area.LineContentFactory, org.axsl.area.NormalInlineArea, org.axsl.fo.FoContext, org.axsl.galley.GeneralInlineArea, org.axsl.galley.LeaderArea, org.axsl.galley.TextArea, OrderedTreeNode

public final class LeaderArea
extends AbstractAncestralInlineArea
implements org.axsl.galley.LeaderArea, org.axsl.area.AncestralNormalInlineArea

An Area containing a leader item.

There are at least two approaches that can be taken in the design of this class. The first is that its instances are placeholders during the layout process, and then at render-time, it should convert or replace itself with other objects (likes words and spaces) that represent its content. The problem with this approach is that it may not take advantage of the Renderer's capabilities. FOray has instead chosen to let the Renderer render the leader in whatever manner it sees fit.

Space and rule leaders are pretty straightforward. Dot leaders and use-content leaders require more effort. FOray treats a dot leader as a specific case (a subset) of use-content leaders. In other words, the content of use-content is a dot. To render any use-content leader, the Renderer must know the following things:


Nested Class Summary
 
Nested classes/interfaces inherited from class org.foray.common.AbstractOrderedTreeNode
AbstractOrderedTreeNode.PostOrderDescendantIterator
 
Method Summary
 int actualWordSpacing()
          Computes the size of the extra word spacing that should be between each dot character, that is, the additional displacement beyond the width of the space character itself.
 CharSequence dotLeaderText()
           
 int dotLeaderTextOffset()
          Computes the offset from this's start-edge at which the first dot should appear.
 int dotLeaderTextSize()
          Returns the size of the leader text.
 String getAreaName()
           
 int getCharWidth(int c)
          Computes the width of a character, in millipoints.
 FOLinkage getLinkage()
          Returns the raw "generated by" instance.
 Area getParent()
           
 org.axsl.font.FontUse getPrimaryFont()
           
 org.axsl.font.FontUse getSecondaryFont(int codePoint)
           
 CharSequence getText()
           
 int letterSpacing()
           
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.
 void render(org.axsl.galley.RenderVisitor visitor)
           
 void setParent(AreaNode node)
          Sets the parent node.
 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()
          Returns the font-size trait.
 org.axsl.fo.fo.Leader traitGeneratedBy()
           
 int traitIPDimensionOpt()
          Return the optimum IP dimension for this area.
 org.axsl.common.value.LeaderAlignment traitLeaderAlignment()
          Pass-thru of the FOTree trait value.
 int traitLeaderLengthMax()
          Returns the maximum length of this leader, in millipoints.
 int traitLeaderLengthMin()
          Returns the minimum length of this leader, in millipoints.
 int traitLeaderLengthOpt()
          Returns the optimum length of this leader, in millipoints.
 org.axsl.common.value.LeaderPattern traitLeaderPattern()
           Pass-thru of the FOTree trait value, with one exception.
 int traitLeaderPatternWidth()
          Pass-thru of the FOTree trait value.
 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.
 org.axsl.common.value.RuleStyle traitRuleStyle()
           
 int traitRuleThickness()
           
 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 wordSpacing()
           
 
Methods inherited from class org.foray.area.AbstractAncestralInlineArea
fontOptions, getChildren, makeBasicLinkArea, makeBidiOverrideArea, makeExternalGraphicArea, makeForeignObjectArea, makeGlyphAreaSequence, makeIndexPageCitationListArea, makeInlineArea, makeInlineContainerArea, makeLeaderArea, makePageNumberArea, makePageNumberCitationArea, makePageNumberCitationLastArea, makeScalingValueCitationArea, orthography
 
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.TextArea
fontOptions, orthography
 
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
 
Methods inherited from interface org.axsl.area.LineContentFactory
makeBasicLinkArea, makeBidiOverrideArea, makeExternalGraphicArea, makeForeignObjectArea, makeGlyphAreaSequence, makeIndexPageCitationListArea, makeInlineArea, makeInlineContainerArea, makeLeaderArea, makePageNumberArea, makePageNumberCitationArea, makePageNumberCitationLastArea, makeScalingValueCitationArea
 

Method Detail

traitLeaderPattern

public org.axsl.common.value.LeaderPattern traitLeaderPattern()
Pass-thru of the FOTree trait value, with one exception. In the case of leader-pattern="rule", if the effective rule-thickness is 0, return the value for leader-pattern="space", as if it were actually a space leader. Note that by applying this condition to rule-thickness, the case of rule-style="none" is included, since FOTree returns a value of zero for rule-thickness in that case. TODO: Renderers that need to do special handling of rules with thickness of zero (including the PDFRenderer) can eventually remove that special handling. We'll refrain from doing so until we are sure there are no unintended side-effects of this override logic.

Specified by:
traitLeaderPattern in interface org.axsl.galley.LeaderArea
See Also:
LeaderPatternPa.traitLeaderPattern(org.axsl.fo.FoContext)

traitLeaderPatternWidth

public int traitLeaderPatternWidth()
Pass-thru of the FOTree trait value.

Returns:
The leader pattern width, in millipoints.
See Also:
LeaderPatternWidthPa.traitLeaderPatternWidth(org.axsl.fo.FoContext)

traitLeaderAlignment

public org.axsl.common.value.LeaderAlignment traitLeaderAlignment()
Pass-thru of the FOTree trait value.

Returns:
The leader alignment.
See Also:
LeaderAlignmentPa.traitLeaderAlignment(org.axsl.fo.FoContext)

traitRuleStyle

public org.axsl.common.value.RuleStyle traitRuleStyle()
Specified by:
traitRuleStyle in interface org.axsl.galley.LeaderArea

traitRuleThickness

public int traitRuleThickness()
Specified by:
traitRuleThickness in interface org.axsl.galley.LeaderArea

actualWordSpacing

public int actualWordSpacing()
Computes the size of the extra word spacing that should be between each dot character, that is, the additional displacement beyond the width of the space character itself. If leader-pattern width = use-font-metrics, this will be equal to 0. This is what the Renderer should set "word-space" to if it is able.

Returns:
The additional word spacing, in millipoints, that should be applied when rendering this leader.

wordSpacing

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

letterSpacing

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

dotLeaderTextOffset

public int dotLeaderTextOffset()
Computes the offset from this's start-edge at which the first dot should appear. The renderer needs to adjust its positioning to account for this space before starting to write the text.

Returns:
The length, in millipoints, from the start-edge, that should mark the start-edge of the first dot.

getText

public CharSequence getText()
Specified by:
getText in interface org.axsl.galley.TextArea

dotLeaderText

public CharSequence dotLeaderText()
Specified by:
dotLeaderText in interface org.axsl.galley.LeaderArea

dotLeaderTextSize

public int dotLeaderTextSize()
Returns the size of the leader text.

Returns:
The size, in millipoints, of the text portion of the leader. This does not count the leading or trailing space portions.

traitLeaderLengthMin

public int traitLeaderLengthMin()
Returns the minimum length of this leader, in millipoints.

Returns:
The minimum length of this leader, in millipoints.

traitLeaderLengthOpt

public int traitLeaderLengthOpt()
Returns the optimum length of this leader, in millipoints.

Returns:
The optimum length of this leader, in millipoints.

traitLeaderLengthMax

public int traitLeaderLengthMax()
Returns the maximum length of this leader, in millipoints.

Returns:
The maximum length of this leader, in millipoints.

getAreaName

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

render

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

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.

traitGeneratedBy

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

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.

traitBorderStartWidth

public int traitBorderStartWidth()
Description copied from class: Area
Returns the border-start-width trait for this area.

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

traitBorderEndWidth

public int traitBorderEndWidth()
Description copied from class: Area
Returns the border-end-width trait for this area.

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

traitBorderBeforeWidth

public int traitBorderBeforeWidth()
Description copied from class: Area
Returns the border-before-width trait for this area.

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

traitBorderAfterWidth

public int traitBorderAfterWidth()
Description copied from class: Area
Returns the border-after-width trait for this area.

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

traitPaddingStart

public int traitPaddingStart()
Description copied from class: Area
Returns the padding-start trait for this area.

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

traitPaddingEnd

public int traitPaddingEnd()
Description copied from class: Area
Returns the padding-end trait for this area.

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

traitPaddingBefore

public int traitPaddingBefore()
Description copied from class: Area
Returns the padding-before trait for this area.

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

traitPaddingAfter

public int traitPaddingAfter()
Description copied from class: Area
Returns the padding-after trait for this area.

Specified by:
traitPaddingAfter in class Area
Returns:
The padding-after 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.

getCharWidth

public int getCharWidth(int c)
Computes the width of a character, in millipoints.

Parameters:
c - The Unicode codepoint whose width should be computed.
Returns:
The width of the codepoint, in millipoints.

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

traitFontSize

public int traitFontSize()
Returns the font-size trait.

Specified by:
traitFontSize in interface org.axsl.galley.TextArea
Returns:
The font-size trait.

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


Copyright © 2017. All rights reserved.