Package hec.map

Class LocalRect

java.lang.Object
hec.map.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 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

    • equals

      public boolean equals(LocalRect rc)
    • 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)
    • contains

      public boolean contains(LocalRect rect)
    • 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
    • toString

      public String toString()
      Overrides:
      toString in class Object