Beginning Java 7 - Ivor Horton - Errata
Beginning Java 7 - Ivor Horton - Errata
Chapte Print
Page Details Date
r Run
5 Error in Text 03/16/2012
Currently reads:
"By coding everything yourself you will maximizes your learning experience."
Should read:
"By coding everything yourself you will maximize your learning experience."
Currently reads: Here's a simple program that you use to can try out the compiler:
Should read: Here's a simple program that you can use to try out the compiler:
should read:
public void putHatOn() {
"I can illustrate how this works by assuming the variable indicators contains the binary value 0b1111_1111_0000_1111, which
you could also write as the hexadecimal value 0xFF07."
Given the mask value of 0b0000_0000_0000_0100, the ~mask value should be 0b1111_1111_1111_1011, not
0b1111_1111_1111_0100.
2 59 Error in Text 8 June
(middle of the paragraph under Figure 2-5) 2015
Currently Reads:
When the sign bit is not propagated, the shift right operation does not have a numerical interpretation for negative values
because the sign bit is treated the same as any other bit, and zeros are inserted from the right.
Should Read:
When the sign bit is not propagated, the shift right operation does not have a numerical interpretation for negative values
because the sign bit is treated the same as any other bit, and zeros are inserted from the left.
Should read:
03/13/2012
4 123 Error in Code
There is currently an error in the code in the TRY IT OUT: The Weather Fanatic example for a 2 dimensional array.
Should read:
Currently reads:
zCenter = oldSphere.yCenter;
Should read:
zCenter = oldSphere.zCenter;
04/27/2012
325 Error in Code
There is an error in the readString function.
Currently reads:
|| ttype == '''') {
Should read:
|| ttype == '\'') {
Currently reads:
fetParent()
Should read:
getParent()
Should read:
"New16.gif"
03/09/2013
802 Error in Code
The following lines should be deleted:
p1.setLocation(p1.x, p1.y - height1);
p2.setLocation(p2.x, p2.y - height2);
g2D.draw(new Line2D.Float(p1, p2));
06/14/2012
823 Error in Code
Code currently reads:
import java.awt.*;
import java.io.Serializable;
public abstract class Element implements Serializable {
protected Element(Point position, Color color) {
this.position = position;
this.color = color;
}
public Color getColor() {
return color;
}
public Point getPosition() {
return position;
}
public java.awt.Rectangle getBounds() {
return bounds;
}
public abstract void draw(Graphics2D g2D);
public abstract void modify(Point start, Point last);
protected Point position; // Position of a shape
protected Color color; // Color of a shape
protected java.awt.Rectangle bounds; // Bounding rectangle
private final static long serialVersionUID = 1001L;
}
import java.awt.*;
import java.io.Serializable;
public abstract class Element implements Serializable {
protected Element(Point position, Color color) {
this.position = position;
this.color = color;
}
public Color getColor() {
return color;
}
public Point getPosition() {
return position;
}
public java.awt.Rectangle getBounds() {
return bounds;
}
public abstract void draw(Graphics2D g2D);
public abstract void modify(Point start, Point last);
protected Point position; // Position of a shape
protected Color color; // Color of a shape
protected java.awt.Rectangle bounds; // Bounding rectangle
protected static final Point origin = new Point(); // Origin for elements
private final static long serialVersionUID = 1001L;
}
Currently reads:
g2D.translate(position)
Should read:
g2D.translate(position.x, position.y)
When you rotate an element, the bounding rectangle changes. You must determine the bounding rectangle for an element based
on its position and rotation angle in the getBounds() method that the shape classes inherit from the Element class. If you don't
do this, elements will not display correctly when you rotate them. Here's a new version of the getBounds() method in the
Element class in Element.java:
This first create an AffineTransform object, at, that represents a translation from the origin to the point, position. A transform
that is a rotation through angle radians is then concatenated with at so the combination represents the transform that will
position the bounding rectangle for the element at the correct location with the rotation applied. You want to produce a
bounding rectangle for the element in its rotated position with the top-left at the origin so you concatenate a translation
transform with at that moves the rotated bounding rectangle back to the origin. Finally you call the createTransformedShape()
member of at to apply the transformation the the bounding rectangle for the element and return the Shape object that results.
You then call the getBounds() member for the Shape object to obtain the bounding rectangle for the element when it is rotated.
922 Error in Text 03/09/2013
After the code ending on page 922, please insert text:
if(fileName.indexOf(extension) >= 0) {
should read:
if(fileName.indexOf(".") >= 0) {
Should be:
WindowAdapter
935 Error in Code 03/09/2013
Currently reads:
Should read:
03/09/2013
958 Error in Code
getPrintable() is missing the closing } for the else statement.
The code should read:
// return NO_SUCH_PAGE;
// }
Graphics2D g2D = (Graphics2D) g;
The first two lines should be bold code font. The third line should be code font but not bold.