JDK-4270230 : RFE: insufficient precision in general paths
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.2.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1999-09-09
  • Updated: 2000-09-18
  • Resolved: 2000-09-18
Related Reports
Duplicate :  
Description

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) 
======================================================================

Comments
WORK AROUND Name: rlT66838 Date: 09/09/99 Ignore the affine transform mechanism in the 2D API and do all your own transformations to device coordinates. ======================================================================
11-06-2004