Class Rectangle

java.lang.Object
org.eclipse.gef.geometry.planar.Rectangle
All Implemented Interfaces:
Serializable, Cloneable, IGeometry, IRotatable<Polygon>, IScalable<Rectangle>, IShape, ITranslatable<Rectangle>

public final class Rectangle extends 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 within PrecisionUtils) to compensate for rounding effects.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a Rectangle with 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 new Rectangle with the given location and size.
    Constructs a new Rectangle, which is the smallest one containing both given Points.
    Constructs a new Rectangle with x, y, width, and height values of the given Rectangle.
  • Method Summary

    Modifier and Type
    Method
    Description
    Overridden with public visibility as recommended within Cloneable .
    boolean
    contains(double x, double y)
    Returns whether the point given by x and y is within the boundaries of this Rectangle.
    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 this Rectangle.
    boolean
    Tests whether the given IGeometry is fully contained by this IShape.
    boolean
    Returns whether the given point is within the boundaries of this Rectangle.
    boolean
    Tests whether this Rectangle fully contains the given other Rectangle.
    boolean
    equals(double x, double y, double width, double height)
    Returns true if this Rectangle's x, y, width, and height values are identical to the provided ones.
    boolean
    Returns whether the input object is equal to this Rectangle or not.
    expand(double h, double v)
    Expands the horizontal and vertical sides of this AbstractRectangleBasedGeometry with the values provided as input, and returns this for convenience.
    expand(double left, double top, double right, double bottom)
    Expands this AbstractRectangleBasedGeometry by the given amounts, and returns this for convenience.
    double
    Returns the area of this Rectangle, i.e. the product of its width and height.
    Returns a new Point representing the middle point of the bottom side of this Rectangle.
    Returns a new Point representing the bottom left point of this Rectangle.
    Returns a new Point representing the bottom right point of this Rectangle.
    Returns the smallest Rectangle fully enclosing this IGeometry.
    Returns the center Point of this AbstractRectangleBasedGeometry.
    Returns a new Rectangle which has the exact same parameters as this Rectangle.
    getExpanded(double h, double v)
    Returns a new expanded AbstractRectangleBasedGeometry, where the sides are incremented by the horizontal and vertical values provided.
    getExpanded(double left, double top, double right, double bottom)
    Creates and returns a new AbstractRectangleBasedGeometry with the bounds of this AbstractRectangleBasedGeometry expanded by the given insets.
    final double
    Returns the height of this AbstractRectangleBasedGeometry.
    Returns a new Rectangle which has the intersection of this Rectangle and the rectangle provided as input.
    Returns a new Point representing the middle point of the left hand side of this Rectangle.
    Returns a Point specifying the x and y coordinates of this AbstractRectangleBasedGeometry.
    Returns an ICurve representing the outline of this IShape .
    Returns an array of Lines representing the top, right, bottom, and left borders of this Rectangle.
    Returns an array of Points representing the top-left, top-right, bottom-right, and bottom-left border points of this Rectangle.
    Returns a new Point which represents the middle point of the right hand side of this Rectangle.
    Rotates this Rectangle counter-clock-wise by the given Angle around the center Point of this Rectangle (see AbstractRectangleBasedGeometry.getCenter()).
    getRotatedCCW(Angle alpha, double cx, double cy)
    Rotates this Rectangle counter-clock-wise by the given Angle around the given Point.
    getRotatedCCW(Angle alpha, Point center)
    Rotates this Rectangle counter-clock-wise by the given Angle around the given Point.
    Rotates this Rectangle clock-wise by the given Angle around the center (AbstractRectangleBasedGeometry.getCenter()) of this Rectangle.
    getRotatedCW(Angle alpha, double cx, double cy)
    Rotates this Rectangle clock-wise by the given Angle alpha around the given Point (cx, cy).
    getRotatedCW(Angle alpha, Point center)
    Rotates this Rectangle clock-wise by the given Angle alpha around the given Point.
    getScaled(double factor)
    Scales a copy of the calling object by the given factor relative to its center Point.
    getScaled(double factorX, double factorY)
    Scales a copy of the calling object by the given factors relative to its center Point.
    getScaled(double factor, double centerX, double centerY)
    Scales a copy of the calling object by the given factor relative to the given center Point (cx, cy).
    getScaled(double factorX, double factorY, double centerX, double centerY)
    Scales a copy of the calling object by the given factors relative to the given center Point (cx, cy).
    getScaled(double factorX, double factorY, Point center)
    Scales a copy of the calling object by the given factors relative to the given center Point.
    getScaled(double factor, Point center)
    Scales a copy of the calling object by the given factor relative to the given center Point.
    getShrinked(double h, double v)
    Returns a new AbstractRectangleBasedGeometry, where the sides are shrinked by the horizontal and vertical values supplied.
    getShrinked(double left, double top, double right, double bottom)
    Returns a new AbstractRectangleBasedGeometry shrinked by the specified insets.
    final Dimension
    Returns a Dimension that records the width and height of this AbstractRectangleBasedGeometry.
    Returns a new Point which represents the middle point of the top side of this Rectangle.
    Returns a new Point which represents the top left hand corner of this Rectangle.
    Returns a new Point which represents the top right hand corner of this Rectangle.
    Returns a Polygon, which represents the transformed Rectangle.
    getTranslated(double dx, double dy)
    Translates a copy of this object by the given values in x and y direction.
    Translates a copy of this object by the given Point.
    Returns a new rectangle whose width and height have been interchanged, as well as its x and y values.
    Returns a new Rectangle which contains both this Rectangle and the Point supplied as input.
    Returns a new Rectangle which contains both this Rectangle and the Rectangle supplied as input.
    final double
    Returns the width of this AbstractRectangleBasedGeometry.
    final double
    Returns the x coordinate this AbstractRectangleBasedGeometry.
    final double
    Returns the y coordinate of this AbstractRectangleBasedGeometry.
    final int
     
    Sets the bounds of this Rectangle to the intersection of this Rectangle with the given one.
    boolean
    Returns true if this Rectangle's width or height is less than or equal to 0.
    scale(double factor)
    Scales the calling object by the given factor relative to its center Point.
    scale(double fx, double fy)
    Scales the calling object by the given factors relative to the given center Point.
    scale(double factor, double cx, double cy)
    Scales the calling object by the given factor relative to the given center Point (cx, cy).
    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).
    scale(double fx, double fy, Point center)
    Scales the calling object by the given factors relative to the given center Point.
    scale(double factor, Point center)
    Scales the calling object by the given factor relative to the given center Point.
    final Rectangle
    setBounds(double x, double y, double w, double h)
    Sets the x, y, width, and height values of this AbstractRectangleBasedGeometry to the given values.
    final Rectangle
    Sets the x, y, width, and height values of this AbstractRectangleBasedGeometry to the respective values specified by the passed-in Point and the passed-in Dimension.
    final Rectangle
    Sets the x and y coordinates and the width and height of this AbstractRectangleBasedGeometry to the respective values of the given Rectangle.
    final Rectangle
    setHeight(double height)
    Sets the height of this AbstractRectangleBasedGeometry to the given value.
    final Rectangle
    setLocation(double x, double y)
    Sets the x and y coordinates of this AbstractRectangleBasedGeometry to the specified values.
    final Rectangle
    Sets the x and y coordinates of this AbstractRectangleBasedGeometry to the respective values of the given Point.
    final Rectangle
    setSize(double w, double h)
    Sets the width and height of this AbstractRectangleBasedGeometry to the given values.
    final Rectangle
    Sets the width and height of this AbstractRectangleBasedGeometry to the width and height of the given Dimension.
    final Rectangle
    setWidth(double width)
    Sets the width of this AbstractRectangleBasedGeometry to the passed-in value.
    final Rectangle
    setX(double x)
    Sets the x-coordinate of this AbstractRectangleBasedGeometry to the given value.
    final Rectangle
    setY(double y)
    Sets the y-coordinate of this AbstractRectangleBasedGeometry to the given value.
    shrink(double h, double v)
    Shrinks the sides of this AbstractRectangleBasedGeometry by the horizontal and vertical values provided as input, and returns this AbstractRectangleBasedGeometry for convenience.
    shrink(double left, double top, double right, double bottom)
    Shrinks this AbstractRectangleBasedGeometry by the specified amounts.
    Converts this IGeometry into a Path representation.
    Converts this Rectangle into a Polygon representation.
     
    boolean
    Returns true if the input IGeometry touches this IGeometry, i.e. there is at least one common point.
    boolean
    Tests whether this Rectangle and the given Line touch, i.e. whether they have at least one point in common.
    boolean
    Tests whether this Rectangle and the given other Rectangle touch, i.e. whether they have at least one point in common.
    translate(double dx, double dy)
    Translates the object by the given values in x and y direction.
    Translates the object by the given Point.
    Switches the x and y values, as well as the width and height of this Rectangle.
    union(double x, double y)
    Updates this Rectangle's bounds so that the Point given by (x,y) is contained.
    union(double x, double y, double w, double h)
    Updates this Rectangle's bounds to the union of this Rectangle and the Rectangle with location (x, y) and size(w, h).
    Updates this Rectangle's bounds so that the given Point is included within.
    Updates this Rectangle's bounds to the union of this Rectangle and the Rectangle.

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait

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

    getBounds
  • Constructor Details

    • Rectangle

      public Rectangle()
      Constructs a Rectangle with 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.
      Parameters:
      x - the x location of the new Rectangle
      y - the y location of the new Rectangle
      width - the width of the new Rectangle
      height - the height of the new Rectangle
    • Rectangle

      public Rectangle(Point location, Dimension size)
      Constructs a new Rectangle with the given location and size.
      Parameters:
      location - the location of the new Rectangle
      size - the size of the new Rectangle
    • Rectangle

      public Rectangle(Point p1, Point p2)
      Constructs a new Rectangle, which is the smallest one containing both given Points.
      Parameters:
      p1 - the first point used to construct the new Rectangle
      p2 - the second point used to construct the new Rectangle
    • Rectangle

      public Rectangle(Rectangle r)
      Constructs a new Rectangle with x, y, width, and height values of the given Rectangle.
      Parameters:
      r - the Rectangle, whose x, y, width, and height values should be used to initialize the new Rectangle
  • Method Details

    • 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 test
      y - 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 this Rectangle.
      Parameters:
      x - The x coordinate of the rectangle to be tested for containment
      y - The y coordinate of the rectangle to be tested for containment
      width - The width of the rectangle to be tested for containment
      height - The height of the rectangle to be tested for containment
      Returns:
      true if the rectangle characterized by (x,y, width, height) is (imprecisely) fully contained within this Rectangle, false otherwise
    • contains

      public boolean contains(IGeometry g)
      Description copied from interface: IShape
      Tests whether the given IGeometry is fully contained by this IShape.
      Specified by:
      contains in interface IShape
      Parameters:
      g - The IGeometry to test for containment
      Returns:
      true if the given IGeometry is fully contained by this IShape, false otherwise.
    • 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.
      Specified by:
      contains in interface IGeometry
      Parameters:
      p - Point being tested for containment
      Returns:
      true if the Point is within this Rectangle
    • contains

      public boolean contains(Rectangle r)
      Tests whether this Rectangle fully contains the given other Rectangle.
      Parameters:
      r - the other Rectangle to test for being contained by this Rectangle
      Returns:
      true if this Rectangle contains the other Rectangle, otherwise false
      See Also:
    • equals

      public boolean equals(double x, double y, double width, double height)
      Returns true if this Rectangle's x, y, width, and height values are identical to the provided ones.
      Parameters:
      x - The x value to test
      y - The y value to test
      width - The width value to test
      height - The height value to test
      Returns:
      true if this Rectangle's x, y, width, and height values are (imprecisely) equal to the provided ones, false otherwise
    • equals

      public boolean equals(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:
      equals in class Object
      Parameters:
      o - Object being tested for equality
      Returns:
      Returns the result of the equality test
    • getArea

      public double getArea()
      Returns the area of this Rectangle, 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.
      Specified by:
      getCopy in interface IGeometry
      Returns:
      Copy of 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
      Returns an ICurve representing the outline of this IShape .
      Specified by:
      getOutline in interface IShape
      Returns:
      An ICurve representing this IShape's outline.
    • getOutlineSegments

      public Line[] getOutlineSegments()
      Returns an array of Lines representing the top, right, bottom, and left borders of this Rectangle.
      Specified by:
      getOutlineSegments in interface IShape
      Returns:
      An array containing Line representations of this Rectangle's borders.
    • getPoints

      public Point[] getPoints()
      Returns an array of Points representing the top-left, top-right, bottom-right, and bottom-left border points of this Rectangle.
      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 this Rectangle counter-clock-wise by the given Angle around the center Point of this Rectangle (see AbstractRectangleBasedGeometry.getCenter()).
      Specified by:
      getRotatedCCW in interface IRotatable<Polygon>
      Parameters:
      alpha - The rotation Angle.
      Returns:
      the resulting Polygon
      See Also:
    • getRotatedCCW

      public Polygon getRotatedCCW(Angle alpha, double cx, double cy)
      Rotates this Rectangle counter-clock-wise by the given Angle around the given Point. If the rotation Angle is not an integer multiple of 90 degrees, the resulting figure cannot be expressed as a Rectangle object. That's why this method returns a Polygon instead.
      Specified by:
      getRotatedCCW in interface IRotatable<Polygon>
      Parameters:
      alpha - the rotation angle
      cx - x-component of the center point for the rotation
      cy - y-component of the center point for the rotation
      Returns:
      the resulting Polygon
    • getRotatedCCW

      public Polygon getRotatedCCW(Angle alpha, Point center)
      Rotates this Rectangle counter-clock-wise by the given Angle around the given Point. If the rotation Angle is not an integer multiple of 90 degrees, the resulting figure cannot be expressed as a Rectangle object. That's why this method returns a Polygon instead.
      Specified by:
      getRotatedCCW in interface IRotatable<Polygon>
      Parameters:
      alpha - the rotation angle
      center - the center point for the rotation
      Returns:
      the resulting Polygon
    • getRotatedCW

      public Polygon getRotatedCW(Angle alpha)
      Rotates this Rectangle clock-wise by the given Angle around the center (AbstractRectangleBasedGeometry.getCenter()) of this Rectangle.
      Specified by:
      getRotatedCW in interface IRotatable<Polygon>
      Parameters:
      alpha - the rotation Angle
      Returns:
      the resulting Polygon
      See Also:
    • getRotatedCW

      public Polygon getRotatedCW(Angle alpha, double cx, double cy)
      Rotates this Rectangle clock-wise by the given Angle alpha around the given Point (cx, cy). If the rotation Angle is not an integer multiple of 90 degrees, the resulting figure cannot be expressed as a Rectangle object. That's why this method returns a Polygon instead.
      Specified by:
      getRotatedCW in interface IRotatable<Polygon>
      Parameters:
      alpha - the rotation angle
      cx - x-component of the center point for the rotation
      cy - y-component of the center point for the rotation
      Returns:
      the resulting Polygon
    • getRotatedCW

      public Polygon getRotatedCW(Angle alpha, Point center)
      Rotates this Rectangle clock-wise by the given Angle alpha around the given Point. If the rotation Angle is not an integer multiple of 90 degrees, the resulting figure cannot be expressed as a Rectangle object. That's why this method returns a Polygon instead.
      Specified by:
      getRotatedCW in interface IRotatable<Polygon>
      Parameters:
      alpha - the rotation angle
      center - 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)
      Returns a Polygon, which represents the transformed Rectangle.
      Specified by:
      getTransformed in interface IGeometry
      Specified by:
      getTransformed in interface IShape
      Parameters:
      t - The AffineTransform to be applied
      Returns:
      a transformed Path representation of this IGeometry
      See Also:
    • 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
    • intersect

      public Rectangle intersect(Rectangle r)
      Sets the bounds of this Rectangle to the intersection of this Rectangle with the given one.
      Parameters:
      r - The Rectangle to intersect this Rectangle with.
      Returns:
      this for convenience.
    • isEmpty

      public boolean isEmpty()
      Returns true if this Rectangle's width or height is less than or equal to 0.
      Returns:
      true if this Rectangle is (imprecisely) considered to be empty
    • 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.
      See Also:
    • toPolygon

      public Polygon toPolygon()
      Converts this Rectangle into a Polygon representation. The control points used to construct the polygon are the border points returned by getPoints().
      Returns:
      A Polygon representation for this Rectangle
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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.
    • touches

      public boolean touches(Line l)
      Tests whether this Rectangle and the given Line touch, i.e. whether they have at least one point in common.
      Parameters:
      l - The Line to test.
      Returns:
      true if this Rectangle and the given Line share at least one common point, false otherwise.
    • touches

      public boolean touches(Rectangle r)
      Tests whether this Rectangle and the given other Rectangle touch, i.e. whether they have at least one point in common.
      Parameters:
      r - The Rectangle to test
      Returns:
      true if this Rectangle and the given Rectangle share at least one common point, false otherwise.
      See Also:
    • 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:
      this for convenience
    • union

      public Rectangle union(double x, double y)
      Updates this Rectangle's bounds so that the Point given by (x,y) is contained.
      Parameters:
      x - The x-coordinate of the Point to union with
      y - The y-coordinate of the Point to union with
      Returns:
      this for convenience
    • union

      public Rectangle union(double x, double y, double w, double h)
      Updates this Rectangle's bounds to the union of this Rectangle and the Rectangle with location (x, y) and size(w, h).
      Parameters:
      x - The x-coordinate of the Rectangle to union with.
      y - The y-coordinate of the Rectangle to union with
      w - The width of the Rectangle to union with
      h - The height of the Rectangle to union with
      Returns:
      this for convenience
    • union

      public Rectangle union(Point p)
      Updates this Rectangle's bounds so that the given Point is included within.
      Parameters:
      p - The Point to union with
      Returns:
      this for convenience
    • union

      public Rectangle union(Rectangle r)
      Updates this Rectangle's bounds to the union of this Rectangle and the Rectangle.
      Parameters:
      r - The Rectangle to union with
      Returns:
      this for convenience
    • expand

      public Rectangle expand(double h, double v)
      Expands the horizontal and vertical sides of this AbstractRectangleBasedGeometry with the values provided as input, and returns this for convenience. The location of its center is kept constant.
      Parameters:
      h - the horizontal increment
      v - the vertical increment
      Returns:
      this for convenience
    • expand

      public Rectangle expand(double left, double top, double right, double bottom)
      Expands this AbstractRectangleBasedGeometry by the given amounts, and returns this for convenience.
      Parameters:
      left - the amount to expand the left side
      top - the amount to expand the top side
      right - the amount to expand the right side
      bottom - the amount to expand the bottom side
      Returns:
      this for convenience
    • 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
    • getCenter

      public Point getCenter()
      Returns the center Point of this AbstractRectangleBasedGeometry.
      Returns:
      the center Point of this AbstractRectangleBasedGeometry
    • getExpanded

      public Rectangle getExpanded(double h, double v)
      Returns a new expanded AbstractRectangleBasedGeometry, where the sides are incremented by the horizontal and vertical values provided. The center of the AbstractRectangleBasedGeometry is maintained constant.
      Parameters:
      h - The horizontal increment
      v - The vertical increment
      Returns:
      a new expanded AbstractRectangleBasedGeometry
    • getExpanded

      public Rectangle getExpanded(double left, double top, double right, double bottom)
      Creates and returns a new AbstractRectangleBasedGeometry with the bounds of this AbstractRectangleBasedGeometry expanded by the given insets.
      Parameters:
      left - the amount to expand the left side
      top - the amount to expand the top side
      right - the amount to expand the right side
      bottom - the amount to expand the bottom side
      Returns:
      a new expanded AbstractRectangleBasedGeometry
    • getHeight

      public final double getHeight()
      Returns the height of this AbstractRectangleBasedGeometry.
      Returns:
      the height of this AbstractRectangleBasedGeometry
    • getLocation

      public Point getLocation()
      Returns a Point specifying the x and y coordinates of this AbstractRectangleBasedGeometry.
      Returns:
      a Point representing the x and y coordinates of this AbstractRectangleBasedGeometry
    • getScaled

      public Rectangle 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<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
      Parameters:
      factor - scale-factor
      Returns:
      the new, scaled object
    • getScaled

      public Rectangle getScaled(double factorX, double factorY)
      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<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
      Parameters:
      factorX - x-scale-factor
      factorY - y-scale-factor
      Returns:
      the new, scaled object
    • getScaled

      public Rectangle getScaled(double factor, double centerX, double centerY)
      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<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
      Parameters:
      factor - scale-factor
      centerX - x-coordinate of the relative Point for the scaling
      centerY - y-coordinate of the relative Point for the scaling
      Returns:
      the new, scaled object
    • getScaled

      public Rectangle getScaled(double factorX, double factorY, double centerX, double centerY)
      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<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
      Parameters:
      factorX - x-scale-factor
      factorY - y-scale-factor
      centerX - x-coordinate of the relative Point for the scaling
      centerY - y-coordinate of the relative Point for the scaling
      Returns:
      the new, scaled object
    • getScaled

      public Rectangle getScaled(double factorX, double factorY, 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<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
      Parameters:
      factorX - x-scale-factor
      factorY - y-scale-factor
      center - relative Point for the scaling
      Returns:
      the new, scaled object
    • getScaled

      public Rectangle 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<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
      Parameters:
      factor - scale-factor
      center - relative Point for the scaling
      Returns:
      the new, scaled object
    • getShrinked

      public Rectangle getShrinked(double h, double v)
      Returns a new AbstractRectangleBasedGeometry, where the sides are shrinked by the horizontal and vertical values supplied. The center of this AbstractRectangleBasedGeometry is kept constant.
      Parameters:
      h - horizontal reduction amount
      v - vertical reduction amount
      Returns:
      a new, shrinked AbstractRectangleBasedGeometry
    • getShrinked

      public Rectangle getShrinked(double left, double top, double right, double bottom)
      Returns a new AbstractRectangleBasedGeometry shrinked by the specified insets.
      Parameters:
      left - the amount to shrink the left side
      top - the amount to shrink the top side
      right - the amount to shrink the right side
      bottom - the amount to shrink the bottom side
      Returns:
      a new, shrinked AbstractRectangleBasedGeometry
    • getSize

      public final Dimension getSize()
      Returns a Dimension that records the width and height of this AbstractRectangleBasedGeometry.
      Returns:
      a Dimension that records the width and height of this AbstractRectangleBasedGeometry
    • getTranslated

      public Rectangle 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<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
      Parameters:
      dx - x-translation
      dy - y-translation
      Returns:
      a new, translated object
    • getTranslated

      public Rectangle getTranslated(Point pt)
      Description copied from interface: ITranslatable
      Translates a copy of this object by the given Point.
      Specified by:
      getTranslated in interface ITranslatable<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
      Parameters:
      pt - translation Point
      Returns:
      a new, translated object
    • getWidth

      public final double getWidth()
      Returns the width of this AbstractRectangleBasedGeometry.
      Returns:
      the width of this AbstractRectangleBasedGeometry
    • getX

      public final double getX()
      Returns the x coordinate this AbstractRectangleBasedGeometry.
      Returns:
      the x coordinate this AbstractRectangleBasedGeometry
    • getY

      public final double getY()
      Returns the y coordinate of this AbstractRectangleBasedGeometry.
      Returns:
      the y coordinate of this AbstractRectangleBasedGeometry
    • scale

      public Rectangle 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<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
      Parameters:
      factor - scale-factor
      Returns:
      this for convenience
    • scale

      public Rectangle 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<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
      Parameters:
      fx - x-scale-factor
      fy - y-scale-factor
      Returns:
      this for convenience
    • scale

      public Rectangle 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<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
      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 Rectangle 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<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
      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 Rectangle 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<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
      Parameters:
      fx - x-scale-factor
      fy - y-scale-factor
      center - relative Point for the scaling
      Returns:
      this for convenience
    • scale

      public Rectangle 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<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
      Parameters:
      factor - scale-factor
      center - relative Point for the scaling
      Returns:
      this for convenience
    • setBounds

      public final Rectangle setBounds(double x, double y, double w, double h)
      Sets the x, y, width, and height values of this AbstractRectangleBasedGeometry to the given values.
      Parameters:
      x - the new x-coordinate
      y - the new y-coordinate
      w - the new width
      h - the new height
      Returns:
      this for convenience
    • setBounds

      public final Rectangle setBounds(Point loc, Dimension size)
      Sets the x, y, width, and height values of this AbstractRectangleBasedGeometry to the respective values specified by the passed-in Point and the passed-in Dimension.
      Parameters:
      loc - the Point specifying the new x and y coordinates of this AbstractRectangleBasedGeometry
      size - the Dimension specifying the new width and height of this AbstractRectangleBasedGeometry
      Returns:
      this for convenience
    • setBounds

      public final Rectangle setBounds(Rectangle r)
      Sets the x and y coordinates and the width and height of this AbstractRectangleBasedGeometry to the respective values of the given Rectangle.
      Parameters:
      r - the Rectangle specifying the new x, y, width, and height values of this AbstractRectangleBasedGeometry
      Returns:
      this for convenience
    • setHeight

      public final Rectangle setHeight(double height)
      Sets the height of this AbstractRectangleBasedGeometry to the given value.
      Parameters:
      height - the new height
      Returns:
      this for convenience
    • setLocation

      public final Rectangle setLocation(double x, double y)
      Sets the x and y coordinates of this AbstractRectangleBasedGeometry to the specified values.
      Parameters:
      x - the new x coordinate of this AbstractRectangleBasedGeometry
      y - the new y coordinate of this AbstractRectangleBasedGeometry
      Returns:
      this for convenience
    • setLocation

      public final Rectangle setLocation(Point p)
      Sets the x and y coordinates of this AbstractRectangleBasedGeometry to the respective values of the given Point.
      Parameters:
      p - the Point specifying the new x and y coordinates of this AbstractRectangleBasedGeometry
      Returns:
      this for convenience
    • setSize

      public final Rectangle setSize(Dimension d)
      Sets the width and height of this AbstractRectangleBasedGeometry to the width and height of the given Dimension.
      Parameters:
      d - the Dimension specifying the new width and height of this AbstractRectangleBasedGeometry
      Returns:
      this for convenience
    • setSize

      public final Rectangle setSize(double w, double h)
      Sets the width and height of this AbstractRectangleBasedGeometry to the given values.
      Parameters:
      w - the new width of this AbstractRectangleBasedGeometry
      h - the new height of this AbstractRectangleBasedGeometry
      Returns:
      this for convenience
    • setWidth

      public final Rectangle setWidth(double width)
      Sets the width of this AbstractRectangleBasedGeometry to the passed-in value.
      Parameters:
      width - the new width of this AbstractRectangleBasedGeometry
      Returns:
      this for convenience
    • setX

      public final Rectangle setX(double x)
      Sets the x-coordinate of this AbstractRectangleBasedGeometry to the given value.
      Parameters:
      x - The new x-coordinate.
      Returns:
      this for convenience.
    • setY

      public final Rectangle setY(double y)
      Sets the y-coordinate of this AbstractRectangleBasedGeometry to the given value.
      Parameters:
      y - The new y-coordinate.
      Returns:
      this for convenience.
    • shrink

      public Rectangle shrink(double h, double v)
      Shrinks the sides of this AbstractRectangleBasedGeometry by the horizontal and vertical values provided as input, and returns this AbstractRectangleBasedGeometry for convenience. The center of this AbstractRectangleBasedGeometry is kept constant.
      Parameters:
      h - horizontal reduction amount
      v - vertical reduction amount
      Returns:
      this for convenience
    • shrink

      public Rectangle shrink(double left, double top, double right, double bottom)
      Shrinks this AbstractRectangleBasedGeometry by the specified amounts.
      Parameters:
      left - the amount to shrink the left side
      top - the amount to shrink the top side
      right - the amount to shrink the right side
      bottom - the amount to shrink the bottom side
      Returns:
      this for convenience
    • translate

      public Rectangle 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<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
      Parameters:
      dx - x-translation
      dy - y-translation
      Returns:
      this for convenience
    • translate

      public Rectangle translate(Point p)
      Description copied from interface: ITranslatable
      Translates the object by the given Point.
      Specified by:
      translate in interface ITranslatable<T extends org.eclipse.gef.geometry.planar.AbstractRectangleBasedGeometry<?,?>>
      Parameters:
      p - translation Point
      Returns:
      this for convenience
    • clone

      public Object clone()
      Overridden with public visibility as recommended within Cloneable .
      Overrides:
      clone in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
      See Also: