Search in sources :

Example 1 with TreeStatus

use of org.apache.pdfbox.debugger.treestatus.TreeStatus in project pdfbox by apache.

the class Tree method getTreePathMenuItem.

/**
 * Produce the JMenuItem that gives way to copy tree path string to clipboard
 * @param path the TreePath instance
 * @return Menu Item
 */
private JMenuItem getTreePathMenuItem(final TreePath path) {
    JMenuItem copyPathMenuItem = new JMenuItem("Copy Tree Path");
    copyPathMenuItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            clipboard.setContents(new StringSelection(new TreeStatus(rootNode).getStringForPath(path)), null);
        }
    });
    return copyPathMenuItem;
}
Also used : TreeStatus(org.apache.pdfbox.debugger.treestatus.TreeStatus) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) Clipboard(java.awt.datatransfer.Clipboard) JMenuItem(javax.swing.JMenuItem) StringSelection(java.awt.datatransfer.StringSelection)

Example 2 with TreeStatus

use of org.apache.pdfbox.debugger.treestatus.TreeStatus in project pdfbox by apache.

the class PDFDebugger method initTree.

public void initTree() {
    TreeStatus treeStatus = new TreeStatus(document.getDocument().getTrailer());
    statusPane.updateTreeStatus(treeStatus);
    if (isPageMode) {
        File file = new File(currentFilePath);
        DocumentEntry documentEntry = new DocumentEntry(document, file.getName());
        ZoomMenu.getInstance().resetZoom();
        RotationMenu.getInstance().setRotationSelection(RotationMenu.ROTATE_0_DEGREES);
        tree.setModel(new PDFTreeModel(documentEntry));
        // Root/Pages/Kids/[0] is not always the first page, so use the first row instead:
        tree.setSelectionPath(tree.getPathForRow(1));
    } else {
        tree.setModel(new PDFTreeModel(document));
        tree.setSelectionPath(treeStatus.getPathForString("Root"));
    }
}
Also used : TreeStatus(org.apache.pdfbox.debugger.treestatus.TreeStatus) DocumentEntry(org.apache.pdfbox.debugger.ui.DocumentEntry) PDFTreeModel(org.apache.pdfbox.debugger.ui.PDFTreeModel) File(java.io.File)

Aggregations

TreeStatus (org.apache.pdfbox.debugger.treestatus.TreeStatus)2 Clipboard (java.awt.datatransfer.Clipboard)1 StringSelection (java.awt.datatransfer.StringSelection)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 File (java.io.File)1 JMenuItem (javax.swing.JMenuItem)1 DocumentEntry (org.apache.pdfbox.debugger.ui.DocumentEntry)1 PDFTreeModel (org.apache.pdfbox.debugger.ui.PDFTreeModel)1