Java 2D API Graphics

Java 2D API Graphics

2.83 (6 ratings by Goodreads)
By (author) 

List price: US$72.99

Currently unavailable

Add to wishlist

AbeBooks may have this title (opens in new window).

Try AbeBooks


You can create awesome graphics with the Java 2D graphics API -- and Java 2D Graphics shows you how, in full color! From textures to painting, montages to animation, you'll see exactly what can be done -- and then learn how to do it, step-by-step, with dozens of detailed code examples. Sun Microsystems Java architect Vincent Hardy offers a detailed overview of the Java 2D API, its features, components, and key applications -- including banner management, animation, presentations, pluggable look-and-feel, and more. He also introduces his exclusive Graphics Layer Framework, a high-level programming model that dramatically simplifies Java 2D programming, and is included free on the accompanying CD-ROM. Master fundamental Java 2D API principles and concepts, including shapes, text management, imaging, color models, and layering. Learn how to control rendering tradeoffs between speed and quality. Create motion effects, textures, embosses, lighting effects, text effects, animations, and more. Master the arts of composition, including montage, feathering, and displacement maps. From web pages to office tools, sophisticated graphics are becoming crucial to a wide range of applications. With this book, developers can get them -- without the expense and hassle of platform-specific development.
show more

Product details

  • Mixed media product | 509 pages
  • 177.8 x 233.68 x 22.86mm | 816.46g
  • Prentice Hall
  • Upper Saddle River, United States
  • English
  • w. numerous figs. (mostly col.).
  • 0130142662
  • 9780130142665

Table of contents

(NOTE: Most chapters conclude with a Conclusion.)I. JAVA 2D API OVERVIEW.

1. The Java 2D API Rendering Model.

The Java 2D API Rendering Model. The Java 2D API Features. Output Device Independence. Renderable Graphic Objects. Graphic Context Attributes.

2. Java 2D API Overview.

Acquiring a Graphics2D Object. Coordinate Spaces. * User Space. * Device Space. * Reconciling User Space and Device Space. Graphic Objects and Rendering Methods. Rendering Shapes. Rendering Text. * Simple Text Rendering. * Styled Text Rendering. * Advanced Text Manipulation. * Custom Glyph Layouts. Rendering Images. * Bufferedimage. * Creating a Bufferedimage and Loading Images. * Filtering Images. Graphic Context Attributes.

3. Rendering to an Output Device: Screen, Printer, and Images.

Drawing to the Screen. Drawing to the Printer. Rendering to an Offscreen Buffer. Resolution Independence.

4. Manipulating and Rendering Shapes, Images, and Text.

Shapes. Different Uses of Shape. * Creating an Arbitrary Shape. * Drawing Shapes. * Filling Shapes. * Transforming Shapes. * Clipping. * Hit Detection. Different Types of Shapes. Summary. Rendering Images: Bufferedimages. Rendering a Bufferedimage. Bufferedimage Internals. * Concerns Addressed By Bufferedimage. * Databuffer. * Samplemodel. * Colormodels. * Colorspace. * Putting It All Together Again. * Saving a JPEG File in CMYK. Bufferedimageop. * Affinetransformop. * Colorconvertop. * Convolveop. * Rescaleop. * Lookupop. * Bandcombineop. Summary. Text Manipulation. Attributedstring. A Closer Look At Textattribute. * Font Definition Attributes. * Text Layout Control. * Rendering Control. Advanced Text Rendering with Textlayout and Linebreakmeasurer. * International Text Complexities. * Text Editing Features. * Text Rendering Support. * Creating and Using an Attributedstring. * Creating a Text Paragraph. Custom Glyph Layouts. * Creating a Glyphvector. * Processing the Largest Glyph Width. * Custom Glyph Layout. * Rendering a Glyphvector.

5. Graphic Context Attributes.

Affinetransform. A Formal Definition of Affinetransform. Types of Elementary Transforms. * Scale. * Rotation. * Shear. * Translation. * Reflection. Composing Affinetransforms. * Transform Composition Defined: Transform Stack. * Composition Order. * Composing For More Intuitive Effects. Summary. Strokes. The Stroke Interface. The Basicstroke Implementation. * Stroke Size. * End Caps. * Line Joins. * Dashing Patterns. * Miter Limit. Summary. Paints. What Kinds of Paints Are There? * Color. * Gradientpaint. * TexturePaint. Advantage of the Paint Interface. Features of the Paint Interface. * The Paintcontext Interface. Summary. Font. What Are Fonts? Available Fonts. Using Fonts. Creating Fonts. * Font Name. * Font Size. * Font Weight. * Font Posture. * Fonttransform. * Font Constructors. * Deriving Fonts. Font Metrics. * Vertical Metrics. * Horizontal Metrics. * Accessing Font Metrics. Summary. Composite. What Is Compositing? Where Is Compositing Used? Alphacomposite Rules. * Creating an Alphacomposite. * Visual Representation of Alphacomposite Rules. Composite Internals. * The Composite Interface. * The Compositecontext Interface. Summary. Renderinghints. Why Renderinghints? * Platform Rendering Capabilities. * Programmer's Rendering Ideal. * Reconciling Capabilities and Options. Where and How Are Renderinghints Used? * Graphics2D. * Paint and Composite. * Bufferedimageop. Available Renderinghints. * Pixel Interpolation. * Alpha Interpolation. * antialiasing. * Color Rendering. * Dithering. * Fractional Metrics. * Rendering. Summary. Clipping. Defining the Clipping Area. Summary. Parting Thoughts. End of Part I.


6. The Graphic Layers Framework Fundamentals.

Purpose of the Graphic Layers Framework. Overview of the GLF Packages. The "Hello Layers" Example. Step. Defining the Layer Stack. Step. Creating a Compositionfactory and Defining Its Option Set. * Creating a Compositionfactory. * Defining the Compositionfactory Option Set. Step. Implementing the Compositionfactory: Creating and Stacking Layers. * Creating a Layer Stack. * Background Layer. * Text Layer. * Shadow Layer. * Stacking Layers. Viewing the Hello Layers Composition. Modifying and Experimenting with Control Properties.

7. The GLF Core: Working with Layers.

Introduction: Graphical Compositions. The Composition Interface. Layers and Layercompositions. The Layer Abstract Class. Using Layercompositions. The Layercomposition Operation (Advanced Topic). * Backgroundpaint. * Renderinghints. * The Paint Process. * Offscreen Layer Rendering. * Layer Filtering. Bufferedimageop Vs Rasterop. * Filter Margins. * Layer Masking. * Finishing the Paint Process. Position. Anchoring Objects. Adjusting Positions about the anchor. Applying Transforms about an Object's Center. Shapelayer. Shapelayer Operation: Placing Shapes and Using Renderers. Fillrenderer. Strokerenderer. Compositerenderer. Setting Shapelayer Mementos. Textlayer. Operation. Maketextblock (Advanced Topic). * Breaking Lines Into Paragraphs. * Turning Text Into a Shape. Imagelayer. Imagelayer Operation. Positioning Images in a Layercomposition. Compositionproxylayer. Compositionproxylayer Operation. Reusing Compositions with Compositionproxylayer. One Last Example.

8. The GLF Studio and Utilities: Experimenting with Layers.

Introduction. Viewing Compositions. Supporting Classes. * Compositioncomponent. * Compositionframe. Utilities That Display Compositions. * Compositionviewer. * Compositionshow. * Compositionstudio. Saving Compositions. Serializing Composition Configurations. * What Is Serialization? * Serializing Compositionfactories. Text-Based Serialization. Saving Compositions as Images. Configuring Compositions. Loading a Compositionfactory. * Loading a Compositionfactory as a Java Bean. * Loading a Compositionfactory as a File. Configuring a Composition. * Mapping Property Names to UI Label Name. * Supported Property Types and Related User-Interface Controls. * Configuring a Font Property. * Configuring a Glyph Property. * Configuring a Color Property. * Configuring a File. Previewing a Compositionfactory Configuration. Saving a Compositionfactory Configuration. Afterword about Loading Images.

9. The GLF Goodies: Taking Advantage of Java 2D's Extensible Design.

Introduction. Custom Paints. Creating a Custom Paint Implementation (Advanced Topic). * Writing an Implementation of the Paintcontext Interface. * Writing an Implementation of the Paint Interface. Gradientpaintext. Radialgradientpaint. Radialgradientpaintext. Custom Strokes. Compositestroke. Controlstroke. Shapestroke. Wavestroke. Textstroke. Custom Composite. Creating a Custom Composite Implementation (Advanced Topic). * Writing an Implementation of the Compositecontext Interface. * Writing a Composite Implementation. Colorcomposite: Combining HSB Values. * Colorcomposite Defined. * Using Colorcomposite. * About the Colorcomposite Implementation. Custom Bufferedimageops and Rasterops. The Bufferedimageop and Rasterop Interfaces. * Hints. * Spatial Information. * Creating a Compatible Destination. * Filtering. Implementing a Custom Filter (Advanced Topic). * Bufferedimageop or Rasterop. * Hints. * Spatial Characteristics. * Supported Formats. * Implementation. Lightop. * Operation/Design. * Adding Lights to a Litsurface. The Toneadjustmentop Filter. The Compositeop and Compositerasterop Filters. Nonlinear Transformations. Transform and Abstracttransform. Wavetransform. Bumptransform. Nonlinear Transforms Approximations. End of Part II.


10. Introduction.

How to Read This Part. Format Technical Content. Rendering Effects Index. More Rendering Effects: the Gallery. Important Note on Performance.

11. Creating Realistic Shadows.

Creating a Drop Shadow. Shadow Basics. * Creating a Sense of Light and Depth. * Creating a Realistic Shadow. The Image Shadow Layer Stack. Getting the Raw Material. * Loading an Image and Its Mask. * Creating and Transforming the Composition Label. Computing the Composition Size. Creating the Composition Layers. * The Label Layer. * The Label Shadow Layer. * The Tinted Image Layer. * The Image Shadow Layer. * Stacking Up Layers. Creating a Cast Shadow. Layer Stack Description. Getting the Raw Material. * Creating the Wavy Label. * Creating the Cookie-Cutter Cut Ellipse. Computing the Composition Size. Creating the Composition Layers. * Label Layer. * Label Shadow Layer. * Symbol Cast Shadow. * Embossed Symbol Layer. * Stacking Up Layers. Creating a Recessed Shadow. Layer Stack Description. Getting the Raw Material. Computing the Composition Size. Creating the Layers. * Label Layer. * Label Shadow Layer. * Dark Rim and Light Rim. * Stacking Up Layers. Putting It All Together. Loading a Compositionfactory Bean. Configuring and Building a Compositionfactory Object. Using Compositionproxylayer.

12. Making Text Stand Out.

Creating a Simple Glow. Layer Stack. Getting the Raw Material. Computing the Layer Size. Creating the Composition Layers. * Text Glow Layer. * Text Layer. * Image Glow. * Image Layer. * Stacking Up Layers. Creating a Sophisticated Glow. Creating a More Sophisticated Glow. Creating a Background Texture with Shapes.

13. Sculpting with Light.

The Layer Stack. Getting the Raw Material. Computing the Composition Size. Embossing with Spotlight. Using Lightop For Embossing. * Creating a Spotlight. * Creating a Texture Map. * Creating a Litsurface. * Creating a Lightop Filter. Attaching Lightop to a Shapelayer. Carving with Spotlight. Extruding with Spotlight. Increasing Legibility. Adding a Dark Glow Under the Embossed Text. Adjusting the Carved Text's Color. Painting the Top of the Extruded Text. Stacking Up Layers.

14. Fancy Text Layouts.

Creating a Circular Text Layout. Layer Stack. Circular Text Layout. * Laying Out Text. * Creating a Layer. Creating a Triangular Text Layout. Making Symbol Tags Legible and Attractive. Layer Stack. Getting the Raw Material and Computing the Composition Size. Background Glyph Layer. Stroking with Multiple Pen Width. Putting It All Together Again.

15. Tinting Photographs.

Layer Stack. Getting the Raw Material. Computing the Composition Size. Creating the Composition Layers. Antiquing a Photograph with Fuzzy Edges. Fast Blur to Create a Border Effect. Making Text Legible Again.

16. Creating a Sense of Volume.

Creating a Sphere. Creating the Proper Radial Gradient Paint. * Positioning the Radial Gradient Paint Control Circle. * Choosing the Right Gradient Colors. Using Radialgradientpaintext Creatively. * Creating the Sphere. * Creating the Sphere Shadow. Creating a Cylinder. Getting the Raw Material: Creating the Cylinder Shapes. Building the Cylinder Body and Top. Creating the Shadow. Creating a Bar. Creating the Base Rectangular Shapes. Rendering the Bar Face. Creating the Bar Side Layer. Creating the Bar Top. Creating the Shadow. Putting It All Together Again. Layer Stack. Getting the Raw Material. Creating the Composition Layers. * Sky and Sea. * Sun and Sun Rays. * Stroking with Text. Grouping Compositions in a Single Layer.

17. Gallery.

Brushed Metal. Recessed Shadow. Shadow Stand-Out. GLF Logo. Gradient Waves. Text Flowers. Soft Focus. Sunset. Shape Texture. Lookup Pattern. Lights. Bibliography.

show more

About Vincent Hardy

Vincent Hardy is a Java architect at Sun Microsystems' Java Solution Center, Menlo Park, CA, and a columnist for Java Report. He has extensive experience with the Java 2D API.
show more

Rating details

6 ratings
2.83 out of 5 stars
5 0% (0)
4 33% (2)
3 17% (1)
2 50% (3)
1 0% (0)
Book ratings by Goodreads
Goodreads is the world's largest site for readers with over 50 million reviews. We're featuring millions of their reader ratings on our book pages to help you find your new favourite book. Close X