5 |
from org.nongnu import alph |
from org.nongnu import alph |
6 |
from org.nongnu import storm |
from org.nongnu import storm |
7 |
|
|
8 |
from org.fenfire.vocab import SPATIAL, PAPER |
from org.fenfire.vocab import SPATIAL, PAPER, PP |
9 |
|
|
10 |
ff.test.gfx.needGL() |
ff.test.gfx.needGL() |
11 |
|
|
12 |
|
from org.fenfire.test.gfx import * |
13 |
|
|
14 |
|
class DummyMill(vob.gl.PaperMill): |
15 |
|
def __init__(self, pap): |
16 |
|
self.pap = pap |
17 |
|
def getPaper(self, seed): |
18 |
|
return self.pap |
19 |
|
|
20 |
def testRenderClick(): |
def testRenderClick(): |
21 |
|
"""Test that rendering a canvas works right and |
22 |
|
that we get a click. |
23 |
|
""" |
24 |
|
|
25 |
|
# Create the fen, set up data |
26 |
|
|
27 |
fen = ff.test.fen.newFen() |
fen = ff.test.fen.newFen() |
28 |
con = ff.util.AlphContent(fen) |
con = ff.util.AlphContent(fen) |
29 |
|
|
30 |
nodec = ff.swamp.Nodes.N() |
nodec = ff.util.RDFUtil.N(fen, PP.Paper) |
31 |
node1 = ff.swamp.Nodes.N() |
node1 = ff.swamp.Nodes.N() |
32 |
node2 = ff.swamp.Nodes.N() |
node2 = ff.swamp.Nodes.N() |
33 |
|
|
43 |
ff.util.RDFUtil.setInt(fen, node2, SPATIAL.coordX, 200) |
ff.util.RDFUtil.setInt(fen, node2, SPATIAL.coordX, 200) |
44 |
ff.util.RDFUtil.setInt(fen, node2, SPATIAL.coordY, 500) |
ff.util.RDFUtil.setInt(fen, node2, SPATIAL.coordY, 500) |
45 |
|
|
46 |
vs = ff.test.gfx.getvs() |
|
47 |
|
# Create the view structure |
48 |
|
vs = getvs() |
49 |
|
|
50 |
|
textnodeview = ff.view.TextNodeView( |
51 |
|
fen.txtfunc, |
52 |
|
vs.gfxapi.getTextStyle("Sans", 0, 16), |
53 |
|
1) |
54 |
|
|
55 |
|
|
56 |
|
canvasView2D = ff.view.CanvasView2D(fen, textnodeview) |
57 |
|
|
58 |
|
paperView2D = ff.view.PaperView2D(None, canvasView2D) |
59 |
|
paperView2D.paperMill = DummyMill( |
60 |
|
vob.gl.SpecialPapers.solidPaper(java.awt.Color.yellow)) |
61 |
|
|
62 |
|
irregu2D = ff.view.IrregularViewportView2D(paperView2D) |
63 |
|
|
64 |
|
# Finally, create the vobscene |
65 |
|
vs.put(SolidBackdropVob(Color.black)) |
66 |
|
|
67 |
|
box2screen = vs.orthoBoxCS(0, "b2s", 0, 100, 100, 1, 1, 300, 300) |
68 |
|
box2plane = vs.orthoBoxCS(0, "b2p", 0, 0, 0, .5, .5, 300, 300) |
69 |
|
|
70 |
|
irregu2D.render(vs, nodec, box2screen, box2screen, box2plane) |
71 |
|
|
72 |
|
render(vs) |
73 |
|
|
74 |
|
checkAvgColor(50, 50, 10, 10, (0, 0, 0), 5) |
75 |
|
checkAvgColor(150, 150, 10, 10, (255, 255, 0), 5) |
76 |
|
checkAvgColor(450, 450, 10, 10, (0, 0, 0), 5) |