Class Glue

All Implemented Interfaces:
Dimensions, Flexible
Direct Known Subclasses:
Leader

public class Glue extends DiscardableElement implements Flexible
Whitespace that has a default width but can be shrunk or stretched.
  • Field Summary

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

    DRAW_DEBUG
  • Constructor Summary

    Constructors
    Constructor
    Description
    Glue(long size, long stretch, boolean stretchIsInfinite, long shrink, boolean shrinkIsInfinite, boolean isHorizontal)
    All units are in scaled points.
    Glue(long size, long stretch, long shrink, boolean isHorizontal)
    Convenience constructor for non-infinite glue.
    Glue(long size, Flexibility stretch, Flexibility shrink, boolean isHorizontal)
    All units are in scaled points.
  • Method Summary

    Modifier and Type
    Method
    Description
    fixed(long newSize)
    Fix the element to the specified size.
    long
    Return the depth (below the baseline) of the element.
    long
    Return the height (above the baseline) of the element.
    How much this element can shrink.
    long
    Get the size of this element in the dimension of its flexibility.
    How much this element can stretch.
    long
    Return the width of the element.
    static Glue
    horizontal(long size)
    Return fixed horizontal glue.
    static Glue
    infinite(boolean isHorizontal)
    Return infinite glue of zero size.
    static Glue
    Return infinite horizontal glue of zero width.
    static Glue
    Return infinite vertical glue of zero height.
    boolean
     
    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.
    void
    println(PrintStream stream, String indent)
    Pretty prints the element to the PrintWriter with the given indent.
     
    Return a text version of the element, ideally containing only the text of the element and its children.
    static Glue
    vertical(long size)
    Return fixed vertical glue.

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

    getVerticalSize, println, shouldSkipElementAtStart, toTextString, visit

    Methods inherited from class java.lang.Object

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

    • Glue

      public Glue(long size, Flexibility stretch, Flexibility shrink, boolean isHorizontal)
      All units are in scaled points.
      Parameters:
      size - the ideal size of the glue.
      stretch - the maximum extra space that can be added.
      shrink - the maximum extra space that can be removed.
    • Glue

      public Glue(long size, long stretch, boolean stretchIsInfinite, long shrink, boolean shrinkIsInfinite, boolean isHorizontal)
      All units are in scaled points.
      Parameters:
      size - the ideal size of the glue.
      stretch - the maximum extra space that can be added (not infinite).
      shrink - the maximum extra space that can be removed (not infinite).
    • Glue

      public Glue(long size, long stretch, long shrink, boolean isHorizontal)
      Convenience constructor for non-infinite glue. All units are in scaled points.
      Parameters:
      size - the ideal size of the glue.
      stretch - the maximum extra space that can be added (not infinite).
      shrink - the maximum extra space that can be removed (not infinite).
  • Method Details

    • horizontal

      public static Glue horizontal(long size)
      Return fixed horizontal glue.
    • vertical

      public static Glue vertical(long size)
      Return fixed vertical glue.
    • infinite

      public static Glue infinite(boolean isHorizontal)
      Return infinite glue of zero size.
    • infiniteHorizontal

      public static Glue infiniteHorizontal()
      Return infinite horizontal glue of zero width.
    • infiniteVertical

      public static Glue infiniteVertical()
      Return infinite vertical glue of zero height.
    • getSize

      public long getSize()
      Description copied from interface: Flexible
      Get the size of this element in the dimension of its flexibility.
      Specified by:
      getSize in interface Flexible
    • getStretch

      public Flexibility getStretch()
      Description copied from interface: Flexible
      How much this element can stretch.
      Specified by:
      getStretch in interface Flexible
    • getShrink

      public Flexibility getShrink()
      Description copied from interface: Flexible
      How much this element can shrink.
      Specified by:
      getShrink in interface Flexible
    • fixed

      public Glue fixed(long newSize)
      Description copied from interface: Flexible
      Fix the element to the specified size.
      Specified by:
      fixed in interface Flexible
    • isHorizontal

      public boolean isHorizontal()
    • getWidth

      public long getWidth()
      Description copied from class: Element
      Return the width of the element.
      Specified by:
      getWidth in interface Dimensions
      Specified by:
      getWidth in class Element
    • getHeight

      public long getHeight()
      Description copied from class: Element
      Return the height (above the baseline) of the element.
      Specified by:
      getHeight in interface Dimensions
      Specified by:
      getHeight in class Element
    • getDepth

      public long getDepth()
      Description copied from class: Element
      Return the depth (below the baseline) of the element.
      Specified by:
      getDepth in interface Dimensions
      Specified by:
      getDepth in class Element
    • 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
    • println

      public void println(PrintStream stream, String indent)
      Description copied from class: Element
      Pretty prints the element to the PrintWriter with the given indent. The method must print its own newline.
      Overrides:
      println in class Element
    • toTextString

      public String toTextString()
      Description copied from class: Element
      Return a text version of the element, ideally containing only the text of the element and its children.
      Overrides:
      toTextString in class Element
    • toString

      public String toString()
      Overrides:
      toString in class Object