1 17 18 19 20 package org.apache.fop.area.inline; 21 22 import org.apache.fop.area.PageViewport; 23 import org.apache.fop.area.Resolvable; 24 import org.apache.fop.fonts.Font; 25 26 import java.util.List ; 27 28 33 public class UnresolvedPageNumber extends TextArea implements Resolvable { 34 35 private boolean resolved = false; 36 private String pageIDRef; 37 private String text; 38 private boolean pageType; 39 40 41 public static final boolean FIRST = true; 42 43 public static final boolean LAST = false; 44 45 private transient Font font; 47 48 54 public UnresolvedPageNumber(String id, Font f) { 55 this(id, f, FIRST); 56 } 57 58 66 public UnresolvedPageNumber(String id, Font f, boolean type) { 67 pageIDRef = id; 68 font = f; 69 text = "?"; 70 pageType = type; 71 } 72 73 78 public String [] getIDRefs() { 79 return new String [] {pageIDRef}; 80 } 81 82 92 public void resolveIDRef(String id, List pages) { 93 if (!resolved && pageIDRef.equals(id) && pages != null) { 94 if (log.isDebugEnabled()) { 95 log.debug("Resolving pageNumber: " + id); 96 } 97 resolved = true; 98 PageViewport page; 99 if (pageType == FIRST) { 100 page = (PageViewport)pages.get(0); 101 } else { 102 page = (PageViewport)pages.get(pages.size() - 1); 103 } 104 removeText(); 106 text = page.getPageNumberString(); 107 addWord(text, 0); 108 if (font != null) { 110 handleIPDVariation(font.getWordWidth(text) - getIPD()); 111 font = null; 113 } else { 114 log.warn("Cannot update the IPD of an unresolved page number." 115 + " No font information available."); 116 } 117 } 118 } 119 120 125 public boolean isResolved() { 126 return resolved; 127 } 128 129 136 public boolean applyVariationFactor(double variationFactor, 137 int lineStretch, int lineShrink) { 138 return true; 139 } 140 } 141 | Popular Tags |