Class Rectangle2D.Float

  • All Implemented Interfaces:
    java.lang.Cloneable, Shape
    Direct Known Subclasses:
    Rectangle
    Enclosing class:
    Rectangle2D

    public static class Rectangle2D.Float
    extends Rectangle2D
    A Rectangle2D with float coordinates.
    • Field Detail

      • x

        public float x
        The x coordinate of the top left corner
      • y

        public float y
        The y coordinate of the top right corner
      • width

        public float width
        The width of the rectangle
      • height

        public float height
        The height of the rectangle;
    • Constructor Detail

      • Float

        public Float()
        Create an empty rectangle at (0,0)
      • Float

        public Float​(float x,
                     float y,
                     float width,
                     float height)
        Create a rectangle with float coordinates
        Parameters:
        x - the x coordinate of the top left corner
        y - the y coordinate of the top left corner
        width - the width of the rectangle
        height - the height of the rectangle
    • Method Detail

      • getX

        public double getX()
        Description copied from class: RectangularShape
        Get the x coordinate as a double
        Specified by:
        getX in class RectangularShape
        Returns:
        the x coordinate
      • getY

        public double getY()
        Description copied from class: RectangularShape
        Get the y coordinate as a double
        Specified by:
        getY in class RectangularShape
        Returns:
        the y coordinate
      • isEmpty

        public boolean isEmpty()
        Description copied from class: RectangularShape
        Test if the rectangular shape is empty
        Specified by:
        isEmpty in class RectangularShape
        Returns:
        true iff the shape is empty
      • getBounds2D

        public Rectangle2D getBounds2D()
        Get the bounds as a Rectangle2D with float coordinates
        Returns:
        the bounding rectangle
      • setRect

        public void setRect​(float x,
                            float y,
                            float w,
                            float h)
        Set the rectangle using float coordinates
        Parameters:
        x - the x coordinate of the top left corner
        y - the y coordinate of the top left corner
        w - the width
        h - the height
      • setRect

        public void setRect​(Rectangle2D r)
        Description copied from class: Rectangle2D
        Set this Rectangle2D to be the same as a given Rectangle2D
        Overrides:
        setRect in class Rectangle2D
        Parameters:
        r - the Rectangle2D
      • setRect

        public void setRect​(double x,
                            double y,
                            double w,
                            double h)
        Description copied from class: Rectangle2D
        Set this rectangle to a rectangle defined by double coordinates
        Specified by:
        setRect in class Rectangle2D
        Parameters:
        x - the x coordinate of the top left corner
        y - the y coordinate of the top right corner
        w - the width of the rectangle
        h - the height of the rectangle
      • outcode

        public int outcode​(double x,
                           double y)
        Description copied from class: Rectangle2D
        Returns a mask value that specifies where a point lies with respect to this rectangle.
        Specified by:
        outcode in class Rectangle2D
        Parameters:
        x - the x coordinate of the given point
        y - the y coordinate of the given point
        Returns:
        the mask value