Package org.eclipse.gef.geometry.planar
Class Rectangle
- java.lang.Object
-
- org.eclipse.gef.geometry.planar.Rectangle
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,IGeometry,IRotatable<Polygon>,IScalable<Rectangle>,IShape,ITranslatable<Rectangle>
public final class Rectangle extends java.lang.Object implements IShape
Represents the geometric shape of a rectangle, where a rectangle is characterized by means of its upper left corner (x,y) and its size (width, height). Note that while all manipulations (e.g. within shrink, expand) within this class are based on double precision, all comparisons (e.g. within contains, intersects, equals, etc.) are based on a limited precision (with an accuracy defined withinPrecisionUtils) to compensate for rounding effects.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Rectangle()Constructs aRectanglewith location (0,0) and a size of (0,0).Rectangle(double x, double y, double width, double height)Constructs a Rectangle from the given values for its location (upper-left corner point) and its size.Rectangle(Point location, Dimension size)Constructs a newRectanglewith the given location and size.Rectangle(Point p1, Point p2)Rectangle(Rectangle r)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()Overridden with public visibility as recommended withinCloneable.booleancontains(double x, double y)Returns whether the point given by x and y is within the boundaries of this Rectangle.booleancontains(double x, double y, double width, double height)Returns true in case the rectangle specified by (x, y, width, height) is contained within thisRectangle.booleancontains(IGeometry g)booleancontains(Point p)Returns whether the given point is within the boundaries of this Rectangle.booleancontains(Rectangle r)booleanequals(double x, double y, double width, double height)Returnstrueif this Rectangle's x, y, width, and height values are identical to the provided ones.booleanequals(java.lang.Object o)Returns whether the input object is equal to this Rectangle or not.Texpand(double h, double v)Expands the horizontal and vertical sides of thisAbstractRectangleBasedGeometrywith the values provided as input, and returnsthisfor convenience.Texpand(double left, double top, double right, double bottom)Expands thisAbstractRectangleBasedGeometryby the given amounts, and returns this for convenience.doublegetArea()Returns the area of thisRectangle, i.e. the product of its width and height.PointgetBottom()Returns a new Point representing the middle point of the bottom side of this Rectangle.PointgetBottomLeft()Returns a new Point representing the bottom left point of this Rectangle.PointgetBottomRight()Returns a new Point representing the bottom right point of this Rectangle.RectanglegetBounds()PointgetCenter()Returns the centerPointof thisAbstractRectangleBasedGeometry.RectanglegetCopy()Returns a new Rectangle which has the exact same parameters as this Rectangle.TgetExpanded(double h, double v)Returns a new expandedAbstractRectangleBasedGeometry, where the sides are incremented by the horizontal and vertical values provided.TgetExpanded(double left, double top, double right, double bottom)Creates and returns a newAbstractRectangleBasedGeometrywith the bounds of thisAbstractRectangleBasedGeometryexpanded by the given insets.doublegetHeight()Returns the height of thisAbstractRectangleBasedGeometry.RectanglegetIntersected(Rectangle rect)Returns a new Rectangle which has the intersection of this Rectangle and the rectangle provided as input.PointgetLeft()Returns a new Point representing the middle point of the left hand side of this Rectangle.PointgetLocation()Returns aPointspecifying the x and y coordinates of thisAbstractRectangleBasedGeometry.PolylinegetOutline()Line[]getOutlineSegments()Point[]getPoints()PointgetRight()Returns a new Point which represents the middle point of the right hand side of this Rectangle.PolygongetRotatedCCW(Angle alpha)PolygongetRotatedCCW(Angle alpha, double cx, double cy)PolygongetRotatedCCW(Angle alpha, Point center)PolygongetRotatedCW(Angle alpha)PolygongetRotatedCW(Angle alpha, double cx, double cy)PolygongetRotatedCW(Angle alpha, Point center)TgetScaled(double factor)Scales a copy of the calling object by the given factor relative to its centerPoint.TgetScaled(double factorX, double factorY)Scales a copy of the calling object by the given factors relative to its centerPoint.TgetScaled(double factor, double centerX, double centerY)Scales a copy of the calling object by the given factor relative to the given centerPoint(cx, cy).TgetScaled(double factorX, double factorY, double centerX, double centerY)Scales a copy of the calling object by the given factors relative to the given centerPoint(cx, cy).TgetScaled(double factorX, double factorY, Point center)Scales a copy of the calling object by the given factors relative to the given centerPoint.TgetScaled(double factor, Point center)Scales a copy of the calling object by the given factor relative to the given centerPoint.TgetShrinked(double h, double v)Returns a newAbstractRectangleBasedGeometry, where the sides are shrinked by the horizontal and vertical values supplied.TgetShrinked(double left, double top, double right, double bottom)Returns a newAbstractRectangleBasedGeometryshrinked by the specified insets.DimensiongetSize()Returns aDimensionthat records the width and height of thisAbstractRectangleBasedGeometry.PointgetTop()Returns a new Point which represents the middle point of the top side of this Rectangle.PointgetTopLeft()Returns a new Point which represents the top left hand corner of this Rectangle.PointgetTopRight()Returns a new Point which represents the top right hand corner of this Rectangle.PolygongetTransformed(AffineTransform t)TgetTranslated(double dx, double dy)Translates a copy of this object by the given values in x and y direction.TgetTranslated(Point pt)Translates a copy of this object by the givenPoint.RectanglegetTransposed()Returns a new rectangle whose width and height have been interchanged, as well as its x and y values.RectanglegetUnioned(Point p)Returns a new Rectangle which contains both this Rectangle and the Point supplied as input.RectanglegetUnioned(Rectangle rect)Returns a new Rectangle which contains both this Rectangle and the Rectangle supplied as input.doublegetWidth()Returns the width of thisAbstractRectangleBasedGeometry.doublegetX()Returns the x coordinate thisAbstractRectangleBasedGeometry.doublegetY()Returns the y coordinate of thisAbstractRectangleBasedGeometry.inthashCode()Rectangleintersect(Rectangle r)booleanisEmpty()Returnstrueif this Rectangle's width or height is less than or equal to 0.Tscale(double factor)Scales the calling object by the given factor relative to its centerPoint.Tscale(double fx, double fy)Scales the calling object by the given factors relative to the given centerPoint.Tscale(double factor, double cx, double cy)Scales the calling object by the given factor relative to the given centerPoint(cx, cy).Tscale(double fx, double fy, double cx, double cy)Scales the calling object by the given factors relative to the given centerPoint(cx, cy).Tscale(double fx, double fy, Point center)Scales the calling object by the given factors relative to the given centerPoint.Tscale(double factor, Point center)Scales the calling object by the given factor relative to the given centerPoint.TsetBounds(double x, double y, double w, double h)Sets the x, y, width, and height values of thisAbstractRectangleBasedGeometryto the given values.TsetBounds(Point loc, Dimension size)TsetBounds(Rectangle r)Sets the x and y coordinates and the width and height of thisAbstractRectangleBasedGeometryto the respective values of the givenRectangle.TsetHeight(double height)Sets the height of thisAbstractRectangleBasedGeometryto the given value.TsetLocation(double x, double y)Sets the x and y coordinates of thisAbstractRectangleBasedGeometryto the specified values.TsetLocation(Point p)Sets the x and y coordinates of thisAbstractRectangleBasedGeometryto the respective values of the givenPoint.TsetSize(double w, double h)Sets the width and height of thisAbstractRectangleBasedGeometryto the given values.TsetSize(Dimension d)Sets the width and height of thisAbstractRectangleBasedGeometryto the width and height of the givenDimension.TsetWidth(double width)Sets the width of thisAbstractRectangleBasedGeometryto the passed-in value.TsetX(double x)Sets the x-coordinate of thisAbstractRectangleBasedGeometryto the given value.TsetY(double y)Sets the y-coordinate of thisAbstractRectangleBasedGeometryto the given value.Tshrink(double h, double v)Shrinks the sides of thisAbstractRectangleBasedGeometryby the horizontal and vertical values provided as input, and returns thisAbstractRectangleBasedGeometryfor convenience.Tshrink(double left, double top, double right, double bottom)Shrinks thisAbstractRectangleBasedGeometryby the specified amounts.PathtoPath()PolygontoPolygon()java.lang.StringtoString()booleantouches(IGeometry g)booleantouches(Line l)booleantouches(Rectangle r)Ttranslate(double dx, double dy)Translates the object by the given values in x and y direction.Ttranslate(Point p)Translates the object by the givenPoint.Rectangletranspose()Switches the x and y values, as well as the width and height of this Rectangle.Rectangleunion(double x, double y)Rectangleunion(double x, double y, double w, double h)Rectangleunion(Point p)Rectangleunion(Rectangle r)
-
-
-
Constructor Detail
-
Rectangle
public Rectangle()
Constructs aRectanglewith location (0,0) and a size of (0,0).
-
Rectangle
public Rectangle(double x, double y, double width, double height)Constructs a Rectangle from the given values for its location (upper-left corner point) and its size. If a negative, width or height is passed in, 0 will be used instead.
-
Rectangle
public Rectangle(Point location, Dimension size)
Constructs a newRectanglewith the given location and size.
-
-
Method Detail
-
contains
public boolean contains(double x, double y)Returns whether the point given by x and y is within the boundaries of this Rectangle.- Parameters:
x- the x-coordinate of the point to testy- the y-coordinate of the point to test- Returns:
- true if the Point is (imprecisely) contained within this Rectangle
-
contains
public boolean contains(double x, double y, double width, double height)Returns true in case the rectangle specified by (x, y, width, height) is contained within thisRectangle.- Parameters:
x- The x coordinate of the rectangle to be tested for containmenty- The y coordinate of the rectangle to be tested for containmentwidth- The width of the rectangle to be tested for containmentheight- The height of the rectangle to be tested for containment- Returns:
trueif the rectangle characterized by (x,y, width, height) is (imprecisely) fully contained within thisRectangle,falseotherwise
-
contains
public boolean contains(Point p)
Returns whether the given point is within the boundaries of this Rectangle. The boundaries are inclusive of the top and left edges, but exclusive of the bottom and right edges.
-
contains
public boolean contains(Rectangle r)
- Parameters:
r- the otherRectangleto test for being contained by thisRectangle- Returns:
trueif thisRectanglecontains the otherRectangle, otherwisefalse- See Also:
IShape.contains(IGeometry)
-
equals
public boolean equals(double x, double y, double width, double height)Returnstrueif this Rectangle's x, y, width, and height values are identical to the provided ones.- Parameters:
x- The x value to testy- The y value to testwidth- The width value to testheight- The height value to test- Returns:
trueif this Rectangle's x, y, width, and height values are (imprecisely) equal to the provided ones,falseotherwise
-
equals
public boolean equals(java.lang.Object o)
Returns whether the input object is equal to this Rectangle or not. Rectangles are equivalent if their x, y, height, and width values are the same.- Overrides:
equalsin classjava.lang.Object- Parameters:
o- Object being tested for equality- Returns:
- Returns the result of the equality test
-
getArea
public double getArea()
Returns the area of thisRectangle, i.e. the product of its width and height.- Returns:
- the area of this
Rectangle
-
getBottom
public Point getBottom()
Returns a new Point representing the middle point of the bottom side of this Rectangle.- Returns:
- Point at the bottom of the Rectangle
-
getBottomLeft
public Point getBottomLeft()
Returns a new Point representing the bottom left point of this Rectangle.- Returns:
- Point at the bottom left of the rectangle
-
getBottomRight
public Point getBottomRight()
Returns a new Point representing the bottom right point of this Rectangle.- Returns:
- Point at the bottom right of the rectangle
-
getCopy
public Rectangle getCopy()
Returns a new Rectangle which has the exact same parameters as this Rectangle.
-
getIntersected
public Rectangle getIntersected(Rectangle rect)
Returns a new Rectangle which has the intersection of this Rectangle and the rectangle provided as input. Returns an empty Rectangle if there is no intersection.- Parameters:
rect- Rectangle provided to test for intersection- Returns:
- A new Rectangle representing the intersection
-
getLeft
public Point getLeft()
Returns a new Point representing the middle point of the left hand side of this Rectangle.- Returns:
- Point at the left of the Rectangle
-
getOutline
public Polyline getOutline()
Description copied from interface:IShape- Specified by:
getOutlinein interfaceIShape- Returns:
- An
ICurverepresenting thisIShape's outline.
-
getOutlineSegments
public Line[] getOutlineSegments()
- Specified by:
getOutlineSegmentsin interfaceIShape- Returns:
- An array containing
Linerepresentations of thisRectangle's borders.
-
getPoints
public Point[] getPoints()
Returns an array ofPoints representing the top-left, top-right, bottom-right, and bottom-left border points of thisRectangle.- Returns:
- An array containing the border points of this
Rectangle
-
getRight
public Point getRight()
Returns a new Point which represents the middle point of the right hand side of this Rectangle.- Returns:
- Point at the right of the Rectangle
-
getRotatedCCW
public Polygon getRotatedCCW(Angle alpha)
Rotates thisRectanglecounter-clock-wise by the givenAnglearound the centerPointof thisRectangle(seeAbstractRectangleBasedGeometry.getCenter()).- Specified by:
getRotatedCCWin interfaceIRotatable<Polygon>- Parameters:
alpha- The rotationAngle.- Returns:
- the resulting
Polygon - See Also:
IRotatable.getRotatedCCW(Angle, Point)
-
getRotatedCCW
public Polygon getRotatedCCW(Angle alpha, double cx, double cy)
Rotates thisRectanglecounter-clock-wise by the givenAnglearound the givenPoint. If the rotationAngleis not an integer multiple of 90 degrees, the resulting figure cannot be expressed as aRectangleobject. That's why this method returns aPolygoninstead.- Specified by:
getRotatedCCWin interfaceIRotatable<Polygon>- Parameters:
alpha- the rotation anglecx- x-component of the center point for the rotationcy- y-component of the center point for the rotation- Returns:
- the resulting
Polygon
-
getRotatedCCW
public Polygon getRotatedCCW(Angle alpha, Point center)
Rotates thisRectanglecounter-clock-wise by the givenAnglearound the givenPoint. If the rotationAngleis not an integer multiple of 90 degrees, the resulting figure cannot be expressed as aRectangleobject. That's why this method returns aPolygoninstead.- Specified by:
getRotatedCCWin interfaceIRotatable<Polygon>- Parameters:
alpha- the rotation anglecenter- the center point for the rotation- Returns:
- the resulting
Polygon
-
getRotatedCW
public Polygon getRotatedCW(Angle alpha)
Rotates thisRectangleclock-wise by the givenAnglearound the center (AbstractRectangleBasedGeometry.getCenter()) of thisRectangle.- Specified by:
getRotatedCWin interfaceIRotatable<Polygon>- Parameters:
alpha- the rotationAngle- Returns:
- the resulting
Polygon - See Also:
IRotatable.getRotatedCW(Angle, Point)
-
getRotatedCW
public Polygon getRotatedCW(Angle alpha, double cx, double cy)
Rotates thisRectangleclock-wise by the givenAnglealpha around the givenPoint(cx, cy). If the rotationAngleis not an integer multiple of 90 degrees, the resulting figure cannot be expressed as aRectangleobject. That's why this method returns aPolygoninstead.- Specified by:
getRotatedCWin interfaceIRotatable<Polygon>- Parameters:
alpha- the rotation anglecx- x-component of the center point for the rotationcy- y-component of the center point for the rotation- Returns:
- the resulting
Polygon
-
getRotatedCW
public Polygon getRotatedCW(Angle alpha, Point center)
Rotates thisRectangleclock-wise by the givenAnglealpha around the givenPoint. If the rotationAngleis not an integer multiple of 90 degrees, the resulting figure cannot be expressed as aRectangleobject. That's why this method returns aPolygoninstead.- Specified by:
getRotatedCWin interfaceIRotatable<Polygon>- Parameters:
alpha- the rotation anglecenter- the center point for the rotation- Returns:
- the resulting
Polygon
-
getTop
public Point getTop()
Returns a new Point which represents the middle point of the top side of this Rectangle.- Returns:
- Point at the top of the Rectangle
-
getTopLeft
public Point getTopLeft()
Returns a new Point which represents the top left hand corner of this Rectangle.- Returns:
- Point at the top left of the rectangle
-
getTopRight
public Point getTopRight()
Returns a new Point which represents the top right hand corner of this Rectangle.- Returns:
- Point at the top right of the rectangle
-
getTransformed
public Polygon getTransformed(AffineTransform t)
- Specified by:
getTransformedin interfaceIGeometry- Specified by:
getTransformedin interfaceIShape- Parameters:
t- TheAffineTransformto be applied- Returns:
- a transformed
Pathrepresentation of thisIGeometry - See Also:
IGeometry.getTransformed(AffineTransform)
-
getTransposed
public Rectangle getTransposed()
Returns a new rectangle whose width and height have been interchanged, as well as its x and y values. This can be useful in orientation changes.- Returns:
- The transposed rectangle
-
getUnioned
public Rectangle getUnioned(Point p)
Returns a new Rectangle which contains both this Rectangle and the Point supplied as input.- Parameters:
p- Point for calculating union- Returns:
- A new unioned Rectangle
-
getUnioned
public Rectangle getUnioned(Rectangle rect)
Returns a new Rectangle which contains both this Rectangle and the Rectangle supplied as input.- Parameters:
rect- Rectangle for calculating union- Returns:
- A new unioned Rectangle
-
isEmpty
public boolean isEmpty()
Returnstrueif this Rectangle's width or height is less than or equal to 0.- Returns:
trueif this Rectangle is (imprecisely) considered to be empty
-
toPath
public Path toPath()
Description copied from interface:IGeometry- Specified by:
toPathin interfaceIGeometry- Returns:
- A new
Pathrepresentation for thisIGeometry. - See Also:
IGeometry.toPath()
-
toPolygon
public Polygon toPolygon()
Converts thisRectangleinto aPolygonrepresentation. The control points used to construct the polygon are the border points returned bygetPoints().
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
touches
public boolean touches(Line l)
-
touches
public boolean touches(Rectangle r)
Tests whether thisRectangleand the given otherRectangletouch, i.e. whether they have at least one point in common.- Parameters:
r- TheRectangleto test- Returns:
trueif thisRectangleand the givenRectangleshare at least one common point,falseotherwise.- See Also:
IGeometry.touches(IGeometry)
-
transpose
public Rectangle transpose()
Switches the x and y values, as well as the width and height of this Rectangle. Useful for orientation changes.- Returns:
thisfor convenience
-
union
public Rectangle union(double x, double y)
-
union
public Rectangle union(double x, double y, double w, double h)
-
union
public Rectangle union(Point p)
- Parameters:
p- ThePointto union with- Returns:
thisfor convenience
-
union
public Rectangle union(Rectangle r)
- Parameters:
r- TheRectangleto union with- Returns:
thisfor convenience
-
expand
public T expand(double h, double v)Expands the horizontal and vertical sides of thisAbstractRectangleBasedGeometrywith the values provided as input, and returnsthisfor convenience. The location of its center is kept constant.- Parameters:
h- the horizontal incrementv- the vertical increment- Returns:
thisfor convenience
-
expand
public T expand(double left, double top, double right, double bottom)Expands thisAbstractRectangleBasedGeometryby the given amounts, and returns this for convenience.- Parameters:
left- the amount to expand the left sidetop- the amount to expand the top sideright- the amount to expand the right sidebottom- the amount to expand the bottom side- Returns:
thisfor convenience
-
getCenter
public Point getCenter()
Returns the centerPointof thisAbstractRectangleBasedGeometry.- Returns:
- the center
Pointof thisAbstractRectangleBasedGeometry
-
getExpanded
public T getExpanded(double h, double v)Returns a new expandedAbstractRectangleBasedGeometry, where the sides are incremented by the horizontal and vertical values provided. The center of theAbstractRectangleBasedGeometryis maintained constant.- Parameters:
h- The horizontal incrementv- The vertical increment- Returns:
- a new expanded
AbstractRectangleBasedGeometry
-
getExpanded
public T getExpanded(double left, double top, double right, double bottom)Creates and returns a newAbstractRectangleBasedGeometrywith the bounds of thisAbstractRectangleBasedGeometryexpanded by the given insets.- Parameters:
left- the amount to expand the left sidetop- the amount to expand the top sideright- the amount to expand the right sidebottom- the amount to expand the bottom side- Returns:
- a new expanded
AbstractRectangleBasedGeometry
-
getHeight
public final double getHeight()
Returns the height of thisAbstractRectangleBasedGeometry.- Returns:
- the height of this
AbstractRectangleBasedGeometry
-
getLocation
public Point getLocation()
Returns aPointspecifying the x and y coordinates of thisAbstractRectangleBasedGeometry.- Returns:
- a
Pointrepresenting the x and y coordinates of thisAbstractRectangleBasedGeometry
-
getScaled
public T getScaled(double factor)
Description copied from interface:IScalableScales a copy of the calling object by the given factor relative to its centerPoint.
-
getScaled
public T getScaled(double factorX, double factorY)Description copied from interface:IScalableScales a copy of the calling object by the given factors relative to its centerPoint.
-
getScaled
public T getScaled(double factor, double centerX, double centerY)Description copied from interface:IScalableScales a copy of the calling object by the given factor relative to the given centerPoint(cx, cy).- Specified by:
getScaledin interfaceIScalable<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>- Parameters:
factor- scale-factorcenterX- x-coordinate of the relativePointfor the scalingcenterY- y-coordinate of the relativePointfor the scaling- Returns:
- the new, scaled object
-
getScaled
public T getScaled(double factorX, double factorY, double centerX, double centerY)Description copied from interface:IScalableScales a copy of the calling object by the given factors relative to the given centerPoint(cx, cy).- Specified by:
getScaledin interfaceIScalable<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>- Parameters:
factorX- x-scale-factorfactorY- y-scale-factorcenterX- x-coordinate of the relativePointfor the scalingcenterY- y-coordinate of the relativePointfor the scaling- Returns:
- the new, scaled object
-
getScaled
public T getScaled(double factorX, double factorY, Point center)Description copied from interface:IScalableScales a copy of the calling object by the given factors relative to the given centerPoint.
-
getScaled
public T 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.
-
getShrinked
public T getShrinked(double h, double v)Returns a newAbstractRectangleBasedGeometry, where the sides are shrinked by the horizontal and vertical values supplied. The center of thisAbstractRectangleBasedGeometryis kept constant.- Parameters:
h- horizontal reduction amountv- vertical reduction amount- Returns:
- a new, shrinked
AbstractRectangleBasedGeometry
-
getShrinked
public T getShrinked(double left, double top, double right, double bottom)Returns a newAbstractRectangleBasedGeometryshrinked by the specified insets.- Parameters:
left- the amount to shrink the left sidetop- the amount to shrink the top sideright- the amount to shrink the right sidebottom- the amount to shrink the bottom side- Returns:
- a new, shrinked
AbstractRectangleBasedGeometry
-
getSize
public final Dimension getSize()
Returns aDimensionthat records the width and height of thisAbstractRectangleBasedGeometry.- Returns:
- a
Dimensionthat records the width and height of thisAbstractRectangleBasedGeometry
-
getTranslated
public T 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<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>- Parameters:
dx- x-translationdy- y-translation- Returns:
- a new, translated object
-
getTranslated
public T getTranslated(Point pt)
Description copied from interface:ITranslatableTranslates a copy of this object by the givenPoint.- Specified by:
getTranslatedin interfaceITranslatable<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>- Parameters:
pt- translationPoint- Returns:
- a new, translated object
-
getWidth
public final double getWidth()
Returns the width of thisAbstractRectangleBasedGeometry.- Returns:
- the width of this
AbstractRectangleBasedGeometry
-
getX
public final double getX()
Returns the x coordinate thisAbstractRectangleBasedGeometry.- Returns:
- the x coordinate this
AbstractRectangleBasedGeometry
-
getY
public final double getY()
Returns the y coordinate of thisAbstractRectangleBasedGeometry.- Returns:
- the y coordinate of this
AbstractRectangleBasedGeometry
-
scale
public T scale(double factor)
Description copied from interface:IScalableScales the calling object by the given factor relative to its centerPoint.
-
scale
public T scale(double fx, double fy)Description copied from interface:IScalableScales the calling object by the given factors relative to the given centerPoint.
-
scale
public T 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 T 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).- Specified by:
scalein interfaceIScalable<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>- Parameters:
fx- x-scale-factorfy- y-scale-factorcx- x-coordinate of the relativePointfor the scalingcy- y-coordinate of the relativePointfor the scaling- Returns:
thisfor convenience
-
scale
public T 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 T scale(double factor, Point center)Description copied from interface:IScalableScales the calling object by the given factor relative to the given centerPoint.
-
setBounds
public final T setBounds(double x, double y, double w, double h)Sets the x, y, width, and height values of thisAbstractRectangleBasedGeometryto the given values.- Parameters:
x- the new x-coordinatey- the new y-coordinatew- the new widthh- the new height- Returns:
thisfor convenience
-
setBounds
public final T setBounds(Rectangle r)
Sets the x and y coordinates and the width and height of thisAbstractRectangleBasedGeometryto the respective values of the givenRectangle.- Parameters:
r- theRectanglespecifying the new x, y, width, and height values of thisAbstractRectangleBasedGeometry- Returns:
thisfor convenience
-
setHeight
public final T setHeight(double height)
Sets the height of thisAbstractRectangleBasedGeometryto the given value.- Parameters:
height- the new height- Returns:
thisfor convenience
-
setLocation
public final T setLocation(double x, double y)Sets the x and y coordinates of thisAbstractRectangleBasedGeometryto the specified values.- Parameters:
x- the new x coordinate of thisAbstractRectangleBasedGeometryy- the new y coordinate of thisAbstractRectangleBasedGeometry- Returns:
thisfor convenience
-
setLocation
public final T setLocation(Point p)
Sets the x and y coordinates of thisAbstractRectangleBasedGeometryto the respective values of the givenPoint.- Parameters:
p- thePointspecifying the new x and y coordinates of thisAbstractRectangleBasedGeometry- Returns:
thisfor convenience
-
setSize
public final T setSize(Dimension d)
Sets the width and height of thisAbstractRectangleBasedGeometryto the width and height of the givenDimension.- Parameters:
d- theDimensionspecifying the new width and height of thisAbstractRectangleBasedGeometry- Returns:
thisfor convenience
-
setSize
public final T setSize(double w, double h)Sets the width and height of thisAbstractRectangleBasedGeometryto the given values.- Parameters:
w- the new width of thisAbstractRectangleBasedGeometryh- the new height of thisAbstractRectangleBasedGeometry- Returns:
thisfor convenience
-
setWidth
public final T setWidth(double width)
Sets the width of thisAbstractRectangleBasedGeometryto the passed-in value.- Parameters:
width- the new width of thisAbstractRectangleBasedGeometry- Returns:
thisfor convenience
-
setX
public final T setX(double x)
Sets the x-coordinate of thisAbstractRectangleBasedGeometryto the given value.- Parameters:
x- The new x-coordinate.- Returns:
thisfor convenience.
-
setY
public final T setY(double y)
Sets the y-coordinate of thisAbstractRectangleBasedGeometryto the given value.- Parameters:
y- The new y-coordinate.- Returns:
thisfor convenience.
-
shrink
public T shrink(double h, double v)Shrinks the sides of thisAbstractRectangleBasedGeometryby the horizontal and vertical values provided as input, and returns thisAbstractRectangleBasedGeometryfor convenience. The center of thisAbstractRectangleBasedGeometryis kept constant.- Parameters:
h- horizontal reduction amountv- vertical reduction amount- Returns:
thisfor convenience
-
shrink
public T shrink(double left, double top, double right, double bottom)Shrinks thisAbstractRectangleBasedGeometryby the specified amounts.- Parameters:
left- the amount to shrink the left sidetop- the amount to shrink the top sideright- the amount to shrink the right sidebottom- the amount to shrink the bottom side- Returns:
thisfor convenience
-
translate
public T 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<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>- Parameters:
dx- x-translationdy- y-translation- Returns:
thisfor convenience
-
translate
public T translate(Point p)
Description copied from interface:ITranslatableTranslates the object by the givenPoint.- Specified by:
translatein interfaceITranslatable<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>- Parameters:
p- translationPoint- Returns:
thisfor convenience
-
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()
-
-