Class Box

All Implemented Interfaces:
Dimensions
Direct Known Subclasses:
HBox, Image, Rule, Text, VBox

public class Box extends NonDiscardableElement
Represents a 2D box of something, like a word or an image. Can be used by itself to make an empty space.
  • Field Summary

    Fields inherited from class com.teamten.typeset.element.Element

    DRAW_DEBUG
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    Box(long width, long height, long depth)
     
     
    Box(long width, long height, long depth, long shift)
     
    protected
    Box(Dimensions dimensions)
     
    protected
    Box(Dimensions dimensions, long shift)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    drawDebugRectangle(org.apache.pdfbox.pdmodel.PDPageContentStream contents, long x, long y)
    Draw a debug rectangle at specified point, which represents the left-most point at the baseline.
    long
    The distance from the baseline to the bottom of the box.
    protected String
    A string that specifies the three dimensions of the box.
    long
    The distance from the baseline to the top of the box.
    long
    The amount to shift this box, to the right during vertical layout and up during horizontal layout.
    long
    The width (horizontally) of this box.
    long
    layOutHorizontally(long x, long y, org.apache.pdfbox.pdmodel.PDPageContentStream contents)
    Add the element to the contents as part of a horizontal sequence.
    long
    layOutVertically(long x, long y, org.apache.pdfbox.pdmodel.PDPageContentStream contents)
    Add the element to the contents as part of a vertical sequence.
     

    Methods inherited from class com.teamten.typeset.element.Element

    getVerticalSize, println, println, shouldSkipElementAtStart, toTextString, toTextString, visit

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Box

      public Box(long width, long height, long depth, long shift)
    • Box

      public Box(long width, long height, long depth)
    • Box

      protected Box(Dimensions dimensions, long shift)
    • Box

      protected Box(Dimensions dimensions)
  • Method Details

    • drawDebugRectangle

      protected void drawDebugRectangle(org.apache.pdfbox.pdmodel.PDPageContentStream contents, long x, long y) throws IOException
      Draw a debug rectangle at specified point, which represents the left-most point at the baseline.
      Throws:
      IOException
    • getWidth

      public long getWidth()
      The width (horizontally) of this box.
      Specified by:
      getWidth in interface Dimensions
      Specified by:
      getWidth in class Element
    • getHeight

      public long getHeight()
      The distance from the baseline to the top of the box.
      Specified by:
      getHeight in interface Dimensions
      Specified by:
      getHeight in class Element
    • getDepth

      public long getDepth()
      The distance from the baseline to the bottom of the box.
      Specified by:
      getDepth in interface Dimensions
      Specified by:
      getDepth in class Element
    • getShift

      public long getShift()
      The amount to shift this box, to the right during vertical layout and up during horizontal layout.
    • layOutHorizontally

      public long layOutHorizontally(long x, long y, org.apache.pdfbox.pdmodel.PDPageContentStream contents) throws IOException
      Description copied from class: Element
      Add the element to the contents as part of a horizontal sequence.
      Specified by:
      layOutHorizontally in class Element
      Parameters:
      x - the left-most point of the element.
      y - the baseline of the element.
      contents - the stream to add the element to.
      Returns:
      how much to move right afterward.
      Throws:
      IOException
    • layOutVertically

      public long layOutVertically(long x, long y, org.apache.pdfbox.pdmodel.PDPageContentStream contents) throws IOException
      Description copied from class: Element
      Add the element to the contents as part of a vertical sequence.
      Specified by:
      layOutVertically in class Element
      Parameters:
      x - the left-most point of the element.
      y - the upper-left point of the element.
      contents - the stream to add the element to.
      Returns:
      how much to move down afterward.
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getDimensionString

      protected String getDimensionString()
      A string that specifies the three dimensions of the box.