Package ucar.unidata.geoloc
Class ProjectionRect
java.lang.Object
ucar.unidata.geoloc.ProjectionRect
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptiondefault constructor, initialized to center (0,0) and width (10000, 10000)ProjectionRect(double x1, double y1, double x2, double y2) construct a MapArea from any two opposite corner pointsProjectionRect(ProjectionPoint minimum, double width, double height) Construct a ProjectionRect from any two opposite corner points.ProjectionRect(ProjectionPoint corner1, ProjectionPoint corner2) Construct a ProjectionRect from any two opposite corner points.Copy Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(double newx, double newy) Deprecated.use buildervoidadd(ProjectionPoint pt) Deprecated.use buildervoidDeprecated.use builderbooleancontains(ProjectionPoint point) Returnstrueif this bounding box containspoint.booleancontains(ProjectionRect rect) Returnstrueif this bounding box containsrect.booleandoubleReturns the X coordinate of the center of the framing rectangle of theShapeindoubleprecision.doubleReturns the Y coordinate of the center of the framing rectangle of theShapeindoubleprecision.doubleGet the Lower Right Point (same as getMinPoint)Get the Lower Right PointGet the maximum corner of the bounding box.doublegetMaxX()Returns the largest X coordinate of the framing rectangle of theShapeindoubleprecision.doublegetMaxY()Returns the largest Y coordinate of the framing rectangle of theShapeindoubleprecision.Get the minimum corner of the bounding box.doublegetMinX()Returns the smallest X coordinate of the framing rectangle of theShapeindoubleprecision.doublegetMinY()Returns the smallest Y coordinate of the framing rectangle of theShapeindoubleprecision.Get the Upper Left PointGet the Upper Left Point (same as getMaxPoint)doublegetWidth()doublegetX()doublegetY()inthashCode()static voidintersect(ProjectionRect src1, ProjectionRect src2, ProjectionRect dest) Intersects the pair of specified sourceRectangle2Dobjects and puts the result into the specified destinationRectangle2Dobject.booleanintersects(double x, double y, double w, double h) booleanbooleanisEmpty()booleannearlyEquals(ProjectionRect other) Returns the result ofnearlyEquals(ProjectionRect, double), withMisc.defaultMaxRelativeDiffFloat.booleannearlyEquals(ProjectionRect other, double maxRelDiff) Returnstrueif this rectangle is nearly equal toother.voidsetHeight(double h) Deprecated.use buildervoidsetRect(double x, double y, double w, double h) Deprecated.use buildervoidDeprecated.use buildervoidsetWidth(double w) Deprecated.use buildervoidsetX(double x) Deprecated.use buildervoidsetY(double y) Deprecated.use buildertoString()Get a String representation of this object.toString2(int ndec)
-
Constructor Details
-
ProjectionRect
public ProjectionRect()default constructor, initialized to center (0,0) and width (10000, 10000) -
ProjectionRect
Construct a ProjectionRect from any two opposite corner points.- Parameters:
corner1- a corner.corner2- the opposite corner.
-
ProjectionRect
Construct a ProjectionRect from any two opposite corner points.- Parameters:
minimum- lower left corner, ie the minimum x and ywidth- x width.height- y height
-
ProjectionRect
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 boxy1- y coord of the same corner as x1x2- x coord of opposite corner from x1,y1y2- 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 theShapeindoubleprecision.- 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 theShapeindoubleprecision.- 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 theShapeindoubleprecision.- 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 theShapeindoubleprecision.- 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 theShapeindoubleprecision.- 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 theShapeindoubleprecision.- Returns:
- the Y coordinate of the center of the framing rectangle
of the
Shape. - Since:
- 1.2
-
add
Deprecated.use builderAdds aRectangle2Dobject to thisRectangle2D. The resultingRectangle2Dis the union of the twoRectangle2Dobjects.- Parameters:
r- theRectangle2Dto add to thisRectangle2D.- Since:
- 1.2
-
add
Deprecated.use builderAdds a point, specified by the double precision argumentsnewxandnewy, to thisRectangle2D. The resultingRectangle2Dis the smallestRectangle2Dthat contains both the originalRectangle2Dand the specified point.After adding a point, a call to
containswith the added point as an argument does not necessarily returntrue. Thecontainsmethod does not returntruefor 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,containsreturnsfalsefor that point.- Parameters:
newx- the X coordinate of the new pointnewy- the Y coordinate of the new point- Since:
- 1.2
-
add
Deprecated.use builderAdds thePoint2Dobjectptto thisRectangle2D. The resultingRectangle2Dis the smallestRectangle2Dthat contains both the originalRectangle2Dand the specifiedPoint2D.After adding a point, a call to
containswith the added point as an argument does not necessarily returntrue. Thecontainsmethod does not returntruefor 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,containsreturnsfalsefor that point.- Parameters:
pt- the newPoint2Dto add to thisRectangle2D.- Since:
- 1.2
-
isEmpty
public boolean isEmpty() -
intersects
-
intersects
public boolean intersects(double x, double y, double w, double h) -
intersect
Intersects the pair of specified sourceRectangle2Dobjects and puts the result into the specified destinationRectangle2Dobject. 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 ofRectangle2Dobjects to be intersected with each othersrc2- the second of a pair ofRectangle2Dobjects to be intersected with each otherdest- theRectangle2Dthat holds the results of the intersection ofsrc1andsrc2- Since:
- 1.2
-
contains
Returnstrueif this bounding box containspoint.- Parameters:
point- a point in projection coordinates.- Returns:
trueif this bounding box containspoint.
-
contains
Returnstrueif this bounding box containsrect.- Parameters:
rect- a bounding box in projection coordinates- Returns:
trueif this bounding box containsrect.
-
getLowerRightPoint
Get the Lower Right Point- Returns:
- the Lower Right Point
-
getUpperRightPoint
Get the Upper Left Point (same as getMaxPoint)- Returns:
- the Upper Left Point
-
getLowerLeftPoint
Get the Lower Right Point (same as getMinPoint)- Returns:
- the Lower Right Point
-
getUpperLeftPoint
Get the Upper Left Point- Returns:
- the Upper Left Point
-
getMinPoint
Get the minimum corner of the bounding box.- Returns:
- minimum corner of the bounding box
-
getMaxPoint
Get the maximum corner of the bounding box.- Returns:
- maximum corner of the bounding box
-
toString
Get a String representation of this object. -
toString2
-
setX
Deprecated.use builderset minimum X -
setY
Deprecated.use builderset minimum Y- Parameters:
y- minimum y
-
setWidth
Deprecated.use builderset X width- Parameters:
w- x width
-
setHeight
Deprecated.use builderset Y height- Parameters:
h- Y height
-
setRect
Deprecated.use builder -
setRect
Deprecated.use builder -
equals
-
hashCode
public int hashCode() -
nearlyEquals
Returns the result ofnearlyEquals(ProjectionRect, double), withMisc.defaultMaxRelativeDiffFloat. -
nearlyEquals
Returnstrueif this rectangle is nearly equal toother. The "near equality" of corners is determined usingProjectionPoint.nearlyEquals(ProjectionPoint, double), with the specified maxRelDiff.- Parameters:
other- the other rectangle to check.maxRelDiff- the maximumrelative differencethat two corners may have.- Returns:
trueif this rectangle is nearly equal toother.
-