31 |
t = model.createResource() |
t = model.createResource() |
32 |
u = model.createResource() |
u = model.createResource() |
33 |
v = model.createResource() |
v = model.createResource() |
34 |
|
w = model.createResource() |
35 |
|
|
36 |
nodes = {} |
nodes = {} |
37 |
|
|
41 |
|
|
42 |
class Cmp(java.util.Comparator): |
class Cmp(java.util.Comparator): |
43 |
def compare(self, r1, r2): |
def compare(self, r1, r2): |
44 |
return [t,r,s,v,u].index(r1) - [t,r,s,v,u].index(r2) |
return [t,r,s,v,u,w].index(r1) - [t,r,s,v,u,w].index(r2) |
45 |
|
|
46 |
view = gzz.loom.SimpleView(NodeView()) |
view = gzz.loom.SimpleView(NodeView()) |
47 |
|
|
71 |
r.addProperty(p, u) |
r.addProperty(p, u) |
72 |
r.addProperty(p, v) |
r.addProperty(p, v) |
73 |
|
|
74 |
|
w.addProperty(p, r) |
75 |
|
|
76 |
vs = getvs() |
vs = getvs() |
77 |
cursor = gzz.loom.Cursor(Cmp(), r, s) |
cursor = gzz.loom.Cursor(Cmp(), r, s) |
78 |
view.render(vs, 0, cursor) |
view.render(vs, 0, cursor) |
79 |
|
|
80 |
cs_r, cs_s, cs_t, cs_u, cs_v = [vs.matcher.getCS(0, x) |
cs_r, cs_s, cs_t, cs_u, cs_v, cs_w = \ |
81 |
for x in (r,s,t,u,v)] |
[vs.matcher.getCS(0, x) for x in (r,s,t,u,v,w)] |
82 |
|
|
83 |
pr, ps, pt, pu, pv = [vs.coords.transformPoint(cs, 0, 0, None) |
pr, ps, pt, pu, pv, pw = \ |
84 |
for cs in [cs_r, cs_s, cs_t, cs_u, cs_v]] |
[vs.coords.transformPoint(cs, 0, 0, None) |
85 |
|
for cs in [cs_r, cs_s, cs_t, cs_u, cs_v, cs_w]] |
86 |
|
|
87 |
arr = jarray.zeros(2, 'f') |
arr = jarray.zeros(2, 'f') |
88 |
vs.coords.getSqSize(cs_r, arr) |
vs.coords.getSqSize(cs_r, arr) |
94 |
assert abs(pr.y+h_r/2-middle_y) < 3 |
assert abs(pr.y+h_r/2-middle_y) < 3 |
95 |
|
|
96 |
# s,t,u,v should be same size and on a single vertical line |
# s,t,u,v should be same size and on a single vertical line |
97 |
assert ps.x == pt.x == pu.x == pv.x > pr.x |
assert ps.x == pt.x == pu.x == pv.x > pr.x > pw.x |
98 |
|
|
99 |
# s should be approx. the same height as r, |
# s and w should be approx. the same height as r, |
100 |
# while t is above and v,u are below |
# while t is above and v,u are below |
101 |
assert pt.y < ps.y < pv.y < pu.y |
assert pt.y == pw.y < pr.y == ps.y < pv.y < pu.y |
102 |
assert abs(ps.y-pr.y) < 5 |
|
103 |
|
# distances on both sides should be equal |
104 |
|
# this works only if all nodes are same size... XXX |
105 |
|
assert (ps.x - pr.x) == (pr.x - pw.x) |
106 |
|
|
107 |
assert nodes[r] == cs_r |
assert nodes[r] == cs_r |
108 |
assert nodes[s] == cs_s |
assert nodes[s] == cs_s |
109 |
assert nodes[t] == cs_t |
assert nodes[t] == cs_t |
110 |
assert nodes[u] == cs_u |
assert nodes[u] == cs_u |
111 |
assert nodes[v] == cs_v |
assert nodes[v] == cs_v |
112 |
|
assert nodes[w] == cs_w |