01: /*
02: * This file is part of JGAP.
03: *
04: * JGAP offers a dual license model containing the LGPL as well as the MPL.
05: *
06: * For licensing information please see the file license.txt included with JGAP
07: * or have a look at the top of class org.jgap.Chromosome which representatively
08: * includes the JGAP license policy applicable for any file delivered with JGAP.
09: */
10: package examples.gp.anttrail;
11:
12: import java.awt.*;
13: import org.jgap.util.tree.*;
14: import org.jgap.gp.terminal.*;
15: import org.jgap.gp.impl.*;
16:
17: /**
18: * Renders the nodes' colors of a tree to display.
19: *
20: * @author Klaus Meffert
21: * @since 3.0
22: */
23: public class AntTreeNodeRenderer extends JGAPTreeNodeRenderer {
24: /** String containing the CVS revision. Read out via reflection!*/
25: private final static String CVS_REVISION = "$Revision: 1.2 $";
26:
27: //This implementation basis the shade of the node on the level
28: //but you may employ any property of your node.
29: public Color getNodeColor(Object a_node, int a_level) {
30: String name = ((JGAPTreeNode) a_node).getName();
31: Color out;
32: if (name.equals(Move.class.getName())) {
33: out = new Color(0, 140, 86);
34: } else if (name.equals(Left.class.getName())) {
35: out = new Color(44, 200, 70);
36: } else if (name.equals(Right.class.getName())) {
37: out = new Color(0, 86, 22);
38: } else {
39: return super.getNodeColor(a_node, a_level);
40: }
41: return out;
42: }
43: }
|