tmpkus / piccolo2d

Automatically exported from code.google.com/p/piccolo2d
0 stars 0 forks source link

artifacts in JComponent border using PSwing #213

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. compile and run the attached example, TestPSwingBorder.java
2. examine the borders of the 2 identical JComponents, one rendered with 
PSwing, the other with pure Swing

What is the expected output? What do you see instead?

Expected that the borders (in this case, blue line borders) would look the same 
for PSwing and pure Swing. Instead, the PSwing border contains white horizontal 
and vertical lines (see attached screenshot, TestPSwingBorder.jpg).  This only 
seems to happen when the PSwing is scaled up, and only with some scale values.

This has been observed on Win7 and Mac OS, with Java 5 and 6.  Most recent 
tests were on Win7 (6.1 build 7600) and Mac OS 10.6.6, both with Java 1.6.0_22.

Original issue reported on code.google.com by cmal...@pixelzoom.com on 28 Mar 2011 at 11:56

Attachments:

GoogleCodeExporter commented 9 years ago
Interesting, MatteBorder doesn't do this. In you code, replace LineBorder with:

setBorder(BorderFactory.createMatteBorder(10,10,10,10,Color.blue));

LineBorder's implementation (the jdk source code that comes w/ MacOS) of 
paintBorder() looks like this:

        for(i = 0; i < thickness; i++)  {
        g.drawRect(x + i, y + i, width - i - i - 1, height - i - i - 1);
        }

It just draws a consecutive of rectangles. I think when the Graphics object is 
scaled this approach is leaving whitespace between the consecutive lines.

MatteBorder's implementation uses fillRects instead of consecutive of 
single-pixel-width rectangles.

Not sure what Piccolo2D can do about this. I suppose we could detect the use of 
LineBorder and recover from their implementation (ie., reimplement the painting 
of LineBorders ourself to do something like what Matte does.)

Original comment by atdi...@gmail.com on 29 Mar 2011 at 2:06

GoogleCodeExporter commented 9 years ago
Thanks for investigating atdixon!  That's an incredibly lame implementation of 
LineBorder.  And I suppose that the Win & Linux implementations are identical.

Using a MatteBorder seems like a fine workaround. So I don't think Piccolo 
should spend any further time on this. I'm going to close this as "Won't Fix".  
If anyone disagrees with this feel free to reopen.

Original comment by cmal...@pixelzoom.com on 29 Mar 2011 at 4:51

GoogleCodeExporter commented 9 years ago
LineBorder supports rounded rectangles, not sure if MatteBorder does.

Let's leave this open for now b/c it seems like such a common thing to want to 
do.

Original comment by atdi...@gmail.com on 29 Mar 2011 at 4:58

GoogleCodeExporter commented 9 years ago
Ah, good point about rounded rectangles.  I agree, leave open for now.

Original comment by cmal...@pixelzoom.com on 29 Mar 2011 at 5:02

GoogleCodeExporter commented 9 years ago

Original comment by heue...@gmail.com on 31 Aug 2012 at 8:27

GoogleCodeExporter commented 9 years ago

Original comment by heue...@gmail.com on 31 Aug 2012 at 8:28

GoogleCodeExporter commented 9 years ago

Original comment by heue...@gmail.com on 31 Aug 2012 at 8:30

GoogleCodeExporter commented 9 years ago

Original comment by heue...@gmail.com on 26 Nov 2013 at 11:23