public class XyBounds extends java.lang.Object implements XyArea<XyBounds>
While a rectangular shape may serve these purposes just as well, having a purpose-specific class does improve code semantics. With that in mind, this class intentionally does not currently implement Shape - however I am considering the pros and cons of that decision.
Copyright 2007 Partner Software, Inc.
| Constructor and Description |
|---|
XyBounds(double[] coords,
int start,
int end) |
XyBounds(DoubleBuffer coords) |
XyBounds(double x,
double y)
Creates a degenerate bounds containing a single point.
|
XyBounds(double x1,
double y1,
double... additionalCoords)
Creates a bounds from the given x1 and y1 plus additional coordinate
pairs.
|
XyBounds(DynamicDoubleArray coords) |
XyBounds(java.lang.Iterable<XyPoint> points)
Creates a bounds containing the given points.
|
XyBounds(XyPoint... points)
Creates a bounds containing the given points.
|
XyBounds(XyPoint point)
Creates a degenerate bounds containing a single XyPoint.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(double x,
double y)
Returns true if the given point's are greater than or equal to the
minimums and less than (but not equal to) the maximums.
|
boolean |
contains(XyBounds bounds)
Returns true if the given bounds is equal to or inside this one.
|
boolean |
contains(XyPoint point)
Returns true if the given point's are greater than or equal to the
minimums and less than (but not equal to) the maximums.
|
boolean |
equals(java.lang.Object nother) |
double |
getArea()
Returns the 2-dimensional area covered by this...
|
XyBounds |
getBounds()
Returns an XyBounds object representing the rectangular extents of this
shape.
|
XyPoint |
getCenter()
The center point.
|
double |
getHeight()
Height of these bounds.
|
XyPoint |
getMaximumPoint()
Returns a point with both maximum x and y; this is the same as
getNeCorner().
|
double |
getMaximumX() |
double |
getMaximumY() |
XyPoint |
getMinimumPoint()
Returns a point with both minimum x and y; this is the same as
getSwCorner().
|
double |
getMinimumX() |
double |
getMinimumY() |
XyPoint |
getNeCorner()
The top-right, or "northeast", corner, consisting of maximum x and
maximum y.
|
XyPoint |
getNwCorner()
The top-left, or "northwest", corner, consisting of minimum x and maximum
y.
|
double |
getPerimeter()
Returns the total length of the lines and/or curves bounding the area.
|
XyPoint |
getSeCorner()
The bottom-right, or "southeast", corner, consisting of maximum x and
minimum y.
|
XyPoint |
getSwCorner()
The bottom-left, or "southwest", corner, consisting of minimum x and
minimum y.
|
double |
getWidth()
Width of these bounds.
|
XyBounds |
intersectionWith(XyBounds nother)
Returns the intersection of this bounds with the given bounds.
|
boolean |
intersects(XyBounds nother)
Returns true if this bounds intersects the one given.
|
java.util.Iterator<XyPoint> |
iterator() |
XyBounds |
scaledBy(double factor)
Return a scaled version of the shape by multiplying all coordinates by
the given factor in both dimensions.
|
XyBounds |
stretchedToInclude(double x,
double y)
Returns a new XyBounds that is expanded to include the given point.
|
XyBounds |
stretchedToInclude(XyBounds nother)
Returns a new XyBounds that is expanded to include the given bounds.
|
XyBounds |
stretchedToInclude(XyPoint point)
Returns a new XyBounds that is expanded to include the given point.
|
XyPolygon |
toPolygon()
Same as
XyArea.toPolygon(XyAngle) with a default angle granularity of
1/60 circle (1 degree, pi/30 radians). |
XyPolygon |
toPolygon(XyAngle granularity)
Converts this area to a polygon which approximates it in some fashion.
|
XyRectangle |
toRectangle()
Returns an XyRectangle covering the same area as these bounds.
|
java.lang.String |
toString() |
XyShape |
transformedBy(XyTransform transform)
Transform the shape using the given transform.
|
XyBounds |
translatedBy(double offsetX,
double offsetY)
Translate the shape by adding all coordinates to the given x and y
offsets.
|
XyBounds |
unionWith(XyBounds nother)
Returns the union of this bounds with the given bounds.
|
XyBounds |
withMaxima(double newMaximumX,
double newMaximumY)
Returns a modified version of this bounds with the given maxima.
|
XyBounds |
withMaxima(XyPoint newMaxima)
Returns a modified version of this bounds with the given maxima.
|
XyBounds |
withMaximumX(double newMaximumX)
Returns a modified version of this bounds with the given maximumX.
|
XyBounds |
withMaximumY(double newMaximumY)
Returns a modified version of this bounds with the given maximumY.
|
XyBounds |
withMinima(double newMinimumX,
double newMinimumY)
Returns a modified version of this bounds with the given minima.
|
XyBounds |
withMinima(XyPoint newMinima)
Returns a modified version of this bounds with the given minima.
|
XyBounds |
withMinimumX(double newMinimumX)
Returns a modified version of this bounds with the given minimumX.
|
XyBounds |
withMinimumY(double newMinimumY)
Returns a modified version of this bounds with the given minimumY.
|
public XyBounds(double x,
double y)
public XyBounds(double x1,
double y1,
double... additionalCoords)
public XyBounds(XyPoint point)
public XyBounds(XyPoint... points)
public XyBounds(java.lang.Iterable<XyPoint> points)
public XyBounds(double[] coords,
int start,
int end)
public XyBounds(DoubleBuffer coords)
public XyBounds(DynamicDoubleArray coords)
public XyBounds withMinimumX(double newMinimumX)
public XyBounds withMinimumY(double newMinimumY)
public XyBounds withMaximumX(double newMaximumX)
public XyBounds withMaximumY(double newMaximumY)
public XyBounds withMinima(double newMinimumX, double newMinimumY)
public XyBounds withMaxima(double newMaximumX, double newMaximumY)
public XyBounds withMinima(XyPoint newMinima)
public XyBounds withMaxima(XyPoint newMaxima)
public XyBounds stretchedToInclude(double x, double y)
public XyBounds stretchedToInclude(XyPoint point)
public XyBounds stretchedToInclude(XyBounds nother)
nother - other bounds to include.public boolean contains(XyPoint point)
public boolean contains(double x,
double y)
public boolean contains(XyBounds bounds)
public boolean intersects(XyBounds nother)
public XyBounds intersectionWith(XyBounds nother)
public XyBounds unionWith(XyBounds nother)
public XyRectangle toRectangle()
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object nother)
equals in class java.lang.Objectpublic double getMinimumX()
public double getMinimumY()
public double getMaximumX()
public double getMaximumY()
public XyPoint getMinimumPoint()
public XyPoint getMaximumPoint()
public XyPoint getNwCorner()
public XyPoint getSwCorner()
public XyPoint getNeCorner()
public XyPoint getSeCorner()
public XyPoint getCenter()
public double getWidth()
public double getHeight()
public XyBounds getBounds()
XyShapepublic XyShape transformedBy(XyTransform transform)
XyShapetransformedBy in interface XyShape<XyBounds>transform - affine transform to apply.public java.util.Iterator<XyPoint> iterator()
iterator in interface java.lang.Iterable<XyPoint>public XyBounds scaledBy(double factor)
XyShapepublic XyBounds translatedBy(double offsetX, double offsetY)
XyShapetranslatedBy in interface XyShape<XyBounds>offsetX - offset for the x dimensionoffsetY - offset for the y dimensionpublic double getArea()
XyAreapublic double getPerimeter()
XyAreagetPerimeter in interface XyArea<XyBounds>public XyPolygon toPolygon()
XyAreaXyArea.toPolygon(XyAngle) with a default angle granularity of
1/60 circle (1 degree, pi/30 radians).public XyPolygon toPolygon(XyAngle granularity)
XyAreaThe angle parameter allows a certain level of control of the output. Essentially it dictates the minimum angular granularity used to approximate curved paths. For example, a circle would be turned into a polygon by placing points around the circle, separated by the given angle.