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

RFE: insufficient precision in general paths

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.2
    • client-libs
    • 2d
    • generic
    • generic



      Name: rlT66838 Date: 09/09/99


      The awt.geom.GeneralPath class stores coordinates internally as
      floats rather than doubles. Since drawing with Strokes uses
      the GeneralPath class as an intermediary, it becomes quite easy
      to suffer catastropic loss of precision unless one works directly
      in device coordinates (supposedly unnecessary with the 2D api!)

      As an example, consider the code
          public void render(Graphics2D g, double offset) {
      Line2D l = new Line2D.Double (off, off, off+1.0, off+1.0);
      g.setStroke(new BasicStroke(1f));
      g.translate(-off, -off);
      g.scale(100.0, 100.0);
      g.draw(l);
          }
      which works correctly only if render is called with offset less
      than about 1e+7 in absolute value. This kind of example occurs
      naturally in geographic mapping applications.

      Note further that all the other classes in awt.geom have 2
      variants, float and double. GeneralPath should too.
      (Review ID: 94214)
      ======================================================================

            flar Jim Graham
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: