Class SizeInt

java.lang.Object
com.helger.base.dimension.SizeInt
All Implemented Interfaces:
IHasDimensionInt, IHasHeightInt, IHasWidthInt

@Immutable public class SizeInt extends Object implements IHasDimensionInt
This class represents an object having width and height.
Author:
Philip Helger
  • Constructor Details

    • SizeInt

      public SizeInt(@Nonnull IHasDimensionInt aObj)
    • SizeInt

      public SizeInt(@Nonnegative int nWidth, @Nonnegative int nHeight)
  • Method Details

    • getWidth

      @Nonnegative public int getWidth()
      Specified by:
      getWidth in interface IHasWidthInt
      Returns:
      The width of an object
    • getHeight

      @Nonnegative public int getHeight()
      Specified by:
      getHeight in interface IHasHeightInt
      Returns:
      The height of an object
    • getBestMatchingSize

      @Nonnull @CheckReturnValue public SizeInt getBestMatchingSize(@Nonnegative int nMaxWidth, @Nonnegative int nMaxHeight)
      Return the scaled width and height relative to a maximum size.
      Parameters:
      nMaxWidth - Maximum width. Must be > 0.
      nMaxHeight - Maximum height. Must be > 0.
      Returns:
      An array with 2 elements, where the first element is the width, and the second is the height.
    • getScaledToWidth

      @Nonnull @CheckReturnValue public SizeInt getScaledToWidth(@Nonnegative int nNewWidth)
    • getScaledToHeight

      @Nonnull @CheckReturnValue public SizeInt getScaledToHeight(@Nonnegative int nNewHeight)
    • getAdded

      @Nonnull @CheckReturnValue public SizeInt getAdded(@Nonnull IHasDimensionInt aToAdd)
    • getSubtracted

      @Nonnull @CheckReturnValue public SizeInt getSubtracted(@Nonnull IHasDimensionInt aToSubtract)
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object