Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4191600

contains() and empty Rectangle handling is inconsistant

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P5 P5
    • None
    • 1.2.0, 1.3.0
    • client-libs
    • 2d
    • Fix Understood
    • generic, x86
    • generic, windows_nt



      Name: gsC80088 Date: 11/19/98


      The documentation states a Rectangle with a negative
      width or height is empty;
      But, the isEmpty() function states it as less than
      or EQUAL to zero;
      But, an isEmpty() Rectangle of 0 width and height
      does draws a one pixel dot;
      But, with ANTIALIASING on the 0 Rectangle is NOT drawn;
      The same occurs for 0 width lines.
      A Rectangle with a width and height of 1 draws
      a 2 pixel square Rectangle with or without
      ANTIALIASING.
      Rectangle.contains(int X, int Y, int W, int H)
      incorrectly returns false when W or H equals 0 if
      the point (X, Y) is in the rectangle(Look at the
      source).

      The following form a consistant set of rules.

      Rectangle empty = new Rectangle(-1, -1);
      Rectangle point = new Rectangle(0, 0);
      Rectangle dot = new Rectangle(1, 1);
      Rectangle rect = new Rectangle(0, 0, 2, 2);

      A rectangle with negative width or height is
      never drawn and rect.contains(empty) return false
      for all posible locations of rect and empty.

      A rectangle with 0 width or height is never drawn.
      However, rect.contains(point) returns true when
      point is at (0, 0), (0, 1) or (1, 0).

      A rectangle with a width and height of 1 appears
      as a single pixel assuming a 1 to 1 user to
      device scaling. rect.contains(dot) returns true
      for the same locations given for "point".

      A rectangle with a width and height of 2 should
      appears twice the size of a rectangle with a
      width and height of 1 given any user to device
      scaling that doesn't introduce rounding errors.

      The following should hold for a point and dot
      both located at (0, 0):

      dot.contains(point) TRUE
      dot.contains(dot) TRUE
      point.contains(point) TRUE
      point.contains(dot) FALSE

      For rigor one could document the handling of
      Rectangles of size (0, 1) or (1, 0) but the
      behaviors should be clear at this point.

      END OF RULES -------

      Basicly a Rectangle of size 2x2 should appear
      twice the size of a Rectangle of size 1x1 and
      a Rectangle of size 0x0 should not appear but
      should act like a Point and be able to be contained
      in another Rectangle. The actual implementation
      violates all three of these rules and is
      inconsistant when used with ANTIALIASING.

      - dwood
      (Review ID: 42018)
      ======================================================================

            Unassigned Unassigned
            gstone Greg Stone
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: