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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidassignFromJSON(com.google.gson.JsonElement value) clone()booleancontains(double x, double y) Tests if a rectangle contains a point.booleanTests if a rectangle contains a point.booleanIndicates whether some other object is "equal to" this one.doubleReturns the bottom side offset.Returns the bottom left point.Returns the bottom right point.Returns the center point.doubleReturns the height.Returns a JavaScript representation of the value of this object.doublegetLeft()Returns the X position (left side offset).Returns a normalized rectangle.doublegetRight()Returns the the right side offset.doublegetTop()Returns the Y position (top side offset).Returns the top left point.Returns the top right point.doublegetWidth()Returns the width.doublegetX()Returns the X-position (left side offset).doublegetY()Returns the Y-position (top side offset).booleanintersects(WRectF other) Tests if two rectangles intersect.booleanisEmpty()Determines whether or not this rectangle is empty.voidsetHeight(double height) Sets the Y-position of the top side.voidsetWidth(double width) Sets the width.voidsetX(double x) Sets the X-position of the left side.voidsetY(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 sizewidthxheight. -
WRectF
-
WRectF
Creates a rectangle.Constructs a rectangle from the two points
topLeftandbottomRight.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:
clonein 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:WJavaScriptExposableObjectReturns 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:
getJsValuein classWJavaScriptExposableObject
-
toPath
-
assignFromJSON
protected void assignFromJSON(com.google.gson.JsonElement value) - Specified by:
assignFromJSONin classWJavaScriptExposableObject
-