Mark Stephens

Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX.

He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

Clipping is slow in Java

28 sec read

In general, Java has developed into a fairly nifty language, with a good execution speed. However, some operations are still disappointing in comparison to other languages…

I have been investigating a PDF file to see why it is slow on our PDF renderer. Running it in my favourite Java Profiler showed that it spent a lot of time in the setClip command, even though I was setting the clip to a simple Rectangle. I can understand a hit on a complex shape but not a simple Shape. Optimising the code to reduce calls to setClip() has speeded up that PDF file by an order of magnitude.

So I  am now working though my code to ensure that I call setClip() very sparingly. Are there any Java language features which you find annoyingly slow?

Mark Stephens

Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX.

He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

Leave a Reply

Your email address will not be published. Required fields are marked *