|
Description
|
orig synopsis: "Extraneous lines in drawing when using Arc2D and Area classes"
[7/11/99 xxxxx@xxxxx -- since this only occurs for some combinations of angles, it does appear to be a real bug.
For example, a start angle of 3 degrees, with angular extent of 49 doesn't work, but start angle of 18 degrees,
with angular extent of 35 DOES work.]
User's test case:
I apologize if you receive a duplicate submission as I
inadvertently hit
a wrong key when entering my first submission
which sent me to a new page.
I am working on an app where I want to draw part of an annulus
(basically a pie slice with a smaller pie slice removed from it).
Below is some code which shows the problem I am seeing. When I
run the code, extraneous lines are drawn along the straight edges
of the annulus section. These extraneous lines only appear for
certain combinations of starting angles and angular extents.
The
problem might be in the Arc2D draw method or in the Area subtract
method.
I have searched the bug parade and did not see any mention of
this particular problem.
I am using Java 1.2.2 (build JDK-1.2.2-W) on a NT 4.0 system.
Michael Carlin
xxxxx@xxxxx
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
public class AnnulusTest extends JComponent
{
public static void main( String[] args )
{
JFrame f = new JFrame();
f.getContentPane().add( new AnnulusTest() );
f.setSize( 400, 400 );
f.setVisible( true );
}
private Arc2D innerArc;
private Arc2D outerArc;
private Area annulusArea;
private int x0;
private int y0;
private int innerRadius;
private int outerRadius;
private double startAngle;
private double angularExtent;
public AnnulusTest()
{
this( 70, 150, 50, 120, 3, 49 );
}
public AnnulusTest( int x0, int y0, int innerRadius, int outerRadius,
double startAngle, double angularExtent )
{
this.x0 = x0;
this.y0 = y0;
this.innerRadius = innerRadius;
this.outerRadius = outerRadius;
this.startAngle = startAngle;
this.angularExtent = angularExtent;
innerArc = new Arc2D.Double();
innerArc.setArcByCenter( x0, y0, innerRadius, startAngle,
angularExtent, Arc2D.PIE );
outerArc = new Arc2D.Double();
outerArc.setArcByCenter( x0, y0, outerRadius, startAngle,
angularExtent, Arc2D.PIE );
annulusArea = new Area( outerArc );
annulusArea.subtract( new Area( innerArc ) );
}
public void paintComponent( Graphics g )
{
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint( RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_SPEED );
// Draw the outline of the resulting area.
g2.setPaint( Color.black );
g2.draw( annulusArea );
}
}
(Review ID: 85434)
======================================================================
|