Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Painting JLabel with border not showing text but filled rectangle #25

Closed
markustw opened this issue Mar 31, 2020 · 3 comments
Closed

Painting JLabel with border not showing text but filled rectangle #25

markustw opened this issue Mar 31, 2020 · 3 comments

Comments

@markustw
Copy link

Creating SVG of a JLabel with a colored border with SVGGraphics2D paints a filled rectangle in the size of the label instead of a text surrounded by a rectangle:

JLabel label = new JLabel("Label with border");
label.setBorder(BorderFactory.createLineBorder(Color.YELLOW)); // removing border shows text
label.setSize(label.getPreferredSize());

SVGGraphics2D graphics = new SVGGraphics2D(100, 40);
label.printAll(graphics);

Sorry for filing in another issue. We just tested JFreeSVG for generating SVG in our application. This and issue #24 are the two major issues we found.

@jfree
Copy link
Owner

jfree commented Apr 1, 2020

Thanks for the report. I had a quick look, the LineBorder class in Swing is drawing the border by filling a path with an inner and an outer boundary:

Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
path.append(outer, false);
path.append(inner, false);
g2d.fill(path);
g2d.setColor(oldColor);

I'll have to dig deeper into how the path is translated for rendering in SVG, there must be some error there.

@jfree
Copy link
Owner

jfree commented Apr 1, 2020

The path element was using the default winding rule, whereas in this case the "even-odd" rule is required. I've committed a fix for this (to be included in the next release, 4.2).

@jfree jfree closed this as completed Apr 1, 2020
@markustw
Copy link
Author

Thank you. Please note that OrsonPdf has the same issue. Shall I open an Issue for OrsonPdf ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants