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

AffineTransform.createTransformedShape().contains(Rectangle2D) incorrect for rectangles of 0 size

    Details

    • Subcomponent:
      2d
    • Introduced In Version:
    • Resolved In Build:
      b73
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0-ea"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b35)
      Java HotSpot(TM) Client VM (build 1.6.0-ea-b35, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      When using Shape.contains(Rectangle2D) when the rectangle is of 0 width, the result is incorrect. It should return a result similar to intersects(Rectangle2D) or contains(Point2D).


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
          public static void main(String[] args)
          {
              Rectangle rect = new Rectangle(-5, -5, 10, 10);
              Rectangle select1 = new Rectangle(1, 1, 1, 1);
              Rectangle select2 = new Rectangle(1, 1, 0, 0);
              Rectangle select3 = new Rectangle(100, 100, 1, 1);
              Rectangle select4 = new Rectangle(100, 100, 0, 0);
              
              System.err.println(rect + " contains(" + select1 + ") " + (rect.contains(select1)));
              System.err.println(rect + " contains(" + select2 + ") " + (rect.contains(select2))); //Should be true
              System.err.println(rect + " contains(" + select3 + ") " + (rect.contains(select3)));
              System.err.println(rect + " contains(" + select4 + ") " + (rect.contains(select4)));
              
              AffineTransform xform = new AffineTransform();
              xform.setToRotation(Math.PI / 4);
              Shape shape = xform.createTransformedShape(rect);
              
              System.err.println(shape + " contains(" + select1 + ") " + (shape.contains(select1)));
              System.err.println(shape + " contains(" + select2 + ") " + (shape.contains(select2)));
              System.err.println(shape + " contains(" + select3 + ") " + (shape.contains(select3)));
              System.err.println(shape + " contains(" + select4 + ") " + (shape.contains(select4))); //Should be false
              
          }

      ---------- END SOURCE ----------
      ###@###.### 2005-06-13 08:37:15 GMT

        Attachments

          Activity

            People

            • Assignee:
              flar Jim Graham
              Reporter:
              jssunw Jitender S (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: