/Users/lyon/j4p/src/graphics/graph/ImagePanel.java
|
1 package graphics.graph;
2
3 import java.awt.*;
4
5 public class ImagePanel extends Panel
6 /**
7 * The responsibility of this class is to provide an instance of a
8 * Panel that knows how to interface with the GraphManager. All it
9 * really does accept update the update message and cutils.delegate it
10 * appropriately.
11 */ {
12 private static ImagePanel ip = new ImagePanel();
13 private GraphManager gm;
14
15 private ImagePanel() {
16 }
17
18 public static ImagePanel getImagePanel()
19 /**
20 * Static getter to support the singleton design pattern.
21 *
22 * @return ImagePanel
23 */ {
24 return ip;
25 }
26
27 public void setGraphManager(GraphManager graphManager)
28 /**
29 * Set the GraphManager. Even though GraphManager is a singleton,
30 * we didn't want to set it at instantiation time because ImagePanel
31 * (this) is also a singleton and GraphManager has a reference to this.
32 * To avoid confusion of circular instantiating, GraphManager sends
33 * a message here when it is ready to become referenced.
34 *
35 * @param GraphManager
36 */ {
37 gm = graphManager;
38 }
39
40 public synchronized void update(Graphics g)
41 /**
42 * Delegate the particulars of updating to the GraphManager.
43 *
44 * @param Graphics
45 */ {
46 gm.update(g);
47 }
48 }