Class PDOutlineNode
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode
-
- All Implemented Interfaces:
COSObjectable
- Direct Known Subclasses:
PDDocumentOutline,PDOutlineItem
public class PDOutlineNode extends java.lang.Object implements COSObjectable
This represents an node in an outline in a pdf document.- Version:
- $Revision: 1.3 $
- Author:
- Ben Litchfield
-
-
Field Summary
Fields Modifier and Type Field Description protected COSDictionarynodeThe dictionary for this node.
-
Constructor Summary
Constructors Constructor Description PDOutlineNode()Default Constructor.PDOutlineNode(COSDictionary dict)Default Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendChild(PDOutlineItem outlineNode)append a child node to this node.voidcloseNode()Close this node.COSDictionarygetCOSDictionary()Convert this standard java object to a COS object.COSBasegetCOSObject()Convert this standard java object to a COS object.PDOutlineItemgetFirstChild()Return the first child or null if there is no child.PDOutlineItemgetLastChild()Return the last child or null if there is no child.intgetOpenCount()Get the number of open nodes.protected PDOutlineNodegetParent()Get the parent of this object.booleanisNodeOpen()Node is open if the open count is greater than zero.voidopenNode()This will set this node to be open when it is shown in the viewer.protected voidsetFirstChild(PDOutlineNode outlineNode)Set the first child, this will be maintained by this class.protected voidsetLastChild(PDOutlineNode outlineNode)Set the last child, this will be maintained by this class.protected voidsetOpenCount(int openCount)Set the open count.protected voidsetParent(PDOutlineNode parent)Set the parent of this object, this is maintained by these objects and should not be called by any clients of PDFBox code.protected voidupdateParentOpenCount(int amount)The count parameter needs to be updated when you add or remove elements to the outline.
-
-
-
Field Detail
-
node
protected COSDictionary node
The dictionary for this node.
-
-
Constructor Detail
-
PDOutlineNode
public PDOutlineNode()
Default Constructor.
-
PDOutlineNode
public PDOutlineNode(COSDictionary dict)
Default Constructor.- Parameters:
dict- The dictionary storage.
-
-
Method Detail
-
getCOSObject
public COSBase getCOSObject()
Convert this standard java object to a COS object.- Specified by:
getCOSObjectin interfaceCOSObjectable- Returns:
- The cos object that matches this Java object.
-
getCOSDictionary
public COSDictionary getCOSDictionary()
Convert this standard java object to a COS object.- Returns:
- The cos object that matches this Java object.
-
getParent
protected PDOutlineNode getParent()
Get the parent of this object. This will either be a DocumentOutline or an OutlineItem.- Returns:
- The parent of this object, or null if this is the document outline and there is no parent.
-
setParent
protected void setParent(PDOutlineNode parent)
Set the parent of this object, this is maintained by these objects and should not be called by any clients of PDFBox code.- Parameters:
parent- The parent of this object.
-
appendChild
public void appendChild(PDOutlineItem outlineNode)
append a child node to this node.- Parameters:
outlineNode- The node to add.
-
getFirstChild
public PDOutlineItem getFirstChild()
Return the first child or null if there is no child.- Returns:
- The first child.
-
setFirstChild
protected void setFirstChild(PDOutlineNode outlineNode)
Set the first child, this will be maintained by this class.- Parameters:
outlineNode- The new first child.
-
getLastChild
public PDOutlineItem getLastChild()
Return the last child or null if there is no child.- Returns:
- The last child.
-
setLastChild
protected void setLastChild(PDOutlineNode outlineNode)
Set the last child, this will be maintained by this class.- Parameters:
outlineNode- The new last child.
-
getOpenCount
public int getOpenCount()
Get the number of open nodes. Or a negative number if this node is closed. See PDF Reference for more details. This value is updated as you append children and siblings.- Returns:
- The Count attribute of the outline dictionary.
-
setOpenCount
protected void setOpenCount(int openCount)
Set the open count. This number is automatically managed for you when you add items to the outline.- Parameters:
openCount- The new open cound.
-
openNode
public void openNode()
This will set this node to be open when it is shown in the viewer. By default, when a new node is created it will be closed. This will do nothing if the node is already open.
-
closeNode
public void closeNode()
Close this node.
-
isNodeOpen
public boolean isNodeOpen()
Node is open if the open count is greater than zero.- Returns:
- true if this node is open.
-
updateParentOpenCount
protected void updateParentOpenCount(int amount)
The count parameter needs to be updated when you add or remove elements to the outline. When you add an element at a lower level then you need to increase all of the parents.- Parameters:
amount- The amount to update by.
-
-