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