org.jtgl.core
Class JTGLRect

java.lang.Object
  extended by org.jtgl.core.JTGLRect

public final class JTGLRect
extends java.lang.Object

Rectangle primitive

Author:
Manuel Polo (manuel_polo at yahoo dot es)

Field Summary
 int height
           
 int width
           
 int x
           
 int y
           
 
Constructor Summary
JTGLRect()
           
JTGLRect(int width, int height)
           
JTGLRect(int x, int y, int width, int height)
          Creates a new instance of JTGLRect
JTGLRect(JTGLRect rect)
           
 
Method Summary
 JTGLRect addDimension(int factor)
           
 JTGLRect addDimension(int w, int h)
           
 void center(int offsetX, int offsetY, int width, int height)
           
 void center(JTGLRect container)
           
 void copy(int x, int y, int width, int height)
           
 void copy(JTGLRect from)
           
 void empty()
           
 boolean equals(java.lang.Object obj)
           
 JTGLRect getClone()
           
 int getHeight()
           
 int getWidth()
           
 int getX()
           
 int getY()
           
static JTGLRect intersection(int r1x, int r1y, int r1width, int r1height, int r2x, int r2y, int r2width, int r2height)
           
static JTGLRect intersection(int r1x, int r1y, int r1width, int r1height, int r2x, int r2y, int r2width, int r2height, JTGLRect result)
           
 JTGLRect intersection(JTGLRect r)
          Computes the intersection of this JTGLRect with the specified Rectangle.
 boolean intersects(JTGLRect r)
           
 boolean isEmpty()
           
 JTGLRect mulDimension(int factor)
           
 JTGLRect mulDimension(int w, int h)
           
 void setDimension(int width, int height)
           
 void setHeight(int height)
           
 void setLocation(int x, int y)
           
 void setWidth(int width)
           
 java.lang.String toString()
           
 void translate(int x, int y)
           
 JTGLRect union(JTGLRect r)
          Computes the union of this JTGLRect with the specified JTGLRect.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public int x

y

public int y

width

public int width

height

public int height
Constructor Detail

JTGLRect

public JTGLRect(int x,
                int y,
                int width,
                int height)
Creates a new instance of JTGLRect


JTGLRect

public JTGLRect(int width,
                int height)

JTGLRect

public JTGLRect()

JTGLRect

public JTGLRect(JTGLRect rect)
Method Detail

setWidth

public void setWidth(int width)

setHeight

public void setHeight(int height)

setLocation

public void setLocation(int x,
                        int y)

translate

public void translate(int x,
                      int y)

center

public void center(JTGLRect container)

center

public void center(int offsetX,
                   int offsetY,
                   int width,
                   int height)

getX

public int getX()

getY

public int getY()

empty

public void empty()

isEmpty

public boolean isEmpty()

setDimension

public void setDimension(int width,
                         int height)

getWidth

public int getWidth()

getHeight

public int getHeight()

addDimension

public JTGLRect addDimension(int w,
                             int h)

addDimension

public JTGLRect addDimension(int factor)

mulDimension

public JTGLRect mulDimension(int w,
                             int h)

mulDimension

public JTGLRect mulDimension(int factor)

intersects

public boolean intersects(JTGLRect r)

intersection

public JTGLRect intersection(JTGLRect r)
Computes the intersection of this JTGLRect with the specified Rectangle. Returns a new JTGLRect that represents the intersection of the two rectangles. If the two rectangles do not intersect, the result will be an empty rectangle.

Parameters:
r - the specified Rectangle
Returns:
the largest Rectangle contained in both the specified Rectangle and in this Rectangle; or if the rectangles do not intersect, an empty rectangle.

intersection

public static JTGLRect intersection(int r1x,
                                    int r1y,
                                    int r1width,
                                    int r1height,
                                    int r2x,
                                    int r2y,
                                    int r2width,
                                    int r2height,
                                    JTGLRect result)

intersection

public static JTGLRect intersection(int r1x,
                                    int r1y,
                                    int r1width,
                                    int r1height,
                                    int r2x,
                                    int r2y,
                                    int r2width,
                                    int r2height)

union

public JTGLRect union(JTGLRect r)
Computes the union of this JTGLRect with the specified JTGLRect. Returns a new Rectangle that represents the union of the two rectangles

Parameters:
r - the specified JTGLRect
Returns:
the smallest JTGLRect containing both the specified JTGLRect and this JTGLRect.

copy

public void copy(JTGLRect from)

copy

public void copy(int x,
                 int y,
                 int width,
                 int height)

getClone

public JTGLRect getClone()

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object