Class FXRectangles

java.lang.Object
org.jhotdraw8.geom.FXRectangles

public class FXRectangles extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NonNull javafx.geometry.BoundingBox
    add(@NonNull javafx.geometry.Bounds a, @NonNull javafx.geometry.Bounds b)
     
    static @NonNull javafx.geometry.Point2D
     
    static @NonNull javafx.geometry.Point2D
    center(@NonNull javafx.geometry.Bounds r)
    Calculate the center of the given bounds
    static @NonNull javafx.geometry.Point2D
    center(@NonNull javafx.geometry.Rectangle2D r)
    Calculate the center of the given bounds
    static boolean
    contains(@NonNull javafx.geometry.Bounds r, double x, double y, double tolerance)
    Returns true if the bounds contain the specified point within the given tolerance.
    static boolean
    contains(@NonNull javafx.geometry.Bounds r, @NonNull javafx.geometry.Point2D p, double tolerance)
    Returns true if the bounds contain the specified point within the given tolerance.
    static boolean
    contains(@NonNull javafx.geometry.Rectangle2D r1, @NonNull javafx.geometry.Rectangle2D r2)
    Returns true, if rectangle 1 contains rectangle 2.
    static @NonNull javafx.geometry.Point2D
    east(@NonNull javafx.geometry.Rectangle2D r)
     
    static @NonNull javafx.geometry.BoundingBox
    Gets the bounds of the specified shape.
    static @NonNull javafx.geometry.Bounds
    getBounds(@NonNull javafx.geometry.Rectangle2D r)
    Gets the bounds of the specified shape.
    static @NonNull javafx.geometry.Bounds
    grow(@NonNull javafx.geometry.Bounds r, double hv)
    Resizes the Bounds both horizontally and vertically.
    static @NonNull javafx.geometry.Bounds
    grow(@NonNull javafx.geometry.Bounds r, double h, double v)
    Resizes the Bounds both horizontally and vertically.
    static @NonNull javafx.geometry.Rectangle2D
    grow(@NonNull javafx.geometry.Rectangle2D r, double h, double v)
    Resizes the Rectangle2D both horizontally and vertically.
    static @NonNull javafx.geometry.Bounds
    intersection(@NonNull javafx.geometry.Bounds a, @NonNull javafx.geometry.Bounds b)
     
    static boolean
    isEmpty(@NonNull javafx.geometry.Rectangle2D b)
    Returns true if the widht or the height is less or equal 0.
    static boolean
    isFinite(@NonNull javafx.geometry.Bounds bounds)
    Returns true if the given bounds are finite.
    static @NonNull javafx.geometry.Point2D
    north(@NonNull javafx.geometry.Rectangle2D r)
     
    static int
    outcode(@NonNull javafx.geometry.Rectangle2D r1, @NonNull javafx.geometry.Rectangle2D r2)
    This method computes a binary OR of the appropriate mask values indicating, for each side of Rectangle2D r1, whether or not the Rectangle2D r2 is on the same side of the edge as the rest of this Rectangle2D.
    static @NonNull javafx.geometry.Point2D
    south(@NonNull javafx.geometry.Rectangle2D r)
     
    toAwtRectangle2D(@NonNull javafx.geometry.Bounds r)
    Converts a bounding box to a AWT rectangle.
    static @NonNull javafx.geometry.Rectangle2D
    toRectangle2D(@NonNull javafx.geometry.Bounds r)
    Converts a bounding box to a FX rectangle.
    toString(@Nullable javafx.geometry.Bounds b)
     
    toString(@Nullable javafx.geometry.Rectangle2D b)
     
    static @NonNull javafx.geometry.Bounds
    union(@NonNull javafx.geometry.Bounds a, @NonNull javafx.geometry.Bounds... bs)
     
    static @NonNull javafx.geometry.Point2D
    west(@NonNull javafx.geometry.Rectangle2D r)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FXRectangles

      public FXRectangles()
  • Method Details

    • getBounds

      public static @NonNull javafx.geometry.BoundingBox getBounds(@NonNull Shape shape)
      Gets the bounds of the specified shape.
      Parameters:
      shape - an AWT shape
      Returns:
      JavaFX bounds
    • toAwtRectangle2D

      public static @NonNull Rectangle2D.Double toAwtRectangle2D(@NonNull javafx.geometry.Bounds r)
      Converts a bounding box to a AWT rectangle.
      Parameters:
      r - a bounding box
      Returns:
      the rectangle
    • toRectangle2D

      public static @NonNull javafx.geometry.Rectangle2D toRectangle2D(@NonNull javafx.geometry.Bounds r)
      Converts a bounding box to a FX rectangle.
      Parameters:
      r - a bounding box
      Returns:
      the rectangle
    • add

      public static @NonNull javafx.geometry.BoundingBox add(@NonNull javafx.geometry.Bounds a, @NonNull javafx.geometry.Bounds b)
    • center

      public static @NonNull javafx.geometry.Point2D center(@NonNull javafx.geometry.Bounds r)
      Calculate the center of the given bounds
      Parameters:
      r - the bounds
      Returns:
      the center
    • contains

      public static boolean contains(@NonNull javafx.geometry.Bounds r, @NonNull javafx.geometry.Point2D p, double tolerance)
      Returns true if the bounds contain the specified point within the given tolerance.
      Parameters:
      r - the bounds
      p - the point
      tolerance - the tolerance
      Returns:
      true if inside
    • contains

      public static boolean contains(@NonNull javafx.geometry.Bounds r, double x, double y, double tolerance)
      Returns true if the bounds contain the specified point within the given tolerance.
      Parameters:
      r - the bounds
      x - the x-coordinate of the point
      y - the y-coordinate of the point
      tolerance - the tolerance
      Returns:
      true if inside
    • getBounds

      public static @NonNull javafx.geometry.Bounds getBounds(@NonNull javafx.geometry.Rectangle2D r)
      Gets the bounds of the specified shape.
      Parameters:
      r - a rectangle
      Returns:
      JavaFX bounds
    • grow

      public static @NonNull javafx.geometry.Bounds grow(@NonNull javafx.geometry.Bounds r, double h, double v)
      Resizes the Bounds both horizontally and vertically.

      This method returns a new Bounds so that it is h units larger on both the left and right side, and v units larger at both the top and bottom.

      The new Bounds has (x - h, y - v) as its top-left corner, a width of width + 2h, and a height of height + 2v.

      If negative values are supplied for h and v, the size of the Rectangle2D decreases accordingly. The grow method does not check whether the resulting values of width and height are non-negative.

      Parameters:
      r - the bounds
      h - the horizontal expansion
      v - the vertical expansion
      Returns:
      the new rectangle
    • grow

      public static @NonNull javafx.geometry.Bounds grow(@NonNull javafx.geometry.Bounds r, double hv)
      Resizes the Bounds both horizontally and vertically.
      Parameters:
      r - the bounds
      hv - the horizontal and vertical expansion
      Returns:
      the new rectangle
      See Also:
    • union

      public static @NonNull javafx.geometry.Bounds union(@NonNull javafx.geometry.Bounds a, @NonNull javafx.geometry.Bounds... bs)
    • isFinite

      public static boolean isFinite(@NonNull javafx.geometry.Bounds bounds)
      Returns true if the given bounds are finite.
      Parameters:
      bounds - the bounds
      Returns:
      true if finiite
    • intersection

      public static @NonNull javafx.geometry.Bounds intersection(@NonNull javafx.geometry.Bounds a, @NonNull javafx.geometry.Bounds b)
    • center

      public static @NonNull javafx.geometry.Point2D center(@NonNull Rectangle2D r)
    • center

      public static @NonNull javafx.geometry.Point2D center(@NonNull javafx.geometry.Rectangle2D r)
      Calculate the center of the given bounds
      Parameters:
      r - the bounds
      Returns:
      the center
    • east

      public static @NonNull javafx.geometry.Point2D east(@NonNull javafx.geometry.Rectangle2D r)
    • north

      public static @NonNull javafx.geometry.Point2D north(@NonNull javafx.geometry.Rectangle2D r)
    • outcode

      public static int outcode(@NonNull javafx.geometry.Rectangle2D r1, @NonNull javafx.geometry.Rectangle2D r2)
      This method computes a binary OR of the appropriate mask values indicating, for each side of Rectangle2D r1, whether or not the Rectangle2D r2 is on the same side of the edge as the rest of this Rectangle2D.
      Parameters:
      r1 - rectangle 1
      r2 - rectangle 2
      Returns:
      the logical OR of all appropriate out codes OUT_RIGHT, OUT_LEFT, OUT_BOTTOM, OUT_TOP.
    • south

      public static @NonNull javafx.geometry.Point2D south(@NonNull javafx.geometry.Rectangle2D r)
    • isEmpty

      public static boolean isEmpty(@NonNull javafx.geometry.Rectangle2D b)
      Returns true if the widht or the height is less or equal 0.
      Parameters:
      b - a rectangle
      Returns:
      true if empty
    • toString

      public static @NonNull String toString(@Nullable javafx.geometry.Bounds b)
    • contains

      public static boolean contains(@NonNull javafx.geometry.Rectangle2D r1, @NonNull javafx.geometry.Rectangle2D r2)
      Returns true, if rectangle 1 contains rectangle 2.

      This method is similar to Rectangle2D.contains, but also returns true, when rectangle1 contains rectangle2 and either or both of them are empty.

      Parameters:
      r1 - Rectangle2D 1.
      r2 - Rectangle2D 2.
      Returns:
      true if r1 contains r2.
    • grow

      public static @NonNull javafx.geometry.Rectangle2D grow(@NonNull javafx.geometry.Rectangle2D r, double h, double v)
      Resizes the Rectangle2D both horizontally and vertically.

      This method returns a new Rectangle2D so that it is h units larger on both the left and right side, and v units larger at both the top and bottom.

      The new Rectangle2D has (x - h, y - v) as its top-left corner, a width of width + 2h, and a height of height + 2v.

      If negative values are supplied for h and v, the size of the Rectangle2D decreases accordingly. The grow method does not check whether the resulting values of width and height are non-negative.

      Parameters:
      r - the rectangle
      h - the horizontal expansion
      v - the vertical expansion
      Returns:
      the new rectangle
    • toString

      public static @NonNull String toString(@Nullable javafx.geometry.Rectangle2D b)
    • west

      public static @NonNull javafx.geometry.Point2D west(@NonNull javafx.geometry.Rectangle2D r)