Package ca.spatial.table
Class Extent2D
java.lang.Object
java.awt.geom.RectangularShape
java.awt.geom.Rectangle2D
java.awt.geom.Rectangle2D.Double
ca.spatial.table.Extent2D
- All Implemented Interfaces:
Shape
,Serializable
,Cloneable
,Comparable
A class to perform operations on enclosing rectangles
- Author:
- Carey Lockwood, Tom Moore Modified, methods added and commented by Tom Moore
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class java.awt.geom.Rectangle2D
Rectangle2D.Double, Rectangle2D.Float
-
Field Summary
Fields inherited from class java.awt.geom.Rectangle2D.Double
height, width, x, y
Fields inherited from class java.awt.geom.Rectangle2D
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP
-
Constructor Summary
ConstructorsConstructorDescriptionExtent2D()
Extent2D(double x, double y, double w, double h)
Extent2D(Rectangle2D r)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
adjustAspect(Extent2D target)
Expand the source extent to the aspect ratio of target.bottom()
Return a new extent that covers the bottom half of this extentint
Define the sorted order of Extent2D objects to be top-to-bottom, left-to-right.double
Return the minimum distance between the two extents.left()
Return a new extent that covers the left half of this extentboolean
void
recenter(double xcen, double ycen)
Recenter the extent at the specified pointright()
Return a new extent that covers the right half of this extentround(double roundOff)
Create an extent that is enlarged so that the corners of the current extent are rounded to the specified roundOff value.snap(double xOffset, double yOffset, double roundOff)
Create an extent that is snapped so that the corners of the current extent are aligned to the specified offset values.Create an extent that is snapped so that the corners of the current extent are aligned to the corners of the specified extent.top()
Return a new extent that covers the top half of this extenttoString()
void
translate(double xdel, double ydel)
Translate the extent by the specified distancevoid
zoom(double factor)
Expand or contract the extent by the specified factorMethods inherited from class java.awt.geom.Rectangle2D.Double
createIntersection, createUnion, getBounds2D, getHeight, getWidth, getX, getY, isEmpty, outcode, setRect, setRect
Methods inherited from class java.awt.geom.Rectangle2D
add, add, add, contains, contains, equals, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, union
Methods inherited from class java.awt.geom.RectangularShape
clone, contains, contains, getBounds, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
-
Constructor Details
-
Extent2D
public Extent2D() -
Extent2D
-
Extent2D
public Extent2D(double x, double y, double w, double h)
-
-
Method Details
-
adjustAspect
Expand the source extent to the aspect ratio of target.- Parameters:
target
- The extent with the desired aspect ratio.
-
zoom
public void zoom(double factor)Expand or contract the extent by the specified factor- Parameters:
factor
- If less than 1 the extent will shrink, if greater than 1 the extent will grow.
-
recenter
public void recenter(double xcen, double ycen)Recenter the extent at the specified point -
translate
public void translate(double xdel, double ydel)Translate the extent by the specified distance -
left
Return a new extent that covers the left half of this extent -
right
Return a new extent that covers the right half of this extent -
top
Return a new extent that covers the top half of this extent -
bottom
Return a new extent that covers the bottom half of this extent -
overlaps
-
round
Create an extent that is enlarged so that the corners of the current extent are rounded to the specified roundOff value. The left and bottom will be reduced to the next lowest even multiple of the roundOff value. The right and top values will be increased to the next even multiple of the roundOff value.- Parameters:
roundOff
- The value that the corners of the new extent will be 'snapped' to.
-
snap
Create an extent that is snapped so that the corners of the current extent are aligned to the corners of the specified extent. The left and bottom will be reduced to the next lowest even multiple of the adjustment value. The right and top values will be increased to the next higher even multiple of the adjustment value.- Parameters:
ext
- An extent that the current extent will be snapped to.roundOff
- The modulus value that will be used to find the closest adjustment.
-
snap
Create an extent that is snapped so that the corners of the current extent are aligned to the specified offset values. The left and bottom will be reduced to the next lowest even multiple of the adjustment value. The right and top values will be increased to the next higher even multiple of the adjustment value.- Parameters:
xOffset
- The x snapping adjustment value.yOffset
- The y snapping adjustment value.roundOff
- The modulus value that will be used to find the closest adjustment.
-
toString
- Overrides:
toString
in classRectangle2D.Double
-
compareTo
Define the sorted order of Extent2D objects to be top-to-bottom, left-to-right.- Specified by:
compareTo
in interfaceComparable
-
distance
Return the minimum distance between the two extents. If the extents overlap then return 0;
-