Package com.iizix

Class Rect

  • All Implemented Interfaces:
    java.lang.Cloneable

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

      Fields 
      Modifier and TypeFieldDescription
      intcx
      The width of the rectangle.
      intcy
      The height of the rectangle.
      static Rect[]EMPTY
      Empty array of Rect's.
      intx
      The X position of the rectangle.
      inty
      The Y position of the rectangle.
    • Constructor Summary

      Constructors 
      ConstructorDescription
      Rect()
      Constructor for x=y=cx=cy=0.
      Rect​(int x, int y, int cx, int cy)
      Constructor.
      Rect​(ReadTransaction trans)
      Constructor from a Transaction.
      Rect​(java.lang.String string)
      Constructor from a String formatted as "x,y,cx,cy".
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      voidappend​(SendTransaction trans)
      Appends the rectangle to a transaction.
      voidclear()
      Reinitializes the contents.
      Rectclone()
      Clones this instance.
      booleanequals​(java.lang.Object o)
      Checks if two rectangles are equal.
      inthashCode()
      The hash code.
      booleanisInside​(Position p)
      Checks if a position is inside.
      java.lang.StringtoString()
      Formats to a string as "x,y,cx,cy".
      • Methods inherited from class java.lang.Object

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

      • 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 Detail

      • Rect

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

        public Rect​(java.lang.String string)
        Constructor from a String formatted as "x,y,cx,cy".
        Parameters:
        string - The string.
        Throws:
        java.lang.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 Detail

      • 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​(java.lang.Object o)
        Checks if two rectangles are equal.
        Overrides:
        equals in class java.lang.Object
      • clone

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

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

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

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