Class Rect

java.lang.Object
com.jogamp.opengl.util.packrect.Rect

public class Rect extends Object
Represents a rectangular region on the backing store. The edges of the rectangle are the infinitely thin region between adjacent pixels on the screen. The origin of the rectangle is its upper-left corner. It is inclusive of the pixels on the top and left edges and exclusive of the pixels on the bottom and right edges. For example, a rect at position (0, 0) and of size (1, 1) would include only the pixel at (0, 0).

Negative coordinates and sizes are not supported, since they make no sense in the context of the packer, which deals only with positively sized regions.

This class contains a user data field for efficient hookup to external data structures as well as enough other hooks to efficiently plug into the rectangle packer.

  • Constructor Details

    • Rect

      public Rect()
    • Rect

      public Rect(Object userData)
    • Rect

      public Rect(int x, int y, int w, int h, Object userData)
  • Method Details

    • x

      public int x()
    • y

      public int y()
    • w

      public int w()
    • h

      public int h()
    • getUserData

      public Object getUserData()
    • getNextLocation

      public Rect getNextLocation()
    • setPosition

      public void setPosition(int x, int y)
    • setSize

      public void setSize(int w, int h) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • setUserData

      public void setUserData(Object obj)
    • setNextLocation

      public void setNextLocation(Rect nextLocation)
    • maxX

      public int maxX()
      Returns the maximum x-coordinate contained within this rectangle. Note that this returns a different result than Java 2D's rectangles; for a rectangle of position (0, 0) and size (1, 1) this will return 0, not 1. Returns -1 if the width of this rectangle is 0.
    • maxY

      public int maxY()
      Returns the maximum y-coordinate contained within this rectangle. Note that this returns a different result than Java 2D's rectangles; for a rectangle of position (0, 0) and size (1, 1) this will return 0, not 1. Returns -1 if the height of this rectangle is 0.
    • canContain

      public boolean canContain(Rect other)
    • toString

      public String toString()
      Overrides:
      toString in class Object