org.foray.area
Class AreaNode

java.lang.Object
  extended by org.foray.common.AbstractOrderedTreeNode
      extended by org.foray.area.AreaNode
All Implemented Interfaces:
Iterable<org.axsl.galley.AreaNode>, TreeNode, org.axsl.area.AreaNode, org.axsl.fo.FoContext, OrderedTreeNode
Direct Known Subclasses:
Area, NonArea

public abstract class AreaNode
extends AbstractOrderedTreeNode
implements org.axsl.galley.AreaNode, org.axsl.area.AreaNode

Abstract superclass for all nodes in the AreaTree.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.foray.common.AbstractOrderedTreeNode
AbstractOrderedTreeNode.PostOrderDescendantIterator
 
Constructor Summary
protected AreaNode()
          Constructor.
 
Method Summary
 Area ancestorArea()
           
 Area ancestorBlockAreaNotALineArea()
          Returns the ancestor block area that is not a line area.
 org.axsl.area.BlockContentFactory ancestorBlockContentFactory()
           
 Area ancestorBlockOrRa()
          Returns the nearest ancestor Area that was generated by a block-level formatting object, if such an area exists.
 Area ancestorGeneratedByBlockLevelFO()
          Finds the nearest ancestor area that was generated by a block-level formatting object.
 LineArea ancestorLineArea()
          Returns the ancestor LineArea, if any.
 NormalBlockArea ancestorNormalBlockArea()
           
 PageCollection ancestorPageCollection()
          Returns the ancestor page collection for this area.
 Area ancestorReferenceArea()
          Returns the nearest ancestor reference area.
 SpanRA ancestorSpanRA()
          Returns the ancestor Span area.
 TableRA ancestorTableArea()
           
 int bpdAncestorBlockOrRa()
           
 boolean getAllowsChildren()
           
 AreaTree getAreaTree()
          Returns the ancestor AreaTree for this area.
 AreaNode getChildAt(int childIndex)
           
abstract  List<? extends AreaNode> getChildren()
          Return the List of this node's children.
 Color getColor()
          Returns the color of this Area.
 Area getContainingReferenceArea()
          Returns the nearest ancestor that is a reference area.
 Area getFirstAreaChild()
          Returns the first child that is an Area.
 AreaNode getFirstChild()
          Returns the first child of this node.
 org.axsl.galley.Galley getGalley()
          Returns the ancestor Galley for this area.
 org.axsl.fo.fo.GraftingPoint getGraftingPoint()
           
 Area getLastAreaChild()
          Returns the last child that is an Area.
 AreaNode getLastChild()
          Returns the last child of this node.
abstract  FOLinkage getLinkage()
          Returns the raw "generated by" instance.
 org.apache.commons.logging.Log getLogger()
          Return the logger.
protected  AreaNode getNextChildOfGeneratedBy()
          Returns the next child of this area's "generated-by".
 Area getNextSiblingArea()
          Returns the next sibling node that is an Area, if any.
 FOLinkageNormal getNormalLinkage()
          Returns the normal linkage associated with this Area.
 FOLinkageNormal getNormalLinkage(org.axsl.fo.fo.GraftingPoint graftingPoint)
          Use this overloaded version when we haven't yet gotten the RetrieveMarker instance stashed in the FOLinkageMarker, especially during AreaNode construction.
 OrderedTreeNode getOrderedParent()
          Returns the parent of this node, cast as an OrderedTreeNode.
 PageRA getPage()
           
abstract  AreaNode getParent()
           
protected  AreaNode getPreviousChildOfGeneratedBy()
          Returns the previous child of this area's "generated-by".
 Area getPreviousSiblingArea()
          Returns the previous sibling node that is an Area, if any.
 List<? extends AreaNode> getSiblings()
          Returns the List of this node's parent's children, which includes this node.
 boolean hasUnresolvedRefId()
          Indicates whether this node is dependent on an unresolved "ref-id".
 int heightContainingBlock()
           
 int ipdAncestorBlockArea()
           
 int ipdAncestorBlockOrRa()
           
 int ipdContainingRefArea()
           
 int ipdParentArea()
           
 boolean isFirst()
           
 boolean isFirstChildOfGeneratedBy()
           
 boolean isGeneratedByBlockLevelFo()
          Indicates whether this Area was generated by a block-level FO.
 boolean isLast()
           
protected  boolean isLastChildOfGeneratedBy()
          Indicates whether this is the last child of this area's "generated-by".
 Iterator<org.axsl.galley.AreaNode> iterator()
           
 FOLinkage linkage(org.axsl.fo.Fo foNode, org.axsl.fo.fo.GraftingPoint graftingPoint)
          Retrieves or creates a linkage item for a given FONode.
 Area nearestArea()
           
 BeforeFloatRA nearestBeforeFloatArea()
          Returns this area's ancestor footnote-area, if any, or this, if this is a footnote area, or null if this area is not part of a footnote.
 FootnoteRA nearestFootnoteArea()
          Returns this area's ancestor footnote-area, if any, or this, if this is a footnote area, or null if this area is not part of a footnote.
 Area nearestGeneratedByBlockLevelFo()
           
 NormalBlockArea nearestNormalBlockArea()
          Returns this if this is a normal block area, or the nearest ancestor normal block area otherwise.
 TableRA nearestTableArea()
          Retujrns this if it is an instance of TableRA, or the nearest ancestor TableRA if it is not.
protected abstract  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.
protected  void optimizeChildren()
          Optimizes the children of this node.
protected  void registerWithLinkage(org.axsl.fo.fo.GraftingPoint graftingPoint)
          Creates the linkage to the FO Tree for this area.
 void remove()
          Removes this from the parent's list of children.
 void removeChild(org.axsl.area.AreaNode areaNode)
           
abstract  void setParent(AreaNode node)
          Sets the parent node.
 int tableWidth()
           
abstract  org.axsl.fo.Fo traitGeneratedBy()
           
 int 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.AreaNode
getAreaName, render
 
Methods inherited from interface org.axsl.area.AreaNode
getAreaName, siblingIndex
 
Methods inherited from interface javax.swing.tree.TreeNode
children, getChildCount, getIndex, isLeaf
 

Constructor Detail

AreaNode

protected AreaNode()
Constructor.

Method Detail

registerWithLinkage

protected void registerWithLinkage(org.axsl.fo.fo.GraftingPoint graftingPoint)
Creates the linkage to the FO Tree for this area.

Parameters:
graftingPoint - The ancestor grafting point, if any.

getParent

public abstract AreaNode getParent()
Specified by:
getParent in interface TreeNode

getOrderedParent

public OrderedTreeNode getOrderedParent()
Description copied from interface: OrderedTreeNode
Returns the parent of this node, cast as an OrderedTreeNode.

Specified by:
getOrderedParent in interface OrderedTreeNode
Returns:
The parent of this node.

setParent

public abstract void setParent(AreaNode node)
                        throws org.axsl.area.AreaTreeException
Sets the parent node.

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.

getChildren

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

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

getChildAt

public AreaNode getChildAt(int childIndex)
Specified by:
getChildAt in interface TreeNode

getSiblings

public List<? extends AreaNode> getSiblings()
Description copied from class: AbstractOrderedTreeNode
Returns the List of this node's parent's children, which includes this node.

Specified by:
getSiblings in class AbstractOrderedTreeNode
Returns:
The List of this node's parent's children.

remove

public void remove()
Removes this from the parent's list of children.


removeChild

public void removeChild(org.axsl.area.AreaNode areaNode)
Specified by:
removeChild in interface org.axsl.area.AreaNode

linkage

public FOLinkage linkage(org.axsl.fo.Fo foNode,
                         org.axsl.fo.fo.GraftingPoint graftingPoint)
Retrieves or creates a linkage item for a given FONode.

Parameters:
foNode - The FONode for which linkage is needed.
graftingPoint - The ancestor RetrieveMarker, if any.
Returns:
The linkage item.

getNormalLinkage

public FOLinkageNormal getNormalLinkage()
Returns the normal linkage associated with this Area.

Returns:
The normal linkage associated with this Area.

getNormalLinkage

public FOLinkageNormal getNormalLinkage(org.axsl.fo.fo.GraftingPoint graftingPoint)
Use this overloaded version when we haven't yet gotten the RetrieveMarker instance stashed in the FOLinkageMarker, especially during AreaNode construction.

Parameters:
graftingPoint - The retrieve-marker.
Returns:
The normal linkage associated with this Area.

getPreviousChildOfGeneratedBy

protected AreaNode getPreviousChildOfGeneratedBy()
Returns the previous child of this area's "generated-by".

Returns:
The previous child of this area's "generated-by", or null if this is the first child.

getNextChildOfGeneratedBy

protected AreaNode getNextChildOfGeneratedBy()
Returns the next child of this area's "generated-by".

Returns:
The next child of this area's "generated-by", or null if this is the last child.

isFirstChildOfGeneratedBy

public boolean isFirstChildOfGeneratedBy()
Specified by:
isFirstChildOfGeneratedBy in interface org.axsl.area.AreaNode

isLastChildOfGeneratedBy

protected boolean isLastChildOfGeneratedBy()
Indicates whether this is the last child of this area's "generated-by".

Returns:
True iff this is the last child of this area's "generated-by".

getAreaTree

public AreaTree getAreaTree()
Returns the ancestor AreaTree for this area.

Specified by:
getAreaTree in interface org.axsl.area.AreaNode
Returns:
The ancestor AreaTree for this area.

getGalley

public org.axsl.galley.Galley getGalley()
Returns the ancestor Galley for this area.

Returns:
The ancestor Galley for this area.

ancestorArea

public Area ancestorArea()
Specified by:
ancestorArea in interface org.axsl.area.AreaNode

nearestArea

public Area nearestArea()
Specified by:
nearestArea in interface org.axsl.area.AreaNode

getPreviousSiblingArea

public Area getPreviousSiblingArea()
Returns the previous sibling node that is an Area, if any.

Returns:
The previous sibling area.

getNextSiblingArea

public Area getNextSiblingArea()
Returns the next sibling node that is an Area, if any.

Returns:
The next sibling area.

ancestorBlockAreaNotALineArea

public Area ancestorBlockAreaNotALineArea()
Returns the ancestor block area that is not a line area.

Returns:
The ancestor block area that is not a line area, or null if there is none.

ancestorReferenceArea

public Area ancestorReferenceArea()
Returns the nearest ancestor reference area.

Returns:
The nearest ancestor reference area.

ancestorNormalBlockArea

public NormalBlockArea ancestorNormalBlockArea()
Specified by:
ancestorNormalBlockArea in interface org.axsl.area.AreaNode

nearestNormalBlockArea

public NormalBlockArea nearestNormalBlockArea()
Returns this if this is a normal block area, or the nearest ancestor normal block area otherwise.

Returns:
The nearest normal block area, which can be this.

getContainingReferenceArea

public Area getContainingReferenceArea()
Returns the nearest ancestor that is a reference area.

Returns:
The nearest ancestor that is a reference area.

getPage

public PageRA getPage()
Specified by:
getPage in interface org.axsl.area.AreaNode

getLogger

public org.apache.commons.logging.Log getLogger()
Return the logger.

Returns:
The logger.

nearestGeneratedByBlockLevelFo

public Area nearestGeneratedByBlockLevelFo()
Specified by:
nearestGeneratedByBlockLevelFo in interface org.axsl.area.AreaNode

ancestorGeneratedByBlockLevelFO

public Area ancestorGeneratedByBlockLevelFO()
Finds the nearest ancestor area that was generated by a block-level formatting object.

Returns:
The nearest ancestor Area generated by a block-level FO, or null if there is none.

isGeneratedByBlockLevelFo

public boolean isGeneratedByBlockLevelFo()
Indicates whether this Area was generated by a block-level FO.

Returns:
True iff this Area was generated by a block-level FO.

traitGeneratedBy

public abstract org.axsl.fo.Fo traitGeneratedBy()
Specified by:
traitGeneratedBy in interface org.axsl.area.AreaNode

getFirstChild

public AreaNode getFirstChild()
Description copied from interface: OrderedTreeNode
Returns the first child of this node.

Specified by:
getFirstChild in interface OrderedTreeNode
Overrides:
getFirstChild in class AbstractOrderedTreeNode
Returns:
The first child of this node, or null if this node has no children.

getLastChild

public AreaNode getLastChild()
Description copied from interface: OrderedTreeNode
Returns the last child of this node.

Specified by:
getLastChild in interface OrderedTreeNode
Overrides:
getLastChild in class AbstractOrderedTreeNode
Returns:
The last child of this node, or null if this node has no children.

getFirstAreaChild

public Area getFirstAreaChild()
Returns the first child that is an Area.

Returns:
The first Area child.

getLastAreaChild

public Area getLastAreaChild()
Returns the last child that is an Area.

Returns:
The last Area child.

ancestorSpanRA

public SpanRA ancestorSpanRA()
Returns the ancestor Span area.

Returns:
The ancestor SpanRA, or null if there is none.

ancestorLineArea

public LineArea ancestorLineArea()
Returns the ancestor LineArea, if any.

Returns:
The ancestor LineArea, or null if there is none.

ancestorTableArea

public TableRA ancestorTableArea()
Specified by:
ancestorTableArea in interface org.axsl.area.AreaNode

nearestTableArea

public TableRA nearestTableArea()
Retujrns this if it is an instance of TableRA, or the nearest ancestor TableRA if it is not.

Returns:
This or the nearest ancestor Table.

ancestorBlockContentFactory

public org.axsl.area.BlockContentFactory ancestorBlockContentFactory()
Specified by:
ancestorBlockContentFactory in interface org.axsl.area.AreaNode

ancestorPageCollection

public PageCollection ancestorPageCollection()
Returns the ancestor page collection for this area.

Returns:
The ancestor page collection.

hasUnresolvedRefId

public boolean hasUnresolvedRefId()

Indicates whether this node is dependent on an unresolved "ref-id". For example, a page-number-citation creates a PageNumberCitationArea, the contents of which are not known until the FO with the corresponding "id" property returns at least one normal area in the AreaTree. Until that normal area can be found, the PageNumberCitationArea cannot be resolved and rendered.

The default return value is "false". Areas that are generated by Formatting Objects for whom the property "ref-id" is used should override this method in an appropriate manner.

Returns:
True iff this node has an unresolved "ref-id".

getAllowsChildren

public boolean getAllowsChildren()
Specified by:
getAllowsChildren in interface TreeNode
Specified by:
getAllowsChildren in class AbstractOrderedTreeNode

getGraftingPoint

public org.axsl.fo.fo.GraftingPoint getGraftingPoint()
Specified by:
getGraftingPoint in interface org.axsl.fo.FoContext

getLinkage

public abstract FOLinkage getLinkage()
Returns the raw "generated by" instance.

Returns:
The raw linkage item.

optimize

protected abstract 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. 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().

Returns:
True iff the Area node thinks it should be removed.

optimizeChildren

protected void optimizeChildren()
Optimizes the children of this node.


nearestFootnoteArea

public FootnoteRA nearestFootnoteArea()
Returns this area's ancestor footnote-area, if any, or this, if this is a footnote area, or null if this area is not part of a footnote.

Returns:
The ancestor-or-self footnote-area.

nearestBeforeFloatArea

public BeforeFloatRA nearestBeforeFloatArea()
Returns this area's ancestor footnote-area, if any, or this, if this is a footnote area, or null if this area is not part of a footnote.

Returns:
The ancestor-or-self footnote-area.

ancestorBlockOrRa

public Area ancestorBlockOrRa()
Returns the nearest ancestor Area that was generated by a block-level formatting object, if such an area exists. If not, returns the nearest ancestor Area that is a reference area. If neither of these exists, returns null.

Returns:
The nearest ancestor Area generated by a block-level FO, or that is a RA.

ipdAncestorBlockOrRa

public int ipdAncestorBlockOrRa()
Specified by:
ipdAncestorBlockOrRa in interface org.axsl.fo.FoContext

bpdAncestorBlockOrRa

public int bpdAncestorBlockOrRa()
Specified by:
bpdAncestorBlockOrRa in interface org.axsl.fo.FoContext

iterator

public Iterator<org.axsl.galley.AreaNode> iterator()
Specified by:
iterator in interface Iterable<org.axsl.galley.AreaNode>

tableWidth

public int tableWidth()
Specified by:
tableWidth in interface org.axsl.fo.FoContext

ipdAncestorBlockArea

public int ipdAncestorBlockArea()
Specified by:
ipdAncestorBlockArea in interface org.axsl.fo.FoContext

widthContainingBlock

public int widthContainingBlock()
Specified by:
widthContainingBlock in interface org.axsl.fo.FoContext

heightContainingBlock

public int heightContainingBlock()
Specified by:
heightContainingBlock in interface org.axsl.fo.FoContext

isFirst

public boolean isFirst()
Specified by:
isFirst in interface org.axsl.fo.FoContext

isLast

public boolean isLast()
Specified by:
isLast in interface org.axsl.fo.FoContext

ipdContainingRefArea

public int ipdContainingRefArea()
Specified by:
ipdContainingRefArea in interface org.axsl.fo.FoContext

ipdParentArea

public int ipdParentArea()
Specified by:
ipdParentArea in interface org.axsl.fo.FoContext

getColor

public Color getColor()
Returns the color of this Area. For areas generated by FOs which have color, this is simply the color of the "generated-by" trait. For other areas, it is the color of the Fo that generated the nearest ancestor Area which was generated by an Fo with color.

Returns:
The color of this Area.


Copyright © 2017. All rights reserved.