Package totalcross.ui.gfx
Class Rect
- java.lang.Object
-
- totalcross.ui.gfx.Rect
-
public class Rect extends java.lang.ObjectRect represents a rectangle.
-
-
Constructor Summary
Constructors Constructor Description Rect()Constructs a rectangle with x = y = width = height = 0.Rect(int x, int y, int width, int height)Constructs a rectangle with the given x, y, width and height.Rect(Coord topleft, Coord bottomright)Constructs a rectangle with the given coordsRect(Rect r)Constructs a rectangle with the given rectangle coordinates.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(int xx, int yy)Returns true if the point xx,yy is inside this rect.booleanequals(java.lang.Object other)Returns true if the bounds of this Rect and the given one are the sameinthashCode()Returns the hashcode for this rect, ie, an integer valued 0xXXYYWWHHbooleanintersects(Rect r)Returns true if this rectangle intersects with the given oneRectintersectWith(Rect r)Modify this Rect by doing the intersection with the given rect.RectmodifiedBy(int deltaX, int deltaY, int deltaW, int deltaH)Returns a new rect modified by the specified parameters.voidmodify(int deltaX, int deltaY, int deltaW, int deltaH)Modifies this rect by the specified parameters.voidset(int x, int y, int width, int height)Sets the properties of this rect.voidset(Rect r)Copies the properties of this rect from the given rect.java.lang.StringtoString()voidtranslate(int deltaX, int deltaY)Translates this rect.RectunionWith(Rect r)Modify this Rect by doing an union with the given rect.intx2()Returns x+width-1inty2()Returns y+height-1
-
-
-
Constructor Detail
-
Rect
public Rect()
Constructs a rectangle with x = y = width = height = 0.
-
Rect
public Rect(int x, int y, int width, int height)Constructs a rectangle with the given x, y, width and height.
-
Rect
public Rect(Rect r)
Constructs a rectangle with the given rectangle coordinates.
-
-
Method Detail
-
set
public void set(int x, int y, int width, int height)Sets the properties of this rect.
-
set
public void set(Rect r)
Copies the properties of this rect from the given rect.
-
contains
public boolean contains(int xx, int yy)Returns true if the point xx,yy is inside this rect.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
translate
public void translate(int deltaX, int deltaY)Translates this rect. The new positions will be this.x+deltaX, this.y+deltaY.
-
modifiedBy
public Rect modifiedBy(int deltaX, int deltaY, int deltaW, int deltaH)
Returns a new rect modified by the specified parameters.
-
modify
public void modify(int deltaX, int deltaY, int deltaW, int deltaH)Modifies this rect by the specified parameters.
-
x2
public int x2()
Returns x+width-1
-
y2
public int y2()
Returns y+height-1
-
intersects
public boolean intersects(Rect r)
Returns true if this rectangle intersects with the given one
-
intersectWith
public Rect intersectWith(Rect r)
Modify this Rect by doing the intersection with the given rect. Returnsthisrect.
-
unionWith
public Rect unionWith(Rect r)
Modify this Rect by doing an union with the given rect. Returnsthisrect.
-
equals
public boolean equals(java.lang.Object other)
Returns true if the bounds of this Rect and the given one are the same- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
Returns the hashcode for this rect, ie, an integer valued 0xXXYYWWHH- Overrides:
hashCodein classjava.lang.Object
-
-