com.pdfjet.Bookmark Maven / Gradle / Ivy
/* */ package com.pdfjet;
/* */
/* */ import java.util.ArrayList;
/* */ import java.util.LinkedList;
/* */ import java.util.List;
/* */ import java.util.Queue;
/* */
/* */ public class Bookmark
/* */ {
/* 41 */ private int destNumber = 0;
/* 42 */ private Page page = null;
/* 43 */ private float y = 0.0F;
/* 44 */ private String key = null;
/* 45 */ private String title = null;
/* 46 */ private Bookmark parent = null;
/* 47 */ private Bookmark prev = null;
/* 48 */ private Bookmark next = null;
/* 49 */ private List children = null;
/* 50 */ private Destination dest = null;
/* */
/* 52 */ protected int objNumber = 0;
/* 53 */ protected String prefix = null;
/* */
/* */ public Bookmark(PDF paramPDF)
/* */ {
/* 57 */ paramPDF.toc = this;
/* */ }
/* */
/* */ private Bookmark(Page paramPage, float paramFloat, String paramString1, String paramString2)
/* */ {
/* 62 */ this.page = paramPage;
/* 63 */ this.y = paramFloat;
/* 64 */ this.key = paramString1;
/* 65 */ this.title = paramString2;
/* */ }
/* */
/* */ public Bookmark addBookmark(Page paramPage, Title paramTitle)
/* */ {
/* 70 */ return addBookmark(paramPage, paramTitle.text.getY(), paramTitle.text.getText());
/* */ }
/* */
/* */ public Bookmark addBookmark(Page paramPage, float paramFloat, String paramString)
/* */ {
/* 75 */ Bookmark localBookmark1 = this;
/* 76 */ while (localBookmark1.parent != null) {
/* 77 */ localBookmark1 = localBookmark1.getParent();
/* */ }
/* 79 */ String str = localBookmark1.next();
/* */
/* 81 */ Bookmark localBookmark2 = new Bookmark(paramPage, paramFloat, str, paramString.replaceAll("\\s+", " "));
/* 82 */ localBookmark2.parent = this;
/* 83 */ localBookmark2.dest = paramPage.addDestination(str, paramFloat);
/* 84 */ if (this.children == null) {
/* 85 */ this.children = new ArrayList();
/* */ }
/* */ else {
/* 88 */ localBookmark2.prev = ((Bookmark)this.children.get(this.children.size() - 1));
/* 89 */ ((Bookmark)this.children.get(this.children.size() - 1)).next = localBookmark2;
/* */ }
/* 91 */ this.children.add(localBookmark2);
/* 92 */ return localBookmark2;
/* */ }
/* */
/* */ public String getDestKey()
/* */ {
/* 97 */ return this.key;
/* */ }
/* */
/* */ public String getTitle()
/* */ {
/* 102 */ return this.title;
/* */ }
/* */
/* */ public Bookmark getParent()
/* */ {
/* 107 */ return this.parent;
/* */ }
/* */
/* */ public Bookmark autoNumber(TextLine paramTextLine)
/* */ {
/* 112 */ Bookmark localBookmark = getPrevBookmark();
/* 113 */ if (localBookmark == null) {
/* 114 */ localBookmark = getParent();
/* 115 */ if (localBookmark.prefix == null) {
/* 116 */ this.prefix = "1";
/* */ }
/* */ else {
/* 119 */ localBookmark.prefix += ".1";
/* */ }
/* */
/* */ }
/* 123 */ else if (localBookmark.prefix == null) {
/* 124 */ if (localBookmark.getParent().prefix == null) {
/* 125 */ this.prefix = "1";
/* */ }
/* */ else
/* 128 */ this.prefix = (localBookmark.getParent().prefix + ".1");
/* */ }
/* */ else
/* */ {
/* 132 */ int i = localBookmark.prefix.lastIndexOf('.');
/* 133 */ if (i == -1) {
/* 134 */ this.prefix = String.valueOf(Integer.valueOf(localBookmark.prefix).intValue() + 1);
/* */ }
/* */ else {
/* 137 */ this.prefix = (localBookmark.prefix.substring(0, i) + ".");
/* 138 */ this.prefix += String.valueOf(Integer.valueOf(localBookmark.prefix.substring(i + 1)).intValue() + 1);
/* */ }
/* */ }
/* */
/* 142 */ paramTextLine.setText(this.prefix);
/* 143 */ this.title = (this.prefix + " " + this.title);
/* 144 */ return this;
/* */ }
/* */
/* */ protected List toArrayList()
/* */ {
/* 149 */ int i = 0;
/* 150 */ ArrayList localArrayList = new ArrayList();
/* 151 */ LinkedList localLinkedList = new LinkedList();
/* 152 */ localLinkedList.add(this);
/* 153 */ while (!localLinkedList.isEmpty()) {
/* 154 */ Bookmark localBookmark = (Bookmark)localLinkedList.poll();
/* 155 */ localBookmark.objNumber = (i++);
/* 156 */ localArrayList.add(localBookmark);
/* 157 */ if (localBookmark.getChildren() != null) {
/* 158 */ localLinkedList.addAll(localBookmark.getChildren());
/* */ }
/* */ }
/* 161 */ return localArrayList;
/* */ }
/* */
/* */ protected List getChildren()
/* */ {
/* 166 */ return this.children;
/* */ }
/* */
/* */ protected Bookmark getPrevBookmark()
/* */ {
/* 171 */ return this.prev;
/* */ }
/* */
/* */ protected Bookmark getNextBookmark()
/* */ {
/* 176 */ return this.next;
/* */ }
/* */
/* */ protected Bookmark getFirstChild()
/* */ {
/* 181 */ return (Bookmark)this.children.get(0);
/* */ }
/* */
/* */ protected Bookmark getLastChild()
/* */ {
/* 186 */ return (Bookmark)this.children.get(this.children.size() - 1);
/* */ }
/* */
/* */ protected Destination getDestination()
/* */ {
/* 191 */ return this.dest;
/* */ }
/* */
/* */ private String next()
/* */ {
/* 196 */ this.destNumber += 1;
/* 197 */ return "dest#" + String.valueOf(this.destNumber);
/* */ }
/* */ }
/* Location: E:\EGGWIFI\Customer\trunk\src\Workspace\Customer\Customer Maven Webapp\src\main\webapp\WEB-INF\lib\PDFjet.jar
* Qualified Name: com.pdfjet.Bookmark
* JD-Core Version: 0.6.2
*/