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
package horstmann.ch06_scene2;
import java.awt.Graphics2D;

/**
   A shape that manages its selection state.
 */
public abstract class SelectableShape implements SceneShape
{
  public void setSelected(boolean b)
  {
    selected = b;
  }

  public boolean isSelected()
  {
    return selected;
  }

  public void drawSelection(Graphics2D g2)
  {
    translate(1, 1);
    draw(g2);
    translate(1, 1);
    draw(g2);
    translate(-2, -2);
  }

  private boolean selected;
}