/Users/lyon/j4p/src/graphics/graph/NodeDrawer.java
|
1 package graphics.graph;
2
3 import java.awt.*;
4
5 public class NodeDrawer
6 /**
7 * The responsibility of this class is to
8 * draw the nodes onto a Graphics interface.
9 */ {
10 private PickBean pb = PickBean.getPickBean();
11 private ColorPanel cp = GraphFactory.getColorPanel();
12 private Nodes nodes = GraphFactory.getNodes();
13
14 private Color getColor(Node n) {
15 return (n == pb.getPick())
16 ? cp.getSelectColor() : (n.isFixed()
17 ? cp.getFixedColor() : cp.getNodeColor());
18 }
19
20 private void paintNode(Graphics g, Node n) {
21 g.setColor(getColor(n));
22 n.draw(g);
23 }
24
25 public void drawNodes(ImageUtil ui) {
26 for (int i = 0; i < nodes.getNumberOfNodes(); i++)
27 paintNode(ui.getOffGraphics(), nodes.getNode(i));
28 }
29 }