Warning: session_start(): open(/var/lib/php/sessions/sess_hs7692sokhbuibflitmfbo5hjq, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!include once #1007377 // Traits for CAL
sclass WebToCAL {
BufferedImage img = newBufferedImage(20, 20, Color.white);
new CirclesAndLines cal;
new Map map;
//new Map, Line> lines;
S makeLabel(Lisp lisp) {
ret web.useCLParse ? conceptLanguageToEnglish(clUnparse(lisp)) : lisp.head;
}
void convert(Web web) {
L nodes = web.nodes;
nodes = listMinusSet(nodes, values(web.relations));
for (WebNode node : nodes) {
Circle c = cal.circle(img, cal_randomCircleCoord(), cal_randomCircleCoord(), makeLabel(first(node.labels)));
map.put(node, c);
for (Lisp l : dropFirst(node.labels))
c.addTrait(makeLabel(l));
}
for (Pair p : keys(web.relations)) {
WebNode rel = web.relations.get(p);
Circle a = map.get(p.a), b = map.get(p.b);
if (a == null || b == null) {
warn("webToCAL: Circle not found");
continue;
}
if (a == b) continue; // TODO
/*Line line = lines.get(p);
if (line == null)
lines.put(p,*/
Line line = cal.arrow(a, makeLabel(first(rel.labels)), b);
for (Lisp l : dropFirst(rel.labels))
line.addTrait(makeLabel(l));
}
cal.onUserMadeCircle = voidfunc(Circle c) {
map.put(web.newNode(c.text), c);
};
cal.onUserMadeArrow = voidfunc(Arrow a) {
getRelation(reverseLookup(map, a.a), reverseLookup(a.b)).addLabel(a.text);
};
}
}
static CirclesAndLines webToCAL(Web web) {
new WebToCAL wtc;
wtc.convert(web);
ret wtc.cal;
}
static void webToCAL(Web web, CirclesAndLines cal, Canvas canvas) {
copyCAL(webToCAL(web), cal);
canvas.update();
}