18 |
# MA 02111-1307 USA |
# MA 02111-1307 USA |
19 |
# |
# |
20 |
|
|
21 |
|
from __future__ import nested_scopes |
22 |
|
|
23 |
import java |
import java |
24 |
from org import fenfire as ff |
from org import fenfire as ff |
26 |
from org.fenfire.vocab import RDF, CANVAS2D |
from org.fenfire.vocab import RDF, CANVAS2D |
27 |
|
|
28 |
|
|
29 |
def createDemoSpace(fen, myAlph, treetime, ppActions, structure_ff): |
def createDemoSpace(fen, myAlph, treetime, structure_ff): |
30 |
"""Create a small space using a transclusion and structlinks. |
"""Create a small space using a transclusion and structlinks. |
31 |
""" |
""" |
32 |
paperA = "urn:urn-5:P7OMBN+yp3-m-AkulZN-NeaJV9Sl:_1" |
paperA = Nodes.get("urn:urn-5:P7OMBN+yp3-m-AkulZN-NeaJV9Sl:_1") |
33 |
paperHome = "urn:urn-5:COz-fSvNBZRieCdefRTKO2Mgcjmz:_1" |
paperHome = Nodes.get("urn:urn-5:COz-fSvNBZRieCdefRTKO2Mgcjmz:_1") |
34 |
|
|
35 |
sc = myAlph.addFile(java.io.File('../alph/testdata/test1.pdf'), 'application/pdf') |
sc = myAlph.addFile(java.io.File('../alph/testdata/test1.pdf'), 'application/pdf') |
36 |
|
|
37 |
paperB = "urn:urn-5:P7OMBN+yp3-m-AkulZN-NeaJV9Sl:_2" |
paperB = Nodes.get("urn:urn-5:P7OMBN+yp3-m-AkulZN-NeaJV9Sl:_2") |
38 |
paperC = "urn:urn-5:P7OMBN+yp3-m-AkulZN-NeaJV9Sl:_5" |
paperC = Nodes.get("urn:urn-5:P7OMBN+yp3-m-AkulZN-NeaJV9Sl:_5") |
39 |
fen.graph.add(Nodes.get(paperHome), RDF.type, CANVAS2D.Canvas); |
fen.graph.add(paperHome, RDF.type, CANVAS2D.Canvas); |
40 |
fen.graph.add(Nodes.get(paperA), RDF.type, CANVAS2D.Canvas); |
fen.graph.add(paperA, RDF.type, CANVAS2D.Canvas); |
41 |
fen.graph.add(Nodes.get(paperB), RDF.type, CANVAS2D.Canvas); |
fen.graph.add(paperB, RDF.type, CANVAS2D.Canvas); |
42 |
fen.graph.add(Nodes.get(paperC), RDF.type, CANVAS2D.Canvas); |
fen.graph.add(paperC, RDF.type, CANVAS2D.Canvas); |
43 |
|
|
44 |
if treetime != None: |
if treetime != None: |
45 |
treetime.addLatest(fen.graph, Nodes.get(paperHome)) |
treetime.addLatest(fen.graph, paperHome) |
46 |
treetime.addLatest(fen.graph, Nodes.get(sc.getID())) |
treetime.addLatest(fen.graph, Nodes.get(sc.getID())) |
47 |
treetime.addLatest(fen.graph, Nodes.get(paperA)) |
treetime.addLatest(fen.graph, paperA) |
48 |
treetime.addLatest(fen.graph, Nodes.get(paperB)) |
treetime.addLatest(fen.graph, paperB) |
49 |
treetime.addLatest(fen.graph, Nodes.get(paperC)) |
treetime.addLatest(fen.graph, paperC) |
50 |
|
|
51 |
noteA1 = Nodes.get(ppActions.newNote(paperA, -30,-30, 'This is a test!')) |
canvas2d = ff.structure.Canvas2D.create(fen.graph) |
52 |
noteA2 = Nodes.get(ppActions.newNote(paperA, -60,-70, 'This is a test2!')) |
alphContent = ff.util.AlphContent(fen, structure_ff) |
53 |
noteA2 = Nodes.get(ppActions.newNote(paperA, -60,-100, 'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789')) |
structLink = ff.structure.StructLink.create(fen.graph) |
54 |
noteA3 = Nodes.get(ppActions.newNote(paperA, 100, 100, '')) |
|
55 |
noteA4 = Nodes.get(ppActions.newNote(paperA, -60,70, 'This is a very long test which is used to see if ')) |
def newNote(pap, x, y, str): |
56 |
|
node = Nodes.N() |
57 |
|
canvas2d.placeOnCanvas(pap, node, x, y) |
58 |
|
alphContent.setText(node, str, 1) |
59 |
|
return node |
60 |
|
|
61 |
|
|
62 |
|
noteA1 = newNote(paperA, -30,-30, 'This is a test!') |
63 |
|
noteA2 = newNote(paperA, -60,-70, 'This is a test2!') |
64 |
|
noteA2 = newNote(paperA, -60,-100, 'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789') |
65 |
|
noteA3 = newNote(paperA, 100, 100, '') |
66 |
|
noteA4 = newNote(paperA, -60,70, 'This is a very long test which is used to see if ') |
67 |
|
|
68 |
fen.graph.add(noteA2, RDF.type, ff.vocab.lava.MINDSTRUCT.Data) |
fen.graph.add(noteA2, RDF.type, ff.vocab.lava.MINDSTRUCT.Data) |
69 |
|
|
70 |
ppActions.assocNotes(noteA1, 1, noteA2); |
structLink.link(noteA1, noteA2); |
71 |
|
|
72 |
span = sc.getCurrent().getPage(0).subArea(100, 100, 300, 200); |
span = sc.getCurrent().getPage(0).subArea(100, 100, 300, 200); |
73 |
structure_ff.setContent(noteA3, fen.enfMaker.makeEnfilade(span)) |
structure_ff.setContent(noteA3, fen.enfMaker.makeEnfilade(span)) |
74 |
|
|
75 |
|
|
76 |
noteB1 = Nodes.get(ppActions.newNote(paperB, 1000,500, 'This is an another test!')) |
noteB1 = newNote(paperB, 1000,500, 'This is an another test!') |
77 |
noteA2 = Nodes.get(ppActions.newNote(paperB, 1000,600, 'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789')) |
noteA2 = newNote(paperB, 1000,600, 'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789') |
78 |
|
|
79 |
ppActions.assocNotes(noteA1, 1, noteB1) |
structLink.link(noteA1, noteB1) |
80 |
|
|
81 |
noteHome = Nodes.get(ppActions.newNote(paperHome, 0, 0, 'HOME')) |
noteHome = newNote(paperHome, 0, 0, 'HOME') |
82 |
noteA2 = Nodes.get(ppActions.newNote(paperHome, 0,100, 'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789')) |
noteA2 = newNote(paperHome, 0,100, 'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789') |
83 |
|
|
84 |
ppActions.assocNotes(noteHome, 1, noteA1) |
structLink.link(noteHome, 1, noteA1) |
85 |
|
|
86 |
noteH2 = Nodes.get(ppActions.newNote(paperHome, -400, 0, 'foobar')) |
noteH2 = newNote(paperHome, -400, 0, 'foobar') |
87 |
noteB2 = Nodes.get(ppActions.newNote(paperB, 1200, 300, 'This is yet another test!')) |
noteB2 = newNote(paperB, 1200, 300, 'This is yet another test!') |
88 |
ppActions.assocNotes(noteB2, 1, noteH2) |
structLink.link(noteB2, 1, noteH2) |
89 |
|
|
90 |
|
|
91 |
noteC1 = Nodes.get(ppActions.newNote(paperC, 0, 0, 'baz')) |
noteC1 = newNote(paperC, 0, 0, 'baz') |
92 |
noteC2 = Nodes.get(ppActions.newNote(paperC, -200, 50, 'bar')) |
noteC2 = newNote(paperC, -200, 50, 'bar') |
93 |
noteB3 = Nodes.get(ppActions.newNote(paperB, 1150, 600, 'foo')) |
noteB3 = newNote(paperB, 1150, 600, 'foo') |
94 |
noteA4 = Nodes.get(ppActions.newNote(paperA, -100, -200, 'Lorem ipsum dolor')) |
noteA4 = newNote(paperA, -100, -200, 'Lorem ipsum dolor') |
95 |
|
|
96 |
ppActions.assocNotes(noteC1, 1, noteB3) |
structLink.link(noteC1, 1, noteB3) |
97 |
ppActions.assocNotes(noteA4, 1, noteC2) |
structLink.link(noteA4, 1, noteC2) |
98 |
|
|
99 |
|
|
100 |
def createEmptySpace(fen, myAlph, treetime, ppActions, structure_ff): |
def createEmptySpace(fen, myAlph, treetime, ppActions, structure_ff): |