Java 2D Graphics public void append(Printable painter, PageFormat
Java 2D Graphics } } } class BookComponentPrintableimplements Printable { private Component mComponent; public BookComponentPrintable(Component c) { mComponent = c; } public int print(Graphics g, PageFormat pageFormat, int pageIndex) { Graphics2D g2 = (Graphics2D)g; g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY()); mComponent.paint(g2); return PAGE_EXISTS; } } Chapter 14. Animation and Performance Performance is a term that refers to how fast an application runs. If someone says that an application has “performance issues,” it means the application is too slow. Computer chips double in speed every eighteen months or so, but software increases proportionately in size and complexity. There’s a lot of stuff between your application and the silicon. If you’re a Java developer, there’s an extra layer the Java Virtual Machine (JVM). All developers, and especially Java developers, have to be careful to make sure that their applications run fast enough to be useful. What does this have to do with the 2D API? Many developers have expressed interest in using the 2D API in animations, where each frame of the animation is generated on the fly. While the 2D API wasn’t designed specifically for animation, it can be used in this way. This chapter includes a flexible framework for building animation applications. It also includes three applications, built from the framework, that allow you to examine the effects of various 2D operations on the animation rate. 14.1 It’s Tougher Than You Might Think Whether 2D can render frames at a smooth animation rate depends on many factors, including the following: the application itself the JVM implementation the 2D API implementation, which may vary in different JDK releases the operating system the operating system configuration the display hardware (i.e. a video card) the system processor speed the system bus speed available memory To make things more complicated, the 2D API may perform different operations depending on the display hardware and software that’s available. page 253
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services