Package org.apache.pdfbox.debugger.ui
Class PDFTreeModel
- java.lang.Object
-
- org.apache.pdfbox.debugger.ui.PDFTreeModel
-
- All Implemented Interfaces:
javax.swing.tree.TreeModel
public class PDFTreeModel extends java.lang.Object implements javax.swing.tree.TreeModelA class to model a PDF document as a tree structure.- Author:
- wurtz, Ben Litchfield
-
-
Constructor Summary
Constructors Constructor Description PDFTreeModel()constructor.PDFTreeModel(DocumentEntry docEntry)Constructor to take a document.PDFTreeModel(org.apache.pdfbox.pdmodel.PDDocument doc)Constructor to take a document.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTreeModelListener(javax.swing.event.TreeModelListener l)Adds a listener for theTreeModelEventposted after the tree changes.java.lang.ObjectgetChild(java.lang.Object parent, int index)Returns the child ofparentat indexindexin the parent's child array.intgetChildCount(java.lang.Object parent)Returns the number of children ofparent.intgetIndexOfChild(java.lang.Object parent, java.lang.Object child)Returns the index of child in parent.java.lang.ObjectgetRoot()Returns the root of the tree.booleanisLeaf(java.lang.Object node)Returnstrueifnodeis a leaf.voidremoveTreeModelListener(javax.swing.event.TreeModelListener l)Removes a listener previously added withaddTreeModelListener.voidvalueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)Messaged when the user has altered the value for the item identified bypathtonewValue.
-
-
-
Constructor Detail
-
PDFTreeModel
public PDFTreeModel()
constructor.
-
PDFTreeModel
public PDFTreeModel(org.apache.pdfbox.pdmodel.PDDocument doc)
Constructor to take a document.- Parameters:
doc- The document to display in the tree.
-
PDFTreeModel
public PDFTreeModel(DocumentEntry docEntry)
Constructor to take a document.- Parameters:
docEntry- The document to display in the tree.
-
-
Method Detail
-
addTreeModelListener
public void addTreeModelListener(javax.swing.event.TreeModelListener l)
Adds a listener for theTreeModelEventposted after the tree changes.- Specified by:
addTreeModelListenerin interfacejavax.swing.tree.TreeModel- Parameters:
l- the listener to add- See Also:
removeTreeModelListener(javax.swing.event.TreeModelListener)
-
getChild
public java.lang.Object getChild(java.lang.Object parent, int index)Returns the child ofparentat indexindexin the parent's child array.parentmust be a node previously obtained from this data source. This should not returnnullifindexis a valid index forparent(that isindex >= 0 && index < getChildCount(parent)).- Specified by:
getChildin interfacejavax.swing.tree.TreeModel- Parameters:
parent- a node in the tree, obtained from this data sourceindex- The index into the parent object to location the child object.- Returns:
- the child of
parentat indexindex - Throws:
java.lang.IllegalArgumentException- if an unknown unknown COS type is passed as parent parameter.
-
getChildCount
public int getChildCount(java.lang.Object parent)
Returns the number of children ofparent. Returns 0 if the node is a leaf or if it has no children.parentmust be a node previously obtained from this data source.- Specified by:
getChildCountin interfacejavax.swing.tree.TreeModel- Parameters:
parent- a node in the tree, obtained from this data source- Returns:
- the number of children of the node
parent
-
getIndexOfChild
public int getIndexOfChild(java.lang.Object parent, java.lang.Object child)Returns the index of child in parent. Ifparentisnullorchildisnull, returns -1.- Specified by:
getIndexOfChildin interfacejavax.swing.tree.TreeModel- Parameters:
parent- a node in the tree, obtained from this data sourcechild- the node we are interested in- Returns:
- the index of the child in the parent, or -1 if either
childorparentarenull - Throws:
java.lang.IllegalArgumentException- if an unknown unknown COS type is passed as parent parameter.
-
getRoot
public java.lang.Object getRoot()
Returns the root of the tree. Returnsnullonly if the tree has no nodes.- Specified by:
getRootin interfacejavax.swing.tree.TreeModel- Returns:
- the root of the tree
-
isLeaf
public boolean isLeaf(java.lang.Object node)
Returnstrueifnodeis a leaf. It is possible for this method to returnfalseeven ifnodehas no children. A directory in a filesystem, for example, may contain no files; the node representing the directory is not a leaf, but it also has no children.- Specified by:
isLeafin interfacejavax.swing.tree.TreeModel- Parameters:
node- a node in the tree, obtained from this data source- Returns:
- true if
nodeis a leaf
-
removeTreeModelListener
public void removeTreeModelListener(javax.swing.event.TreeModelListener l)
Removes a listener previously added withaddTreeModelListener.- Specified by:
removeTreeModelListenerin interfacejavax.swing.tree.TreeModel- Parameters:
l- the listener to remove- See Also:
addTreeModelListener(javax.swing.event.TreeModelListener)
-
valueForPathChanged
public void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)Messaged when the user has altered the value for the item identified bypathtonewValue. IfnewValuesignifies a truly new value the model should post atreeNodesChangedevent.- Specified by:
valueForPathChangedin interfacejavax.swing.tree.TreeModel- Parameters:
path- path to the node that the user has alterednewValue- the new value from the TreeCellEditor
-
-