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

RFE: Return tighter bounds for GeneralPath.getBounds2D()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.1
    • client-libs
    • 2d
    • x86
    • windows_xp



      Name: rmT116609 Date: 04/21/2003


      A DESCRIPTION OF THE REQUEST :
      Currently GeneralPath.getBounds2D() returns the bounding box of all control points. Although this is a correct implementation of the Shape.getBounds2D() contract, this method would be much more useful if it returned the geometric bounds the shape.


      JUSTIFICATION :
      Although the bounds of a GeneralPath can be calculated by creating an Area object (Area calculates the tightest bounds) from the GeneralPath this can be very inconvenient.

      Several other AWT APIs such as PaintContext may rely on accurate tight getBounds() information for their implementation. Unfortunately the shape being painted can not be accessed from within PaintContext making it impossible to deduce the tight bounds from the information passed to it.

      This need has shown up before with the following submittals 4437710, 4197755, 4109135, 4099380, 4082610.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Have all shape implementations return the tightest bounding box for getBounds2D() whenever possible. This would make the J2SE implementations of Shape more consistent, powerful and easier to use.
      GeneralPath getBounds2D() returns the bounds of all control points.

      ---------- BEGIN SOURCE ----------
      Graphics2D g;

      GeneralPath gp = new GeneralPath();
      gp.moveTo(200, 200);
      gp.curveTo(700, 300, 1200, 700, 400, 800);
      gp.curveTo(200, 600, 150, 300, 200, 200);
      gp.closePath();
      g.paint(gp);
      g.paint(gp.getBounds2D());
      ---------- END SOURCE ----------
      (Review ID: 184470)
      ======================================================================

            avu Alexey Ushakov
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: