Class WRectF
The rectangle is defined by a top-left point and a width and height.
JavaScript exposability
A WRectF is JavaScript exposable. If a WRectF is JavaScript bound
, it can be accessed in your
custom JavaScript code through its handle's jsRef()
. A
rectangle is represented in JavaScript as an array of four elements (x,y,width,height), e.g. a
rectangle WRectF(10,20,30,40) will be represented in JavaScript as:
[10, 20, 30, 40]
Warning: A WRectF that is JavaScript exposed should be modified only through its
handle
. Any attempt at modifying it will cause an exception to be
thrown.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
assignFromJSON
(com.google.gson.JsonElement value) clone()
boolean
contains
(double x, double y) Tests if a rectangle contains a point.boolean
Tests if a rectangle contains a point.boolean
Indicates whether some other object is "equal to" this one.double
Returns the bottom side offset.Returns the bottom left point.Returns the bottom right point.Returns the center point.double
Returns the height.Returns a JavaScript representation of the value of this object.double
getLeft()
Returns the X position (left side offset).Returns a normalized rectangle.double
getRight()
Returns the the right side offset.double
getTop()
Returns the Y position (top side offset).Returns the top left point.Returns the top right point.double
getWidth()
Returns the width.double
getX()
Returns the X-position (left side offset).double
getY()
Returns the Y-position (top side offset).boolean
intersects
(WRectF other) Tests if two rectangles intersect.boolean
isEmpty()
Determines whether or not this rectangle is empty.void
setHeight
(double height) Sets the Y-position of the top side.void
setWidth
(double width) Sets the width.void
setX
(double x) Sets the X-position of the left side.void
setY
(double y) Sets the Y-position of the top side.toPath()
Makes the union of to rectangles.Methods inherited from class eu.webtoolkit.jwt.WJavaScriptExposableObject
assignBinding, assignBinding, checkModifiable, closeTo, getJsRef, isJavaScriptBound, sameBindingAs
-
Constructor Details
-
WRectF
public WRectF()Default constructor.Constructs an empty rectangle.
- See Also:
-
WRectF
public WRectF(double x, double y, double width, double height) Creates a rectangle.Constructs a rectangle with top left point (
x
,y
) and sizewidth
xheight
. -
WRectF
-
WRectF
Creates a rectangle.Constructs a rectangle from the two points
topLeft
andbottomRight
.If you want to create a rectangle from two arbitrary corner points, you can use this constructor too, but should call
getNormalized()
afterwords.
-
-
Method Details
-
clone
- Specified by:
clone
in classWJavaScriptExposableObject
-
equals
Indicates whether some other object is "equal to" this one. -
isEmpty
public boolean isEmpty()Determines whether or not this rectangle is empty.A rectangle is empty if its width and height are zero.
A rectangle that
WJavaScriptExposableObject.isJavaScriptBound()
is JavaScript bound is never empty. -
setX
public void setX(double x) Sets the X-position of the left side.The right side of the rectangle does not move, and as a result, the rectangle may be resized.
-
setY
public void setY(double y) Sets the Y-position of the top side.The bottom side of the rectangle does not move, and as a result, the rectangle may be resized.
-
setWidth
public void setWidth(double width) Sets the width.The right side of the rectangle may move, but this does not affect the left side.
-
setHeight
public void setHeight(double height) Sets the Y-position of the top side.The bottom side of the rectangle may move, but this does not affect the Y position of the top side.
-
getX
public double getX()Returns the X-position (left side offset).This is equivalent to
getLeft()
. -
getY
public double getY()Returns the Y-position (top side offset).This is equivalent to
getTop()
. -
getWidth
public double getWidth()Returns the width.- See Also:
-
getHeight
public double getHeight()Returns the height.- See Also:
-
getLeft
public double getLeft()Returns the X position (left side offset).- See Also:
-
getTop
public double getTop()Returns the Y position (top side offset).- See Also:
-
getRight
public double getRight()Returns the the right side offset.- See Also:
-
getBottom
public double getBottom()Returns the bottom side offset.- See Also:
-
getTopLeft
Returns the top left point. -
getTopRight
Returns the top right point.- See Also:
-
getCenter
Returns the center point. -
getBottomLeft
Returns the bottom left point.- See Also:
-
getBottomRight
Returns the bottom right point.- See Also:
-
contains
Tests if a rectangle contains a point.Note: This method is not supported if this rectangle
WJavaScriptExposableObject.isJavaScriptBound()
-
contains
public boolean contains(double x, double y) Tests if a rectangle contains a point.Note: This method is not supported if this rectangle
WJavaScriptExposableObject.isJavaScriptBound()
-
intersects
Tests if two rectangles intersect. -
united
Makes the union of to rectangles.Note: This method is not supported if this rectangle
is JavaScript bound
. -
getNormalized
Returns a normalized rectangle.A normalized rectangle has a positive width and height.
This method supports JavaScript bound rectangles.
-
getJsValue
Description copied from class:WJavaScriptExposableObject
Returns a JavaScript representation of the value of this object.Note: The value returned will reflect the current server side value of the object. If this object is JavaScript bound, this value may not reflect the actual client side value. If you need access to the client side value, use
getJsRef()
intead.- Specified by:
getJsValue
in classWJavaScriptExposableObject
-
toPath
-
assignFromJSON
protected void assignFromJSON(com.google.gson.JsonElement value) - Specified by:
assignFromJSON
in classWJavaScriptExposableObject
-