Whole document tree
1.3 Backward Compatibility and Platform IndependenceThe Java 2DTM API maintains backward compatibility with JDK 1.1 software. It is also architected so that applications can maintain platform-independence. 1.3.1 Backward CompatibilityTo ensure backward compatibility, the functionality of existing JDK graphics and imaging classes and interfaces was maintained. Existing features were not removed and no package designations were changed for existing classes. The Java 2D API enhances the functionality of the AWT by implementing new methods in existing classes, extending existing classes, and adding new classes and interfaces that don't affect the legacy APIs. A JDK 1.1 applet interprets the graphics context that's passed in as an instance of Graphics. To gain access to the new features implemented in Graphics2D, a Java 2D API-compatible applet casts the graphics context to a Graphics2D object: public void paint (Graphics g) { Graphics2D g2 = (Graphics2D) g; ... ... g2.setTransform (t); } In some cases, rather than extending a legacy class, the Java 2D API generalizes it. Two techniques were used to generalize legacy classes:
For example, the Java 2D API generalizes the AWT Rectangle class using both of these techniques. The hierarchy for rectangle now looks like: java.lang.Object | +-------java.awt.geom.RectangularShape | +---------java.awt.geom.Rectangle2D | +-------java.awt.Rectangle In the JDK 1.1 software, Rectangle simply extended Object. It now extends the new Rectangle2D class and implements both Shape and Serializable. Two parent classes were added to the Rectangle hierarchy: RectangularShape and Rectangle2D. Applets written for JDK 1.1 software are unaware of the new parent classes and interface implementations, but are unaffected because Rectangle still contains the methods and m embers that were present in earlier versions. 1.3.2 Platform IndependenceTo enable the development of platform-independent applications, the Java 2D API makes no assumptions about the resolution, color space, or color model of the target rendering device. Nor does the Java 2D API assume any particular image file format. CONTENTS | PREV | NEXT Copyright © 1997-1999 Sun Microsystems, Inc. All Rights Reserved. |