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 ofRectangles. TheRectangles that build up aRegiondo not have to be touching. The area covered by theRegionis exactly the area that all of its correspondingRectangles are covering. ARegiondifferentiates between the internalRectangles and the externalRectangles. The externalRectangles are those that you feed it, in order to construct theRegion. The internalRectangles 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 Regionadd(Rectangle rectangle)java.lang.Objectclone()Overridden with public visibility as recommended withinCloneable.booleancontains(IGeometry g)Checks if the givenIGeometryis fully contained by thisIMultiShape.booleancontains(Point p)booleanequals(java.lang.Object obj)protected Line[]getAllEdges()Collects all outline segments of the internalRectangles.RectanglegetBounds()RegiongetCopy()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.RinggetRotatedCCW(Angle angle)RinggetRotatedCCW(Angle angle, double cx, double cy)RinggetRotatedCCW(Angle angle, Point center)RinggetRotatedCW(Angle angle)RinggetRotatedCW(Angle angle, double cx, double cy)RinggetRotatedCW(Angle angle, Point center)RegiongetScaled(double factor)Scales a copy of the calling object by the given factor relative to its centerPoint.RegiongetScaled(double fx, double fy)Scales a copy of the calling object by the given factors relative to its centerPoint.RegiongetScaled(double factor, double cx, double cy)Scales a copy of the calling object by the given factor relative to the given centerPoint(cx, cy).RegiongetScaled(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).RegiongetScaled(double fx, double fy, Point center)Scales a copy of the calling object by the given factors relative to the given centerPoint.RegiongetScaled(double factor, Point center)Scales a copy of the calling object by the given factor relative to the given centerPoint.Rectangle[]getShapes()Returns theIShapes that constitute thisIMultiShape.RinggetTransformed(AffineTransform t)RegiongetTranslated(double dx, double dy)Translates a copy of this object by the given values in x and y direction.RegiongetTranslated(Point d)Translates a copy of this object by the givenPoint.inthashCode()Regionscale(double factor)Scales the calling object by the given factor relative to its centerPoint.Regionscale(double fx, double fy)Scales the calling object by the given factors relative to the given centerPoint.Regionscale(double factor, double cx, double cy)Scales the calling object by the given factor relative to the given centerPoint(cx, cy).Regionscale(double fx, double fy, double cx, double cy)Scales the calling object by the given factors relative to the given centerPoint(cx, cy).Regionscale(double fx, double fy, Point center)Scales the calling object by the given factors relative to the given centerPoint.Regionscale(double factor, Point center)Scales the calling object by the given factor relative to the given centerPoint.PathtoPath()RingtoRing()booleantouches(IGeometry g)Regiontranslate(double dx, double dy)Translates the object by the given values in x and y direction.Regiontranslate(Point d)Translates the object by the givenPoint.
-
-
-
Method Detail
-
contains
public boolean contains(IGeometry g)
Description copied from interface:IMultiShapeChecks if the givenIGeometryis fully contained by thisIMultiShape.- Specified by:
containsin interfaceIMultiShape- Parameters:
g- TheIGeometrywhich is tested for containment.- Returns:
trueif theIGeometryis contained by thisIMultiShape, otherwisefalse
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
getAllEdges
protected Line[] getAllEdges()
Collects all outline segments of the internalRectangles.- Returns:
- all the outline segments of the internal
Rectangles
-
getCopy
public Region getCopy()
Description copied from interface:IGeometryReturns a new identical copy of thisIGeometry.
-
getRotatedCCW
public Ring getRotatedCCW(Angle angle)
Description copied from interface:IRotatableRotates the calling object by specifiedAnglecounter-clock-wise (CCW) around its centerPoint. Does not necessarily return an object of the same type.- Specified by:
getRotatedCCWin interfaceIRotatable<Ring>- Parameters:
angle- rotationAngle- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getRotatedCCW
public Ring getRotatedCCW(Angle angle, double cx, double cy)
Description copied from interface:IRotatableRotates the calling object by the specifiedAnglecounter-clock-wise (CCW) around the specified centerPoint(cx, cy). Does not necessarily return an object of the same type.- Specified by:
getRotatedCCWin interfaceIRotatable<Ring>- Parameters:
angle- rotationAnglecx- x-coordinate of the relativePointfor the rotationcy- y-coordinate of the relativePointfor the rotation- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getRotatedCCW
public Ring getRotatedCCW(Angle angle, Point center)
Description copied from interface:IRotatableRotates the calling object by the specifiedAnglecounter-clock-wise (CCW) around the specified centerPoint. Does not necessarily return an object of the same type.- Specified by:
getRotatedCCWin interfaceIRotatable<Ring>- Parameters:
angle- rotationAnglecenter- relativePointfor the rotation- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getRotatedCW
public Ring getRotatedCW(Angle angle)
Description copied from interface:IRotatableRotates the calling object by specifiedAngleclock-wise (CW) around its centerPoint. Does not necessarily return an object of the same type.- Specified by:
getRotatedCWin interfaceIRotatable<Ring>- Parameters:
angle- rotationAngle- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getRotatedCW
public Ring getRotatedCW(Angle angle, double cx, double cy)
Description copied from interface:IRotatableRotates the calling object by the specifiedAngleclock-wise (CW) around the specified centerPoint(cx, cy). Does not necessarily return an object of the same type.- Specified by:
getRotatedCWin interfaceIRotatable<Ring>- Parameters:
angle- rotationAnglecx- x-coordinate of the relativePointfor the rotationcy- y-coordinate of the relativePointfor the rotation- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getRotatedCW
public Ring getRotatedCW(Angle angle, Point center)
Description copied from interface:IRotatableRotates the calling object by the specifiedAngleclock-wise (CW) around the specified centerPoint. Does not necessarily return an object of the same type.- Specified by:
getRotatedCWin interfaceIRotatable<Ring>- Parameters:
angle- rotationAnglecenter- relativePointfor the rotation- Returns:
- an
IGeometryrepresenting the result of the rotation
-
getScaled
public Region getScaled(double factor)
Description copied from interface:IScalableScales 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:IScalableScales 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:IScalableScales 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:IScalableScales 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:IScalableScales 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:IScalableScales a copy of the calling object by the given factor relative to the given centerPoint.
-
getShapes
public Rectangle[] getShapes()
Description copied from interface:IMultiShapeReturns theIShapes that constitute thisIMultiShape.- Specified by:
getShapesin interfaceIMultiShape- Returns:
- an array of
IShapes, representing the parts that make up thisIMultiShape.
-
getTransformed
public Ring getTransformed(AffineTransform t)
Default implementation returning a transformedPathrepresentation of thisIGeometry. Subclasses may override this method to return a more specific representation.- Specified by:
getTransformedin interfaceIGeometry- Parameters:
t- TheAffineTransformto be applied- Returns:
- a transformed
Pathrepresentation of thisIGeometry
-
getTranslated
public Region getTranslated(double dx, double dy)
Description copied from interface:ITranslatableTranslates a copy of this object by the given values in x and y direction.- Specified by:
getTranslatedin interfaceITranslatable<Region>- Parameters:
dx- x-translationdy- y-translation- Returns:
- a new, translated object
-
getTranslated
public Region getTranslated(Point d)
Description copied from interface:ITranslatableTranslates a copy of this object by the givenPoint.- Specified by:
getTranslatedin interfaceITranslatable<Region>- Parameters:
d- translationPoint- Returns:
- a new, translated object
-
scale
public Region scale(double factor)
Description copied from interface:IScalableScales the calling object by the given factor relative to its centerPoint.
-
scale
public Region scale(double fx, double fy)
Description copied from interface:IScalableScales 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:IScalableScales 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:IScalableScales 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:IScalableScales the calling object by the given factors relative to the given centerPoint.
-
scale
public Region scale(double factor, Point center)
Description copied from interface:IScalableScales the calling object by the given factor relative to the given centerPoint.
-
translate
public Region translate(double dx, double dy)
Description copied from interface:ITranslatableTranslates the object by the given values in x and y direction.- Specified by:
translatein interfaceITranslatable<Region>- Parameters:
dx- x-translationdy- y-translation- Returns:
thisfor convenience
-
translate
public Region translate(Point d)
Description copied from interface:ITranslatableTranslates the object by the givenPoint.- Specified by:
translatein interfaceITranslatable<Region>- Parameters:
d- translationPoint- Returns:
thisfor convenience
-
getOutlines
public Polyline[] getOutlines()
Description copied from interface:IMultiShapeComputes the outlines of this
IMultiShape.The outlines are returned as an array of
ICurves. For every closed outline of thisIMultiShapeoneICurveis returned.- Specified by:
getOutlinesin interfaceIMultiShape- Returns:
- an array of
ICurves, one for each closed outline
-
getOutlineSegments
public Line[] getOutlineSegments()
Computes the outline segments of this
AbstractMultiShape.The outline segments of this
AbstractMultiShapeare those outline segments of the internalIShapes that only exist once.- Specified by:
getOutlineSegmentsin interfaceIMultiShape- Returns:
- the outline segments of this
AbstractMultiShape
-
clone
public java.lang.Object clone()
Overridden with public visibility as recommended withinCloneable.- Overrides:
clonein classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCodein classjava.lang.Object- See Also:
Object.hashCode()
-
-