This problem was also occuring with polygons. But it seems to have been fixed in JDK 
1.4.0:
I was able to reproduce this problem using JDK 1.3.1, but it worked just fine with JDK 
1.4.0beta3

Emmanuel

Anders Hasselkvist wrote:

> If you run the code below you will see a small white area in the lower right part of 
>the generalpath. This is a simple path but I have quite complex paths and would like 
>to know if there is an easy way to fix this? It seams like fill and draw methods draw 
>things with some kind of offset from each other. I have tried to create two different 
>generalpaths, one for draw and one for fill. Then I moved (translated) the 
>generalpath used by fill one pixel down and one pixel to the right. Unfortunately I 
>ended up having small white areas in the upper left part of my paths instead.
>
> Anders
>
> //--------------------------------------------------------
> import java.awt.*;
> import java.awt.geom.*;
> import javax.swing.*;
>
> public class GPPanel extends JPanel {
>   private JFrame frame;
>   private Dimension dim = new Dimension(400,400);
>
>   int[] px = {200,300,200,100};
>   int[] py = {100,200,300,200};
>
>   GeneralPath gp = new GeneralPath();
>
>   public GPPanel (JFrame frame) {
>     this.frame = frame;
>
>     gp.moveTo(px[0], py[0]);
>     for (int i=1; i<px.length; i++)
>       gp.lineTo(px[i], py[i]);
>
>     gp.closePath();
>
>     setBackground(Color.white);
>     setPreferredSize(dim);
>   }
>
>   public void paintComponent(Graphics g) {
>     super.paintComponent(g);
>     Graphics2D g2d = (Graphics2D)g;
>
>     g2d.setColor(getBackground());
>     g2d.fillRect(0, 0, dim.width, dim.height);
>
>     g2d.setColor(Color.gray);
>     g2d.fill(gp);
>
>     g2d.setColor(Color.red);
>     g2d.draw(gp);
>   }
>
>   public static void main(String[] args) {
>     JFrame f = new JFrame();
>     GPPanel p = new GPPanel(f);
>
>     f.getContentPane().add(p);
>     f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>     f.pack();
>     f.show();
>   }
> }
> //--------------------------------------------------------
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff JAVA2D-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

--
E. Pietriga            |  MIT/LCS
[EMAIL PROTECTED]        |  Room NE 43-350
http://www.w3.org      |  200 Technology Square
tel (+1) 617-253-0466  |  Cambridge, MA 02139 USA

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to