Class ProjectionRect

java.lang.Object
ucar.unidata.geoloc.ProjectionRect
All Implemented Interfaces:
Serializable

public class ProjectionRect extends Object implements Serializable
Bounding box for ProjectionPoint's. Note that getX() getY() really means getMinX(), getMinY(), rather than "upper left point" of the rectangle. LOOK will not implement Serializable in ver6 LOOK may be immutable AutoValue in ver6
See Also:
  • Constructor Details

    • ProjectionRect

      public ProjectionRect()
      default constructor, initialized to center (0,0) and width (10000, 10000)
    • ProjectionRect

      public ProjectionRect(ProjectionPoint corner1, ProjectionPoint corner2)
      Construct a ProjectionRect from any two opposite corner points.
      Parameters:
      corner1 - a corner.
      corner2 - the opposite corner.
    • ProjectionRect

      public ProjectionRect(ProjectionPoint minimum, double width, double height)
      Construct a ProjectionRect from any two opposite corner points.
      Parameters:
      minimum - lower left corner, ie the minimum x and y
      width - x width.
      height - y height
    • ProjectionRect

      public ProjectionRect(ProjectionRect r)
      Copy Constructor
      Parameters:
      r - rectangle to copy
    • ProjectionRect

      public ProjectionRect(double x1, double y1, double x2, double y2)
      construct a MapArea from any two opposite corner points
      Parameters:
      x1 - x coord of any corner of the bounding box
      y1 - y coord of the same corner as x1
      x2 - x coord of opposite corner from x1,y1
      y2 - y coord of same corner as x2
  • Method Details

    • getX

      public double getX()
    • getY

      public double getY()
    • getWidth

      public double getWidth()
    • getHeight

      public double getHeight()
    • getMinX

      public double getMinX()
      Returns the smallest X coordinate of the framing rectangle of the Shape in double precision.
      Returns:
      the smallest X coordinate of the framing rectangle of the Shape.
      Since:
      1.2
    • getMinY

      public double getMinY()
      Returns the smallest Y coordinate of the framing rectangle of the Shape in double precision.
      Returns:
      the smallest Y coordinate of the framing rectangle of the Shape.
      Since:
      1.2
    • getMaxX

      public double getMaxX()
      Returns the largest X coordinate of the framing rectangle of the Shape in double precision.
      Returns:
      the largest X coordinate of the framing rectangle of the Shape.
      Since:
      1.2
    • getMaxY

      public double getMaxY()
      Returns the largest Y coordinate of the framing rectangle of the Shape in double precision.
      Returns:
      the largest Y coordinate of the framing rectangle of the Shape.
      Since:
      1.2
    • getCenterX

      public double getCenterX()
      Returns the X coordinate of the center of the framing rectangle of the Shape in double precision.
      Returns:
      the X coordinate of the center of the framing rectangle of the Shape.
      Since:
      1.2
    • getCenterY

      public double getCenterY()
      Returns the Y coordinate of the center of the framing rectangle of the Shape in double precision.
      Returns:
      the Y coordinate of the center of the framing rectangle of the Shape.
      Since:
      1.2
    • add

      @Deprecated public void add(ProjectionRect r)
      Deprecated.
      use builder
      Adds a Rectangle2D object to this Rectangle2D. The resulting Rectangle2D is the union of the two Rectangle2D objects.
      Parameters:
      r - the Rectangle2D to add to this Rectangle2D.
      Since:
      1.2
    • add

      @Deprecated public void add(double newx, double newy)
      Deprecated.
      use builder
      Adds a point, specified by the double precision arguments newx and newy, to this Rectangle2D. The resulting Rectangle2D is the smallest Rectangle2D that contains both the original Rectangle2D and the specified point.

      After adding a point, a call to contains with the added point as an argument does not necessarily return true. The contains method does not return true for points on the right or bottom edges of a rectangle. Therefore, if the added point falls on the left or bottom edge of the enlarged rectangle, contains returns false for that point.

      Parameters:
      newx - the X coordinate of the new point
      newy - the Y coordinate of the new point
      Since:
      1.2
    • add

      @Deprecated public void add(ProjectionPoint pt)
      Deprecated.
      use builder
      Adds the Point2D object pt to this Rectangle2D. The resulting Rectangle2D is the smallest Rectangle2D that contains both the original Rectangle2D and the specified Point2D.

      After adding a point, a call to contains with the added point as an argument does not necessarily return true. The contains method does not return true for points on the right or bottom edges of a rectangle. Therefore, if the added point falls on the left or bottom edge of the enlarged rectangle, contains returns false for that point.

      Parameters:
      pt - the new Point2D to add to this Rectangle2D.
      Since:
      1.2
    • isEmpty

      public boolean isEmpty()
    • intersects

      public boolean intersects(ProjectionRect r)
    • intersects

      public boolean intersects(double x, double y, double w, double h)
    • intersect

      public static void intersect(ProjectionRect src1, ProjectionRect src2, ProjectionRect dest)
      Intersects the pair of specified source Rectangle2D objects and puts the result into the specified destination Rectangle2D object. One of the source rectangles can also be the destination to avoid creating a third Rectangle2D object, but in this case the original points of this source rectangle will be overwritten by this method.
      Parameters:
      src1 - the first of a pair of Rectangle2D objects to be intersected with each other
      src2 - the second of a pair of Rectangle2D objects to be intersected with each other
      dest - the Rectangle2D that holds the results of the intersection of src1 and src2
      Since:
      1.2
    • contains

      public boolean contains(ProjectionPoint point)
      Returns true if this bounding box contains point.
      Parameters:
      point - a point in projection coordinates.
      Returns:
      true if this bounding box contains point.
    • contains

      public boolean contains(ProjectionRect rect)
      Returns true if this bounding box contains rect.
      Parameters:
      rect - a bounding box in projection coordinates
      Returns:
      true if this bounding box contains rect.
    • getLowerRightPoint

      public ProjectionPoint getLowerRightPoint()
      Get the Lower Right Point
      Returns:
      the Lower Right Point
    • getUpperRightPoint

      public ProjectionPoint getUpperRightPoint()
      Get the Upper Left Point (same as getMaxPoint)
      Returns:
      the Upper Left Point
    • getLowerLeftPoint

      public ProjectionPoint getLowerLeftPoint()
      Get the Lower Right Point (same as getMinPoint)
      Returns:
      the Lower Right Point
    • getUpperLeftPoint

      public ProjectionPoint getUpperLeftPoint()
      Get the Upper Left Point
      Returns:
      the Upper Left Point
    • getMinPoint

      public ProjectionPoint getMinPoint()
      Get the minimum corner of the bounding box.
      Returns:
      minimum corner of the bounding box
    • getMaxPoint

      public ProjectionPoint getMaxPoint()
      Get the maximum corner of the bounding box.
      Returns:
      maximum corner of the bounding box
    • toString

      public String toString()
      Get a String representation of this object.
      Overrides:
      toString in class Object
      Returns:
      a String representation of this object.
    • toString2

      public String toString2(int ndec)
    • setX

      @Deprecated public void setX(double x)
      Deprecated.
      use builder
      set minimum X
    • setY

      @Deprecated public void setY(double y)
      Deprecated.
      use builder
      set minimum Y
      Parameters:
      y - minimum y
    • setWidth

      @Deprecated public void setWidth(double w)
      Deprecated.
      use builder
      set X width
      Parameters:
      w - x width
    • setHeight

      @Deprecated public void setHeight(double h)
      Deprecated.
      use builder
      set Y height
      Parameters:
      h - Y height
    • setRect

      @Deprecated public void setRect(ProjectionRect r)
      Deprecated.
      use builder
    • setRect

      @Deprecated public void setRect(double x, double y, double w, double h)
      Deprecated.
      use builder
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • nearlyEquals

      public boolean nearlyEquals(ProjectionRect other)
    • nearlyEquals

      public boolean nearlyEquals(ProjectionRect other, double maxRelDiff)
      Returns true if this rectangle is nearly equal to other. The "near equality" of corners is determined using ProjectionPoint.nearlyEquals(ProjectionPoint, double), with the specified maxRelDiff.
      Parameters:
      other - the other rectangle to check.
      maxRelDiff - the maximum relative difference that two corners may have.
      Returns:
      true if this rectangle is nearly equal to other.