-
Bug
-
Resolution: Fixed
-
P2
-
1.2.0, 1.3.0
-
beta2
-
x86
-
windows_95, windows_nt
Name: gsC80088 Date: 02/10/99
BasicStroke with width=0 should draw lines as thin as possible for the device.
The current behaviour (in JDK 1.2fcs) work well in most case. But if we use
an AffineTransform with a high ratio scaleX/scaleY, lines become to width. The source code below illustrate the problem:
import java.awt.*;
import javax.swing.*;
public class Test extends JFrame
{
private final Shape shape;
private final double scaleX,scaleY;
public Test(double width, double height)
{
super("width/height=3D"+width/height);
shape =3D new Ellipse2D.Double(0.25*width, 0.25*height, width, height);
scaleX =3D 200/width;
scaleY =3D 200/height;
setSize(300,300);
show();
}
public void paint(Graphics g)
{
final Graphics2D g2=3D(Graphics2D) g;
g2.scale(scaleX,scaleY);
g2.setStroke(new BasicStroke(0));
g2.draw(shape);
}
public static void main(String[] args)
{
new Test(200, 200);
new Test(1, 10000);
new Test(10000, 1);
new Test(0.01, 10000);
new Test(10000, 0.01);
}
}
A ratio of 1E+6 in "real life" may seem exaggerate, but it is not. A typical
example is time series. In a three-months temperature measurement, we have a
range of almost 1E+10 milliseconds on the X axis (because Date objects measure
time in milliseconds...), but a range of only a few degrees on the Y axis.
We got trouble when we try to plot the graph of a time series with such scales.
(Review ID: 53954)
======================================================================
- duplicates
-
JDK-4205908 Java2D: BasicStroke in XOR mode does not work properly
- Closed