public class Region extends java.lang.Object implements ITranslatable<Region>, IScalable<Region>, IRotatable<Ring>
Rectangle
s. The Rectangle
s that build up a
Region
do not have to be touching. The area covered by the
Region
is exactly the area that all of its corresponding
Rectangle
s are covering.
A Region
differentiates between the internal Rectangle
s and
the external Rectangle
s. The external Rectangle
s are those
that you feed it, in order to construct the Region
. The internal
Rectangle
s are those used for computations of the Region
.
They are defined to not share any area, so that only their borders can be
overlapping.Constructor and Description |
---|
Region()
Constructs a new
Region not covering any area. |
Region(Rectangle... rectangles)
|
Region(Region other)
|
Modifier and Type | Method and Description |
---|---|
Region |
add(Rectangle rectangle)
|
java.lang.Object |
clone()
Overridden with public visibility as recommended within
Cloneable
. |
boolean |
contains(IGeometry g)
Checks if the given
IGeometry is fully contained by this
IMultiShape . |
boolean |
contains(Point p)
|
boolean |
equals(java.lang.Object obj) |
protected Line[] |
getAllEdges()
Collects all outline segments of the internal
Rectangle s. |
Rectangle |
getBounds()
|
Region |
getCopy()
Returns a new identical copy of this
IGeometry . |
Point[] |
getOutlineIntersections(ICurve c)
|
Polyline[] |
getOutlines()
Computes the outlines of this
IMultiShape . |
Line[] |
getOutlineSegments()
Computes the outline segments of this
AbstractMultiShape . |
Ring |
getRotatedCCW(Angle angle)
|
Ring |
getRotatedCCW(Angle angle,
double cx,
double cy)
|
Ring |
getRotatedCCW(Angle angle,
Point center)
|
Ring |
getRotatedCW(Angle angle)
|
Ring |
getRotatedCW(Angle angle,
double cx,
double cy)
|
Ring |
getRotatedCW(Angle angle,
Point center)
|
Region |
getScaled(double factor)
Scales a copy of the calling object by the given factor relative to its
center
Point . |
Region |
getScaled(double fx,
double fy)
Scales a copy of the calling object by the given factors relative to its
center
Point . |
Region |
getScaled(double factor,
double cx,
double cy)
Scales a copy of the calling object by the given factor relative to the
given center
Point (cx, cy). |
Region |
getScaled(double fx,
double fy,
double cx,
double cy)
Scales a copy of the calling object by the given factors relative to the
given center
Point (cx, cy). |
Region |
getScaled(double fx,
double fy,
Point center)
Scales a copy of the calling object by the given factors relative to the
given center
Point . |
Region |
getScaled(double factor,
Point center)
Scales a copy of the calling object by the given factor relative to the
given center
Point . |
Rectangle[] |
getShapes()
Returns the
IShape s that constitute this IMultiShape . |
Ring |
getTransformed(AffineTransform t)
|
Region |
getTranslated(double dx,
double dy)
Translates a copy of this object by the given values in x and y
direction.
|
Region |
getTranslated(Point d)
Translates a copy of this object by the given
Point . |
int |
hashCode() |
Region |
scale(double factor)
Scales the calling object by the given factor relative to its center
Point . |
Region |
scale(double fx,
double fy)
Scales the calling object by the given factors relative to the given
center
Point . |
Region |
scale(double factor,
double cx,
double cy)
Scales the calling object by the given factor relative to the given
center
Point (cx, cy). |
Region |
scale(double fx,
double fy,
double cx,
double cy)
Scales the calling object by the given factors relative to the given
center
Point (cx, cy). |
Region |
scale(double fx,
double fy,
Point center)
Scales the calling object by the given factors relative to the given
center
Point . |
Region |
scale(double factor,
Point center)
Scales the calling object by the given factor relative to the given
center
Point . |
Path |
toPath()
|
Ring |
toRing()
|
boolean |
touches(IGeometry g)
|
Region |
translate(double dx,
double dy)
Translates the object by the given values in x and y direction.
|
Region |
translate(Point d)
Translates the object by the given
Point . |
public Region()
Region
not covering any area.public Region(Rectangle... rectangles)
Region
from the given list of Rectangle
s.
The given Rectangle
s are add(Rectangle)
ed to the
Region
one after the other.public boolean contains(IGeometry g)
IMultiShape
IGeometry
is fully contained by this
IMultiShape
.contains
in interface IMultiShape
g
- The IGeometry
which is tested for containment.true
if the IGeometry
is contained by this
IMultiShape
, otherwise false
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
protected Line[] getAllEdges()
Rectangle
s.Rectangle
spublic Region getCopy()
IGeometry
IGeometry
.public Ring getRotatedCCW(Angle angle)
IRotatable
Angle
counter-clock-wise
(CCW) around its center Point
. Does not necessarily return an
object of the same type.getRotatedCCW
in interface IRotatable<Ring>
angle
- rotation Angle
IGeometry
representing the result of the rotationpublic Ring getRotatedCCW(Angle angle, double cx, double cy)
IRotatable
Angle
counter-clock-wise (CCW) around the specified center Point
(cx,
cy). Does not necessarily return an object of the same type.getRotatedCCW
in interface IRotatable<Ring>
angle
- rotation Angle
cx
- x-coordinate of the relative Point
for the rotationcy
- y-coordinate of the relative Point
for the rotationIGeometry
representing the result of the rotationpublic Ring getRotatedCCW(Angle angle, Point center)
IRotatable
Angle
counter-clock-wise (CCW) around the specified center Point
. Does
not necessarily return an object of the same type.getRotatedCCW
in interface IRotatable<Ring>
angle
- rotation Angle
center
- relative Point
for the rotationIGeometry
representing the result of the rotationpublic Ring getRotatedCW(Angle angle)
IRotatable
Angle
clock-wise (CW)
around its center Point
. Does not necessarily return an object of
the same type.getRotatedCW
in interface IRotatable<Ring>
angle
- rotation Angle
IGeometry
representing the result of the rotationpublic Ring getRotatedCW(Angle angle, double cx, double cy)
IRotatable
Angle
clock-wise (CW)
around the specified center Point
(cx, cy). Does not necessarily
return an object of the same type.getRotatedCW
in interface IRotatable<Ring>
angle
- rotation Angle
cx
- x-coordinate of the relative Point
for the rotationcy
- y-coordinate of the relative Point
for the rotationIGeometry
representing the result of the rotationpublic Ring getRotatedCW(Angle angle, Point center)
IRotatable
Angle
clock-wise (CW)
around the specified center Point
. Does not necessarily return an
object of the same type.getRotatedCW
in interface IRotatable<Ring>
angle
- rotation Angle
center
- relative Point
for the rotationIGeometry
representing the result of the rotationpublic Region getScaled(double factor)
IScalable
Point
.public Region getScaled(double fx, double fy)
IScalable
Point
.public Region getScaled(double factor, double cx, double cy)
IScalable
Point
(cx, cy).public Region getScaled(double fx, double fy, double cx, double cy)
IScalable
Point
(cx, cy).public Region getScaled(double fx, double fy, Point center)
IScalable
Point
.public Region getScaled(double factor, Point center)
IScalable
Point
.public Rectangle[] getShapes()
IMultiShape
IShape
s that constitute this IMultiShape
.getShapes
in interface IMultiShape
IShape
s, representing the parts that make up
this IMultiShape
.public Ring getTransformed(AffineTransform t)
Path
representation of this IGeometry
. Subclasses may override this
method to return a more specific representation.getTransformed
in interface IGeometry
t
- The AffineTransform
to be appliedPath
representation of this
IGeometry
public Region getTranslated(double dx, double dy)
ITranslatable
getTranslated
in interface ITranslatable<Region>
dx
- x-translationdy
- y-translationpublic Region getTranslated(Point d)
ITranslatable
Point
.getTranslated
in interface ITranslatable<Region>
d
- translation Point
public Region scale(double factor)
IScalable
Point
.public Region scale(double fx, double fy)
IScalable
Point
.public Region scale(double factor, double cx, double cy)
IScalable
Point
(cx, cy).public Region scale(double fx, double fy, double cx, double cy)
IScalable
Point
(cx, cy).public Region scale(double fx, double fy, Point center)
IScalable
Point
.public Region scale(double factor, Point center)
IScalable
Point
.public Region translate(double dx, double dy)
ITranslatable
translate
in interface ITranslatable<Region>
dx
- x-translationdy
- y-translationthis
for conveniencepublic Region translate(Point d)
ITranslatable
Point
.translate
in interface ITranslatable<Region>
d
- translation Point
this
for conveniencepublic Polyline[] getOutlines()
IMultiShape
Computes the outlines of this IMultiShape
.
The outlines are returned as an array of ICurve
s. For every
closed outline of this IMultiShape
one ICurve
is
returned.
getOutlines
in interface IMultiShape
ICurve
s, one for each closed outlinepublic Line[] getOutlineSegments()
Computes the outline segments of this AbstractMultiShape
.
The outline segments of this AbstractMultiShape
are those outline
segments of the internal IShape
s that only exist once.
getOutlineSegments
in interface IMultiShape
AbstractMultiShape
public java.lang.Object clone()
Cloneable
.clone
in class java.lang.Object
public final int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
Copyright (c) 2014 itemis AG, and others. All rights reserved.