Java 2D Graphics by Jonathan Knudsen This errata page lists errors outstanding in the most recent printing. If you have any error reports or technical questions, you can send them to booktech@oreilly.com. (Please specify the printing date of your copy.) This page was updated on January 27, 2004. Here's a key to the markup: [page-number]: serious technical mistake {page-number}: minor technical mistake : important language/formatting problem (page-number): language change or minor formatting problem ?page-number?: reader question or request for clarification Confirmed errors: {2} In the second paragraph, the last package is listed as: "com.sun.image.code.jpeg" it should read: "com.sun.image.codec.jpeg" (8) In the third line of the 1st paragraph, 'createGraphics()' should be replaced by 'getGraphics()'. The method call in the following listing is correct. (15) Step 3 states "The paint() method draws the picture you see in Figure 1-1." It should say "in Figure C-1 (in the color insert)." (32-33) Figures 3.5 and 3.7 have the control points labeled as the filled squares and the endpoints are the unfilled squares when in fact the control point should be labeled as the open squares and the endpoint as the filled squares. {36} In Figure 3-9, the numbers should run from 0 through 6, NOT 1 through 7. Otherwise, the text that begins at the bottom of page 35 says the exact opposite of what the author intended. {76} IN PRINT: 6th line from top; "halfLength This is half of the line width." SHOULD BE: "halfWidth This is half of the line width." {76} last paragraph; In the paragraph "Dashes", the description of dash array: "The even elements of the array (starting at index 0) determine where the line is visible, while the odd elements determine where it's invisible." is technically incorrect. In fact, BasicStroke "cyclic" applies the dash array elements to alternates visible and invisible. For example: an array like {10, 20, 30} (odd number of array elements and phase == 0) will first 10 units visible, then 20 units invisible, then 30 units visible, then 10 units invisible, then 20 units visible, ... etc As the result shown, because "cyclic" rule, we cannot say the even elements are always visible and the odd elements are always invisible. (if the number of dash array is not even) (89) In the box, there is a typo in the first paragraph. The text currently reads: "AffineTransfrom" It should read: "AffineTransform" (107) 2nd paragraph; The code example: hints.add(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDERING_ON); is incorrect. It can be fixed by changing "add" to "put" and changing "VALUE_RENDER_ON" to "VALUE_RENDER_QUALITY". The resulting code excerpt is: public void paint(Graphics g) { Graphics2D g2 = (Graphics2D)g; RenderingHints hints = new RenderingHints( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2.setRenderingHints(hints); // ... (111) Just under the heading "Drawing Text," the book invites the reader to "use one of Graphics2D's drawText() methods" to render text. it should read: "use one of Graphics2D's drawString() method" {245} code output; The output on Win32/jdk1.3 and MacOSX/jdk1.3 is: java.awt.Color[r=255,g=0,b=0] -> 0 java.awt.Color[r=0,g=255,b=0] -> 1 java.awt.Color[r=0,g=0,b=255] -> 2 java.awt.Color[r=64,g=255,b=64] -> 1 java.awt.Color[r=255,g=255,b=0] -> 0 java.awt.Color[r=0,g=255,b=255] -> 1 0 -> unnormalized components 255 0 0 1 -> unnormalized components 0 255 0 2 -> unnormalized components 0 0 255 3 -> unnormalized components 255 255 255 4 -> unnormalized components 0 0 0 The book has extra 255's at the end of the last 5 lines. This is incorrect. [300] In the sixth line of the print () method: "paint(g2)" should read: "paintComponent(g2)" {Index} In chapter 6, there's an example called 'TextRendering.java'. This class makes use of a class called 'ApplicationFrame'. I looked in the index and found no reference to this class. At the beginning of the book, on page 8, I found a description of this class, and I was able to deduce that the drawing that took place in the example could also be done in a regular, AWT frame. I really think that this class, 'ApplicationFrame', should be included in the index. It seems to turn up in just about every example. Insert an index entry of ApplicationFrame, 8