provided by: 
Originally published at Internet.comJava Programming Notes # 1550 * Preface * General * Viewing tip * Figures * Listings * Supplementary material * General background information * Preview * Discussion and sample code * Recap * Run the program * Summary * What's next? * Download * Resources * Complete program listings * Copyright * About the author -----------------------------------
Preface
General
Part of a series
This lesson is part of a series designed to start with Java 3D basics and work up to some very complicated programs, such as the program that I explained in the earlier lesson titled "Understanding Lighting in the Java 3D API" (see Resources).
The first lesson in this series was titled "Back to Basics in the Java 3D API." The previous lesson was titled "Combining Rotation and Translation in Java 3d."; This lesson is titled "Understanding Transforms in Java 2D."
Not a typographical error!
I really did mean Java 2D and not Java 3D in the previous sentence. That was not a typographical error.
I imagine that now you are wondering why I would include a lesson on Java 2D in a series that is designed to teach you about Java 3D. Believe me, there is a good reason, which I will explain a little later.
My current plan is for future lessons to deal with user and object interaction as well as transforms, advanced animation, and textures in Java 3D.
What you will learn
In this lesson, you will learn to understand transforms in Java 2D in a way that you will be able to extend to an understanding of transforms in Java 3D. You will also learn how to write Java 2D code that makes use of that understanding.
Compiling and running Java 2D programs
In previous lessons, I told you that in order to compile and run programs using the Java 3D API, you will need to download and install the Java 3D API software. As of the date of this writing, Java 3D version 1.5.0 is available for download.
In addition, you will need to download and install either Microsoft DirectX or OpenGL to run Java 3D programs. All of the Java 3D sample programs in this series of tutorials were developed and tested using Microsoft DirectX. They were not tested using OpenGL.
However, no special download and installation is required for Java 2D. For some time now, Java 2D has been an integral part of the standard edition of Java 2. I recommend that you use the Sun product often referred to as Java SE 6 (version 1.6.0 or later) if it is available for your platform. If not, version 1.5, and probably version 1.4 should suffice as well.
Viewing tip
I recommend that you open another copy of this document in a separate browser window and use the following links to easily find and view the figures and listings while you are reading about them. Figures * Figure 1. Program output at startup. * Figure 2. Matrices for translation, scaling, and rotation. * Figure 3. Matrix operations for the three basic transforms. * Figure 4. Matrix computation for a point using translation matrix. * Figure 5. The six specifiable values displayed on the screen. * Figure 6. The default transform. * Figure 7. Display the current transform after origin adjustment. * Figure 8. Graphic output produced by user input scale values. * Figure 9. The new transform matrix values after scaling. * Figure 10. Translating by 50 and 30 for x and y. * Figure 11. Contents of the current transform matrix after translation. * Figure 12. Graphic output after application of the shear transform. * Figure 13. Contents of the current transform following the shear. * Figure 14. Prepare to explain a rotate transform. * Figure 15. Graphic output following 30-degree rotate transform. * Figure 16. Contents of the current transform following a rotate transform. * Figure 17. Graphic output from the final translate transform. * Figure 18. Contents of the final transform matrix.
Listings
* Listing 1. The displayMatrix method. * Listing 2. The drawOrigin method. * Listing 3.Beginning of the class named Java2D001. * Listing 4. Beginning of the inner class named GUI. * Listing 5. Beginning of the inner class named Display. * Listing 6. Move the origin to the center of the canvas. * Listing 7. Cause the positive y direction to be up instead of down. * Listing 8. Draw a cyan rectangle, a circle, and a cross at the origin. * Listing 9. Apply a user-specified scale transform. * Listing 10. Apply a user specified translate transform. * Listing 11. Update the current transform to include shear. * Listing 12. Update the current transform to apply a rotate transform. * Listing 13. The final translate transform. * Listing 14. Program listing for the program named Java2D001.
Supplementary material
I recommend that you also study the other lessons in my extensive collection of online Java tutorials. You will find a consolidated index at www.DickBaldwin.com.
General background information
Why a lesson on Java 2D?
We have reached the point in this series where you need to learn about transforms in Java 3D. This is not a trivial topic. It is an extremely complex topic. Although transforms are also not a trivial topic in Java 2D, it is much easier to understand transforms in Java 2D than in Java 3D.
While transforms in the two APIs are not implemented in exactly the same way, the transform
Author: Richard G. Baldwin
Read article at Internet.com site