40 |
public class DefaultNodeView implements NodeView { |
public class DefaultNodeView implements NodeView { |
41 |
protected Loom loom; |
protected Loom loom; |
42 |
protected TextStyle style; |
protected TextStyle style; |
43 |
protected Vob resourceVob, literalVob, selResourceVob, selLiteralVob; |
|
44 |
|
protected Color resourceColor = new Color(102, 255, 102); |
45 |
|
protected Color literalColor = new Color(255, 204, 51); |
46 |
|
|
47 |
|
protected OvalBgVob resourceVob; |
48 |
|
protected RectBgVob literalVob; |
49 |
|
|
50 |
public DefaultNodeView(Loom loom) { |
public DefaultNodeView(Loom loom) { |
51 |
this.loom = loom; |
this.loom = loom; |
52 |
style = GraphicsAPI.getInstance() |
style = GraphicsAPI.getInstance() |
53 |
.getTextStyle("Serif", 0, 12); |
.getTextStyle("Serif", 0, 12); |
54 |
resourceVob = new OvalBgVob(new Color(102, 255, 102), false, null); |
resourceVob = new OvalBgVob(Color.white, false, null); |
55 |
literalVob = new RectBgVob(new Color(255, 204, 51), false, null); |
resourceVob.addColor(resourceColor); |
56 |
selResourceVob = new OvalBgVob(new Color(102, 255, 102), true, |
literalVob = new RectBgVob(Color.white, false, null); |
57 |
loom.colors.getCursorBorderColor()); |
literalVob.addColor(literalColor); |
58 |
selLiteralVob = new RectBgVob(new Color(255, 204, 51), true, |
} |
59 |
loom.colors.getCursorBorderColor()); |
|
60 |
|
protected Vob getBgVob(boolean isResource, boolean isSelected, |
61 |
|
boolean isMarked) { |
62 |
|
if(!isSelected && !isMarked) |
63 |
|
return isResource ? (Vob)resourceVob : (Vob)literalVob; |
64 |
|
|
65 |
|
Color bg = isSelected ? loom.colors.getCursorBorderColor() : null; |
66 |
|
if(isResource) { |
67 |
|
OvalBgVob vob = new OvalBgVob(Color.white, isSelected, bg); |
68 |
|
vob.addColor(resourceColor); |
69 |
|
if(isMarked) vob.addColor(Color.red); |
70 |
|
return vob; |
71 |
|
} else { |
72 |
|
RectBgVob vob = new RectBgVob(Color.white, isSelected, bg); |
73 |
|
vob.addColor(literalColor); |
74 |
|
if(isMarked) vob.addColor(Color.red); |
75 |
|
return vob; |
76 |
|
} |
77 |
} |
} |
78 |
|
|
79 |
|
|
80 |
/** Argh-- global variable because getText() |
/** Argh-- global variable because getText() |
81 |
* can only return one thing :-( :-( |
* can only return one thing :-( :-( |
137 |
int dir = spec.dir; |
int dir = spec.dir; |
138 |
|
|
139 |
boolean selected = spec.equals(loom.cursor.getRotationNodespec(dir)); |
boolean selected = spec.equals(loom.cursor.getRotationNodespec(dir)); |
140 |
if(node instanceof Resource) { |
sc.map.put(getBgVob(node instanceof Resource, selected, |
141 |
if(selected) |
loom.markedNodes.contains(node)), into); |
142 |
sc.map.put(selResourceVob, into); |
|
|
else |
|
|
sc.map.put(resourceVob, into); |
|
|
} else { |
|
|
if(selected) |
|
|
sc.map.put(selLiteralVob, into); |
|
|
else |
|
|
sc.map.put(literalVob, into); |
|
|
} |
|
|
|
|
143 |
String s = getText(node, true); |
String s = getText(node, true); |
144 |
|
|
145 |
if(s.length() > 17) { |
if(s.length() > 17) { |