1
14 package demo.io.graphml;
15
16 import y.view.NodeRealizer;
17 import y.view.ShapeNodeRealizer;
18
19 import java.awt.Color;
20 import java.awt.Graphics2D;
21
22 import demo.view.DemoDefaults;
23
24
30 public class CustomNodeRealizer extends ShapeNodeRealizer {
31 private int customValue;
33 private String customAttribute;
35
36
37 public CustomNodeRealizer() {
38 setSize(60, 40);
39 setCustomAttribute("v1.0");
40 setCustomValue(333);
41 setFillColor(DemoDefaults.DEFAULT_NODE_COLOR);
42 }
43
44
45 public CustomNodeRealizer(NodeRealizer nr) {
46 super(nr);
47 if (nr instanceof CustomNodeRealizer) {
49 CustomNodeRealizer fnr = (CustomNodeRealizer) nr;
50 setCustomValue(fnr.customValue);
52 setCustomAttribute(fnr.customAttribute);
53 }
54 }
55
56 public NodeRealizer createCopy(NodeRealizer nr) {
57 return new CustomNodeRealizer(nr);
58 }
59
60 public void paintText(Graphics2D gfx) {
61 super.paintText(gfx);
62 gfx.setColor(Color.blue);
63 gfx.drawString("value: " + getCustomValue(), (float) getX() + 4, (float) getY() + 12);
64 gfx.drawString("attr: " + getCustomAttribute(), (float) getX() + 4, (float) (getY() + getHeight() - 2));
65 }
66
67 public int getCustomValue() {
68 return customValue;
69 }
70
71 public void setCustomValue(int customValue) {
72 this.customValue = customValue;
73 }
74
75 public String getCustomAttribute() {
76 return customAttribute;
77 }
78
79 public void setCustomAttribute(String customAttribute) {
80 this.customAttribute = customAttribute;
81 }
82 }
83