Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

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?


Do you need to write or read JPEG in Java?

We have an easy guide on how to write JPEG in Java using ImageIO and JDeli. You can learn how to read/write most of the image files in ImageIO. However, it gives little control over the process.

JDeli is easy to use and offers complete support, so why don't you give a try?

Find out:

Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Leave a Reply

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

IDRsolutions Ltd 2020. All rights reserved.