Package com.luciad.cartesian
Class Rectangle
java.lang.Object
com.luciad.cartesian.Rectangle
A "POD" for a 2D rectangle.
Not a geometry, to be used for communicating 2D cartesian rectangles.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates aRectangleat the origin, with width and height 0.Rectangle(double x, double y, double width, double height) Creates aRectanglewith the provided x, y, width, and height values.Rectangle(Coordinate corner1, Coordinate corner2) Creates aRectanglewith the given corners. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the coordinate in the center of this rectangle.doubleThe rectangle's height.Returns the coordinate at the lower left corner of this rectangle.Returns the coordinate at the lower right corner of this rectangle.Returns the coordinate at the upper left corner of this rectangle.Returns the coordinate at the upper right corner of this rectangle.doublegetWidth()The rectangle's width.doublegetX()The lower left corner's x-ordinate.doublegetY()The lower left corner's y-ordinate.voidgrow(double margin) Grows this rectangle by the given margin.inthashCode()Returns the hash for this rectangle.booleanisValid()Returns whether all fields are neither not-a-number nor infinite and the width and height are non-negative.toString()
-
Constructor Details
-
Rectangle
public Rectangle()Creates aRectangleat the origin, with width and height 0. -
Rectangle
public Rectangle(double x, double y, double width, double height) Creates aRectanglewith the provided x, y, width, and height values.- Parameters:
x- the lower left corner's x-ordinatey- the lower left corner's y-ordinatewidth- the rectangle's widthheight- the rectangle's height
-
Rectangle
Creates aRectanglewith the given corners.The corners do not need to have any particular relation to each other. Only the x and y ordinates of the corners are considered.
- Parameters:
corner1- one corner positioncorner2- another corner position
-
Rectangle
-
-
Method Details
-
grow
public void grow(double margin) Grows this rectangle by the given margin.The lower left corner is moved in the direction of negative x and y by margin. The upper right corner is moved in the direction of positive x and y by margin.
- Parameters:
margin- a margin
-
getX
public double getX()The lower left corner's x-ordinate. -
getY
public double getY()The lower left corner's y-ordinate. -
getWidth
public double getWidth()The rectangle's width. -
getHeight
public double getHeight()The rectangle's height. -
getLowerLeftCorner
Returns the coordinate at the lower left corner of this rectangle.- Returns:
- the coordinate at the lower left corner of this rectangle.
-
getLowerRightCorner
Returns the coordinate at the lower right corner of this rectangle.- Returns:
- the coordinate at the lower right corner of this rectangle.
-
getUpperLeftCorner
Returns the coordinate at the upper left corner of this rectangle.- Returns:
- the coordinate at the upper left corner of this rectangle.
-
getUpperRightCorner
Returns the coordinate at the upper right corner of this rectangle.- Returns:
- the coordinate at the upper right corner of this rectangle.
-
getCenter
Returns the coordinate in the center of this rectangle.- Returns:
- the coordinate in the center of this rectangle.
-
isValid
public boolean isValid()Returns whether all fields are neither not-a-number nor infinite and the width and height are non-negative.- Returns:
- whether all fields are neither not-a-number nor infinite and the width and height are non-negative.
-
equals
-
hashCode
public int hashCode()Returns the hash for this rectangle. -
toString
-