Class WRectF


public class WRectF extends WJavaScriptExposableObject
A value class that defines a rectangle.

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 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 size width x height.

    • WRectF

      public WRectF(WRectF other)
    • WRectF

      public WRectF(WPointF topLeft, WPointF bottomRight)
      Creates a rectangle.

      Constructs a rectangle from the two points topLeft and bottomRight .

      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

      public WRectF clone()
      Specified by:
      clone in class WJavaScriptExposableObject
    • equals

      public boolean equals(WRectF rhs)
      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().

      See Also:
    • getY

      public double getY()
      Returns the Y-position (top side offset).

      This is equivalent to getTop().

      See Also:
    • 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

      public WPointF getTopLeft()
      Returns the top left point.

      See Also:
    • getTopRight

      public WPointF getTopRight()
      Returns the top right point.

      See Also:
    • getCenter

      public WPointF getCenter()
      Returns the center point.
    • getBottomLeft

      public WPointF getBottomLeft()
      Returns the bottom left point.

      See Also:
    • getBottomRight

      public WPointF getBottomRight()
      Returns the bottom right point.

      See Also:
    • contains

      public boolean contains(WPointF p)
      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

      public boolean intersects(WRectF other)
      Tests if two rectangles intersect.
    • united

      public WRectF united(WRectF other)
      Makes the union of to rectangles.

      Note: This method is not supported if this rectangle is JavaScript bound.

    • getNormalized

      public WRectF getNormalized()
      Returns a normalized rectangle.

      A normalized rectangle has a positive width and height.

      This method supports JavaScript bound rectangles.

    • getJsValue

      public String 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 class WJavaScriptExposableObject
    • toPath

      public WPainterPath toPath()
    • assignFromJSON

      protected void assignFromJSON(com.google.gson.JsonElement value)
      Specified by:
      assignFromJSON in class WJavaScriptExposableObject