<<

Haase_index.fm Page 553 Thursday, July 12, 2007 12:34 PM

Index

A creating, 163–164 Abstract Window Toolkit (AWT), 12–13 cutouts, 167 Acceleration, interpolating, 360–363 description, 153–155 ActionTrigger, 384 destination pixels, 156 Acyclic gradients, 195–197 drop shadow, 167 Add composite, 171–175 Dst rule, 157 Adobe kuler, 547 DstAtop rule, 158 Aerith DstIn rule, 158 blending modes, 542 DstOut rule, 159 coding applications DstOver rule, 159 blending modes, 542 erasing a background, 157, 165 layers, 540–542 picture frames, 167 from screen mockups, 540–544 Porter-Duff equations, 153–154 history of, 531–532 Porter-Duff rules, 155–162 online resources, 550 problems with, 168–170 running, 532–533 replacing existing drawings, 161, 166–168 screen mockups setting up, 163–164 coding from, 540–544 soft-clipping, 168 colors, 545–547 source pixels, 156 gradients, 547 Src rule, 160 guides, 543 SrcAtop rule, 160 required skills, 544–545 SrcIn rule, 161, 166–168 workflow design, 538–539 SrcOut rule, 161 workflow design SrcOver rule, 162, 165–166 with a graphics editor, 535–537 temporary offscreen images, 170 on paper, 533–535, 537–538 translucency effect, 162, 165–166 screen mockups, 538–543 Xor rule, 162 Affine transforms, 63–70, 203–204 AlphaComposite class, 468–470 AffineTransformOp filter, 203–204 Anchor points, 369 AJAX (Asynchronous JavaScript and Animated Transitions, 497–530 XML), 2–3 Animation. See also Motion effects. AlphaComposite. See also Composites. frame rate antialiased-clipping, 168 frame-based animation, 268 Clear rule, 157, 165 minimum required, 289–290 common uses, 164–168 smoothing, 318, 332

553

Haase_index.fm Page 554 Thursday, July 12, 2007 12:34 PM

554 INDEX

Animation, continued time-based frame-based definition, 265 flicker, 269 flicker, 269 frame rate, 268 intermediate steps, 270 intermediate steps, 270 linear interpolation, 273–274 linear interpolation, 273–274 problems, 268–275 overview, 266–268 realistic motion, 272–275 problems, 268–275 speed, 269–271 realistic motion, 272–275 buffering, 269, 271–272 speed, 269–271 timer resolution. See also Timing Swing buffering, 269, 271–272 Framework. GUIs, 303–304 currentTimeMillis(), 291–293 repeating, 345, 351–352 definition, 288–289 running, querying, 347 increasing, 278 smoothing measuring, 297–299 antialiasing, 327, 340–341 milliseconds, 276–278, 291–293 apparent smoothness, 320 nanoseconds, 278, 291–293 blur effect, 339–340 nanoTime(), 291–293 bouncing motion, 320 performance, 288, 290, 299–300 color effect, 320–329, 332, 338–339 sleeping, 293–297 color spaces, 322 timer utilities. See also Timing consistency, 318–319 Framework. contrast, 325–326 callbacks, 284–285 demo, 335–341 currentTimeMillis(), 276–278 double buffering, 334 demos, 282–284, 286–288 frame rates, 318, 332 fixed delay, 285 hard edges, 326–327 fixed rate, 285 jumpy motion, 328–329 interframe volatility, 277–278 linear shapes, 332 milliseconds, 276–278 motion blur, 328–329 nanoseconds, 278 object color, versus background, nanoTime(), 278 325–326 querying current time, 275–278 perceived performance, 316 sleep(), 279–280, 293–297 performance, 317–318 sleeping, 279–282, 293–297 pixel color change, 322–323 Timer (.util), 282 realistic motion, 319–320 Timer (javax.swing), 284–288 rendering, 337–341 timers, 280–284 resolution, optimizing, 318–319 wait(), 279–280, 295–297 straight edges, 327–328 wake-up calls, 279–282 tearing, 330 transitions. See Transitions. timing effect, 317–320 Animator class vertical retrace effect, 329–334 cancel(), 347 starting, 345, 347, 352–353 constructor methods, 346 stopping, 347, 353 control flow, 347

Haase_index.fm Page 555 Thursday, July 12, 2007 12:34 PM

INDEX 555

definition, 345 box, 426–428 description, 346 depth of field, 423 isRunning(), 347 description, 423–425 pause(), 347 Gaussian, 428–432 resume(), 347 motion blur, 328–329 start(), 347 performance, 433–434 stop(), 347 reflection, 435–437 Antialiased-clipping, 168 simple, 426–428 Antialiasing Bokeh, 423–424 demo, 56 Books and publications. See also Online description, 54–56 resources. jaggies, 54 “Compositing Digital Images,” 153 shapes, 57 Principles and smoothing animation, 327, 340–341 Practices, 377 text, 57–59 Filthy Rich Clients, online resources, 551 AntiAliasingDemo demo, 56 The Geometry Toolbox for Graphics and Area averaging, image scaling, 103–104 Modeling, 377 Articles. See Books and publications. “The Perils of Asynchronous JavaScript and XML Image.getScaledInstance(),” 98 (AJAX), 2–3 System Properties for Java 2D..., 145 Asynchronous paint requests, 17–19 user interface design, 547 Authors’ sites, xxiii, 551 visual design, 547 Autoboxing, 405 Borders, on components, 75 Auto-reversing triggers, 381 Boring stuff, not found AWT (Abstract Window Toolkit), Box blur, 426–428 12–13 Bright spots, simulating, 189–192 Brightening, 213–214, 444–446 brighter(), 444 B BufferedImage objects Back buffers, 29 advantages of, 95–96 Backgrounds converting images to, 96–97 color, graphics state, 49, 50 definition, 93 color, versus object color, 325–326 transparent/translucent images, 97 erasing, 157, 165 BufferedImageOp filter, 201–203, 214–221 BasicRace demo, 358–359, 363–364 Buttons layer, 238 Bicubic image scaling, 102–104 Bilinear image scaling, 102–104 Blending modes, 542. See also C AlphaComposite; Composites. Caching Blocking EDT, 31–32 gradients, 193–195 Bloom effect, 6, 478–482 intermediate images, 134–141 Blur Callbacks animation, 339–340 cleanup operations, 348–349 bokeh, 423–424 definition, 345

Haase_index.fm Page 556 Thursday, July 12, 2007 12:34 PM

556 INDEX

Callbacks, continued Compatible images Swing event thread, 284–285 converting to, 124–126 timing events, receiving, 348–350 definition, 94 timing targets, 349–350 performance, 121–126 Campbell, Chris, 98, 111, 147 uses for, 122–123 cancel(), 347 compose(), 174–177 Canceling triggers, 381 Composing pixels, 174–177 Choppy animation. See Animation, smoothing. CompositeContext composite, 174–175 Circular gradients, 189–192 CompositeEffect effect, 512–513 Clear rule, 157, 165 Composites. See also AlphaComposite. clip(), 61 adding source/destination values, 171–174 The clip composing pixels, 174–177 constraining primitives to, 120 creating graphics state, 49, 61–62 Add composite, 171–175 honoring, 117–120 CompositeContext composite, performance, 115–121 174–175 Clipping images overview, 170–171 antialiased-clipping, 168 defining area for, 174–177 the clip, 121 graphics state, 49 soft-clipping, 168 immutability, 173 clipRect(), 61 library of, 171 Coalescing paint requests, 18 “Compositing Digital Images,” 153 Color Schemer Online, 546 Computer Graphics Principles and Color Schemer Studio, 546 Practices, 377 Color spaces, animation, 322 Consistency, animation, 318–319 ColorConvertOp filter, 204–206 Contrast, animation, 325–326 Colors Control points, 369 channels, 154 Convolution kernel, 206–209 effects on animation, 320–329, 332, ConvolveOp filter, 206–211 338–339 Convolving images, 206–211 fading, 470–472 Cooler applications, 1–552 graphics primitives, 63–64 copyArea(), 83 mapping source/destination, 211–213 CopyAreaPerformance demo, 83–87 model conversion, 204–206, 211–213 Copying areas, 83–87 object, versus background, 325–326 Cross-fading, 472 online resources, 546–547 currentTimeMillis(), 276–278, 291–293 opacity. See Opacity; Translucency; Custom interpolation, 377–378 Transparency. Cutouts, 167 rules for. See AlphaComposite; Cyclic gradients, 195–197 Composites. screen mockups, 545–547 COLOURlovers, 547 D Combo-box drop-down layer, 238 Darkening images, 213–214 Command-line flags, 145–149 Data binding, 1

Haase_index.fm Page 557 Thursday, July 12, 2007 12:34 PM

INDEX 557

DataBuffer, grabbing, 129–132 PictureScaler, 109–111 Deadlock, 35–37 Pulse, 474–478 Debugging performance, 148–149 PulseField, 482–484 Deceleration, interpolating, 360–363 reflection, 253–262 Demos RepaintManager, 253–262 animation rotating objects, 63–64, 67–68, 68–74 FadingButton, 304–306 RotationAboutCenter, 68–74 MovingButton, 306–310 ScaleTest, 105–109 MovingButtonContainer, 310–314 scaling images, 105–109, 109–111 SmoothMoves, 335–341 SearchTransition, 503–509, 516–518 SwingTimerDemo, 286–288 simulated depth, 180–181 UtilTimerDemo, 282–284 SmoothMoves, 335–341 AntiAliasingDemo, 56 Spring, 486–489 color, graphics primitives, 63–64 text hints, setting, 59–68 CopyAreaPerformance, 83–87 Timing Framework copying areas, 83–87 BasicRace, 358–359, 363–364 custom components, matching desktop bouncing spheres, 382–392 settings, 59–68 FadingButton, 353–356 DiagonalLine, 74–75 interpolation, 363–364 donut shape, 79 Interpolator, 372–378 drawing, 87–89 interpolator race, 363–364 drawing shapes, 80–83 KeyFrames class, 414–419 DrawShapes, 80–83 MultiStepRace, 414–419 Fading, 468–470 property setters, 393–395 FillDraw, 87–89 PropertySetter class, 398 filling, 87–89 racetrack, 356–359, 398–399, filling a blank canvas, 22–23 414–419 FontHints, 59–68 SetterRace, 398 gradients, 180–181 spline interpolation, 372–375, 376–378 graphics state SplineEditor, 376–378 persistence, 71–72 SplineInterpolatorTest, 372–375 setting, 51–54 triggers, 382–392 image scaling transformations, 63–64, 67–68 high resolution pictures, 109–111 translating objects, 63–64, 67–68 photographs, 105–109 translucency, 249–251 progressively larger images, 105–109 TranslucentPanel, 249–251 scale(), 63–64, 67–68 Depth of field, 423 vector drawings, 105–109 derive(), 164 ImageBrowser, 519–526 Design books, 547 IntermediateImages, 137–142 Design tools. See Aerith. loaded file names, displaying, 39–41 Desktop Java Graphics APIs. See AWT loading images from a hard drive, 39–41 (Abstract Window Toolkit); Java Morphing, 491–495 2D; Swing. performance, 137–142 Destination pixels, 156 Haase_index.fm Page 558 Thursday, July 12, 2007 12:34 PM

558 INDEX

DiagonalLine demo, 74–75 library of components for, 472 DirectX, performance, 148 strategies for, 467–468 Dirty regions, 251 morphing Discrete interpolation, 367–368, buttons, 491–495 409–411 demo, 491–495 DiscreteInterpolator class, description, 489–491 367–368 shape tweening, 490 Displays motion maximum refresh rate, 289 description, 460–465 prototyping. See Screen mockups. drag and drop, 462 dispose(), 174–175 moving objects, 462–465 Double-buffering, 28–31, 334 undo/redo syndrome, 460 Drag-and-drop, 238, 462 pulsating DRAG_LAYER, 238 bloom, 6, 478–482. See also Glow. draw(), 78 demos, 474–478, 482–484 drawImage(), 76–77, 102–103 description, 473–474 Drawing glow, 474–478. See also Bloom. fill versus draw, 87–89 spring, 484–489 rectangles, 78 shapes, 80–83 drawLine(), 77 E drawRect(), 78 EDT (Event Dispatch Thread). See also DrawShapes demo, 80–83 Events. drawString(), 78 blocking, 31–32 Drop shadow deadlock, 35–37 AlphaComposite, 167 definition, 31 description, 437–438 description, 16 realistic, 440–442 identifying, 35 simple, 438–440 perceived performance, 31–32 Dst rule, 157 posting a runnable task, 34, 35–37 DstAtop rule, 158 thread safety, 33–37 DstIn rule, 158 Timer class, 37–38 DstOut rule, 159 timers, 37–38 DstOver rule, 159 Effects Duff, Tom, 153 animated. See Dynamic effects. Duration of animation, 345, 350–351 CompositeEffect, 512–513 Dynamic effects. See also Static effects. custom, creating, 513–516 bloom, 6, 478–482 description, 509 fading. See also Transitions. Effects API, 510–516 AlphaComposite class, 468–470 FadeIn, 510 color, 470–472 FadeOut, 510 cross, 472 init(), 513 demo, 468–470 Move, 510, 514 description, 465–467 nonanimated. See Static effects. Haase_index.fm Page 559 Thursday, July 12, 2007 12:34 PM

INDEX 559

paint(), 513 Filling removing, 512 demo, 87–89 Rotate, 510, 515–516 versus drawing, 87 setEffect(), 511–513 fillRect(), 78 setup(), 513 Filters transition types, 511–513 affine transformations, 203–204 Unchanging, 511 AffineTransformOp, 203–204 using, 511–513 applying to multiple images, 202 Effects API, 510–516 black border, removing, 209–211 end(), 348–349 brightening images, 213–214 End caps, 51 BufferedImageOp, 201–203, 214–221 Evaluator class, 399–401 color model conversion, 204–206, Event Dispatch Thread (EDT). See EDT 211–213 (Event Dispatch Thread). ColorConvertOp, 204–206 Event handling. See Triggers. ConvolveOp, 206–211 Events. See also EDT (Event Dispatch convolving images, 206–211 Thread). creating, 214–221 automation timing, 348–350, 495 darkening images, 213–214 demos, 311–312 edge problems, 209–211 glass pane, 231–235 grayscale conversion, 204–206 input, blocking, 230–235 immutability, 217 mouse, 231–235 LookupOp, 211–213 rendering, 16 mapping source/destination color values, Examples. See Demos. 211–213 offscreen processing, 201–202 overview, 200 F at painting time, 201 FadeIn effect, 510 performance, 219, 220, 222 FadeOut effect, 510 picture shape, 203–204 Fading. See also Transitions. RescaleOp, 213–214, 445–446 AlphaComposite class, 468–470 scaling color values, 213–214 buttons, demo, 353–356 scaling pictures, 203–204 color, 470–472 tinting images, 213–214, 214–221 cross, 472 Filthy Rich Clients demo, 468–470 definition, 1, 3–7 description, 465–467 effectives, 3–7 in/out, 186 overview, 3–7 library of components for, 472 Filthy Rich Clients, online resources, strategies for, 467–468 551 FadingButton demo, 353–356 Firing triggers, 381 Farin, Gerald E., 377 Fixed delay, 285 Feiner, Steven, 377 Fixed rate, 285 fill(), 78 Floating-toolbars layer, 238 FillDraw demo, 87–89 FocusTrigger, 385–386 Haase_index.fm Page 560 Thursday, July 12, 2007 12:34 PM

560 INDEX

Foley, James D., 377 GradientPaint class, 187–188 FontHints demo, 59–68 Gradients. See also Highlights; Reflection. Fonts, graphics state, 49, 50–51 acyclic, 195–197 Foreground color, graphics state, 49, 50 bright spots, 189–192 Frame rates caching, 193–195 frame-based animation, 268 circular, 189–192 minimum required, 289–290 cyclic, 195–197 smoothing, 318, 332 dual (multistops linear), 187–189 Frame-based animation. See Animation, fading in/out, 186 frame-based. nonhorizontal, 195–197 nonvertical, 195–197 optimizing, 193–197 G performance, 193–197 Gaussian blurs, 428–432 radial, 189–192 The Geometry Toolbox for Graphics and reflection, 182–186 Modeling, 377 regular (two-stops linear), 179–186 getBackground(), 50 screen mockups, 547 getColor(), 50 shiny surfaces, 187–189 getComposite(), 62–63 simulated depth, 180–181 getFasterScaledInstance(), 111–113 specular highlights, 189–192 getFont(), 50–51 spheres, 189–192 getGraphics(), 47–48 Graham, Jim, 111, 492 getHSBColor(), 444–445 Graphics. See also Images. getInterval(), 414 antialiasing getPaint(), 63 demo, 56 getRenderingHint(), 53 description, 54–56 getRGB(), 219 jaggies, 54 getScaledInstance() shapes, 57 performance, 102, 107, 109 text, 57–59 “The Perils of borders, on components, 75 Image.getScaledInstance()”, 98 copying areas, 83 getStroke(), 51 demos getSubimage(), 120 color, graphics primitives, 63–64 Glass pane. See also Layered panes. copying areas, 83–87 blocking input events, 230–235 custom components, matching desktop in the JFrame hierarchy, 224 settings, 59–68 limitations, 237 diagonal line, 74–75 mouse events, 231–235 donut shape, 79 optimized painting, 227–230 drawing, 87–89 overview, 223–225 drawing shapes, 80–83 painting on, 225–230 filling, 87–89 root panes, 223 image scaling, 63–64, 67–68 transitions, 527–528 rotating objects, 63–64, 67–68, visibility, 225 68–74 Glow, 474–478 text hints, setting, 59–68 Haase_index.fm Page 561 Thursday, July 12, 2007 12:34 PM

INDEX 561

transformations, 63–64, 67–68 Graphics2D object, 44–45 translating objects, 63–64, 67–68 Grayscale conversion, 204–206 drawing, 87 GUI toolkits, 12–13 filling, 87 GUIs, animation, 303–304 matrix math, 64–67 rectangles, drawing and filling, 78 rendering. See also Rendering, with H Swing. Hansford, Dianne, 377 description, 45–46 Hard edges, animation, 326–327 getting the Graphics object, 46–48 High resolution pictures, scaling, 109–111 into images, 47–48 Highlights (emphasis), on text, 448–450 temporary state change, 46–47 Highlights (lighting). See also Gradients. rendering hints brightening, 444–446 definition, 49 description, 442–444 image scaling, 53–54 images, 445–446 KEY_ANTIALIASING, 57 text, 444–445 KEY_INTERPOLATION, 53–54 Hints KEY_TEXT_ANTIALIASING, 57–59 image scaling, 102–103 shape antialiasing, 57 rendering text antialiasing, 57–59, 59–68 definition, 49 VALUE_ANTIALIAS, 57 image scaling, 53–54 VALUE_INTERPOLATION, 53–54 KEY_ANTIALIASING, 57 VALUE_TEXT_ANTIALIAS, 58–59 KEY_INTERPOLATION, 53–54 shapes, drawing and filling, 78 KEY_TEXT_ANTIALIASING, 57–59 Graphics object shape antialiasing, 57 changing, 70 text antialiasing, 57–59, 59–68 getting, 46–48 VALUE_ANTIALIAS, 57 versus Graphics2D object, 44–45 VALUE_INTERPOLATION, 53–54 Graphics state VALUE_TEXT_ANTIALIAS, 58–59 background color, 49, 50 Honoring the clip, 117–120 clips, 49, 61–62 HSB color, converting to RGB, 444–445 clobbered, restoring, 73 Hughes, John F., 377 clobbering, 72 composite, 49 description, 48–49 I fonts, 49, 50–51 Image files, 94 foreground color, 49, 50 Image I/O, 94 image scaling, 53–54 Image objects, 92 paint property, 49 ImageHolder object, 523–525 persistence, 71–72 Images. See also Graphics. properties, 48–51 3D, 134–142 setting, 51–54 brightening, 213–214, 445–446 stroke, 49, 51 BufferedImage objects temporary change, 46–47 advantages of, 95–96 transform property, 49 converting images to, 96–97 Haase_index.fm Page 562 Thursday, July 12, 2007 12:34 PM

562 INDEX

Images, BufferedImage objects, continued bicubic, 54, 102–104 definition, 93 bilinear, 54, 102–104 transparent/translucent images, 97 demos the clip, 115–121 high resolution pictures, 109–111 clipping progressively larger images, antialiased-clipping, 168 105–109 the clip, 115–121 drawImage(), 77, 102–103 soft-clipping, 168 getFasterScaledInstance(), compatible 111–113 converting to, 124–126 getScaledInstance(), 102, 107, definition, 94 109 performance, 121–126 graphics state, 53–54 uses for, 122–123 hints for, 102–103 convolving, 206–211 matrix math, 64–67 darkening, 213–214 nearest neighbor, 53–54, 102–104 definition, 91 to a new image, 101 drawing, 76–77 overview, 98–99 filters. See Filters. prescaled, 524 image files, 94 progressive bilinear, 104 image I/O, 94 quality versus performance, 101–104 Image objects, 92 rendering hints, 53–54 intermediate subregions of images, 100 caching, 141 translation, 100 definition, 94 Immutability, 173, 217 image-based rendering, 134 init(), 513 performance, 134–142 Interframe volatility, 277–278 translucency, 142 Intermediate images loading images from a hard drive, 39–41 caching, 141 managed definition, 94 advantages of, 128–129 image-based rendering, 134 definition, 94 performance, 134–142 frequent rendering, 132–133 translucency, 142 grabbing the DataBuffer, 129–132 IntermediateImages demo, 137–142 history of, 126 interpolate(), 366–367 performance, 126–133 Interpolation mipmapping, 524 acceleration, 360–363 surface loss, 93 anchor points, 369 tinting, 213–214, 214–221 control points, 369 toolkit, 93–94 deceleration, 360–363 types of, 92–95 definition, 345 VolatileImage objects, 92–93 demo, 363–364 Images, scaling description, 359–360 affine transforms, 100 setAcceleration(), 360–363 area averaging, 103–104 setDeceleration(), 360–363 Haase_index.fm Page 563 Thursday, July 12, 2007 12:34 PM

INDEX 563

Interpolator class ordering components, 242–243 custom interpolation, 377–378 overview, 238–242 demos, 372–378 PALETTE_LAYER, 238 description, 364–365 palettes layer, 238 discrete interpolation, 367–368 popup window layer, 238 DiscreteInterpolator class, 367–368 relative values, 241–242 interpolate(), 366–367 tables layer, 238 key frames, 408–411 tooltips layer, 238 linear interpolation, 366–367 warning messages, 238–239 LinearInterpolator class, 366–367 JOGL project, online resources, 550 spline interpolation, 368–372 SplineInterpolator class, 368–372 Timing Framework, 408–411 K types of, 365–372 Key frames, 408–411 uses for, 365 KEY_ANTIALIASING hint, 57 Interpolator race demo, 363–364 Keyboard animation commands, 338–341 invokeAndWait(), 35–37 KeyFrames class invokeLater(), 34 constructors, 411–414 isEventDispatchThread(), 35 demo, 414–419 isRunning(), 347 description, 402–404 getInterval(), 414 helper classes, 404–411 J Interpolator class, 408–411 Jaggies, 54 KeyTimes class, 407–408 Java 2D KeyValues class, 404–407 description, 13 methods, 414 graphics capabilities, 43–45 KEY_INTERPOLATION hint, 53–54 Graphics object, 44–45 KEY_TEXT_ANTIALIASING hint, 57–59 Graphics2D object, 44–45 KeyTimes class, 407–408 Java sites, 550–551 KeyValues class, 404–407 JLayeredPane component. See also Layered Knuth, Donald, 197 panes. alternative to, 244–247 bottommost layer, 238 L buttons layer, 238 Layered panes. See also Glass pane; combo-box drop-down layer, 238 JLayeredPane component. drag-and-drop operations, 238 bottommost layer, 238 DRAG_LAYER, 238 buttons layer, 238 floating-toolbars layer, 238 combo-box drop-down layer, 238 layers, 238 drag-and-drop operations, 238 layout manager, 243–244 floating-toolbars layer, 238 menus layer, 238 versus glass pane, 237 modal dialog layer, 238 layers, 238 MODAL_LAYER, 238 layout manager, 243–244 Haase_index.fm Page 564 Thursday, July 12, 2007 12:34 PM

564 INDEX

Layered panes, continued MODAL_LAYER, 238 menus layer, 238 Monitors. See Displays. modal dialog layer, 238 Morphing ordering components, 242–243 buttons, 491–495 overview, 238–242 demo, 491–495 palettes layer, 238 description, 489–491 popup window layer, 238 shape tweening, 490 relative values, 241–242 Morphing2D class, 492–495 tables layer, 238 Motion blur, 328–329 tooltips layer, 238 Motion effects. See also Animation. warning messages, 238–239 description, 460–465 Layout manager, 243–244, 507, 522 drag and drop, 462 Libraries moving objects, 462–465 Animated Transitions library, 497–530, 550 undo/redo syndrome, 460 Timing Framework, 343–420, 549 MouseTrigger, 388–390 Lighting highlights. See Highlights (lighting). Move effect, 510, 514 Linear interpolation, 366–367 Linear shapes, animation, 332 LinearGradientPaint class, 188–189 N LinearInterpolator class, 366–367 Nanoseconds, 278, 291–293 Lines nanoTime(), 278, 291–293 attributes, 51 Nearest neighbor image scaling, 102–104 end caps, 51 Nonhorizontal gradients, 195–197 width, 51 Nonvertical gradients, 195–197 width, and performance, 51 Listeners, adding, 380–381 LookupOp filter, 211–213 O Online demos. See Demos. Online resources. See also Books and M publications. Main thread, 31–32 Adobe kuler, 547 Managed images Aerith project, 550 advantages of, 128–129 Animated Transitions library, 550 definition, 94 authors’ sites, xxiii, 551 frequent rendering, 132–133 Color Schemer Online, 546 grabbing the DataBuffer, 129–132 Color Schemer Studio, 546 history of, 126 colors, 546–547 performance, 126–133 COLOURlovers, 547 Matrix math, 64–67 Filthy Rich Clients, 551 Menus layer, 238 Java 2D FAQ, 145 Milliseconds, 276–278, 291–293 Java sites, 550–551 Mipmapping, 524 JOGL project, 550 Mockups. See Aerith. SMIL (Synchronized Multimedia Integra- Modal dialog layer, 238 tion Language), 377 Haase_index.fm Page 565 Thursday, July 12, 2007 12:34 PM

INDEX 565

Swing component library, 472 Pausing an animation, 347 SwingLabs project, 550 Perceived performance Tiiming Framework library, 549 animation, 316 Opacity. See also Translucency; Transpar- EDT (Event Dispatch Thread), 31–32 ency; Visibility. threading, 31–32 drop shadow, 167–168 Performance. See also Perceived performance. Java 2D, 27–28 animation, 317–318 painting, 21, 27–28 blur, 433–434 rendering, 27–28 the clip, 115–121 OpenGL pipeline, 147–148 command-line flags, 145–149 Optimizing compatible images, 121–126 animation resolution, 318–319 copying areas, 83–87 gradients, 193–197 debugging, 148–149 painting. See RepaintManager. demos, 137–142 painting glass pane, 227–230 diagonal lines, 120 Ordering components. See JLayeredPane DirectX, 148 component; Layered panes. EDT (Event Dispatch Thread), 31–32 filters, 219, 220, 222 gradients, 193–197 P honoring the clip, 117–120 paint() intermediate images, 134–142 calling directly, 48 line width, 51 custom effects, 513 managed images, 126–133 description, 19–20 OpenGL pipeline, 147–148 overriding, 21, 24–27 versus quality, image scaling, 101–104 Paint property, graphics state, 49 rendering, 143–145, 146–148 paintComponent(), 21–24 repaint(), 227 Painter’s algorithm, 21 threading, 31–32 Painting. See also paint(); repaint(). timer resolution, 288, 290, 299–300 asynchronous requests, 17–19 transitions, 529–530 coalescing requests, 18 “The Perils of Image.getScaledInstance(),” description, 17 98 entire components, 18 Petrucci, Sébastian, 441 on the glass pane, 225–230 Photographs opacity, 21, 27–28 browsing, 519–526 optimizing. See RepaintManager. scaling, 105–109 over the user interface. See Glass pane. Picture frames, 167 setOpaque(), 21, 27–28 PictureScaler demo, 109–111 subregions of components, 18 Pixel color change, 322–323 synchronous requests, 19–20 Pixels, colors, 211 PALETTE_LAYER, 238 Popup window layer, 238 Palettes layer, 238 Porter, Thomas, 153 Papers. See Books and publications. Porter-Duff equations, 153–154 pause(), 347 Porter-Duff rules, 155–162 Haase_index.fm Page 566 Thursday, July 12, 2007 12:34 PM

566 INDEX

Posting a runnable task, 34, 35–37 drawing, 435 Prescaled images, 524 simulating, 182–186 Progressive bilinear image scaling, 104 Regular (two-stops linear) gradients, Properties, graphics state, 48–51 179–186 Property setters Rendering definition, 392 animation, 337–341 demos, 393–395 description, 45–46 getter, 394 getting the Graphics object, 46–48 known types, 395 image-based, 134 object access, 394 into images, 47–48 setter, 394 managed images, 132–133 PropertySetter class performance, 143–145, 146–148 constructors, 395–397 temporary state change, 46–47 definition, 395 text in drawing areas, 78 demo, 398 Rendering, with Swing. See also evaluating intermediate types, Threading. 399–401 back buffers, 29 Evaluator class, 399–401 customized, 21–24 factory methods, 397–398 demos TimingTarget methods, 398 buttons, painting, 23–24 Prototyping. See Aerith. buttons, translucent, 25–27 Publications. See Books and publications. filling a blank canvas, 22–23 Pulsating effects description, 20–21 bloom, 6, 478–482 double-buffering, 28–31 demos, 474–478, 482–484 events, 16 description, 473–474 flicker, 29–30 glow, 474–478 opacity, 27–28 paintComponent(), 21–24 painter’s algorithm, 21 Q painting. See also paint(); repaint(). Querying running animations, 347 asynchronous requests, 17–19 coalescing requests, 18 description, 17 R entire components, 18 Racetrack demo, 356–359 opacity, 21, 27–28 Radial gradients, 189–192 setOpaque(), 21, 27–28 RadialGradientPaint class, 189–192 subregions of components, 18 rasterStolen variable, 132 synchronous requests, 19–20 Realistic drop shadow, 440–442 translucency, 27–28 Realistic motion, 319–320 triple-buffering, 28 Reflection. See also Gradients. Rendering hints blurred, 435–437 definition, 49 demos, 253–262 image scaling, 53–54 description, 434 KEY_ANTIALIASING, 57 Haase_index.fm Page 567 Thursday, July 12, 2007 12:34 PM

INDEX 567

KEY_INTERPOLATION, 53–54 Scaling KEY_TEXT_ANTIALIASING, 57–59 color values, 213–214 shape antialiasing, 57 images. See Images, scaling. text antialiasing, 57–59, 59–68 pictures, 203–204 VALUE_ANTIALIAS, 57 Screen mockups. See also Aerith. VALUE_INTERPOLATION, 53–54 coding from, 540–544 VALUE_TEXT_ANTIALIAS, 58–59 colors, 545–547 repaint(), 18–19, 227 gradients, 547 RepaintManager, 251–262 guides, 543 repeat(), 349 required skills, 544–545 Repeating animations workflow design, 538–539 definition, 345 Screens. See Displays. description, 351–352 ScreenTransition object, setRepeatBehavior(), 351–352 525–526 setRepeatCount(), 351–352 setAcceleration(), 360–363 Replacing existing drawings, 161, setBackground(), 50 166–168 setClip(), 61 RescaleOp filter, 213–214, 445–446 setColor(), 50 Resolution setComposite(), 62–63 animation, optimizing, 318–319 setDeceleration(), 360–363 definition, 345 setDuration(), 350–351 description, 352 setEffect(), 511–513 setResolution(), 352 setFont(), 50–51 smoothing, 318–319 setOpaque(), 21, 27–28 timer. See Timer resolution. setPaint(), 63 Timing Framework, 345, 352 setRenderingHint(), 53 resume(), 347 setRepeatBehavior(), 351–352 Resuming an animation, 347 setRepeatCount(), 351–352 RGB color, converting to HSB, 444–445 setResolution(), 352 RGBtoHSB(), 444–445 setStartDelay(), 352 Rich clients, definition, 2 setStartDirection(), 352 Root panes, 223 setStartFraction(), 353 rotate(), 63–64, 67–68 setStroke(), 51 Rotate effect, 510, 515–516 setTransform(), 63–64 Rotating objects, 63–64, 67–68, 68–74 setup(), 513 RotationAboutCenter demo, 68–74 setupNextScreen(), 527–528 Rules for colors, transparency, translucency. Shapes See AlphaComposite; antialiasing, 57 Composites. drawing, 78 filling, 78 tweening, 490. See also Morphing. S Sharpening scale(), 63–64, 67–68 description, 450–451 ScaleTest demo, 105–109 downscaled images, 455–458 Haase_index.fm Page 568 Thursday, July 12, 2007 12:34 PM

568 INDEX

Sharpening, continued depth of field, 423 simple, 452–454 description, 423–425 USM (unsharp masking), 454 Gaussian, 428–432 Sharpening kernels, 454 performance, 433–434 Shiny surfaces, simulating, 187–189 simple, 426–428 sleep(), 279–280, 293–297 drop shadow Sleeping, 279–282, 293–297 description, 437–438 SMIL (Synchronized Multimedia Integra- realistic, 440–442 tion Language), 377 simple, 438–440 Smoothing edges. See Antialiasing. highlights (emphasis), on text, SmoothMoves demo, 335–341 448–450 Soft-clipping, 168 highlights (lighting) Source pixels, 156 brightening, 444–446 Specular highlights, simulating, 189–192 description, 442–444 Spheres, simulating, 189–192 images, 445–446 Spline interpolation, 368–375, 376–378 text, 444–445 SplineEditor demo, 376–378 reflection SplineInterpolator class, 368–372 blurred, 435–437 SplineInterpolatorTest demo, 372–375 description, 434 Spotlighting, 446–448 drawing, 435 Spring effect, 484–489 sharpening Src rule, 160 description, 450–451 SrcAtop rule, 160 downscaled images, 455–458 SrcIn rule, 161, 166–168 simple, 452–454 SrcOut rule, 161 USM (unsharp masking), 454 SrcOver rule, 162, 165–166 sharpening kernels, 454 start(), 347 spotlighting, 446–448 Start delay, 352 stop(), 347 Start direction, 352 Stopping animations, 347, 353 Start fraction, 353 Straight edges, animation, 327–328 Starting animations Stroke, graphics state, 49, 51 definition, 345 Surface loss, 93 setStartDelay(), 352 Swing, 13. See also Rendering, with setStartDirection(), 352 Swing. setStartFraction(), 353 SwingLabs project, online resources, start(), 347 550 start delay, 352 SwingUtilities class, 38–41 start direction, 352 SwingWorker class, 38–41 start fraction, 353 Synchronized Multimedia Integration Static effects. See also Dynamic effects. Language (SMIL), 377 blur Synchronous paint requests, 19–20 bokeh, 423–424 System Properties for Java 2D..., box, 426–428 145 Haase_index.fm Page 569 Thursday, July 12, 2007 12:34 PM

INDEX 569

T Timer (javax.swing), 38, 284–288 Tables layer, 238 Timer resolution Tearing artifact, 330 currentTimeMillis(), 291–293 Temporary offscreen images, 170 definition, 288–289 Text increasing, 278 antialiasing, 57–59, 59–68 measuring, 297–299 brightening, 444–445 milliseconds, 276–278, 291–293 in drawing areas, 77 nanoseconds, 278, 291–293 highlights (emphasis), 448–450, 482–484 nanoTime(), 291–293 highlights (lighting), 444–445 performance, 288, 290, 299–300 hints, setting, 59–68 sleeping, 293–297 pulsating border, 482–484 Timer utilities Thin clients, 1 callbacks, 284–285 Thread safety, 33–37 currentTimeMillis(), 276–278 Threading. See also Rendering. demos, 282–284, 286–288 deadlocks, 35–37 fixed delay, 285 description, 31–32 fixed rate, 285 EDT (Event Dispatch Thread) interframe volatility, 277–278 blocking, 31–32 milliseconds, 276–278 deadlock, 35–37 nanoseconds, 278 definition, 31 nanoTime(), 278 description, 16 querying current time, 275–278 identifying, 35 sleep(), 279–280, 293–297 perceived performance, 31–32 sleeping, 279–282, 293–297 posting a runnable task, 34, 35–37 Timer (java.util), 282–284 thread safety, 33–37 Timer (javax.swing), 284–288 Timer class, 37–38 timers, 280–284 timers, 37–38 wait(), 279–280, 295–297 invokeAndWait(), 35–37 wake-up calls, 279–282 invokeLater(), 34 Timers, 37–38, 280–284 isEventDispatchThread(), 35 Timing effects, animation, 317–320, loaded file names, displaying, 39–41 335–337 loading images from a hard drive, 39–41 Timing events, receiving, 348–350 main thread, 31–32 Timing Framework perceived performance, 31–32 Animator class, 345–347 SwingUtilities class, 38–41 autoboxing, 405 SwingWorker class, 38–41 callbacks. See also TimingTarget object. toolkit thread, 31–32 cleanup operations, 348–349 utility classes for, 38–41 definition, 345 Threading model, 33–37 timing events, receiving, 348–350 Time-based animation. See Animation, timing targets, 349–350 time-based. controlling running animations, 347–348 Timer (java.util), 37–38, 282 definition, 344 Haase_index.fm Page 570 Thursday, July 12, 2007 12:34 PM

570 INDEX

Timing Framework, continued description, 402–404 demos getInterval(), 414 bouncing spheres, 382–392 helper classes, 404–411 fading button, 353–356 Interpolator class, 408–411 interpolator race, 363–364 KeyTimes class, 407–408 KeyFrames class, 414–419 KeyValues class, 404–407 multistep race, 414–419 methods, 414 property setters, 393–395 online resources, 549 racetrack, 356–359, 363–364, pausing an animation, 347 391–392, 393–395, 398–399, property setters 414–419 definition, 392 spline editor, 376 demos, 393–395 trigger race, 391–392 getter, 394 triggers, 382–392 known types, 395 duration of animation, 345, 350–351 object access, 394 ending behavior, 345 setter, 394 interpolation PropertySetter class acceleration, 360–363 constructors, 395–397 anchor points, 369 definition, 395 control points, 369 demo, 398 deceleration, 360–363 evaluating intermediate types, definition, 345 399–401 demo, 363–364 Evaluator class, 399–401 description, 359–360 factory methods, 397–398 setAcceleration(), 360–363 TimingTarget methods, 398 setDeceleration(), 360–363 querying running animations, 347 Interpolator repetition of animations, 345, custom interpolation, 377–378 351–352 demos, 372–378, 414–419 resolution, 345, 352 description, 364–365 resuming an animation, 347 discrete interpolation, 367–368 setDuration(), 350–351 DiscreteInterpolator class, starting an animation, 347 367–368 starting behavior, 345, 352–353 interpolate(), 366–367 stopping an animation, 347 linear interpolation, 366–367 TimingTarget object, 348–350. See LinearInterpolator class, 366–367 also Callbacks. spline interpolation, 368–372 triggers SplineInterpolator class, 368–372 ActionTrigger, 384 types of, 365–372 auto-reversing, 381 uses for, 365 built-in, 382–384 key frames, 402–414 canceling, 381 KeyFrames class creating, 380 constructors, 411–414 definition, 379–380 demo, 414–419 demos, 382–392 Haase_index.fm Page 571 Thursday, July 12, 2007 12:34 PM

INDEX 571

firing, 381 Unchanging, 511 FocusTrigger, 385–386 using, 511–513 listeners, adding, 380–381 glass pane, 527–528 MouseTrigger, 388–390 GUI states, 501–502 superclasses, 381–382 image browser, 519–522 TimingTrigger, 389–390 layout changes, animating, 528–529 Trigger class, 381–382 layout details, hiding, 527–528 TriggerEvent class, 382 next-screen setup, 527–528 uses for, 344 performance, 529–530 Timing targets, 349–350 search engine, 503–509, 516–518 timingEvent(), 349 setupNextScreen(), 527–528 TimingTarget methods, 398 translate(), 63–64, 67–68 TimingTarget object, 348–350 Translating objects, 63–64, 67–68 TimingTargetAdapter class, 350 Translation, image scaling, 100 TimingTrigger, 389–390 Translucency. See also Opacity; Tinting images, 213–214, 214–221 Transparency. Toolkit images, 93–94 BufferedImage objects, 97 Toolkit thread, 31–32 demo, 249–251 Toolkits for GUIs. See GUI toolkits. effect, 162, 165–166 Tooltips layer, 238 intermediate images, 142 transform(), 63–64 painting, 27–28 Transform property, graphics state, 49 rules for. See AlphaComposite; Transformations, 63–68 Composites. Transitions. See also Animated transitions; TranslucentPanel demo, 249–251 Fading. Transparency, 97. See also Opacity; Animated Transitions library, 501 Translucency. AnimatedTransitions API, Trigger class, 381–382 502–503 TriggerEvent class, 382 between application states, 497–501 Triggers effects ActionTrigger, 384 CompositeEffect, 512–513 auto-reversing, 381 custom, creating, 513–516 built-in, 382–384 description, 509 canceling, 381 Effects API, 510–516 creating, 380 FadeIn, 510 definition, 379–380 FadeOut, 510 demos, 382–392 init(), 513 firing, 381 Move, 510, 514 FocusTrigger, 385–386 paint(), 513 listeners, adding, 380–381 removing, 512 MouseTrigger, 388–390 Rotate, 510, 515–516 superclasses, 381–382 setEffect(), 511–513 TimingTrigger, 389–390 setup(), 513 Trigger class, 381–382 transition types, 511–513 TriggerEvent class, 382 Haase_index.fm Page 572 Thursday, July 12, 2007 12:34 PM

572 INDEX

Triple-buffering, 28 Visibility. See also Opacity; Translucency; Tweening. See Morphing. Transparency. Two-stops linear (regular) gradients, the clip, 115–121 179–186 glass pane, 225 Vision feature, 535–537 Visual design, books and publications, U 547 Unchanging effect, 511 VolatileImage objects, 92–93 Undo/redo syndrome, 460 UnsharpMaskFilter class, 455–458 User interface design, books and W publications, 547 wait(), 279–280, 295–297 USM (unsharp masking), 454 Wake-up calls, 279–282 Warning messages, 238–239 Web clients, 2 V Web resources. See Online resources. VALUE_ANTIALIAS hint, 57 Workflow design. See also Aerith. VALUE_INTERPOLATION hint, 53–54 with a graphics editor, 535–537 VALUE_TEXT_ANTIALIAS hint, 58–59 on paper, 533–535, 537–538 Van Dam, Andries, 377 screen mockups, 538–543 VDTs. See Displays. Vector drawings, scaling, 105–109 Vertical retrace effect, 329–334 X Violet, Scott, 18, 46 Xor rule, 162