Documentation of 'math.geom2d.polygon.Rectangle2D' Java class
Rectangle2D
math.geom2d.polygon

Class Rectangle2D

    • Constructor Summary

      Constructors 
      Constructor and Description
      Rectangle2D()
      Empty constructor (size and position zero)
      Rectangle2D(double x0, double y0, double w, double h)
      Main constructor, specifying position of reference corner and rectangle dimensions.
      Rectangle2D(Point2D p1, Point2D p2)
      Creates a rectangle from two corner points.
      Rectangle2D(java.awt.geom.Rectangle2D rect)
      Constructor from awt, to allow easy construction from existing apps.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addVertex(Point2D point)
      Adds a vertex as last vertex of this polygon.
      boolean almostEquals(GeometricObject2D obj, double eps)
      Checks if the two objects are similar up to a given threshold value.
      double area()
      Computes the area of this rectangle, given by the product of width by height.
      Polygon2D asPolygon(int n)
      Returns an approximation of the domain as a polygon, or a MultiPolygon.
      CirculinearContourArray2D<LinearRing2D> boundary()
      Overrides the definition of boundary() such that the boundary of a polygon is defined as a set of LinearRing2D.
      Box2D boundingBox()
      Returns the bounding box of the rectangle.
      CirculinearDomain2D buffer(double dist)
      Computes the buffer of the shape, formed by the set of points located at a distance from the shape that is lower or equal to d.
      Point2D centroid()
      Computes the centroid (center of mass) of this rectangle.
      Polygon2D clip(Box2D box)
      Returns the clipped polygon.
      int closestVertexIndex(Point2D point)
      Computes the index of the closest vertex to the input point.
      Polygon2D complement()
      Returns a new simple Polygon whose vertices are in reverse order of this rectangle.
      boolean contains(double x, double y)
      Checks if this rectangle contains the point given by (x,y)
      boolean contains(Point2D point)
      Checks if this rectangle contains the given point.
      java.util.Collection<LinearRing2D> contours()
      Returns the set of contours that enclose this domain.
      double distance(double x, double y)
      Returns the distance of the point to the polygon.
      double distance(Point2D p)
      Returns the distance of the point to the polygon.
      void draw(java.awt.Graphics2D g2)
      Draws the shape on the given graphics.
      int edgeNumber()
      Returns 4, as a rectangle has four edges.
      java.util.Collection<LineSegment2D> edges()
      Returns the four edges that constitute the boundary of this rectangle.
      boolean equals(java.lang.Object obj)
      Tests if rectangles are the same.
      void fill(java.awt.Graphics2D g2)
      Fills the interior of the domain, using the Graphics current Paint.
      double getHeight() 
      double getWidth() 
      double getX() 
      double getY() 
      void insertVertex(int i, Point2D point)
      Inserts a vertex at the specified position.
      boolean isBounded()
      Always returns true, because a rectangle is always bounded.
      boolean isEmpty()
      Returns true if the shape does not contain any point.
      void removeVertex(int i)
      Removes the vertex at the given index.
      void setVertex(int i, Point2D point)
      Sets the position of the i-th vertex
      SimplePolygon2D transform(AffineTransform2D trans)
      Returns the new Polygon created by an affine transform of this polygon.
      CirculinearDomain2D transform(CircleInversion2D inv)
      Transforms the shape by a circle inversion.
      Point2D vertex(int i)
      Returns the i-th vertex of the polygon.
      int vertexNumber()
      Returns the number of vertices of the rectangle, which is 4.
      java.util.Collection<Point2D> vertices()
      Returns the vertices of the rectangle as a collection of points.
      • Methods inherited from class java.lang.Object

        getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Rectangle2D

        public Rectangle2D(double x0,
                           double y0,
                           double w,
                           double h)
        Main constructor, specifying position of reference corner and rectangle dimensions.
      • Rectangle2D

        public Rectangle2D()
        Empty constructor (size and position zero)
      • Rectangle2D

        public Rectangle2D(java.awt.geom.Rectangle2D rect)
        Constructor from awt, to allow easy construction from existing apps.
      • Rectangle2D

        public Rectangle2D(Point2D p1,
                           Point2D p2)
        Creates a rectangle from two corner points. Origin and dimensions are automatically determined.
    • Method Detail

      • getX

        public double getX()
      • getY

        public double getY()
      • getWidth

        public double getWidth()
      • getHeight

        public double getHeight()
      • vertices

        public java.util.Collection<Point2D> vertices()
        Returns the vertices of the rectangle as a collection of points.
        Specified by:
        vertices in interface Polygon2D
        Returns:
        the vertices of the rectangle.
      • vertexNumber

        public int vertexNumber()
        Returns the number of vertices of the rectangle, which is 4.
        Specified by:
        vertexNumber in interface Polygon2D
        Since:
        0.6.3
      • vertex

        public Point2D vertex(int i)
        Returns the i-th vertex of the polygon.
        Specified by:
        vertex in interface Polygon2D
        Parameters:
        i - index of the vertex, between 0 and 3
      • setVertex

        public void setVertex(int i,
                              Point2D point)
        Description copied from interface: Polygon2D
        Sets the position of the i-th vertex
        Specified by:
        setVertex in interface Polygon2D
        Parameters:
        i - the vertex index
        point - the new position of the vertex
      • addVertex

        public void addVertex(Point2D point)
        Description copied from interface: Polygon2D
        Adds a vertex as last vertex of this polygon.
        Specified by:
        addVertex in interface Polygon2D
        Parameters:
        point - the position of the new vertex
      • insertVertex

        public void insertVertex(int i,
                                 Point2D point)
        Description copied from interface: Polygon2D
        Inserts a vertex at the specified position.
        Specified by:
        insertVertex in interface Polygon2D
        Parameters:
        i - index at which the specified vertex is to be inserted
        point - the position of the new vertex
      • removeVertex

        public void removeVertex(int i)
        Description copied from interface: Polygon2D
        Removes the vertex at the given index.
        Specified by:
        removeVertex in interface Polygon2D
        Parameters:
        i - index of the vertex to remove
      • closestVertexIndex

        public int closestVertexIndex(Point2D point)
        Computes the index of the closest vertex to the input point.
        Specified by:
        closestVertexIndex in interface Polygon2D
      • edges

        public java.util.Collection<LineSegment2D> edges()
        Returns the four edges that constitute the boundary of this rectangle.
        Specified by:
        edges in interface Polygon2D
      • edgeNumber

        public int edgeNumber()
        Returns 4, as a rectangle has four edges.
        Specified by:
        edgeNumber in interface Polygon2D
      • area

        public double area()
        Computes the area of this rectangle, given by the product of width by height.
        Specified by:
        area in interface Polygon2D
        Returns:
        the signed area of the polygon.
        Since:
        0.9.1
      • centroid

        public Point2D centroid()
        Computes the centroid (center of mass) of this rectangle.
        Specified by:
        centroid in interface Polygon2D
        Returns:
        the centroid of the polygon
        Since:
        0.9.1
      • asPolygon

        public Polygon2D asPolygon(int n)
        Description copied from interface: Domain2D
        Returns an approximation of the domain as a polygon, or a MultiPolygon.
        Specified by:
        asPolygon in interface Domain2D
        Returns:
        a polygon
      • buffer

        public CirculinearDomain2D buffer(double dist)
        Description copied from interface: CirculinearShape2D
        Computes the buffer of the shape, formed by the set of points located at a distance from the shape that is lower or equal to d.
        Specified by:
        buffer in interface CirculinearShape2D
        Parameters:
        dist - the maximal distance between a point of the buffer and the shape
        Returns:
        the buffer of the shape
      • isBounded

        public boolean isBounded()
        Always returns true, because a rectangle is always bounded.
        Specified by:
        isBounded in interface Shape2D
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: Shape2D
        Returns true if the shape does not contain any point. This is the case for example for PointSet2D without any point.
        Specified by:
        isEmpty in interface Shape2D
        Returns:
        true if the shape does not contain any point.
      • distance

        public double distance(Point2D p)
        Returns the distance of the point to the polygon. The result is the minimal distance computed for each edge if the polygon, or ZERO if the point lies inside the polygon.
        Specified by:
        distance in interface Shape2D
      • distance

        public double distance(double x,
                               double y)
        Returns the distance of the point to the polygon. The result is the minimal distance computed for each edge if the polygon, or ZERO if the point lies inside the polygon.
        Specified by:
        distance in interface Shape2D
      • clip

        public Polygon2D clip(Box2D box)
        Returns the clipped polygon.
        Specified by:
        clip in interface Domain2D
        Specified by:
        clip in interface Polygon2D
        Specified by:
        clip in interface Shape2D
        Parameters:
        box - the clipping box
        Returns:
        the clipped shape
      • boundingBox

        public Box2D boundingBox()
        Returns the bounding box of the rectangle.
        Specified by:
        boundingBox in interface Shape2D
        Returns:
        the bounding box of the shape.
      • contains

        public boolean contains(Point2D point)
        Checks if this rectangle contains the given point.
        Specified by:
        contains in interface Shape2D
      • contains

        public boolean contains(double x,
                                double y)
        Checks if this rectangle contains the point given by (x,y)
        Specified by:
        contains in interface Shape2D
      • draw

        public void draw(java.awt.Graphics2D g2)
        Description copied from interface: Shape2D
        Draws the shape on the given graphics. If the shape is empty, nothing is drawn. If the shape is unbounded, an exception is thrown.
        Specified by:
        draw in interface Domain2D
        Specified by:
        draw in interface Shape2D
        Parameters:
        g2 - the Graphics to draw on
      • fill

        public void fill(java.awt.Graphics2D g2)
        Description copied from interface: Domain2D
        Fills the interior of the domain, using the Graphics current Paint.
        Specified by:
        fill in interface Domain2D
        Parameters:
        g2 - the Graphics to fill on
      • almostEquals

        public boolean almostEquals(GeometricObject2D obj,
                                    double eps)
        Description copied from interface: GeometricObject2D
        Checks if the two objects are similar up to a given threshold value. This method can be used to compare the results of geometric computations, that introduce errors due to numerical computations.
        Specified by:
        almostEquals in interface GeometricObject2D
        Parameters:
        obj - the object to compare
        eps - a threshold value, for example the minimal coordinate difference
        Returns:
        true if both object have the same value up to the threshold
      • equals

        public boolean equals(java.lang.Object obj)
        Tests if rectangles are the same.
        Overrides:
        equals in class java.lang.Object

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.