Drawing dashed lines in Swing can be surprisingly slow, and worse, the default implementation seems to be sub-optimal. Of course, for most apps, this isn’t a big deal, but performance-sensitive apps that draw a lot of dashed lines (or draw them often) can suffer. The first thing to optimize is to only draw the portion […]
Tag Archives: graphics
Unit testing graphics code
Posted April 1, 2011 – 6:07 pmI recently worked on a project that involved heavy use of custom graphics. Specifically, lots of lines. The code was sufficiently important and complex that it needed to be unit tested. However, I had never unit tested drawing code before. A simple strategy would be to paint to an image, then compare the result with […]