# # Copyright (c) 2003 by Benja Fallenstein # # This file is part of Gzz. # # Gzz is free software; you can redistribute it and/or modify it under # the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Gzz is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General # Public License for more details. # # You should have received a copy of the GNU Lesser General # Public License along with Gzz; if not, write to the Free # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # import gzz, java import jarray from test.tools.gfx import getvs from com.hp.hpl.mesa.rdf import jena model = jena.mem.ModelMem() p = model.createProperty("http://fenfire.org/2003/02/test#", "test-property") r = model.createResource() s = model.createResource() t = model.createResource() u = model.createResource() v = model.createResource() w = model.createResource() nodes, dirs = {}, {} class NodeView(gzz.loom.NodeView): def render(self, vs, cs, node, dir): nodes[node] = cs dirs[node] = dir class Cmp(java.util.Comparator): def compare(self, r1, r2): return [t,r,s,v,u,w].index(r1) - [t,r,s,v,u,w].index(r2) view = gzz.loom.WheelView(NodeView()) def testWheel(): r.addProperty(p, s) r.addProperty(p, t) r.addProperty(p, u) r.addProperty(p, v) w.addProperty(p, r) vs = getvs() cursor = gzz.loom.Cursor(Cmp(), r, 1, s) assert cursor.rotation == 0 view.render(vs, 0, cursor) cs_r, cs_s, cs_t, cs_u, cs_v, cs_w = \ [vs.matcher.getCS(0, x) for x in (r,s,t,u,v,w)] pr, ps, pt, pu, pv, pw = \ [vs.coords.transformPoint(cs, 0, 0, None) for cs in [cs_r, cs_s, cs_t, cs_u, cs_v, cs_w]] assert pw.y == pr.y == ps.y assert pt.y < ps.y < pv.y assert pt.x < ps.x > pv.x