01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package horstmann.ch04_animation;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.Icon;
/**
An icon that contains a moveable shape.
*/
public class ShapeIcon implements Icon
{
public ShapeIcon(MoveableShape shape,
int width, int height)
{
this.shape = shape;
this.width = width;
this.height = height;
}
public int getIconWidth()
{
return width;
}
public int getIconHeight()
{
return height;
}
public void paintIcon(Component c, Graphics g, int x, int y)
{
Graphics2D g2 = (Graphics2D) g;
shape.draw(g2);
}
private int width;
private int height;
private MoveableShape shape;
}
|