Package com.iizix

Class Rect

java.lang.Object
com.iizix.Rect
All Implemented Interfaces:
Cloneable

public class Rect extends Object implements Cloneable
Simple rectangle class for multiple use accepting negative width and height.
Author:
Christopher Mindus
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
    The width of the rectangle.
    int
    The height of the rectangle.
    static final Rect[]
    Empty array of Rect's.
    int
    The X position of the rectangle.
    int
    The Y position of the rectangle.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for x=y=cx=cy=0.
    Rect(int x, int y, int cx, int cy)
    Constructor.
    Constructor from a Transaction.
    Rect(String string)
    Constructor from a String formatted as "x,y,cx,cy".
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Appends the rectangle to a transaction.
    void
    Reinitializes the contents.
    Clones this instance.
    boolean
    Checks if two rectangles are equal.
    int
    The hash code.
    boolean
    Checks if a position is inside.
    Formats to a string as "x,y,cx,cy".

    Methods inherited from class java.lang.Object

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

    • EMPTY

      public static final Rect[] EMPTY
      Empty array of Rect's.
    • x

      public int x
      The X position of the rectangle.
    • y

      public int y
      The Y position of the rectangle.
    • cx

      public int cx
      The width of the rectangle.
    • cy

      public int cy
      The height of the rectangle.
  • Constructor Details

    • Rect

      public Rect()
      Constructor for x=y=cx=cy=0.
    • Rect

      public Rect(String string)
      Constructor from a String formatted as "x,y,cx,cy".
      Parameters:
      string - The string.
      Throws:
      IllegalArgumentException - If the string is not well formatted.
    • Rect

      public Rect(ReadTransaction trans)
      Constructor from a Transaction.
      Parameters:
      trans - The transaction.
    • Rect

      public Rect(int x, int y, int cx, int cy)
      Constructor.
      Parameters:
      x - X position.
      y - Y position.
      cx - Width.
      cy - Height.
  • Method Details

    • isInside

      public boolean isInside(Position p)
      Checks if a position is inside.
      Parameters:
      p - The position.
      Returns:
      true if inside, false otherwise.
    • clear

      public void clear()
      Reinitializes the contents.
    • equals

      public boolean equals(Object o)
      Checks if two rectangles are equal.
      Overrides:
      equals in class Object
    • clone

      public Rect clone()
      Clones this instance.
      Overrides:
      clone in class Object
      Returns:
      As cloned instance of GUnit.
    • toString

      public String toString()
      Formats to a string as "x,y,cx,cy".
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      The hash code.
      Overrides:
      hashCode in class Object
    • append

      public void append(SendTransaction trans)
      Appends the rectangle to a transaction.
      Parameters:
      trans - The transaction to append to.