aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/lowagie/tools/plugins/treeview
diff options
context:
space:
mode:
authortknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2006-12-01 12:20:24 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2006-12-01 12:20:24 +0000
commit6025b6016517c6d898d8957d1d7e03ba71431912 (patch)
treeb15bd6fa5ffe9588a9bca3f2b8a7e358f83b6eba /src/main/java/com/lowagie/tools/plugins/treeview
parentd2c77e820ab4aba8235d71275755021347b3ad10 (diff)
downloadpdf-as-3-6025b6016517c6d898d8957d1d7e03ba71431912.tar.gz
pdf-as-3-6025b6016517c6d898d8957d1d7e03ba71431912.tar.bz2
pdf-as-3-6025b6016517c6d898d8957d1d7e03ba71431912.zip
Initial import of release 2.2.REL-2.2@923
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@4 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/com/lowagie/tools/plugins/treeview')
-rw-r--r--src/main/java/com/lowagie/tools/plugins/treeview/AnalyzePDF.java507
-rw-r--r--src/main/java/com/lowagie/tools/plugins/treeview/ArrayTreeNode.java107
-rw-r--r--src/main/java/com/lowagie/tools/plugins/treeview/DictionaryTreeNode.java112
-rw-r--r--src/main/java/com/lowagie/tools/plugins/treeview/FileTreeNode.java86
-rw-r--r--src/main/java/com/lowagie/tools/plugins/treeview/ICommonAnalyzer.java79
-rw-r--r--src/main/java/com/lowagie/tools/plugins/treeview/IUpdatenodeview.java59
-rw-r--r--src/main/java/com/lowagie/tools/plugins/treeview/OutlinelistTreeNode.java98
-rw-r--r--src/main/java/com/lowagie/tools/plugins/treeview/PagelistTreeNode.java87
-rw-r--r--src/main/java/com/lowagie/tools/plugins/treeview/Pagetreenode.java208
-rw-r--r--src/main/java/com/lowagie/tools/plugins/treeview/ProgressDialog.java124
-rw-r--r--src/main/java/com/lowagie/tools/plugins/treeview/SimpletextTreeNode.java69
-rw-r--r--src/main/java/com/lowagie/tools/plugins/treeview/TextpaneTreeNode.java91
-rw-r--r--src/main/java/com/lowagie/tools/plugins/treeview/TreeViewInternalFrame.java272
-rw-r--r--src/main/java/com/lowagie/tools/plugins/treeview/UpdateableTreeNode.java74
14 files changed, 1973 insertions, 0 deletions
diff --git a/src/main/java/com/lowagie/tools/plugins/treeview/AnalyzePDF.java b/src/main/java/com/lowagie/tools/plugins/treeview/AnalyzePDF.java
new file mode 100644
index 0000000..5907f9a
--- /dev/null
+++ b/src/main/java/com/lowagie/tools/plugins/treeview/AnalyzePDF.java
@@ -0,0 +1,507 @@
+/*
+ * $Id: AnalyzePDF.java,v 1.4 2006/05/30 09:11:45 blowagie Exp $
+ * $Name: $
+ *
+ * Copyright 2005 by Anonymous.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the License.
+ *
+ * The Original Code is 'iText, a free JAVA-PDF library'.
+ *
+ * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
+ * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
+ * All Rights Reserved.
+ * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
+ * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
+ *
+ * Contributor(s): all the names of the contributors are added in the source code
+ * where applicable.
+ *
+ * Alternatively, the contents of this file may be used under the terms of the
+ * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
+ * provisions of LGPL are applicable instead of those above. If you wish to
+ * allow use of your version of this file only under the terms of the LGPL
+ * License and not to allow others to use your version of this file under
+ * the MPL, indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by the LGPL.
+ * If you do not delete the provisions above, a recipient may use your version
+ * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the MPL as stated above or under the terms of the GNU
+ * Library General Public License as published by the Free Software Foundation;
+ * either version 2 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
+ * details.
+ *
+ * If you didn't download this code from the following link, you should check if
+ * you aren't using an obsolete version:
+ * http://www.lowagie.com/iText/
+ */
+package com.lowagie.tools.plugins.treeview;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Vector;
+
+import javax.swing.event.TreeModelEvent;
+import javax.swing.event.TreeModelListener;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+
+import com.lowagie.text.pdf.*;
+import java.util.Set;
+import java.util.Iterator;
+import javax.swing.table.TableModel;
+import javax.swing.table.AbstractTableModel;
+
+public class AnalyzePDF
+ extends Thread implements TreeModel, ICommonAnalyzer {
+ DefaultMutableTreeNode root;
+ DefaultMutableTreeNode filenode;
+ int pagecount;
+ ProgressDialog progressdialog;
+ int numberofpages;
+ ArrayList pageInh = new ArrayList();
+ private transient Vector treeModelListeners;
+ PdfReader reader;
+
+ public AnalyzePDF(String infile,
+ com.lowagie.tools.plugins.treeview.ProgressDialog blubb) {
+ this.progressdialog = blubb;
+ try {
+ reader = new PdfReader(infile);
+ root = new SimpletextTreeNode("Dokument");
+ filenode = new FileTreeNode(infile, reader);
+ root.add(filenode);
+ this.numberofpages = reader.getNumberOfPages();
+ }
+ catch (IOException ex) {
+ }
+ pagecount = 0;
+ }
+
+ public TableModel getXReftable() {
+ TableModel tm = new AbstractTableModel() {
+ public int getColumnCount() {
+ return 2;
+ }
+
+ public int getRowCount() {
+ return reader.getXrefSize() - 1;
+ }
+
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ switch (columnIndex) {
+ case 0:
+ return new Integer(rowIndex + 1);
+ case 1:
+ PdfObject pdfob=reader.getPdfObject(rowIndex + 1);
+ if(pdfob.isStream()){
+ return "Stream "+pdfob;
+ }else{
+ return pdfob;
+ }
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Returns the name of the column at <code>columnIndex</code>.
+ *
+ * @param columnIndex the index of the column
+ * @return the name of the column
+ * @todo Implement this javax.swing.table.TableModel method
+ */
+ public String getColumnName(int columnIndex) {
+ switch (columnIndex) {
+ case 0:
+ return "XRefNr";
+ case 1:
+ return "Object";
+ default:
+ return null;
+ }
+
+ }
+ };
+ return tm;
+ }
+
+ /**
+ * Walk down the Pagetree
+ * @param page PdfDictionary
+ * @param pdfreader PdfReader
+ * @param count_in_leaf int
+ * @param node DefaultMutableTreeNode
+ */
+ protected void iteratePages(PdfDictionary page, PdfReader pdfreader,
+ DefaultMutableTreeNode node) {
+ DefaultMutableTreeNode leaf;
+
+ PdfArray kidsPR = (PdfArray) PdfReader.getPdfObject(page.get(PdfName.KIDS));
+ if (kidsPR == null) {
+ node.add(new Pagetreenode(page, pagecount, this, pdfreader));
+ System.out.println("Page= " + (pagecount + 1));
+ pageInh.add(pagecount, page);
+ pagecount++;
+ }
+ else {
+ leaf = new PagelistTreeNode(kidsPR);
+ node.add(leaf);
+ page.put(PdfName.TYPE, PdfName.PAGES);
+ ArrayList kids = kidsPR.getArrayList();
+ for (int k = 0; k < kids.size(); ++k) {
+ PdfDictionary kid = (PdfDictionary) PdfReader.getPdfObject( (
+ PRIndirectReference) kids.get(k));
+ iteratePages(kid, pdfreader, leaf);
+ }
+ }
+ }
+
+ protected void iterateOutlines(PdfDictionary outlines, PdfReader pdfreader,
+ DefaultMutableTreeNode node) {
+ DefaultMutableTreeNode leaf;
+ PdfDictionary kid = outlines;
+ do {
+ PdfString title = (PdfString) pdfreader.getPdfObject(
+ kid.get(PdfName.TITLE));
+ leaf = new OutlinelistTreeNode(title, kid);
+ node.add(leaf);
+ PdfDictionary first = (PdfDictionary) PdfReader.getPdfObject( (
+ PRIndirectReference) kid.get(PdfName.FIRST));
+ if (first != null) {
+ iterateOutlines(first, pdfreader, leaf);
+ }
+ else {
+ PdfDictionary se = (PdfDictionary) PdfReader.getPdfObject( (
+ PRIndirectReference) kid.get(new PdfName("SE")));
+ if (se != null) {
+ iterateObjects(se, pdfreader, leaf);
+ }
+ PdfObject dest = (PdfObject) pdfreader.getPdfObject(kid.get(PdfName.
+ DEST));
+ if (dest != null) {
+ iterateObjects(dest, pdfreader, leaf);
+ }
+ PdfObject a = (PdfObject) pdfreader.getPdfObject(kid.get(PdfName.A));
+ if (a != null) {
+ iterateObjects(a, pdfreader, leaf);
+ }
+ }
+ }
+ while ( (kid = (PdfDictionary) pdfreader.getPdfObject(kid.get(PdfName.NEXT))) != null);
+ }
+
+ /**
+ * Recursive investigate PDF Objecttree (other than pagetree objects!)
+ * @param pdfobj PdfObject
+ * @param pdfreader PdfReader
+ * @param node DefaultMutableTreeNode
+ */
+ public void iterateObjects(PdfObject pdfobj, PdfReader pdfreader,
+ DefaultMutableTreeNode node) {
+ DefaultMutableTreeNode leaf;
+ if (pdfobj.isDictionary()) {
+ leaf = new DictionaryTreeNode("PdfDictionary " + pdfobj,
+ (PdfDictionary) pdfobj);
+ node.add(leaf);
+ Set s = ( (PdfDictionary) pdfobj).getKeys();
+ Iterator it = s.iterator();
+ int i = 0;
+ while (it.hasNext()) {
+ i++;
+ Object obj = it.next();
+// System.out.println("Feld:" + obj);
+
+ PdfObject value = PdfReader.getPdfObject( ( (PdfDictionary) pdfobj).get( (
+ PdfName) obj));
+// System.out.println("Value:" + value);
+ SimpletextTreeNode sttn = new SimpletextTreeNode(obj + " " + value);
+ leaf.add(sttn);
+ if (obj.equals(PdfName.PARENT)) {
+ continue;
+ }
+ if (value != null) {
+ iterateObjects(value, pdfreader, sttn);
+ }
+ }
+ }
+ else if (pdfobj.isArray()) {
+ leaf = new ArrayTreeNode("PdfArray " + pdfobj, (PdfArray) pdfobj);
+ node.add(leaf);
+ ArrayList kids = ( (PdfArray) pdfobj).getArrayList();
+ for (int k = 0; k < kids.size(); ++k) {
+ PdfObject curkid = (PdfObject) kids.get(k);
+ if (curkid.isIndirect()) {
+ PdfObject kid = PdfReader.getPdfObject( (
+ PRIndirectReference) kids.get(k));
+ if (kid != null) {
+ iterateObjects(kid, pdfreader, leaf);
+ }
+ }
+ else if (curkid.isNumber()) {
+
+ }
+ else {
+ PdfObject kid = (PdfObject) kids.get(k);
+ iterateObjects(kid, pdfreader, leaf);
+ }
+ }
+ }
+ else if (pdfobj.isIndirect()) {
+ leaf = new SimpletextTreeNode("PRIndirectReference " + pdfobj);
+ node.add(leaf);
+ PdfObject target = PdfReader.getPdfObject( (
+ PRIndirectReference) pdfobj);
+ if (target != null) {
+ iterateObjects(target, pdfreader, leaf);
+ }
+ }
+ else if (pdfobj.isBoolean()) {
+// leaf = new SimpletextTreeNode("Boolean " + pdfobj);
+// node.add(leaf);
+ }
+ else if (pdfobj.isName()) {
+// leaf = new SimpletextTreeNode("Name " + pdfobj);
+// node.add(leaf);
+ }
+ else if (pdfobj.isNull()) {
+// leaf = new SimpletextTreeNode("Null " + pdfobj);
+// node.add(leaf);
+ }
+ else if (pdfobj.isNumber()) {
+// leaf = new SimpletextTreeNode("Number " + pdfobj);
+// node.add(leaf);
+ }
+ else if (pdfobj.isString()) {
+// leaf = new SimpletextTreeNode("String " + pdfobj);
+// node.add(leaf);
+ }
+ else if (pdfobj.isStream()) {
+ leaf = new TextpaneTreeNode(pdfobj,"Stream");
+ node.add(leaf);
+ leaf = new DictionaryTreeNode("PdfDictionary " + pdfobj,
+ (PdfDictionary) pdfobj);
+ node.add(leaf);
+ Set s = ( (PdfDictionary) pdfobj).getKeys();
+ Iterator it = s.iterator();
+ int i = 0;
+ while (it.hasNext()) {
+ i++;
+ Object obj = it.next();
+// System.out.println("Feld:" + obj);
+
+ PdfObject value = PdfReader.getPdfObject( ( (PdfDictionary) pdfobj).get( (
+ PdfName) obj));
+// System.out.println("Value:" + value);
+ SimpletextTreeNode sttn = new SimpletextTreeNode(obj + " " + value);
+ leaf.add(sttn);
+ if (obj.equals(PdfName.PARENT)) {
+ continue;
+ }
+ if (value != null) {
+ iterateObjects(value, pdfreader, sttn);
+ }
+ }
+
+ }
+
+ else {
+ leaf = new SimpletextTreeNode("Unknown " + pdfobj);
+ node.add(leaf);
+ }
+
+ }
+
+ /**
+ * Returns the root of the tree.
+ *
+ * @return the root of the tree
+ * @todo Diese javax.swing.tree.TreeModel-Methode implementieren
+ */
+ public Object getRoot() {
+ return root;
+ }
+
+ /**
+ * Returns the child of <code>parent</code> at index <code>index</code> in the
+ * parent's child array.
+ *
+ * @param parent a node in the tree, obtained from this data source
+ * @param index int
+ * @return the child of <code>parent</code> at index <code>index</code>
+ * @todo Diese javax.swing.tree.TreeModel-Methode implementieren
+ */
+ public Object getChild(Object parent, int index) {
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) parent;
+ return node.getChildAt(index);
+ }
+
+ /**
+ * Returns the number of children of <code>parent</code>.
+ *
+ * @param parent a node in the tree, obtained from this data source
+ * @return the number of children of the node <code>parent</code>
+ * @todo Diese javax.swing.tree.TreeModel-Methode implementieren
+ */
+ public int getChildCount(Object parent) {
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) parent;
+ return node.getChildCount();
+ }
+
+ /**
+ * Returns <code>true</code> if <code>node</code> is a leaf.
+ *
+ * @param node a node in the tree, obtained from this data source
+ * @return true if <code>node</code> is a leaf
+ * @todo Diese javax.swing.tree.TreeModel-Methode implementieren
+ */
+ public boolean isLeaf(Object node) {
+ DefaultMutableTreeNode leaf = (DefaultMutableTreeNode) node;
+ return leaf.isLeaf();
+ }
+
+ /**
+ * Messaged when the user has altered the value for the item identified by
+ * <code>path</code> to <code>newValue</code>.
+ *
+ * @param path path to the node that the user has altered
+ * @param newValue the new value from the TreeCellEditor
+ * @todo Diese javax.swing.tree.TreeModel-Methode implementieren
+ */
+ public void valueForPathChanged(TreePath path, Object newValue) {
+ throw new RuntimeException("Manipulation of objecttree not yet supported!");
+ }
+
+ /**
+ * Returns the index of child in parent.
+ *
+ * @param parent a note in the tree, obtained from this data source
+ * @param child the node we are interested in
+ * @return the index of the child in the parent, or -1 if either
+ * <code>child</code> or <code>parent</code> are <code>null</code>
+ * @todo Diese javax.swing.tree.TreeModel-Methode implementieren
+ */
+ public int getIndexOfChild(Object parent, Object child) {
+ DefaultMutableTreeNode parentobj = (DefaultMutableTreeNode) parent;
+ DefaultMutableTreeNode childobj = (DefaultMutableTreeNode) child;
+ return parentobj.getIndex(childobj);
+ }
+
+ public synchronized void removeTreeModelListener(TreeModelListener l) {
+ if (treeModelListeners != null && treeModelListeners.contains(l)) {
+ Vector v = (Vector) treeModelListeners.clone();
+ v.removeElement(l);
+ treeModelListeners = v;
+ }
+ }
+
+ public synchronized void addTreeModelListener(TreeModelListener l) {
+ Vector v = treeModelListeners == null ? new Vector(2) :
+ (Vector) treeModelListeners.clone();
+ if (!v.contains(l)) {
+ v.addElement(l);
+ treeModelListeners = v;
+ }
+ }
+
+ protected void fireTreeNodesChanged(TreeModelEvent e) {
+ if (treeModelListeners != null) {
+ Vector listeners = treeModelListeners;
+ int count = listeners.size();
+ for (int i = 0; i < count; i++) {
+ ( (TreeModelListener) listeners.elementAt(i)).treeNodesChanged(e);
+ }
+ }
+ }
+
+ protected void fireTreeNodesInserted(TreeModelEvent e) {
+ if (treeModelListeners != null) {
+ Vector listeners = treeModelListeners;
+ int count = listeners.size();
+ for (int i = 0; i < count; i++) {
+ ( (TreeModelListener) listeners.elementAt(i)).treeNodesInserted(e);
+ }
+ }
+ }
+
+ protected void fireTreeNodesRemoved(TreeModelEvent e) {
+ if (treeModelListeners != null) {
+ Vector listeners = treeModelListeners;
+ int count = listeners.size();
+ for (int i = 0; i < count; i++) {
+ ( (TreeModelListener) listeners.elementAt(i)).treeNodesRemoved(e);
+ }
+ }
+ }
+
+ protected void fireTreeStructureChanged(TreeModelEvent e) {
+ if (treeModelListeners != null) {
+ Vector listeners = treeModelListeners;
+ int count = listeners.size();
+ for (int i = 0; i < count; i++) {
+ ( (TreeModelListener) listeners.elementAt(i)).treeStructureChanged(e);
+ }
+ }
+ }
+
+ /**
+ * When an object implementing interface <code>Runnable</code> is used to
+ * create a thread, starting the thread causes the object's <code>run</code>
+ * method to be called in that separately executing thread.
+ *
+ * @todo Diese java.lang.Runnable-Methode implementieren
+ */
+ public void run() {
+ try {
+ PdfDictionary catalog = reader.getCatalog();
+ PdfDictionary rootPages = (PdfDictionary) PdfReader.getPdfObject(
+ catalog.get(PdfName.PAGES));
+ DefaultMutableTreeNode rootPagesGUI = new SimpletextTreeNode("Pagetree " +
+ rootPages);
+ filenode.add(rootPagesGUI);
+ iteratePages(rootPages, reader, rootPagesGUI);
+
+ PdfDictionary rootOutlines = (PdfDictionary) PdfReader.getPdfObject(
+ catalog.get(PdfName.OUTLINES));
+ if (rootOutlines != null) {
+ DefaultMutableTreeNode outlinetree = new SimpletextTreeNode(
+ "Outlinetree " + rootOutlines);
+ filenode.add(outlinetree);
+ PdfObject firstindref = rootOutlines.get(PdfName.FIRST);
+ if (firstindref != null) {
+ PdfDictionary first = (PdfDictionary) PdfReader.getPdfObject( (
+ PRIndirectReference) firstindref);
+ if (first != null) {
+ iterateOutlines(first, reader, outlinetree);
+ }
+ }
+ }
+ System.out.println(" Pagecount= " + pagecount);
+ progressdialog.setVisible(false);
+ }
+ catch (Exception e) {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public int getPagecount() {
+ return pagecount;
+ }
+
+ public void updatecount() {
+ progressdialog.setAktuelleseite(getPagecount());
+ }
+}
diff --git a/src/main/java/com/lowagie/tools/plugins/treeview/ArrayTreeNode.java b/src/main/java/com/lowagie/tools/plugins/treeview/ArrayTreeNode.java
new file mode 100644
index 0000000..07ec49c
--- /dev/null
+++ b/src/main/java/com/lowagie/tools/plugins/treeview/ArrayTreeNode.java
@@ -0,0 +1,107 @@
+/*
+ * $Id: ArrayTreeNode.java,v 1.2 2006/05/30 09:13:36 blowagie Exp $
+ * $Name: $
+ *
+ * Copyright 2005 by Anonymous.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the License.
+ *
+ * The Original Code is 'iText, a free JAVA-PDF library'.
+ *
+ * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
+ * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
+ * All Rights Reserved.
+ * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
+ * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
+ *
+ * Contributor(s): all the names of the contributors are added in the source code
+ * where applicable.
+ *
+ * Alternatively, the contents of this file may be used under the terms of the
+ * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
+ * provisions of LGPL are applicable instead of those above. If you wish to
+ * allow use of your version of this file only under the terms of the LGPL
+ * License and not to allow others to use your version of this file under
+ * the MPL, indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by the LGPL.
+ * If you do not delete the provisions above, a recipient may use your version
+ * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the MPL as stated above or under the terms of the GNU
+ * Library General Public License as published by the Free Software Foundation;
+ * either version 2 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
+ * details.
+ *
+ * If you didn't download this code from the following link, you should check if
+ * you aren't using an obsolete version:
+ * http://www.lowagie.com/iText/
+ */
+package com.lowagie.tools.plugins.treeview;
+
+import com.lowagie.text.pdf.PdfArray;
+import java.util.ArrayList;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2005</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public class ArrayTreeNode
+ extends UpdateableTreeNode {
+ PdfArray arr;
+
+ public ArrayTreeNode(Object userObject,PdfArray arr) {
+ super(userObject);
+ this.arr=arr;
+ }
+
+ public ArrayTreeNode(Object userObject, boolean allowchildren) {
+ super(userObject, allowchildren);
+ }
+
+ /**
+ * updateview
+ *
+ * @param updateobject IUpdatenodeview
+ * @todo Implement this com.lowagie.tools.plugins.treeview.UpdateableTreeNode method
+ */
+ public void updateview(IUpdatenodeview updateobject) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("<html>");
+ sb.append("<p>");
+ sb.append(this.userObject);
+ sb.append("</p>");
+ ArrayList arl = arr.getArrayList();
+ for (int i = 0; i < arl.size(); i++) {
+ sb.append("<p>");
+ sb.append(" " + arl.get(i).toString());
+ sb.append("</p>");
+ }
+ sb.append("</html>");
+ updateobject.showvalues(sb.toString());
+ }
+ public Icon getIcon(){
+ return new ImageIcon(TreeViewInternalFrame.class.getResource(
+ "array.gif"));
+ }
+}
diff --git a/src/main/java/com/lowagie/tools/plugins/treeview/DictionaryTreeNode.java b/src/main/java/com/lowagie/tools/plugins/treeview/DictionaryTreeNode.java
new file mode 100644
index 0000000..2fc6b4e
--- /dev/null
+++ b/src/main/java/com/lowagie/tools/plugins/treeview/DictionaryTreeNode.java
@@ -0,0 +1,112 @@
+/*
+ * $Id: DictionaryTreeNode.java,v 1.2 2006/05/30 09:13:36 blowagie Exp $
+ * $Name: $
+ *
+ * Copyright 2005 by Anonymous.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the License.
+ *
+ * The Original Code is 'iText, a free JAVA-PDF library'.
+ *
+ * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
+ * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
+ * All Rights Reserved.
+ * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
+ * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
+ *
+ * Contributor(s): all the names of the contributors are added in the source code
+ * where applicable.
+ *
+ * Alternatively, the contents of this file may be used under the terms of the
+ * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
+ * provisions of LGPL are applicable instead of those above. If you wish to
+ * allow use of your version of this file only under the terms of the LGPL
+ * License and not to allow others to use your version of this file under
+ * the MPL, indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by the LGPL.
+ * If you do not delete the provisions above, a recipient may use your version
+ * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the MPL as stated above or under the terms of the GNU
+ * Library General Public License as published by the Free Software Foundation;
+ * either version 2 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
+ * details.
+ *
+ * If you didn't download this code from the following link, you should check if
+ * you aren't using an obsolete version:
+ * http://www.lowagie.com/iText/
+ */
+
+package com.lowagie.tools.plugins.treeview;
+
+import java.util.Set;
+import java.util.Iterator;
+import com.lowagie.text.pdf.PdfDictionary;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2005</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public class DictionaryTreeNode
+ extends UpdateableTreeNode {
+ PdfDictionary dictionary;
+
+ public DictionaryTreeNode(Object userObject, PdfDictionary dictionary) {
+ super(userObject);
+ this.dictionary = dictionary;
+ }
+
+ public DictionaryTreeNode(Object userObject, boolean allowchildren) {
+ super(userObject, allowchildren);
+ }
+
+ /**
+ * updateview
+ *
+ * @param updateobject IUpdatenodeview
+ * @todo Implement this com.lowagie.tools.plugins.treeview.UpdateableTreeNode method
+ */
+ public void updateview(IUpdatenodeview updateobject) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("<html>");
+ sb.append("<p>");
+ sb.append(this.userObject);
+ sb.append("</p>");
+ Set set = dictionary.getKeys();
+ Iterator it = set.iterator();
+ while (it.hasNext()) {
+ sb.append("<p>");
+ sb.append("Key " + it.next().toString());
+ sb.append("</p>");
+ }
+ sb.append("</html>");
+ updateobject.showvalues(sb.toString());
+ }
+
+ public Icon getIcon(){
+ return new ImageIcon(TreeViewInternalFrame.class.getResource(
+ "dictionary.gif"));
+ }
+
+}
diff --git a/src/main/java/com/lowagie/tools/plugins/treeview/FileTreeNode.java b/src/main/java/com/lowagie/tools/plugins/treeview/FileTreeNode.java
new file mode 100644
index 0000000..85e83a6
--- /dev/null
+++ b/src/main/java/com/lowagie/tools/plugins/treeview/FileTreeNode.java
@@ -0,0 +1,86 @@
+/*
+ * $Id: FileTreeNode.java,v 1.3 2006/05/30 09:13:36 blowagie Exp $
+ * $Name: $
+ *
+ * Copyright 2005 by Anonymous.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the License.
+ *
+ * The Original Code is 'iText, a free JAVA-PDF library'.
+ *
+ * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
+ * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
+ * All Rights Reserved.
+ * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
+ * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
+ *
+ * Contributor(s): all the names of the contributors are added in the source code
+ * where applicable.
+ *
+ * Alternatively, the contents of this file may be used under the terms of the
+ * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
+ * provisions of LGPL are applicable instead of those above. If you wish to
+ * allow use of your version of this file only under the terms of the LGPL
+ * License and not to allow others to use your version of this file under
+ * the MPL, indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by the LGPL.
+ * If you do not delete the provisions above, a recipient may use your version
+ * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the MPL as stated above or under the terms of the GNU
+ * Library General Public License as published by the Free Software Foundation;
+ * either version 2 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
+ * details.
+ *
+ * If you didn't download this code from the following link, you should check if
+ * you aren't using an obsolete version:
+ * http://www.lowagie.com/iText/
+ */
+
+package com.lowagie.tools.plugins.treeview;
+
+import com.lowagie.text.pdf.*;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+public class FileTreeNode
+ extends UpdateableTreeNode {
+
+ PdfReader reader;
+ public FileTreeNode(Object p0, PdfReader reader) {
+ super(p0,true);
+ this.reader = reader;
+ }
+
+ public void updateview(IUpdatenodeview updateobject) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("<html>");
+ sb.append("<p>");
+ sb.append(this.userObject);
+ sb.append("</p>");
+ sb.append("<p>");
+ sb.append("PDF Version 1." + this.reader.getPdfVersion());
+ sb.append("</p>");
+ sb.append("<p>");
+ sb.append("Number of Pages: " + this.reader.getNumberOfPages());
+ sb.append("</p>");
+ sb.append("</html>");
+ updateobject.showvalues(sb.toString());
+ }
+ public Icon getIcon(){
+ return new ImageIcon(TreeViewInternalFrame.class.getResource(
+ "icon16.gif"));
+ }
+
+}
diff --git a/src/main/java/com/lowagie/tools/plugins/treeview/ICommonAnalyzer.java b/src/main/java/com/lowagie/tools/plugins/treeview/ICommonAnalyzer.java
new file mode 100644
index 0000000..17093f0
--- /dev/null
+++ b/src/main/java/com/lowagie/tools/plugins/treeview/ICommonAnalyzer.java
@@ -0,0 +1,79 @@
+/*
+ * $Id: ICommonAnalyzer.java,v 1.2 2005/12/06 13:20:39 blowagie Exp $
+ * $Name: $
+ *
+ * Copyright 2005 by Anonymous.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the License.
+ *
+ * The Original Code is 'iText, a free JAVA-PDF library'.
+ *
+ * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
+ * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
+ * All Rights Reserved.
+ * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
+ * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
+ *
+ * Contributor(s): all the names of the contributors are added in the source code
+ * where applicable.
+ *
+ * Alternatively, the contents of this file may be used under the terms of the
+ * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
+ * provisions of LGPL are applicable instead of those above. If you wish to
+ * allow use of your version of this file only under the terms of the LGPL
+ * License and not to allow others to use your version of this file under
+ * the MPL, indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by the LGPL.
+ * If you do not delete the provisions above, a recipient may use your version
+ * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the MPL as stated above or under the terms of the GNU
+ * Library General Public License as published by the Free Software Foundation;
+ * either version 2 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
+ * details.
+ *
+ * If you didn't download this code from the following link, you should check if
+ * you aren't using an obsolete version:
+ * http://www.lowagie.com/iText/
+ */
+
+package com.lowagie.tools.plugins.treeview;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+import com.lowagie.text.pdf.PdfObject;
+import com.lowagie.text.pdf.PdfReader;
+/**
+ *
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2005</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public interface ICommonAnalyzer {
+ /**
+ *
+ * @param pdfobj PdfObject
+ * @param pdfreader PdfReader
+ * @param node DefaultMutableTreeNode
+ */
+ void iterateObjects(PdfObject pdfobj, PdfReader pdfreader,
+ DefaultMutableTreeNode node);
+}
diff --git a/src/main/java/com/lowagie/tools/plugins/treeview/IUpdatenodeview.java b/src/main/java/com/lowagie/tools/plugins/treeview/IUpdatenodeview.java
new file mode 100644
index 0000000..01a3b45
--- /dev/null
+++ b/src/main/java/com/lowagie/tools/plugins/treeview/IUpdatenodeview.java
@@ -0,0 +1,59 @@
+/*
+ * $Id: IUpdatenodeview.java,v 1.1 2005/11/29 21:05:02 blowagie Exp $
+ * $Name: $
+ *
+ * Copyright 2005 by Anonymous.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the License.
+ *
+ * The Original Code is 'iText, a free JAVA-PDF library'.
+ *
+ * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
+ * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
+ * All Rights Reserved.
+ * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
+ * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
+ *
+ * Contributor(s): all the names of the contributors are added in the source code
+ * where applicable.
+ *
+ * Alternatively, the contents of this file may be used under the terms of the
+ * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
+ * provisions of LGPL are applicable instead of those above. If you wish to
+ * allow use of your version of this file only under the terms of the LGPL
+ * License and not to allow others to use your version of this file under
+ * the MPL, indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by the LGPL.
+ * If you do not delete the provisions above, a recipient may use your version
+ * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the MPL as stated above or under the terms of the GNU
+ * Library General Public License as published by the Free Software Foundation;
+ * either version 2 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
+ * details.
+ *
+ * If you didn't download this code from the following link, you should check if
+ * you aren't using an obsolete version:
+ * http://www.lowagie.com/iText/
+ */
+
+package com.lowagie.tools.plugins.treeview;
+
+public interface IUpdatenodeview {
+ public void showempty();
+
+ public void showtext(String text);
+
+ public void showvalues(String text);
+}
diff --git a/src/main/java/com/lowagie/tools/plugins/treeview/OutlinelistTreeNode.java b/src/main/java/com/lowagie/tools/plugins/treeview/OutlinelistTreeNode.java
new file mode 100644
index 0000000..2fd78e5
--- /dev/null
+++ b/src/main/java/com/lowagie/tools/plugins/treeview/OutlinelistTreeNode.java
@@ -0,0 +1,98 @@
+/*
+ * $Id: OutlinelistTreeNode.java,v 1.2 2006/05/30 09:13:36 blowagie Exp $
+ * $Name: $
+ *
+ * Copyright 2005 by Anonymous.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the License.
+ *
+ * The Original Code is 'iText, a free JAVA-PDF library'.
+ *
+ * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
+ * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
+ * All Rights Reserved.
+ * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
+ * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
+ *
+ * Contributor(s): all the names of the contributors are added in the source code
+ * where applicable.
+ *
+ * Alternatively, the contents of this file may be used under the terms of the
+ * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
+ * provisions of LGPL are applicable instead of those above. If you wish to
+ * allow use of your version of this file only under the terms of the LGPL
+ * License and not to allow others to use your version of this file under
+ * the MPL, indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by the LGPL.
+ * If you do not delete the provisions above, a recipient may use your version
+ * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the MPL as stated above or under the terms of the GNU
+ * Library General Public License as published by the Free Software Foundation;
+ * either version 2 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
+ * details.
+ *
+ * If you didn't download this code from the following link, you should check if
+ * you aren't using an obsolete version:
+ * http://www.lowagie.com/iText/
+ */
+
+package com.lowagie.tools.plugins.treeview;
+
+import java.util.ArrayList;
+
+import com.lowagie.text.pdf.PdfArray;
+import com.lowagie.text.pdf.PdfDictionary;
+import java.util.Set;
+import java.util.Iterator;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+public class OutlinelistTreeNode
+ extends UpdateableTreeNode {
+ private com.lowagie.text.pdf.PdfDictionary dictionary;
+ public OutlinelistTreeNode(Object userObject, PdfDictionary dictionary) {
+ super(userObject);
+ this.dictionary = dictionary;
+ }
+
+ public OutlinelistTreeNode(PdfDictionary dictionary) {
+ super("Outlinenode " + dictionary);
+ this.dictionary = dictionary;
+ }
+
+ public void updateview(IUpdatenodeview updateobject) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("<html>");
+ sb.append("<p>");
+ sb.append(this.userObject);
+ sb.append("</p>");
+ Set set = dictionary.getKeys();
+ Iterator it = set.iterator();
+ while (it.hasNext()) {
+ sb.append("<p>");
+ sb.append("Key " + it.next().toString());
+ sb.append("</p>");
+ }
+ sb.append("</html>");
+ updateobject.showvalues(sb.toString());
+
+ }
+
+ public Icon getIcon(){
+ return new ImageIcon(TreeViewInternalFrame.class.getResource(
+ "bookmarks.gif"));
+ }
+
+}
diff --git a/src/main/java/com/lowagie/tools/plugins/treeview/PagelistTreeNode.java b/src/main/java/com/lowagie/tools/plugins/treeview/PagelistTreeNode.java
new file mode 100644
index 0000000..928fefa
--- /dev/null
+++ b/src/main/java/com/lowagie/tools/plugins/treeview/PagelistTreeNode.java
@@ -0,0 +1,87 @@
+/*
+ * $Id: PagelistTreeNode.java,v 1.2 2006/05/30 09:13:36 blowagie Exp $
+ * $Name: $
+ *
+ * Copyright 2005 by Anonymous.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the License.
+ *
+ * The Original Code is 'iText, a free JAVA-PDF library'.
+ *
+ * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
+ * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
+ * All Rights Reserved.
+ * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
+ * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
+ *
+ * Contributor(s): all the names of the contributors are added in the source code
+ * where applicable.
+ *
+ * Alternatively, the contents of this file may be used under the terms of the
+ * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
+ * provisions of LGPL are applicable instead of those above. If you wish to
+ * allow use of your version of this file only under the terms of the LGPL
+ * License and not to allow others to use your version of this file under
+ * the MPL, indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by the LGPL.
+ * If you do not delete the provisions above, a recipient may use your version
+ * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the MPL as stated above or under the terms of the GNU
+ * Library General Public License as published by the Free Software Foundation;
+ * either version 2 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
+ * details.
+ *
+ * If you didn't download this code from the following link, you should check if
+ * you aren't using an obsolete version:
+ * http://www.lowagie.com/iText/
+ */
+
+package com.lowagie.tools.plugins.treeview;
+
+import java.util.ArrayList;
+
+import com.lowagie.text.pdf.PdfArray;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+public class PagelistTreeNode
+ extends UpdateableTreeNode {
+ private com.lowagie.text.pdf.PdfArray pdfarray;
+ public PagelistTreeNode(PdfArray pdfarray) {
+ super("Pagesnode " + pdfarray);
+ this.pdfarray = pdfarray;
+ }
+
+ public void updateview(IUpdatenodeview updateobject) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("<html>");
+ sb.append("<p>");
+ sb.append(this.userObject);
+ sb.append("</p>");
+ ArrayList arl = pdfarray.getArrayList();
+ for (int i = 0; i < arl.size(); i++) {
+ sb.append("<p>");
+ sb.append(" " + arl.get(i).toString());
+ sb.append("</p>");
+ }
+ sb.append("</html>");
+ updateobject.showvalues(sb.toString());
+ }
+
+ public Icon getIcon(){
+ return new ImageIcon(TreeViewInternalFrame.class.getResource(
+ "pageonly.gif"));
+ }
+}
diff --git a/src/main/java/com/lowagie/tools/plugins/treeview/Pagetreenode.java b/src/main/java/com/lowagie/tools/plugins/treeview/Pagetreenode.java
new file mode 100644
index 0000000..4cbcfda
--- /dev/null
+++ b/src/main/java/com/lowagie/tools/plugins/treeview/Pagetreenode.java
@@ -0,0 +1,208 @@
+/*
+ * $Id: Pagetreenode.java,v 1.3 2006/05/30 09:13:36 blowagie Exp $
+ * $Name: $
+ *
+ * Copyright 2005 by Anonymous.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the License.
+ *
+ * The Original Code is 'iText, a free JAVA-PDF library'.
+ *
+ * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
+ * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
+ * All Rights Reserved.
+ * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
+ * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
+ *
+ * Contributor(s): all the names of the contributors are added in the source code
+ * where applicable.
+ *
+ * Alternatively, the contents of this file may be used under the terms of the
+ * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
+ * provisions of LGPL are applicable instead of those above. If you wish to
+ * allow use of your version of this file only under the terms of the LGPL
+ * License and not to allow others to use your version of this file under
+ * the MPL, indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by the LGPL.
+ * If you do not delete the provisions above, a recipient may use your version
+ * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the MPL as stated above or under the terms of the GNU
+ * Library General Public License as published by the Free Software Foundation;
+ * either version 2 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
+ * details.
+ *
+ * If you didn't download this code from the following link, you should check if
+ * you aren't using an obsolete version:
+ * http://www.lowagie.com/iText/
+ */
+
+package com.lowagie.tools.plugins.treeview;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+import com.lowagie.text.Rectangle;
+import com.lowagie.text.pdf.*;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+public class Pagetreenode
+ extends UpdateableTreeNode {
+ private com.lowagie.text.pdf.PdfDictionary dictionary;
+
+ private int seitennummer;
+ private float width;
+ private float height;
+
+ public Pagetreenode(com.lowagie.text.pdf.PdfDictionary page, int seitennummer,
+ ICommonAnalyzer pageanalyzer, PdfReader pdfreader) {
+ super();
+ this.dictionary = page;
+ this.seitennummer = seitennummer;
+ DefaultMutableTreeNode info;
+
+ PdfArray arr = (PdfArray) page.get(PdfName.MEDIABOX);
+ float curwidth = 0;
+ float curheight = 0;
+ if (arr != null) {
+ ArrayList arl = arr.getArrayList();
+ curwidth = Float.parseFloat(arl.get(2).toString());
+ curheight = Float.parseFloat(arl.get(3).toString());
+ info = new SimpletextTreeNode(PdfName.MEDIABOX + " " + curwidth + "*" +
+ curheight);
+ this.add(info);
+
+ }
+ PdfArray arrcrop = (PdfArray) page.get(PdfName.CROPBOX);
+ float curwidthcrop = 0;
+ float curheightcrop = 0;
+ if (arrcrop != null) {
+ ArrayList arl = arrcrop.getArrayList();
+ curwidthcrop = Float.parseFloat(arl.get(2).toString());
+ curheightcrop = Float.parseFloat(arl.get(3).toString());
+ info = new SimpletextTreeNode(PdfName.CROPBOX + " " + curwidthcrop + "*" +
+ curheightcrop);
+ this.add(info);
+
+ }
+
+ PdfNumber rotation = (PdfNumber) PdfReader.getPdfObject(page.get(PdfName.
+ ROTATE));
+
+ if (rotation == null) {
+ System.out.println("Rotation missing");
+ rotation = new PdfNumber(0);
+ }
+ else {
+ info = new SimpletextTreeNode(PdfName.
+ ROTATE + " " + rotation);
+ this.add(info);
+ }
+ Rectangle rect = new Rectangle(curwidthcrop,
+ curheightcrop);
+
+ if ( (rotation.floatValue() == 90) || (rotation.floatValue() == 270)) {
+ rect = rect.rotate();
+ }
+
+ width = rect.width();
+ height = rect.height();
+
+ // ??? Dont want a backreference! PdfDictionary parent = (PdfDictionary) PdfReader.getPdfObject(page.get(PdfName.PARENT));
+ PdfArray dict = (PdfArray) PdfReader.getPdfObject(page.get(PdfName.ANNOTS));
+ if (dict != null) {
+ this.add(new SimpletextTreeNode(PdfName.ANNOTS + " " + dict.length()));
+ SimpletextTreeNode sttn = new SimpletextTreeNode(PdfName.ANNOTS + " " +
+ dict.type());
+ this.add(sttn);
+ pageanalyzer.iterateObjects(dict, pdfreader, sttn);
+
+ }
+ PdfObject reso = PdfReader.getPdfObject(page.get(PdfName.RESOURCES));
+ if (reso != null) {
+ SimpletextTreeNode sttn = new SimpletextTreeNode(PdfName.RESOURCES + " " +
+ reso.type());
+ this.add(sttn);
+ pageanalyzer.iterateObjects(reso, pdfreader, sttn);
+ }
+
+ PdfObject contents = PdfReader.getPdfObject(page.get(PdfName.CONTENTS));
+ if (contents != null) {
+ this.add(new TextpaneTreeNode(contents,"Content"));
+
+ if (contents.isStream()) {
+ PRStream prstr = (PRStream) contents;
+
+ Set s = prstr.getKeys();
+ Iterator it = s.iterator();
+
+ while (it.hasNext()) {
+ Object obj = it.next();
+ System.out.println("Field:" + obj);
+
+ Object value = PdfReader.getPdfObject(prstr.get( (PdfName) obj));
+ System.out.println("Value:" + value);
+ }
+ }
+ }
+ }
+
+ public int getSeitennummer() {
+ return seitennummer;
+ }
+
+ public String toString() {
+ return "Page " + seitennummer;
+ }
+
+ public float getWidth() {
+ return width;
+ }
+
+ public float getHeight() {
+ return height;
+ }
+
+ public void updateview(IUpdatenodeview updateobject) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("<html>");
+ sb.append("<p>");
+ sb.append("Page " + getSeitennummer());
+ sb.append("</p>");
+ sb.append("<p>");
+ sb.append("Size: " + getWidth() + "*" + getHeight());
+ sb.append("</p>");
+
+ Set set = dictionary.getKeys();
+ Iterator it = set.iterator();
+ while (it.hasNext()) {
+ sb.append("<p>");
+ sb.append("Key " + it.next().toString());
+ sb.append("</p>");
+ }
+ sb.append("</html>");
+ updateobject.showvalues(sb.toString());
+ }
+
+ public Icon getIcon(){
+ return new ImageIcon(TreeViewInternalFrame.class.getResource(
+ "pageonly.gif"));
+ }
+
+
+}
diff --git a/src/main/java/com/lowagie/tools/plugins/treeview/ProgressDialog.java b/src/main/java/com/lowagie/tools/plugins/treeview/ProgressDialog.java
new file mode 100644
index 0000000..42e46db
--- /dev/null
+++ b/src/main/java/com/lowagie/tools/plugins/treeview/ProgressDialog.java
@@ -0,0 +1,124 @@
+/*
+ * $Id: ProgressDialog.java,v 1.1 2005/11/29 21:05:02 blowagie Exp $
+ * $Name: $
+ *
+ * Copyright 2005 by Anonymous.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the License.
+ *
+ * The Original Code is 'iText, a free JAVA-PDF library'.
+ *
+ * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
+ * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
+ * All Rights Reserved.
+ * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
+ * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
+ *
+ * Contributor(s): all the names of the contributors are added in the source code
+ * where applicable.
+ *
+ * Alternatively, the contents of this file may be used under the terms of the
+ * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
+ * provisions of LGPL are applicable instead of those above. If you wish to
+ * allow use of your version of this file only under the terms of the LGPL
+ * License and not to allow others to use your version of this file under
+ * the MPL, indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by the LGPL.
+ * If you do not delete the provisions above, a recipient may use your version
+ * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the MPL as stated above or under the terms of the GNU
+ * Library General Public License as published by the Free Software Foundation;
+ * either version 2 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
+ * details.
+ *
+ * If you didn't download this code from the following link, you should check if
+ * you aren't using an obsolete version:
+ * http://www.lowagie.com/iText/
+ */
+
+package com.lowagie.tools.plugins.treeview;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Toolkit;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+
+
+public class ProgressDialog extends JDialog {
+ JPanel panel1 = new JPanel();
+ BorderLayout borderLayout1 = new BorderLayout();
+ JPanel jPanel1 = new JPanel();
+ BorderLayout borderLayout2 = new BorderLayout();
+ BorderLayout borderLayout3 = new BorderLayout();
+ JLabel jLabel1 = new JLabel();
+ JProgressBar jProgressBar1 = new JProgressBar();
+ private int anzahlseiten;
+ private int aktuelleseite;
+
+ public ProgressDialog(Frame frame, String title, boolean modal) {
+ super(frame, title, modal);
+ try {
+ jbInit();
+ pack();
+ }
+ catch(Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public ProgressDialog() {
+ this(null, "", false);
+ }
+
+ private void jbInit() throws Exception {
+ panel1.setLayout(borderLayout1);
+ this.getContentPane().setLayout(borderLayout2);
+ jPanel1.setLayout(borderLayout3);
+ jLabel1.setText("Analysefortschritt");
+ jProgressBar1.setStringPainted(true);
+ getContentPane().add(panel1, BorderLayout.CENTER);
+ panel1.add(jPanel1, BorderLayout.CENTER);
+ jPanel1.add(jProgressBar1, BorderLayout.CENTER);
+ this.getContentPane().add(jLabel1, BorderLayout.NORTH);
+ //Das Fenster zentrieren
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ Dimension frameSize = getSize();
+ if (frameSize.height > screenSize.height) {
+ frameSize.height = screenSize.height;
+ }
+ if (frameSize.width > screenSize.width) {
+ frameSize.width = screenSize.width;
+ }
+ setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
+ }
+ public int getAnzahlseiten() {
+ return anzahlseiten;
+ }
+ public void setAnzahlseiten(int anzahlseiten) {
+ this.anzahlseiten = anzahlseiten;
+ jProgressBar1.setMaximum(anzahlseiten);
+ }
+ public int getAktuelleseite() {
+ return aktuelleseite;
+ }
+ public void setAktuelleseite(int aktuelleseite) {
+ this.aktuelleseite = aktuelleseite;
+ jProgressBar1.setValue(aktuelleseite);
+ }
+}
diff --git a/src/main/java/com/lowagie/tools/plugins/treeview/SimpletextTreeNode.java b/src/main/java/com/lowagie/tools/plugins/treeview/SimpletextTreeNode.java
new file mode 100644
index 0000000..2eedb6e
--- /dev/null
+++ b/src/main/java/com/lowagie/tools/plugins/treeview/SimpletextTreeNode.java
@@ -0,0 +1,69 @@
+/*
+ * $Id: SimpletextTreeNode.java,v 1.1 2005/11/29 21:05:02 blowagie Exp $
+ * $Name: $
+ *
+ * Copyright 2005 by Anonymous.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the License.
+ *
+ * The Original Code is 'iText, a free JAVA-PDF library'.
+ *
+ * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
+ * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
+ * All Rights Reserved.
+ * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
+ * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
+ *
+ * Contributor(s): all the names of the contributors are added in the source code
+ * where applicable.
+ *
+ * Alternatively, the contents of this file may be used under the terms of the
+ * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
+ * provisions of LGPL are applicable instead of those above. If you wish to
+ * allow use of your version of this file only under the terms of the LGPL
+ * License and not to allow others to use your version of this file under
+ * the MPL, indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by the LGPL.
+ * If you do not delete the provisions above, a recipient may use your version
+ * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the MPL as stated above or under the terms of the GNU
+ * Library General Public License as published by the Free Software Foundation;
+ * either version 2 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
+ * details.
+ *
+ * If you didn't download this code from the following link, you should check if
+ * you aren't using an obsolete version:
+ * http://www.lowagie.com/iText/
+ */
+
+package com.lowagie.tools.plugins.treeview;
+
+public class SimpletextTreeNode
+ extends UpdateableTreeNode {
+
+ public SimpletextTreeNode(Object p0) {
+ super(p0);
+ }
+
+ public void updateview(IUpdatenodeview updateobject) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("<html>");
+ sb.append("<p>");
+ sb.append(this.userObject);
+ sb.append("</p>");
+ sb.append("</html>");
+ updateobject.showvalues(sb.toString());
+ }
+}
diff --git a/src/main/java/com/lowagie/tools/plugins/treeview/TextpaneTreeNode.java b/src/main/java/com/lowagie/tools/plugins/treeview/TextpaneTreeNode.java
new file mode 100644
index 0000000..bf37c7a
--- /dev/null
+++ b/src/main/java/com/lowagie/tools/plugins/treeview/TextpaneTreeNode.java
@@ -0,0 +1,91 @@
+/*
+ * $Id: TextpaneTreeNode.java,v 1.2 2006/05/30 09:13:36 blowagie Exp $
+ * $Name: $
+ *
+ * Copyright 2005 by Anonymous.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the License.
+ *
+ * The Original Code is 'iText, a free JAVA-PDF library'.
+ *
+ * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
+ * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
+ * All Rights Reserved.
+ * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
+ * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
+ *
+ * Contributor(s): all the names of the contributors are added in the source code
+ * where applicable.
+ *
+ * Alternatively, the contents of this file may be used under the terms of the
+ * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
+ * provisions of LGPL are applicable instead of those above. If you wish to
+ * allow use of your version of this file only under the terms of the LGPL
+ * License and not to allow others to use your version of this file under
+ * the MPL, indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by the LGPL.
+ * If you do not delete the provisions above, a recipient may use your version
+ * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the MPL as stated above or under the terms of the GNU
+ * Library General Public License as published by the Free Software Foundation;
+ * either version 2 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
+ * details.
+ *
+ * If you didn't download this code from the following link, you should check if
+ * you aren't using an obsolete version:
+ * http://www.lowagie.com/iText/
+ */
+
+package com.lowagie.tools.plugins.treeview;
+
+import java.io.IOException;
+
+import com.lowagie.text.pdf.*;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+public class TextpaneTreeNode
+ extends UpdateableTreeNode {
+ PdfObject contents;
+ String marker;
+
+ public TextpaneTreeNode(PdfObject contents,String marker) {
+ super(contents,false);
+ this.contents = contents;
+ this.marker=marker;
+ }
+
+ public void updateview(IUpdatenodeview updateobject) {
+ if (contents.isStream()) {
+ PRStream prstr = (PRStream) contents;
+ try {
+ byte barr[] = PdfReader.getStreamBytes(prstr);
+ updateobject.showtext(new String(barr));
+ }
+ catch (IOException ex) {
+ }
+ }
+ }
+
+ public String toString() {
+ return marker;
+ }
+
+ public Icon getIcon(){
+ return new ImageIcon(TreeViewInternalFrame.class.getResource(
+ "string.gif"));
+ }
+
+}
diff --git a/src/main/java/com/lowagie/tools/plugins/treeview/TreeViewInternalFrame.java b/src/main/java/com/lowagie/tools/plugins/treeview/TreeViewInternalFrame.java
new file mode 100644
index 0000000..802059b
--- /dev/null
+++ b/src/main/java/com/lowagie/tools/plugins/treeview/TreeViewInternalFrame.java
@@ -0,0 +1,272 @@
+/*
+ * $Id: TreeViewInternalFrame.java,v 1.4 2006/05/29 10:31:32 blowagie Exp $
+ * $Name: $
+ *
+ * Copyright 2005 by Anonymous.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the License.
+ *
+ * The Original Code is 'iText, a free JAVA-PDF library'.
+ *
+ * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
+ * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
+ * All Rights Reserved.
+ * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
+ * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
+ *
+ * Contributor(s): all the names of the contributors are added in the source code
+ * where applicable.
+ *
+ * Alternatively, the contents of this file may be used under the terms of the
+ * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
+ * provisions of LGPL are applicable instead of those above. If you wish to
+ * allow use of your version of this file only under the terms of the LGPL
+ * License and not to allow others to use your version of this file under
+ * the MPL, indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by the LGPL.
+ * If you do not delete the provisions above, a recipient may use your version
+ * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the MPL as stated above or under the terms of the GNU
+ * Library General Public License as published by the Free Software Foundation;
+ * either version 2 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
+ * details.
+ *
+ * If you didn't download this code from the following link, you should check if
+ * you aren't using an obsolete version:
+ * http://www.lowagie.com/iText/
+ */
+
+package com.lowagie.tools.plugins.treeview;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import java.awt.BorderLayout;
+import java.awt.CardLayout;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.*;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.DefaultMutableTreeNode;
+import com.lowagie.tools.SwingWorker;
+import java.awt.Cursor;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import java.awt.Component;
+import javax.swing.table.TableColumnModel;
+
+public class TreeViewInternalFrame
+ extends JInternalFrame implements PropertyChangeListener, IUpdatenodeview {
+ AnalyzePDF analyzer;
+
+ public TreeViewInternalFrame(String title, boolean resizable,
+ boolean closable,
+ boolean maximizable) {
+ super(title, resizable, closable, maximizable);
+ try {
+ jbInit();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ private void jbInit() throws Exception {
+ this.getContentPane().setLayout(borderLayout1);
+ jPanel1.setLayout(borderLayout2);
+ jPanel2.setLayout(cardLayout2);
+ jSplitPane1.setMinimumSize(new Dimension(150, 100));
+ jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
+ jTree1.addTreeSelectionListener(new Untitled1_jTree1_treeSelectionAdapter(this));
+ jPanel4.setLayout(borderLayout3);
+ jPanel5.setLayout(borderLayout5);
+ jTree1.setModel(defaultree);
+ jPanel3.setLayout(borderLayout6);
+ jPanel6.setLayout(borderLayout7);
+ jSplitPane2.setDividerSize(3);
+ jPanel1.add(jSplitPane1, java.awt.BorderLayout.CENTER);
+ this.getContentPane().add(jSplitPane1, java.awt.BorderLayout.CENTER);
+ jPanel2.add(jPanel4, "empty");
+ jPanel2.add(jPanel5, "values");
+ jScrollPane3.setViewportView(jLabel1);
+ jScrollPane2.setViewportView(jTextPane1);
+ jPanel2.add(jScrollPane2, "text");
+ jSplitPane1.add(jPanel3, JSplitPane.TOP);
+ jPanel5.add(jScrollPane3, java.awt.BorderLayout.CENTER);
+ jSplitPane1.add(jPanel2, JSplitPane.BOTTOM);
+ jSplitPane2.add(jScrollPane1, JSplitPane.TOP);
+ jSplitPane2.add(jPanel6, JSplitPane.BOTTOM);
+ jScrollPane4.setViewportView(jTable1);
+ jPanel3.add(jSplitPane2, java.awt.BorderLayout.CENTER);
+ jPanel6.add(jScrollPane4, java.awt.BorderLayout.CENTER);
+ jScrollPane1.setViewportView(jTree1);
+ jSplitPane1.setDividerLocation(170);
+ jSplitPane2.setDividerLocation(200);
+ PDFTreeCellRenderer renderer=new PDFTreeCellRenderer();
+ jTree1.setCellRenderer(renderer);
+ }
+
+ public void setTreemodel(TreeModel treemodel) {
+ jTree1.setModel(treemodel);
+ }
+
+ JPanel jPanel1 = new JPanel();
+ BorderLayout borderLayout1 = new BorderLayout();
+ JSplitPane jSplitPane1 = new JSplitPane();
+ JScrollPane jScrollPane1 = new JScrollPane();
+ JTree jTree1 = new JTree();
+ JPanel jPanel2 = new JPanel();
+ BorderLayout borderLayout2 = new BorderLayout();
+ BorderLayout borderLayout4 = new BorderLayout();
+ CardLayout cardLayout2 = new CardLayout();
+ JPanel jPanel4 = new JPanel();
+ JTextPane jTextPane1 = new JTextPane();
+ JPanel jPanel5 = new JPanel();
+ BorderLayout borderLayout3 = new BorderLayout();
+ BorderLayout borderLayout5 = new BorderLayout();
+ JLabel jLabel1 = new JLabel();
+ JScrollPane jScrollPane2 = new JScrollPane();
+ JScrollPane jScrollPane3 = new JScrollPane();
+ DefaultTreeModel defaultree = new DefaultTreeModel(new DefaultMutableTreeNode());
+ JPanel jPanel3 = new JPanel();
+ BorderLayout borderLayout6 = new BorderLayout();
+ JPanel jPanel6 = new JPanel();
+ JTable jTable1 = new JTable();
+ BorderLayout borderLayout7 = new BorderLayout();
+ JSplitPane jSplitPane2 = new JSplitPane();
+ JScrollPane jScrollPane4 = new JScrollPane();
+ TableColumnModel tableColumnModel1 = jTable1.getColumnModel();
+ /**
+ * This method gets called when a bound property is changed.
+ *
+ * @param evt A PropertyChangeEvent object describing the event source and the property that has
+ * changed.
+ * @todo Implement this java.beans.PropertyChangeListener method
+ */
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ String propertyname = evt.getPropertyName();
+
+ if (propertyname == null) {
+ return;
+ }
+ else if (propertyname.equals("srcfile")) {
+ final String filename = (String) evt.getNewValue();
+ final ProgressDialog blubb;
+ blubb = new ProgressDialog(null, "PDF Analysefortschritt", false);
+
+ final JInternalFrame jif = this;
+ SwingWorker work = new SwingWorker() {
+
+ public Object construct() {
+ AnalyzePDF analyzer = new AnalyzePDF(filename, blubb);
+ jif.setCursor(Cursor.getDefaultCursor());
+ return analyzer;
+ }
+ };
+ jif.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ work.start();
+ blubb.show();
+ analyzer = (AnalyzePDF) work.get();
+
+ Timer activitymonitor = new Timer(250, new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ analyzer.updatecount();
+ }
+ });
+
+ analyzer.start();
+ activitymonitor.start();
+ setTreemodel(analyzer);
+ this.jTable1.setModel(analyzer.getXReftable());
+ }
+ }
+
+ public void jTree1_valueChanged(TreeSelectionEvent e) {
+ String event = e.getClass().toString();
+ if (event.equalsIgnoreCase("class javax.swing.event.TreeSelectionEvent")) {
+ UpdateableTreeNode selectednode = (UpdateableTreeNode) jTree1.
+ getLastSelectedPathComponent();
+ System.out.println("Selected node: " + selectednode);
+ if (selectednode != null) {
+ selectednode.updateview(this);
+ }
+ }
+ }
+
+ /**
+ * This method fills the bottom window with the given text in a JtextPane
+ * IUpdatenodeview method
+ * @param text String Plain text
+ */
+ public void showtext(String text) {
+ jTextPane1.setText(text);
+ cardLayout2.show(jPanel2, "text");
+ jPanel2.repaint();
+ jTextPane1.repaint();
+ }
+
+ /**
+ * This method clears the bottom window
+ * IUpdatenodeview method
+ */
+ public void showempty() {
+ cardLayout2.show(jPanel2, "empty");
+ jPanel2.repaint();
+ }
+
+ /**
+ * This method fills the bottom window with the given text in a JLabel
+ * IUpdatenodeview method
+ * @param text String HTML formatted text
+ */
+ public void showvalues(String text) {
+ jLabel1.setText(text);
+ cardLayout2.show(jPanel2, "values");
+ }
+
+ class PDFTreeCellRenderer extends DefaultTreeCellRenderer{
+ public Component getTreeCellRendererComponent(JTree tree,Object value,boolean selected,boolean expanded,boolean leaf,int row,boolean hasFocus){
+ super.getTreeCellRendererComponent(tree,value,selected,expanded,leaf,row,hasFocus);
+ DefaultMutableTreeNode node=(DefaultMutableTreeNode)value;
+ if(node instanceof UpdateableTreeNode){
+ UpdateableTreeNode utn=(UpdateableTreeNode)node;
+ Object o = node.getUserObject();
+ setFont(getFont().deriveFont(12.1f));
+// setIcon(new ImageIcon(TreeViewInternalFrame.class.getResource(
+// "icon16.gif")));
+ setIcon(utn.getIcon());
+ }
+ return this;
+ }
+ }
+}
+
+class Untitled1_jTree1_treeSelectionAdapter
+ implements TreeSelectionListener {
+ private TreeViewInternalFrame adaptee;
+ Untitled1_jTree1_treeSelectionAdapter(TreeViewInternalFrame adaptee) {
+ this.adaptee = adaptee;
+ }
+
+ public void valueChanged(TreeSelectionEvent e) {
+ adaptee.jTree1_valueChanged(e);
+ }
+
+
+}
diff --git a/src/main/java/com/lowagie/tools/plugins/treeview/UpdateableTreeNode.java b/src/main/java/com/lowagie/tools/plugins/treeview/UpdateableTreeNode.java
new file mode 100644
index 0000000..bd7cf47
--- /dev/null
+++ b/src/main/java/com/lowagie/tools/plugins/treeview/UpdateableTreeNode.java
@@ -0,0 +1,74 @@
+/*
+ * $Id: UpdateableTreeNode.java,v 1.2 2006/05/29 10:31:32 blowagie Exp $
+ * $Name: $
+ *
+ * Copyright 2005 by Anonymous.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the License.
+ *
+ * The Original Code is 'iText, a free JAVA-PDF library'.
+ *
+ * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
+ * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
+ * All Rights Reserved.
+ * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
+ * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
+ *
+ * Contributor(s): all the names of the contributors are added in the source code
+ * where applicable.
+ *
+ * Alternatively, the contents of this file may be used under the terms of the
+ * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
+ * provisions of LGPL are applicable instead of those above. If you wish to
+ * allow use of your version of this file only under the terms of the LGPL
+ * License and not to allow others to use your version of this file under
+ * the MPL, indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by the LGPL.
+ * If you do not delete the provisions above, a recipient may use your version
+ * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the MPL as stated above or under the terms of the GNU
+ * Library General Public License as published by the Free Software Foundation;
+ * either version 2 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
+ * details.
+ *
+ * If you didn't download this code from the following link, you should check if
+ * you aren't using an obsolete version:
+ * http://www.lowagie.com/iText/
+ */
+
+package com.lowagie.tools.plugins.treeview;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.ImageIcon;
+import javax.swing.Icon;
+
+public abstract class UpdateableTreeNode
+ extends DefaultMutableTreeNode {
+ public UpdateableTreeNode() {
+ super();
+ }
+
+ public UpdateableTreeNode(Object userObject) {
+ super(userObject);
+ }
+ public UpdateableTreeNode(Object userObject,boolean allowchildren) {
+ super(userObject,allowchildren);
+ }
+ public abstract void updateview(IUpdatenodeview updateobject);
+ public Icon getIcon(){
+ return null;
+ }
+ }
+