Class Padding

java.lang.Object
uk.ac.starlink.ttools.plot2.Padding

@Equality public class Padding extends Object
Defines user preferences for padding a rectangular area. This resembles Insets, except that each member may be null, to indicate that the user has no preference. And it's immutable.
Since:
9 Dec 2016
Author:
Mark Taylor
  • Constructor Details

    • Padding

      public Padding()
      Constructs an empty padding object (no preferences).
    • Padding

      public Padding(Integer top, Integer left, Integer bottom, Integer right)
      Constructs a padding object with preferences for all dimensions. Any of the arguments may be null.
      Parameters:
      top - required top margin in pixels, or null
      left - required left margin in pixels, or null
      bottom - required bottom margin in pixels, or null
      right - required right margin in pixels, or null
  • Method Details

    • getTop

      public Integer getTop()
      Returns the required top margin.
      Returns:
      top margin in pixels, or null for no preference
    • getLeft

      public Integer getLeft()
      Returns the required left margin.
      Returns:
      left margin in pixels, or null for no preference
    • getBottom

      public Integer getBottom()
      Returns the required bottom margin.
      Returns:
      bottom margin in pixels, or null for no preference
    • getRight

      public Integer getRight()
      Returns the required right margin.
      Returns:
      right margin in pixels, or null for no preference
    • overrideInsets

      public Insets overrideInsets(Insets insets)
      Applies the requirements specified by this object to an existing Insets object. The members of the returned insets object are those of this object where they are non-null, and those of the supplied insets otherwise.
      Parameters:
      insets - input insets object
      Returns:
      new insets object with values taken from this padding where available
    • isDefinite

      public boolean isDefinite()
      Returns true if all the members of this padding object are non-null.
      Returns:
      true iff all margins have definite values
    • toDefiniteInsets

      public Insets toDefiniteInsets()
      Returns the insets object corresponding to this padding object if all the members are non-null, and null otherwise.
      Returns:
      insets if isDefinite(), otherwise null
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object