Class Extent

java.lang.Object
drawit.shapegroups1.Extent

public class Extent
extends Object
Each instance of this class represents a rectangular area in a 2D coordinate system, whose edges are parallel to the coordinate axes. Note: the "top" and "bottom" terminology used by this class assumes that the Y axis points down, as is common in computer graphics. This class must deal with illegal arguments defensively.
  • Method Summary

    Modifier and Type Method Description
    boolean contains​(IntPoint point)
    Returns whether this extent, considered as a closed set of points (i.e.
    boolean equals​(Extent other)
    Returns whether this extent equals the given extent.
    int getBottom()
    Returns the Y coordinate of the edge parallel to the X axis with the largest Y coordinate.
    IntPoint getBottomRight()
    Returns the bottom-right corner of this extent.
    int getHeight()
    Returns the distance between the edges that are parallel to the X axis.
    int getLeft()
    Returns the X coordinate of the edge parallel to the Y axis with the smallest X coordinate.
    int getRight()
    Returns the X coordinate of the edge parallel to the Y axis with the largest X coordinate.
    int getTop()
    Returns the Y coordinate of the edge parallel to the X axis with the smallest Y coordinate.
    IntPoint getTopLeft()
    Returns the top-left corner of this extent.
    int getWidth()
    Returns the distance between the edges that are parallel to the Y axis.
    static Extent ofLeftTopRightBottom​(int left, int top, int right, int bottom)
    Returns an object representing the extent defined by the given left, top, right, and bottom.
    static Extent ofLeftTopWidthHeight​(int left, int top, int width, int height)
    Returns an object representing the extent defined by the given left, top, width, and height.
    Extent withBottom​(int newBottom)
    Returns an object that has the given bottom coordinate and the same left, top, and right coordinate as this object.
    Extent withHeight​(int newHeight)
    Returns an object that has the given height and the same left, top, and right coordinate as this object.
    Extent withLeft​(int newLeft)
    Returns an object that has the given left coordinate and the same right, top, and bottom coordinate as this object.
    Extent withRight​(int newRight)
    Returns an object that has the given right coordinate and the same left, top, and bottom coordinate as this object.
    Extent withTop​(int newTop)
    Returns an object that has the given top coordinate and the same left, right, and bottom coordinate as this object.
    Extent withWidth​(int newWidth)
    Returns an object that has the given width and the same left, top, and bottom coordinate as this object.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getLeft

      public int getLeft()
      Returns the X coordinate of the edge parallel to the Y axis with the smallest X coordinate.
    • getTop

      public int getTop()
      Returns the Y coordinate of the edge parallel to the X axis with the smallest Y coordinate.
    • getRight

      public int getRight()
      Returns the X coordinate of the edge parallel to the Y axis with the largest X coordinate.
    • getBottom

      public int getBottom()
      Returns the Y coordinate of the edge parallel to the X axis with the largest Y coordinate.
    • getWidth

      public int getWidth()
      Returns the distance between the edges that are parallel to the Y axis.
    • getHeight

      public int getHeight()
      Returns the distance between the edges that are parallel to the X axis.
    • getTopLeft

      public IntPoint getTopLeft()
      Returns the top-left corner of this extent.
    • getBottomRight

      public IntPoint getBottomRight()
      Returns the bottom-right corner of this extent.
    • contains

      public boolean contains​(IntPoint point)
      Returns whether this extent, considered as a closed set of points (i.e. including its edges and its vertices), contains the given point.
    • equals

      public boolean equals​(Extent other)
      Returns whether this extent equals the given extent.
    • ofLeftTopWidthHeight

      public static Extent ofLeftTopWidthHeight​(int left, int top, int width, int height)
      Returns an object representing the extent defined by the given left, top, width, and height.
    • ofLeftTopRightBottom

      public static Extent ofLeftTopRightBottom​(int left, int top, int right, int bottom)
      Returns an object representing the extent defined by the given left, top, right, and bottom.
    • withLeft

      public Extent withLeft​(int newLeft)
      Returns an object that has the given left coordinate and the same right, top, and bottom coordinate as this object.
    • withTop

      public Extent withTop​(int newTop)
      Returns an object that has the given top coordinate and the same left, right, and bottom coordinate as this object.
    • withRight

      public Extent withRight​(int newRight)
      Returns an object that has the given right coordinate and the same left, top, and bottom coordinate as this object.
    • withBottom

      public Extent withBottom​(int newBottom)
      Returns an object that has the given bottom coordinate and the same left, top, and right coordinate as this object.
    • withWidth

      public Extent withWidth​(int newWidth)
      Returns an object that has the given width and the same left, top, and bottom coordinate as this object.
    • withHeight

      public Extent withHeight​(int newHeight)
      Returns an object that has the given height and the same left, top, and right coordinate as this object.