I have been looking at a customer PDF where we did not display the filled lines on the page. Firing up my debug tools showed that the lines were being converted to shapes and the clip and the color was correct. So where are the lines?
It turned out that because the lines had a width or height of 1 and a stroke width of less than 1, they were not being drawn. Or rather they were being drawn but with no width and no pixels. The fix is to use fillRect as this code snippet shows
//thin lines do not appear unless we use fillRect
g2.fillRect(currentShape.getBounds().x, currentShape.getBounds().y, currentShape.getBounds().width, currentShape.getBounds().height);
And the lines now appear! More of a Java bug, but still interesting… Have you seen any similar bugs with thin lines in Java?
Latest posts by Mark Stephens (see all)
- 4 ways Companies can make remote working successful - December 21, 2017
- My experience of a Turkish bath (visiting Istanbul for DevFest) - November 24, 2017
- My 5 key takeaways from JavaOne 2017 - October 6, 2017
- My notes and pictures from thursday JavaOne 2017 - October 5, 2017
- My notes and pictures from Wednesday JavaOne 2017 - October 5, 2017