Class Margin

java.lang.Object
com.pdftools.geometry.units.Margin

public class Margin extends Object

The margin defines the space around elements.

The class is based on the respective distances left, bottom, right, and top of type Length.

  • Constructor Details

    • Margin

      public Margin(Length left, Length bottom, Length right, Length top)
      Construct Margin object from individual values
      Parameters:
      left - as Length type
      bottom - as Length type
      right - as Length type
      top - as Length type
    • Margin

      public Margin(double left, double bottom, double right, double top, Length.Units unit)
      Construct Margin object from values and a common unit.
      Parameters:
      left - as numerical value
      bottom - as numerical value
      right - as numerical value
      top - as numerical value
      unit - the unit
    • Margin

      public Margin(Length margin)
      Construct a Margin object of equal margins
      Parameters:
      margin - as Length type
    • Margin

      public Margin(double margin, Length.Units unit)
      Construct a Margin object of equal margins
      Parameters:
      margin - as numerical value
      unit - the unit
  • Method Details

    • parse

      public static Margin parse(String value)
      Create a Margin object from a string representation.
      Parameters:
      value - Allowed are value-unit pairs of the form "<left_value><left_unit> <bottom_value><bottom_unit> <right_value><right_unit> <top_value><top_unit>". Example: "12.3cm 23.4mm 34.5mm 45.6mm"
      Returns:
    • toString

      public String toString()
      Creates a string representation as left-bottom-right-top-tuple with associated suitable metric units, "m", "cm" or "mm".
      Overrides:
      toString in class Object
    • toString

      public String toString(Length.Units unit)
      Creates a string representation as left-bottom-right-top-tuple with the specified unit.
    • getLeft

      public Length getLeft()
      Gets the left margin as Length object.
    • getBottom

      public Length getBottom()
      Gets the bottom margin as Length object.
    • getRight

      public Length getRight()
      Gets the right margin as Length object.
    • getTop

      public Length getTop()
      Gets the top margin as Length object.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object