Rectangle.intersection returning incorrect rectangle representation

XMLWordPrintable

    • Type: Bug
    • Resolution: Not an Issue
    • Priority: P4
    • None
    • Affects Version/s: 8u101
    • Component/s: client-libs
    • x86
    • other

      FULL PRODUCT VERSION :
      java version "1.8.0_101"
      Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.14393]

      A DESCRIPTION OF THE PROBLEM :
      The returned dimensions representation of a Rectangle when calling rectangle.intersection are incorrect.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Rectangle r1 = new Rectangle();
      r1.setBounds(3, 4, 4, 2);
      Rectangle r2 = new Rectangle();
      r2.setBounds(4, 3, 2, 3);

      Rectangle intersection = r1.intersection(r2);



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      When drawn by hand, the resulting intersection rectangle should be:
      x: 4
      y: 3
      width: 2
      height: 1
      ACTUAL -
      However the dimensions returned are:

      x: 4
      y: 4
      width: 2
      height: 2

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Rectangle r1 = new Rectangle();
      r1.setBounds(3, 4, 4, 2);
      Rectangle r2 = new Rectangle();
      r2.setBounds(4, 3, 2, 3);

      Rectangle intersection = r1.intersection(r2);
      ---------- END SOURCE ----------

            Assignee:
            Dmitry Markov
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: