1 50 51 package com.lowagie.text; 52 53 import java.util.Collection ; 54 import java.util.Iterator ; 55 56 63 64 public class MarkedSection extends MarkedObject { 65 66 67 protected MarkedObject title = null; 68 69 73 public MarkedSection(Section section) { 74 super(); 75 if (section.title != null) { 76 title = new MarkedObject(section.title); 77 section.setTitle(null); 78 } 79 this.element = section; 80 } 81 82 90 public void add(int index, Object o) { 91 ((Section)element).add(index, o); 92 } 93 94 102 public boolean add(Object o) { 103 return ((Section)element).add(o); 104 } 105 106 113 public boolean process(ElementListener listener) { 114 try { 115 Element element; 116 for (Iterator i = ((Section)this.element).iterator(); i.hasNext(); ) { 117 element = (Element)i.next(); 118 listener.add(element); 119 } 120 return true; 121 } 122 catch(DocumentException de) { 123 return false; 124 } 125 } 126 127 135 public boolean addAll(Collection collection) { 136 return ((Section)element).addAll(collection); 137 } 138 139 146 public MarkedSection addSection(float indentation, int numberDepth) { 147 MarkedSection section = ((Section)element).addMarkedSection(); 148 section.setIndentation(indentation); 149 section.setNumberDepth(numberDepth); 150 return section; 151 } 152 153 159 public MarkedSection addSection(float indentation) { 160 MarkedSection section = ((Section)element).addMarkedSection(); 161 section.setIndentation(indentation); 162 return section; 163 } 164 165 171 public MarkedSection addSection(int numberDepth) { 172 MarkedSection section = ((Section)element).addMarkedSection(); 173 section.setNumberDepth(numberDepth); 174 return section; 175 } 176 177 182 public MarkedSection addSection() { 183 return ((Section)element).addMarkedSection(); 184 } 185 186 188 193 public void setTitle(MarkedObject title) { 194 if (title.element instanceof Paragraph) 195 this.title = title; 196 } 197 198 201 public MarkedObject title() { 202 if (title == null) { 203 return null; 204 } 205 int depth = Math.min(((Section)element).numbers.size(), ((Section)element).numberDepth); 206 if (depth < 1) { 207 return title; 208 } 209 StringBuffer buf = new StringBuffer (); 210 for (int i = 0; i < depth; i++) { 211 buf.insert(0, "."); 212 buf.insert(0, ((Integer ) ((Section)element).numbers.get(i)).intValue()); 213 } 214 if (buf.length() > 0) buf.append(' '); 215 Paragraph result = new Paragraph((Paragraph)title.element); 216 result.add(0, new Chunk(buf.toString(), ((Paragraph)title.element).getFont())); 217 MarkedObject mo = new MarkedObject(result); 218 mo.markupAttributes = title.markupAttributes; 219 return mo; 220 } 221 222 231 public void setNumberDepth(int numberDepth) { 232 ((Section)element).setNumberDepth(numberDepth); 233 } 234 235 240 public void setIndentationLeft(float indentation) { 241 ((Section)element).setIndentationLeft(indentation); 242 } 243 244 249 public void setIndentationRight(float indentation) { 250 ((Section)element).setIndentationRight(indentation); 251 } 252 253 258 public void setIndentation(float indentation) { 259 ((Section)element).setIndentation(indentation); 260 } 261 262 266 public void setBookmarkOpen(boolean bookmarkOpen) { 267 ((Section)element).setBookmarkOpen(bookmarkOpen); 268 } 269 270 274 public void setTriggerNewPage(boolean triggerNewPage) { 275 ((Section)element).setTriggerNewPage(triggerNewPage); 276 } 277 278 283 public void setBookmarkTitle(String bookmarkTitle) { 284 ((Section)element).setBookmarkTitle(bookmarkTitle); 285 } 286 } | Popular Tags |