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 of `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.

See Also:
  Serialized Form

### Constructor Summary

Constructors
`Region()` Constructs a new `Region` not covering any area.
`Region​(Rectangle... rectangles)` Constructs a new `Region` from the given list of `Rectangle` s.
`Region​(Region other)` Constructs a new `Region` from the given other `Region`.

### Method Summary

All Methods Instance Methods Concrete Methods
`Region` `add​(Rectangle rectangle)` Adds the given `Rectangle` to this `Region`.
`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)` Returns whether the given `Point` is contained within this `IGeometry`.
`boolean` `equals​(java.lang.Object obj)`
`protected Line[]` `getAllEdges()` Collects all outline segments of the internal `Rectangle`s.
`Rectangle` `getBounds()` Returns the smallest `Rectangle` fully enclosing this `IGeometry`.
`Region` `getCopy()` Returns a new identical copy of this `IGeometry`.
`Point[]` `getOutlineIntersections​(ICurve c)` Computes the `Point`s of intersection of this `Region` with the given `ICurve`.
`Polyline[]` `getOutlines()` Computes the outlines of this `IMultiShape`.
`Line[]` `getOutlineSegments()` Computes the outline segments of this `AbstractMultiShape`.
`Ring` `getRotatedCCW​(Angle angle)` Rotates the calling object by specified `Angle` counter-clock-wise (CCW) around its center `Point`.
`Ring` `getRotatedCCW​(Angle angle, double cx, double cy)` Rotates the calling object by the specified `Angle` counter-clock-wise (CCW) around the specified center `Point` (cx, cy).
`Ring` `getRotatedCCW​(Angle angle, Point center)` Rotates the calling object by the specified `Angle` counter-clock-wise (CCW) around the specified center `Point`.
`Ring` `getRotatedCW​(Angle angle)` Rotates the calling object by specified `Angle` clock-wise (CW) around its center `Point`.
`Ring` `getRotatedCW​(Angle angle, double cx, double cy)` Rotates the calling object by the specified `Angle` clock-wise (CW) around the specified center `Point` (cx, cy).
`Ring` `getRotatedCW​(Angle angle, Point center)` Rotates the calling object by the specified `Angle` clock-wise (CW) around the specified center `Point`.
`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)` Default implementation returning a transformed `Path` representation of this `IGeometry`.
`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()` Converts this `IGeometry` into a `Path` representation.
`Ring` `toRing()` Constructs a new `Ring` that covers the same area as this `Region`.
`boolean` `touches​(IGeometry g)` Returns `true` if the input `IGeometry` touches this `IGeometry`, i.e. there is at least one common point.
`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`.

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.eclipse.gef.geometry.planar.IGeometry

`touches`

### Constructor Detail

#### Region

    public Region()

Constructs a new `Region` not covering any area.

#### Region

    public Region​(Rectangle... rectangles)

Constructs a new `Region` from the given list of `Rectangle` s. The given `Rectangle`s are `add(Rectangle)`ed to the `Region` one after the other.

Parameters:
  `rectangles` - The array of `Rectangle`s from which this `Region` is constructed.

#### Region

    public Region​(Region other)

Constructs a new `Region` from the given other `Region`. In other words, it copies the given other `Region`.

Parameters:
  `other` - The `Region` from which this `Region` is constructed.

### Method Detail

#### add

    public Region add​(Rectangle rectangle)

Adds the given `Rectangle` to this `Region`. To assure the required conditions for internal `Rectangle`s, the given `Rectangle` is cut into several sub-`Rectangle`s so that no internal `Rectangle`s share any area.

Parameters:
  `rectangle` - the `Rectangle` to add to this `Region`
Returns:
  `this` for convenience

#### contains

    public boolean contains​(IGeometry g)

Description copied from interface: `IMultiShape`
Checks if the given `IGeometry` is fully contained by this `IMultiShape`.

Specified by:
  `contains` in interface `IMultiShape`
Parameters:
  `g` - The `IGeometry` which is tested for containment.
Returns:
  `true` if the `IGeometry` is contained by this `IMultiShape`, otherwise `false`

#### equals

    public boolean equals​(java.lang.Object obj)

Overrides:
  `equals` in class `java.lang.Object`

#### getAllEdges

    protected Line[] getAllEdges()

Collects all outline segments of the internal `Rectangle`s.

Returns:
  all the outline segments of the internal `Rectangle`s

#### getBounds

    public Rectangle getBounds()

Description copied from interface: `IGeometry`
Returns the smallest `Rectangle` fully enclosing this `IGeometry`.

Specified by:
  `getBounds` in interface `IGeometry`
Returns:
  A new `Rectangle` object that fully encloses this `IGeometry`

#### getCopy

    public Region getCopy()

Description copied from interface: `IGeometry`
Returns a new identical copy of this `IGeometry`.

Specified by:
  `getCopy` in interface `IGeometry`
Returns:
  a copy identical to this `IGeometry`

#### getOutlineIntersections

    public Point[] getOutlineIntersections​(ICurve c)

Computes the `Point`s of intersection of this `Region` with the given `ICurve`.

Parameters:
  `c` - The `ICurve` for which outline intersections are computed.
Returns:
  the intersection `Point`s

#### getRotatedCCW

    public Ring getRotatedCCW​(Angle angle)

Description copied from interface: `IRotatable`
Rotates the calling object by specified `Angle` counter-clock-wise (CCW) around its center `Point`. Does not necessarily return an object of the same type.

Specified by:
  `getRotatedCCW` in interface `IRotatable<Ring>`
Parameters:
  `angle` - rotation `Angle`
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 specified `Angle` counter-clock-wise (CCW) around the specified center `Point` (cx, cy). Does not necessarily return an object of the same type.

Specified by:
  `getRotatedCCW` in interface `IRotatable<Ring>`
Parameters:
  `angle` - rotation `Angle`
  `cx` - x-coordinate of the relative `Point` for the rotation
  `cy` - y-coordinate of the relative `Point` 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 specified `Angle` counter-clock-wise (CCW) around the specified center `Point`. Does not necessarily return an object of the same type.

Specified by:
  `getRotatedCCW` in interface `IRotatable<Ring>`
Parameters:
  `angle` - rotation `Angle`
  `center` - relative `Point` 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 specified `Angle` clock-wise (CW) around its center `Point`. Does not necessarily return an object of the same type.

Specified by:
  `getRotatedCW` in interface `IRotatable<Ring>`
Parameters:
  `angle` - rotation `Angle`
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 specified `Angle` clock-wise (CW) around the specified center `Point` (cx, cy). Does not necessarily return an object of the same type.

Specified by:
  `getRotatedCW` in interface `IRotatable<Ring>`
Parameters:
  `angle` - rotation `Angle`
  `cx` - x-coordinate of the relative `Point` for the rotation
  `cy` - y-coordinate of the relative `Point` 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 specified `Angle` clock-wise (CW) around the specified center `Point`. Does not necessarily return an object of the same type.

Specified by:
  `getRotatedCW` in interface `IRotatable<Ring>`
Parameters:
  `angle` - rotation `Angle`
  `center` - relative `Point` 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 center `Point`.

Specified by:
  `getScaled` in interface `IScalable<Region>`
Parameters:
  `factor` - scale-factor
Returns:
  the new, scaled object

#### 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 center `Point`.

Specified by:
  `getScaled` in interface `IScalable<Region>`
Parameters:
  `fx` - x-scale-factor
  `fy` - y-scale-factor
Returns:
  the new, scaled object

#### 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 center `Point` (cx, cy).

Specified by:
  `getScaled` in interface `IScalable<Region>`
Parameters:
  `factor` - scale-factor
  `cx` - x-coordinate of the relative `Point` for the scaling
  `cy` - y-coordinate of the relative `Point` for the scaling
Returns:
  the new, scaled object

#### 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 center `Point` (cx, cy).

Specified by:
  `getScaled` in interface `IScalable<Region>`
Parameters:
  `fx` - x-scale-factor
  `fy` - y-scale-factor
  `cx` - x-coordinate of the relative `Point` for the scaling
  `cy` - y-coordinate of the relative `Point` for the scaling
Returns:
  the new, scaled object

#### 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 center `Point`.

Specified by:
  `getScaled` in interface `IScalable<Region>`
Parameters:
  `fx` - x-scale-factor
  `fy` - y-scale-factor
  `center` - relative `Point` for the scaling
Returns:
  the new, scaled object

#### 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 center `Point`.

Specified by:
  `getScaled` in interface `IScalable<Region>`
Parameters:
  `factor` - scale-factor
  `center` - relative `Point` for the scaling
Returns:
  the new, scaled object

#### getShapes

    public Rectangle[] getShapes()

Description copied from interface: `IMultiShape`
Returns the `IShape`s that constitute this `IMultiShape`.

Specified by:
  `getShapes` in interface `IMultiShape`
Returns:
  an array of `IShape`s, representing the parts that make up this `IMultiShape`.

#### getTransformed

    public Ring getTransformed​(AffineTransform t)

Default implementation returning a transformed `Path` representation of this `IGeometry`. Subclasses may override this method to return a more specific representation.

Specified by:
  `getTransformed` in interface `IGeometry`
Parameters:
  `t` - The `AffineTransform` to be applied
Returns:
  a transformed `Path` representation of this `IGeometry`

#### 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 interface `ITranslatable<Region>`
Parameters:
  `dx` - x-translation
  `dy` - 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 given `Point`.

Specified by:
  `getTranslated` in interface `ITranslatable<Region>`
Parameters:
  `d` - translation `Point`
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 center `Point`.

Specified by:
  `scale` in interface `IScalable<Region>`
Parameters:
  `factor` - scale-factor
Returns:
  `this` for convenience

#### 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 center `Point`.

Specified by:
  `scale` in interface `IScalable<Region>`
Parameters:
  `fx` - x-scale-factor
  `fy` - y-scale-factor
Returns:
  `this` for convenience

#### 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 center `Point` (cx, cy).

Specified by:
  `scale` in interface `IScalable<Region>`
Parameters:
  `factor` - scale-factor
  `cx` - x-coordinate of the relative `Point` for the scaling
  `cy` - y-coordinate of the relative `Point` for the scaling
Returns:
  `this` for convenience

#### 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 center `Point` (cx, cy).

Specified by:
  `scale` in interface `IScalable<Region>`
Parameters:
  `fx` - x-scale-factor
  `fy` - y-scale-factor
  `cx` - x-coordinate of the relative `Point` for the scaling
  `cy` - y-coordinate of the relative `Point` for the scaling
Returns:
  `this` for convenience

#### 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 center `Point`.

Specified by:
  `scale` in interface `IScalable<Region>`
Parameters:
  `fx` - x-scale-factor
  `fy` - y-scale-factor
  `center` - relative `Point` for the scaling
Returns:
  `this` for convenience

#### 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 center `Point`.

Specified by:
  `scale` in interface `IScalable<Region>`
Parameters:
  `factor` - scale-factor
  `center` - relative `Point` for the scaling
Returns:
  `this` for convenience

#### toRing

    public Ring toRing()

Constructs a new `Ring` that covers the same area as this `Region`.

Returns:
  a new `Ring` that covers the same area as this `Region`

#### 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 interface `ITranslatable<Region>`
Parameters:
  `dx` - x-translation
  `dy` - y-translation
Returns:
  `this` for convenience

#### translate

    public Region translate​(Point d)

Description copied from interface: `ITranslatable`
Translates the object by the given `Point`.

Specified by:
  `translate` in interface `ITranslatable<Region>`
Parameters:
  `d` - translation `Point`
Returns:
  `this` for convenience

#### contains

    public boolean contains​(Point p)

Description copied from interface: `IGeometry`
Returns whether the given `Point` is contained within this `IGeometry`. This includes the case that the `Point` lies on the border of this `IGeometry`.

Specified by:
  `contains` in interface `IGeometry`
Parameters:
  `p` - The `Point` being tested for containment
Returns:
  `true` if the `Point` is contained within this `IGeometry`, `false` otherwise.

#### 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 this `IMultiShape` one `ICurve` is returned.

Specified by:
  `getOutlines` in interface `IMultiShape`
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 internal `IShape`s that only exist once.

Specified by:
  `getOutlineSegments` in interface `IMultiShape`
Returns:
  the outline segments of this `AbstractMultiShape`

#### toPath

    public Path toPath()

Description copied from interface: `IGeometry`
Converts this `IGeometry` into a `Path` representation.

Specified by:
  `toPath` in interface `IGeometry`
Returns:
  A new `Path` representation for this `IGeometry`.

#### clone

    public java.lang.Object clone()

Overridden with public visibility as recommended within `Cloneable` .

Overrides:
  `clone` in class `java.lang.Object`

#### hashCode

    public final int hashCode()

Overrides:
  `hashCode` in class `java.lang.Object`
See Also:
  `Object.hashCode()`

#### touches

    public boolean touches​(IGeometry g)

Description copied from interface: `IGeometry`
Returns `true` if the input `IGeometry` touches this `IGeometry`, i.e. there is at least one common point.

Specified by:
  `touches` in interface `IGeometry`
Parameters:
  `g` - The `IGeometry` for the intersection test
Returns:
  `true` if the input `IGeometry` and this `IGeometry` have at least one common point.