Package org.eclipse.gef.geometry.planar
Class Region
- java.lang.Object
-
- org.eclipse.gef.geometry.planar.Region
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,IGeometry
,IMultiShape
,IRotatable<Ring>
,IScalable<Region>
,ITranslatable<Region>
public class Region extends java.lang.Object implements ITranslatable<Region>, IScalable<Region>, IRotatable<Ring>
A combination ofRectangle
s. TheRectangle
s that build up aRegion
do not have to be touching. The area covered by theRegion
is exactly the area that all of its correspondingRectangle
s are covering. ARegion
differentiates between the internalRectangle
s and the externalRectangle
s. The externalRectangle
s are those that you feed it, in order to construct theRegion
. The internalRectangle
s are those used for computations of theRegion
. They are defined to not share any area, so that only their borders can be overlapping.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Region
add(Rectangle rectangle)
java.lang.Object
clone()
Overridden with public visibility as recommended withinCloneable
.boolean
contains(IGeometry g)
Checks if the givenIGeometry
is fully contained by thisIMultiShape
.boolean
contains(Point p)
boolean
equals(java.lang.Object obj)
protected Line[]
getAllEdges()
Collects all outline segments of the internalRectangle
s.Rectangle
getBounds()
Region
getCopy()
Returns a new identical copy of thisIGeometry
.Point[]
getOutlineIntersections(ICurve c)
Polyline[]
getOutlines()
Computes the outlines of thisIMultiShape
.Line[]
getOutlineSegments()
Computes the outline segments of thisAbstractMultiShape
.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 centerPoint
.Region
getScaled(double fx, double fy)
Scales a copy of the calling object by the given factors relative to its centerPoint
.Region
getScaled(double factor, double cx, double cy)
Scales a copy of the calling object by the given factor relative to the given centerPoint
(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 centerPoint
(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 centerPoint
.Region
getScaled(double factor, Point center)
Scales a copy of the calling object by the given factor relative to the given centerPoint
.Rectangle[]
getShapes()
Returns theIShape
s that constitute thisIMultiShape
.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 givenPoint
.int
hashCode()
Region
scale(double factor)
Scales the calling object by the given factor relative to its centerPoint
.Region
scale(double fx, double fy)
Scales the calling object by the given factors relative to the given centerPoint
.Region
scale(double factor, double cx, double cy)
Scales the calling object by the given factor relative to the given centerPoint
(cx, cy).Region
scale(double fx, double fy, double cx, double cy)
Scales the calling object by the given factors relative to the given centerPoint
(cx, cy).Region
scale(double fx, double fy, Point center)
Scales the calling object by the given factors relative to the given centerPoint
.Region
scale(double factor, Point center)
Scales the calling object by the given factor relative to the given centerPoint
.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 givenPoint
.
-
-
-
Method Detail
-
contains
public boolean contains(IGeometry g)
Description copied from interface:IMultiShape
Checks if the givenIGeometry
is fully contained by thisIMultiShape
.- Specified by:
contains
in interfaceIMultiShape
- Parameters:
g
- TheIGeometry
which is tested for containment.- Returns:
true
if theIGeometry
is contained by thisIMultiShape
, otherwisefalse
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
getAllEdges
protected Line[] getAllEdges()
Collects all outline segments of the internalRectangle
s.- Returns:
- all the outline segments of the internal
Rectangle
s
-
getCopy
public Region getCopy()
Description copied from interface:IGeometry
Returns a new identical copy of thisIGeometry
.
-
getRotatedCCW
public Ring getRotatedCCW(Angle angle)
Description copied from interface:IRotatable
Rotates the calling object by specifiedAngle
counter-clock-wise (CCW) around its centerPoint
. Does not necessarily return an object of the same type.- Specified by:
getRotatedCCW
in interfaceIRotatable<Ring>
- Parameters:
angle
- rotationAngle
- Returns:
- an
IGeometry
representing the result of the rotation
-
getRotatedCCW
public Ring getRotatedCCW(Angle angle, double cx, double cy)
Description copied from interface:IRotatable
Rotates the calling object by the specifiedAngle
counter-clock-wise (CCW) around the specified centerPoint
(cx, cy). Does not necessarily return an object of the same type.- Specified by:
getRotatedCCW
in interfaceIRotatable<Ring>
- Parameters:
angle
- rotationAngle
cx
- x-coordinate of the relativePoint
for the rotationcy
- y-coordinate of the relativePoint
for the rotation- Returns:
- an
IGeometry
representing the result of the rotation
-
getRotatedCCW
public Ring getRotatedCCW(Angle angle, Point center)
Description copied from interface:IRotatable
Rotates the calling object by the specifiedAngle
counter-clock-wise (CCW) around the specified centerPoint
. Does not necessarily return an object of the same type.- Specified by:
getRotatedCCW
in interfaceIRotatable<Ring>
- Parameters:
angle
- rotationAngle
center
- relativePoint
for the rotation- Returns:
- an
IGeometry
representing the result of the rotation
-
getRotatedCW
public Ring getRotatedCW(Angle angle)
Description copied from interface:IRotatable
Rotates the calling object by specifiedAngle
clock-wise (CW) around its centerPoint
. Does not necessarily return an object of the same type.- Specified by:
getRotatedCW
in interfaceIRotatable<Ring>
- Parameters:
angle
- rotationAngle
- Returns:
- an
IGeometry
representing the result of the rotation
-
getRotatedCW
public Ring getRotatedCW(Angle angle, double cx, double cy)
Description copied from interface:IRotatable
Rotates the calling object by the specifiedAngle
clock-wise (CW) around the specified centerPoint
(cx, cy). Does not necessarily return an object of the same type.- Specified by:
getRotatedCW
in interfaceIRotatable<Ring>
- Parameters:
angle
- rotationAngle
cx
- x-coordinate of the relativePoint
for the rotationcy
- y-coordinate of the relativePoint
for the rotation- Returns:
- an
IGeometry
representing the result of the rotation
-
getRotatedCW
public Ring getRotatedCW(Angle angle, Point center)
Description copied from interface:IRotatable
Rotates the calling object by the specifiedAngle
clock-wise (CW) around the specified centerPoint
. Does not necessarily return an object of the same type.- Specified by:
getRotatedCW
in interfaceIRotatable<Ring>
- Parameters:
angle
- rotationAngle
center
- relativePoint
for the rotation- Returns:
- an
IGeometry
representing the result of the rotation
-
getScaled
public Region getScaled(double factor)
Description copied from interface:IScalable
Scales a copy of the calling object by the given factor relative to its centerPoint
.
-
getScaled
public Region getScaled(double fx, double fy)
Description copied from interface:IScalable
Scales a copy of the calling object by the given factors relative to its centerPoint
.
-
getScaled
public Region getScaled(double factor, double cx, double cy)
Description copied from interface:IScalable
Scales a copy of the calling object by the given factor relative to the given centerPoint
(cx, cy).
-
getScaled
public Region getScaled(double fx, double fy, double cx, double cy)
Description copied from interface:IScalable
Scales a copy of the calling object by the given factors relative to the given centerPoint
(cx, cy).
-
getScaled
public Region getScaled(double fx, double fy, Point center)
Description copied from interface:IScalable
Scales a copy of the calling object by the given factors relative to the given centerPoint
.
-
getScaled
public Region getScaled(double factor, Point center)
Description copied from interface:IScalable
Scales a copy of the calling object by the given factor relative to the given centerPoint
.
-
getShapes
public Rectangle[] getShapes()
Description copied from interface:IMultiShape
Returns theIShape
s that constitute thisIMultiShape
.- Specified by:
getShapes
in interfaceIMultiShape
- Returns:
- an array of
IShape
s, representing the parts that make up thisIMultiShape
.
-
getTransformed
public Ring getTransformed(AffineTransform t)
Default implementation returning a transformedPath
representation of thisIGeometry
. Subclasses may override this method to return a more specific representation.- Specified by:
getTransformed
in interfaceIGeometry
- Parameters:
t
- TheAffineTransform
to be applied- Returns:
- a transformed
Path
representation of thisIGeometry
-
getTranslated
public Region getTranslated(double dx, double dy)
Description copied from interface:ITranslatable
Translates a copy of this object by the given values in x and y direction.- Specified by:
getTranslated
in interfaceITranslatable<Region>
- Parameters:
dx
- x-translationdy
- y-translation- Returns:
- a new, translated object
-
getTranslated
public Region getTranslated(Point d)
Description copied from interface:ITranslatable
Translates a copy of this object by the givenPoint
.- Specified by:
getTranslated
in interfaceITranslatable<Region>
- Parameters:
d
- translationPoint
- Returns:
- a new, translated object
-
scale
public Region scale(double factor)
Description copied from interface:IScalable
Scales the calling object by the given factor relative to its centerPoint
.
-
scale
public Region scale(double fx, double fy)
Description copied from interface:IScalable
Scales the calling object by the given factors relative to the given centerPoint
.
-
scale
public Region scale(double factor, double cx, double cy)
Description copied from interface:IScalable
Scales the calling object by the given factor relative to the given centerPoint
(cx, cy).
-
scale
public Region scale(double fx, double fy, double cx, double cy)
Description copied from interface:IScalable
Scales the calling object by the given factors relative to the given centerPoint
(cx, cy).
-
scale
public Region scale(double fx, double fy, Point center)
Description copied from interface:IScalable
Scales the calling object by the given factors relative to the given centerPoint
.
-
scale
public Region scale(double factor, Point center)
Description copied from interface:IScalable
Scales the calling object by the given factor relative to the given centerPoint
.
-
translate
public Region translate(double dx, double dy)
Description copied from interface:ITranslatable
Translates the object by the given values in x and y direction.- Specified by:
translate
in interfaceITranslatable<Region>
- Parameters:
dx
- x-translationdy
- y-translation- Returns:
this
for convenience
-
translate
public Region translate(Point d)
Description copied from interface:ITranslatable
Translates the object by the givenPoint
.- Specified by:
translate
in interfaceITranslatable<Region>
- Parameters:
d
- translationPoint
- Returns:
this
for convenience
-
getOutlines
public Polyline[] getOutlines()
Description copied from interface:IMultiShape
Computes the outlines of this
IMultiShape
.The outlines are returned as an array of
ICurve
s. For every closed outline of thisIMultiShape
oneICurve
is returned.- Specified by:
getOutlines
in interfaceIMultiShape
- Returns:
- an array of
ICurve
s, one for each closed outline
-
getOutlineSegments
public Line[] getOutlineSegments()
Computes the outline segments of this
AbstractMultiShape
.The outline segments of this
AbstractMultiShape
are those outline segments of the internalIShape
s that only exist once.- Specified by:
getOutlineSegments
in interfaceIMultiShape
- Returns:
- the outline segments of this
AbstractMultiShape
-
clone
public java.lang.Object clone()
Overridden with public visibility as recommended withinCloneable
.- Overrides:
clone
in classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
-