Package com.iizix

Class Size

java.lang.Object
com.iizix.Size
All Implemented Interfaces:
Serializable, Cloneable

public class Size extends Object implements Cloneable, Serializable
A size with integers.
Author:
Christopher Mindus
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
    The height.
    int
    The width.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a size initialized to 0,0.
    Size(int width, int height)
    Constructs and initializes position.
    Constructs and initializes position.
  • Method Summary

    Modifier and Type
    Method
    Description
    Clones this instance.
    static int
    Compares to sizes by first the width, then the height.
    boolean
    Check for equality.
    int
    Hash code.
    Creates the string representation of this position as className[width=NN,height=NN].

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • width

      public int width
      The width.
    • height

      public int height
      The height.
  • Constructor Details

    • Size

      public Size()
      Constructs a size initialized to 0,0.
    • Size

      public Size(int width, int height)
      Constructs and initializes position.
      Parameters:
      width - The width.
      height - The height.
    • Size

      public Size(Size s)
      Constructs and initializes position.
      Parameters:
      s - Another size.
  • Method Details

    • equals

      public boolean equals(Object o)
      Check for equality.
      Overrides:
      equals in class Object
      Parameters:
      o - Another size Size, but DSize and GSize are also supported.
      Returns:
      true if equal.
    • clone

      public Size clone()
      Clones this instance.
      Overrides:
      clone in class Object
      Returns:
      As cloned instance of Size.
    • hashCode

      public int hashCode()
      Hash code.
      Overrides:
      hashCode in class Object
      Returns:
      Returns the hash code.
    • toString

      public String toString()
      Creates the string representation of this position as className[width=NN,height=NN].
      Overrides:
      toString in class Object
    • compareWidthThenHeight

      public static int compareWidthThenHeight(Size s1, Size s2)
      Compares to sizes by first the width, then the height.
      Parameters:
      s1 - Size 1 (null allowed).
      s2 - Size 2 (null allowed).
      Returns:
      1 if s2 is wider then higher than s1 (or s2 is null), -1 if smaller (or s1 is null), 0 if equal (both null).