-
Bug
-
Resolution: Fixed
-
P3
-
1.4.1, 1.4.2
-
b26
-
x86
-
windows_xp
Name: jk109818 Date: 09/03/2003
FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
FULL OS VERSION :
Win XP
EXTRA RELEVANT SYSTEM CONFIGURATION :
tested on NVidia GForce4 Ti 4600 and ATI Mobility Radeon 7500 AGP.
A DESCRIPTION OF THE PROBLEM :
Creating a graphics scaled for twips g.scale(0.05,0.05) and setting a Basic Font with dashes and width 20.0. The dashes don't show. Vary either the scale or the width (20.01) and the dashes show. It appears the dashes fail when scale * width = 1.0
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See the full source code attached. In summary:
Creating a graphics scaled for twips g.scale(0.05,0.05) and setting a Basic Font with dashes of width 20.0
private static float[] DASHES = {400.0f, 160.0f};
BasicStroke(20.0f,BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER,1.0f,DASHES,0.0f);
drawing g.draw(new RoundRectangle2D.Double(480,480,6000,4000,800,800));
produces a solid rounded rectangle - no dashes.
Changing either the scale (0.04-0.06) or the width (19.9-20.1) and the dashes show. It looks like it fails when scale*width=1.0
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Dashes should appear when scale is 0.05 and stroke width is 20
ACTUAL -
A solid line instead of a dashed line was used to stroke the rounded rectangle
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
// TestDashes.java
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
public class TestDashes
{
public static void main(String[] args)
{
new TestDashes();
}
public TestDashes()
{
m_Frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
m_Frame.getContentPane().add(new MyCanvas());
m_Frame.setBounds(new Rectangle(50,50,600,400));
m_Frame.setVisible(true);
}
private JFrame m_Frame = new JFrame("Test Dashes");
private static float[] DASHES = {400.0f, 160.0f};
private class MyCanvas extends JComponent
{
public void paint(Graphics dontUseThis)
{
Graphics2D g = (Graphics2D)dontUseThis;
g.scale(0.05,0.05);
// this rounded rect draws solid
BasicStroke s1 = new BasicStroke(20.0f,BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER,1.0f,DASHES,0.0f);
g.setStroke(s1);
g.draw(new RoundRectangle2D.Double(60,60,6000,4000,800,800));
// this rounded rect draws dashes properly - only diff is 20.0 -> 20.1
BasicStroke s2 = new BasicStroke(20.1f,BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER,1.0f,DASHES,0.0f);
g.setStroke(s2);
g.draw(new RoundRectangle2D.Double(480,480,6000,4000,800,800));
}
}
}
// end of TestDashes.java
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
When working in twips, always add 0.1 to the stroke width - 0.1 twips is not visible (1/14400 of an inch) but it makes the dashes work.
Release Regression From : 1.3.1_08
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Incident Review ID: 191885)
======================================================================