Package org.apache.sis.geometry
Class Shapes2D
Utility methods working on Java2D shapes.
The
transform(…)
methods in this class work in the same way than the methods of the same signature
in Envelopes
, except that they work on Rectangle2D
objects instead of Envelope
.
In particular, the same treatment for curvatures and poles is applied. Since:
 0.8
Defined in the sisreferencing
module

Method Summary
Modifier and TypeMethodDescriptionstatic Ellipse2D
Returns a circle passing by the 3 given points.static Point2D
colinearPoint
(Line2D line, Point2D point, double distance) Returns a point on the givenline
segment located at the givendistance
from that line.static Point2D
intersectionPoint
(Line2D a, Line2D b) Returns the intersection point between two line segments.static Point2D
nearestColinearPoint
(Line2D segment, Point2D point) Returns the point on the givenline
segment which is closest to the givenpoint
.static Rectangle2D
transform
(CoordinateOperation operation, Rectangle2D envelope, Rectangle2D destination) Transforms a rectangular envelope using the given coordinate operation.static Rectangle2D
transform
(MathTransform2D transform, Rectangle2D envelope, Rectangle2D destination) Transforms a rectangular envelope using the given math transform.

Method Details

intersectionPoint
Returns the intersection point between two line segments. The lines do not continue to infinity; if the intersection does not occur between the ending points P1 and P2 of the two line segments, then this method returnsnull
. Parameters:
a
 the first line segment.b
 the second line segment. Returns:
 the intersection point, or
null
if none.

nearestColinearPoint
Returns the point on the givenline
segment which is closest to the givenpoint
. Letresult
be the returned point. This method guarantees (except for rounding errors) that:result
is a point on theline
segment. It is located between the P1 and P2 ending points of that line segment. The distance between the
result
point and the givenpoint
is the shortest distance among the set of points meeting the previous condition. This distance can be obtained withpoint.distance(result)
.
 Parameters:
segment
 the line on which to search for a point.point
 a point close to the given line. Returns:
 the nearest point on the given line.
 See Also:

colinearPoint
Returns a point on the givenline
segment located at the givendistance
from that line. Letresult
be the returned point. Ifresult
is not null, then this method guarantees (except for rounding error) that:result
is a point on theline
segment. It is located between the P1 and P2 ending points of that line segment. The distance between the
result
and the givenpoint
is exactly equal todistance
.
null
. If two result points met those conditions, then this method returns the point which is the closest toline.getP1()
. Parameters:
line
 the line on which to search for a point.point
 a point close to the given line.distance
 the distance between the given point and the point to be returned. Returns:
 a point on the given line located at the given distance from the given point.
 See Also:

circle
Returns a circle passing by the 3 given points. Parameters:
P1
 the first point.P2
 the second point.P3
 the third point. Returns:
 a circle passing by the given points.

transform
public static Rectangle2D transform(MathTransform2D transform, Rectangle2D envelope, Rectangle2D destination) throws TransformException Transforms a rectangular envelope using the given math transform. The transformation is only approximated: the returned envelope may be bigger than necessary, or smaller than required if the bounding box contains a pole.Note that this method can not handle the case where the rectangle contains the North or South pole, or when it cross the ±180° longitude, because
MathTransform
does not carry sufficient information. For a more robust rectangle transformation, usetransform(CoordinateOperation, Rectangle2D, Rectangle2D)
instead. Parameters:
transform
 the transform to use. Source and target dimension must be 2.envelope
 the rectangle to transform (may benull
).destination
 the destination rectangle (may beenvelope
). Ifnull
, a new rectangle will be created and returned. Returns:
destination
, or a new rectangle ifdestination
was null andenvelope
was nonnull. Throws:
TransformException
 if a transform failed. See Also:

transform
public static Rectangle2D transform(CoordinateOperation operation, Rectangle2D envelope, Rectangle2D destination) throws TransformException Transforms a rectangular envelope using the given coordinate operation. The transformation is only approximated: the returned envelope may be bigger than the smallest possible bounding box, but should not be smaller in most cases.This method can handle the case where the rectangle contains the North or South pole, or when it cross the ±180° longitude.
 Parameters:
operation
 the operation to use. Source and target dimension must be 2.envelope
 the rectangle to transform (may benull
).destination
 the destination rectangle (may beenvelope
). Ifnull
, a new rectangle will be created and returned. Returns:
destination
, or a new rectangle ifdestination
was null andenvelope
was nonnull. Throws:
TransformException
 if a transform failed. See Also:
