예제 #1
0
 /**
  * Creates a new block box from the given element with the given parent. No style is assigned to
  * the resulting box.
  *
  * @param parent The parent box in the tree of boxes.
  * @param n The element that this box belongs to.
  * @param replaced When set to <code>true</code>, a replaced block box will be created. Otherwise,
  *     a normal non-replaced block will be created.
  * @return The new block box.
  */
 protected BlockBox createBlock(BlockBox parent, Element n, boolean replaced) {
   BlockBox root;
   if (replaced) {
     BlockReplacedBox rbox =
         new BlockReplacedBox(
             (Element) n,
             (Graphics2D) parent.getGraphics().create(),
             parent.getVisualContext().create());
     rbox.setViewport(viewport);
     rbox.setContentObj(
         new ReplacedImage(rbox, rbox.getVisualContext(), baseurl, n.getAttribute("src")));
     root = rbox;
   } else {
     root =
         new BlockBox(
             (Element) n,
             (Graphics2D) parent.getGraphics().create(),
             parent.getVisualContext().create());
     root.setViewport(viewport);
   }
   root.setBase(baseurl);
   root.setParent(parent);
   root.setContainingBlock(parent);
   root.setClipBlock(viewport);
   root.setOrder(next_order++);
   return root;
 }
예제 #2
0
 /**
  * Creates a text box with the given parent and text node assigned.
  *
  * @param contblock The parent node (and the containing block in the same time)
  * @param n The corresponding text node in the DOM tree.
  * @return The new text box.
  */
 protected TextBox createTextBox(BlockBox contblock, Text n) {
   TextBox text =
       new TextBox(
           n,
           (Graphics2D) contblock.getGraphics().create(),
           contblock.getVisualContext().create());
   text.setOrder(next_order++);
   text.setContainingBlock(contblock);
   text.setClipBlock(viewport);
   text.setViewport(viewport);
   text.setBase(baseurl);
   return text;
 }