1 3 package org.faceless.pdf; 4 5 import java.util.*; 6 import java.text.*; 7 8 54 public class LayoutBox extends PeeredObject 55 { 56 60 public static final int CLEAR_NONE=0; 61 62 67 public static final int CLEAR_LEFT=1; 68 69 74 public static final int CLEAR_RIGHT=2; 75 76 final org.faceless.pdf2.LayoutBox box; 77 78 Object getPeer() 79 { 80 return box; 81 } 82 83 LayoutBox(org.faceless.pdf2.LayoutBox box) 84 { 85 this.box=box; 86 } 87 88 94 public LayoutBox(float width) 95 { 96 box = new org.faceless.pdf2.LayoutBox(width); 97 } 98 99 111 public LayoutBox(float width, Locale locale) 112 { 113 box = new org.faceless.pdf2.LayoutBox(width, locale); 114 } 115 116 128 public void setStyle(PDFStyle style) 129 { 130 box.setStyle(style.style); 131 } 132 133 143 public Text addText(String string, PDFStyle style, Locale locale) 144 { 145 return (Text)PeeredObject.getPeer(box.addText(string, style.style, locale)); 146 } 147 148 161 public Text addText(char[] buf, int off, int len, PDFStyle style, Locale locale) 162 { 163 return (Text)PeeredObject.getPeer(box.addText(buf, off, len, style.style, locale)); 164 } 165 166 176 public Text addTextNoBreak(String string, PDFStyle style, Locale locale) 177 { 178 return (Text)PeeredObject.getPeer(box.addTextNoBreak(string, style.style, locale)); 179 } 180 181 195 public Text addTextNoBreak(char[] buf, int off, int len, PDFStyle style, Locale locale) 196 { 197 return (Text)PeeredObject.getPeer(box.addTextNoBreak(buf, off, len, style.style, locale)); 198 } 199 200 206 public void addLineBreak(PDFStyle style) 207 { 208 box.addLineBreak(style.style); 209 } 210 211 220 public Box addBoxInline(float width, float height, int align) 221 { 222 return (Box)PeeredObject.getPeer(box.addBoxInline(width,height,align)); 223 } 224 225 232 public Box addBoxFullWidth(float height) 233 { 234 return (Box)PeeredObject.getPeer(box.addBoxFullWidth(height)); 235 } 236 237 246 public Box addBoxLeft(float width, float height, int clearflags) 247 { 248 return (Box)PeeredObject.getPeer(box.addBoxLeft(width,height,clearflags)); 249 } 250 251 260 public Box addBoxRight(float width, float height, int clearflags) 261 { 262 return (Box)PeeredObject.getPeer(box.addBoxRight(width,height,clearflags)); 263 } 264 265 293 public float addTab(float[] stops) 294 { 295 return box.addTab(stops); 296 } 297 298 301 public boolean isEmpty() 302 { 303 return box.isEmpty(); 304 } 305 306 310 public float getHeight() 311 { 312 return box.getHeight(); 313 } 314 315 321 public boolean isFlushed() 322 { 323 return box.isFlushed(); 324 } 325 326 331 public void flush() 332 { 333 box.flush(); 334 } 335 336 345 public Box[] getBoxes() 346 { 347 org.faceless.pdf2.LayoutBox.Box[] newboxes = box.getBoxes(); 348 Box[] oldboxes = new Box[newboxes.length]; 349 for (int i=0;i<newboxes.length;i++) { 350 oldboxes[i]=(Box)PeeredObject.getPeer(newboxes[i]); 351 } 352 return oldboxes; 353 } 354 355 358 public PDFStyle getStyle() 359 { 360 return (PDFStyle)PeeredObject.getPeer(box.getStyle()); 361 } 362 363 364 365 367 368 369 376 public LayoutBox splitAt(float splitpos) 377 { 378 return (LayoutBox)PeeredObject.getPeer(box.splitAt(splitpos)); 379 } 380 381 387 public int getNumberOfLines() 388 { 389 return box.getNumberOfLines(); 390 } 391 392 393 406 public static class Box extends PeeredObject 407 { 408 final org.faceless.pdf2.LayoutBox.Box box; 409 410 Box(org.faceless.pdf2.LayoutBox.Box box) 411 { 412 this.box=box; 413 } 414 415 Object getPeer() 416 { 417 return box; 418 } 419 420 429 public final int getLineNumber() 430 { 431 return box.getLineNumber(); 432 } 433 434 437 public final float getLeft() 438 { 439 return box.getLeft(); 440 } 441 442 445 public final float getRight() 446 { 447 return box.getRight(); 448 } 449 450 458 public final float getTop() 459 { 460 return box.getTop(); 461 } 462 463 468 public final float getBottom() 469 { 470 return box.getBottom(); 471 } 472 473 483 public final float getLineTop() 484 { 485 return box.getLineTop(); 486 } 487 488 498 public final float getLineBottom() 499 { 500 return box.getLineBottom(); 501 } 502 503 public String toString() 504 { 505 return "{l="+getLeft()+" r="+getRight()+" t="+getTop()+" b="+getBottom()+" lt="+getLineTop()+" lb="+getLineBottom()+" #"+getLineNumber()+"}"; 506 } 507 508 512 public void setImage(PDFImage image) 513 { 514 box.setImage(image.image); 515 } 516 517 521 public PDFImage getImage() 522 { 523 return (PDFImage)PeeredObject.getPeer(box.getImage()); 524 } 525 } 526 527 532 public static class Text extends Box 533 { 534 Text(org.faceless.pdf2.LayoutBox.Text text) 535 { 536 super(text); 537 } 538 539 542 public PDFStyle getStyle() 543 { 544 return (PDFStyle)PeeredObject.getPeer(((org.faceless.pdf2.LayoutBox.Text)this.box).getStyle()); 545 } 546 547 550 public String getText() 551 { 552 return ((org.faceless.pdf2.LayoutBox.Text)this.box).getText(); 553 } 554 555 560 public Text getNextTwin() 561 { 562 return (Text)PeeredObject.getPeer(((org.faceless.pdf2.LayoutBox.Text)this.box).getNextTwin()); 563 } 564 565 573 public void setText(String s) 574 { 575 ((org.faceless.pdf2.LayoutBox.Text)this.box).setText(s); 576 } 577 } 578 } 579 | Popular Tags |