Package hec.geometry

Class LocalRect

java.lang.Object
hec.geometry.LocalRect

public class LocalRect extends Object
Represents rectangles in local coordinate space. A screen coordinate convention is assumed where the y coordinate increases in the downward direction.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
    bottom coordinate
    int
    left coordinate
    int
    right coordinate
    int
    top coordinate
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    LocalRect(int rl, int rt, int rr, int rb)
     
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the area of the rectangle.
    boolean
    contains(int ptx, int pty)
     
    boolean
     
    void
    Copies the coordinates of the given rectangle.
    returns a new LocalRect that represents the intersection of this rect and the given rect.
    void
    Increases the size of the rectangle to include the given point.
    void
    Increases the size of the rectangle to include the given rectangle.
    int
    Gets the height of the rectangle.
    void
    init(int rl, int rt, int rr, int rb)
    Sets corners of the rectangle to given values.
    void
    init(LocalPt tl, LocalPt br)
    Sets all corners of the rectangle the given points.
    void
    Sets all corners of the rectangle the given rectangle.
    void
    Sets all corners of the rectangle the the given point.
    boolean
     
    boolean
    Rectangle is valid if all corners are valid ints and area is not zero.
    void
    insures that the east coordinate is greater than the west, and that the north coordinate is greater than the south.
    int
    Gets the width of the rectangle.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • l

      public int l
      left coordinate
    • t

      public int t
      top coordinate
    • r

      public int r
      right coordinate
    • b

      public int b
      bottom coordinate
  • Constructor Details

    • LocalRect

      public LocalRect()
    • LocalRect

      public LocalRect(int rl, int rt, int rr, int rb)
    • LocalRect

      public LocalRect(LocalPt tl, LocalPt br)
    • LocalRect

      public LocalRect(LocalRect rc)
  • Method Details

    • width

      public int width()
      Gets the width of the rectangle.
      Returns:
      returns r - l.
    • height

      public int height()
      Gets the height of the rectangle.
      Returns:
      returns b - t.
    • area

      public int area()
      Gets the area of the rectangle.
      Returns:
      returns width*height.
    • copy

      public void copy(LocalRect rc)
      Copies the coordinates of the given rectangle.
    • init

      public void init(int rl, int rt, int rr, int rb)
      Sets corners of the rectangle to given values.
    • init

      public void init(LocalPt tl, LocalPt br)
      Sets all corners of the rectangle the given points.
    • init

      public void init(LocalRect rc)
      Sets all corners of the rectangle the given rectangle.
    • initToPoint

      public void initToPoint(LocalPt p)
      Sets all corners of the rectangle the the given point.
    • growToPoint

      public void growToPoint(LocalPt p)
      Increases the size of the rectangle to include the given point.
    • growToRect

      public void growToRect(LocalRect rc)
      Increases the size of the rectangle to include the given rectangle.
    • justify

      public void justify()
      insures that the east coordinate is greater than the west, and that the north coordinate is greater than the south.
    • isValid

      public boolean isValid()
      Rectangle is valid if all corners are valid ints and area is not zero.
    • contains

      public boolean contains(int ptx, int pty)
    • contains

      public boolean contains(LocalPt pt)
    • intersects

      public boolean intersects(LocalRect rc)
    • getIntersection

      public LocalRect getIntersection(LocalRect rc)
      returns a new LocalRect that represents the intersection of this rect and the given rect. if the intersection is null, null is returned