10 |
|
|
11 |
import jarray |
import jarray |
12 |
|
|
13 |
pool = storm.impl.TransientPool(java.util.HashSet()) |
# save and load |
14 |
|
from com.hp.hpl.mesa.rdf.jena.mem import ModelMem |
15 |
|
import os.path |
16 |
|
|
17 |
|
DIR = 'myFenfire/' |
18 |
|
FILE = DIR+'mindmap.rdf' |
19 |
|
|
20 |
|
os.system('mkdir -p '+DIR) |
21 |
|
pool = storm.impl.DirPool(java.io.File(DIR), java.util.HashSet()) |
22 |
myalph = alph.impl.StormAlph(pool) |
myalph = alph.impl.StormAlph(pool) |
23 |
|
|
24 |
|
vob.putil.demo.usingNormalBindings = 0 |
25 |
|
|
26 |
|
# manual system to toggle the load point ;) |
27 |
|
# first time put 0 in here, |
28 |
|
# then Qtrl-Q for quit and save |
29 |
|
# then put load_toggle to 1 and rerun. |
30 |
|
do_load_graph = 0 |
31 |
|
|
32 |
|
# automatic system for previous |
33 |
|
if os.path.isfile(FILE): |
34 |
|
print 'Loading the RDF graph from the file %s', FILE |
35 |
|
do_load_graph = 1 |
36 |
|
else: |
37 |
|
print 'Creating a new RDF graph' |
38 |
|
do_load_graph = 0 |
39 |
|
|
40 |
fen = ff.Fen() |
fen = ff.Fen() |
41 |
fen.graph = fen.constgraph = ff.swamp.impl.HashGraph() |
if do_load_graph: |
42 |
|
m = ModelMem() |
43 |
|
m.read(java.io.FileReader(FILE), None); |
44 |
|
fen.constgraph = fen.graph = ff.swamp.Graphs.toGraph(m); |
45 |
|
else: |
46 |
|
fen.graph = fen.constgraph = ff.swamp.impl.HashGraph() |
47 |
fen.txt = ff.impl.SimpleNodeContent(fen, myalph); |
fen.txt = ff.impl.SimpleNodeContent(fen, myalph); |
48 |
fen.txtfunc = fen.txt.getNodeFunction() |
fen.txtfunc = fen.txt.getNodeFunction() |
49 |
fen.enfiladeOverlap = fen.txt.getTransclusionIndex() |
fen.enfiladeOverlap = fen.txt.getTransclusionIndex() |
50 |
alphContent = ff.util.AlphContent(fen) |
alphContent = ff.util.AlphContent(fen) |
51 |
|
|
52 |
vs = w.createVobScene() |
vs = w.createVobScene() |
53 |
vs.put(background((.8, .4, .9))) |
vs.put(background((1, 1, 1))) |
54 |
|
|
55 |
textstyle = vob.GraphicsAPI.getInstance().getTextStyle("sans", 0, 24) |
textstyle = vob.GraphicsAPI.getInstance().getTextStyle("sans", 0, 24) |
56 |
|
nodeview = ff.view.TextNodeView(fen.txtfunc, textstyle, 1) |
57 |
|
nodeview.setHasNoContext() |
58 |
|
|
59 |
def p(*s): |
def p(*s): |
60 |
print "mind.py::", s |
print "mind.py::", s |
64 |
def rotatelist(list): |
def rotatelist(list): |
65 |
list.append(list.pop(0)) |
list.append(list.pop(0)) |
66 |
|
|
|
|
|
67 |
class MindMap: |
class MindMap: |
68 |
def __init__(self): |
def __init__(self): |
69 |
self._acc = None |
self._acc = None |
132 |
w.setCursor('default') |
w.setCursor('default') |
133 |
self.mm = MindMap() |
self.mm = MindMap() |
134 |
|
|
135 |
init = [ 'elephant', 'carrot', 'mouse', 'line', 'smoke', |
# init = [ 'elephant', 'carrot', 'mouse', 'line', 'smoke', |
136 |
'dog', 'fish', 'wait', 'light', 'smile', 'work to do' ] |
# 'dog', 'fish', 'wait', 'light', 'smile', 'work to do' ] |
137 |
for i in init: |
# for i in init: |
138 |
self.mm.setAccursed(None) |
# self.mm.setAccursed(None) |
139 |
self.mm.insertText(i) |
# self.mm.insertText(i) |
140 |
self.center = None |
self.center = None |
141 |
self.scumm = [ 'go', 'link', 'unlink' ] |
self.scumm = [ 'go', 'link', 'unlink' ] |
142 |
|
|
196 |
self.mm.deleteText() |
self.mm.deleteText() |
197 |
if self.mm.getAccursed() == None: |
if self.mm.getAccursed() == None: |
198 |
self.center = None |
self.center = None |
199 |
|
elif key == "Ctrl-Q": |
200 |
|
p("going to save"); |
201 |
|
|
202 |
|
m = ff.swamp.Graphs.toModel(fen.graph); |
203 |
|
m.write(java.io.FileWriter(FILE)); |
204 |
|
|
205 |
|
java.lang.System.exit(43) |
206 |
|
elif key == "Ctrl-R": |
207 |
|
vob.putil.demo.loadScenes() |
208 |
elif len(key) == 1: |
elif len(key) == 1: |
209 |
if self.mm.getAccursed() == None: |
if self.mm.getAccursed() == None: |
210 |
vob.AbstractUpdateManager.setNoAnimation() |
vob.AbstractUpdateManager.setNoAnimation() |
214 |
|
|
215 |
def scene(self, vs): |
def scene(self, vs): |
216 |
self.vs = vs |
self.vs = vs |
217 |
vs.put(background((.1, .1, .9))) |
vs.put(background((1, 1, 1))) |
218 |
|
|
219 |
unused = [] |
unused = [] |
220 |
iter = fen.graph.findN_X11_Iter(RDF.type, M.Data) |
iter = fen.graph.findN_X11_Iter(RDF.type, M.Data) |
266 |
MindData().place(self.mm, li, vs, pl[0]) |
MindData().place(self.mm, li, vs, pl[0]) |
267 |
self.nodes.put(li, pl) |
self.nodes.put(li, pl) |
268 |
vs.put(vob.vobs.LineVob(xx,yy,int(pl[1]), int(pl[2]), |
vs.put(vob.vobs.LineVob(xx,yy,int(pl[1]), int(pl[2]), |
269 |
java.awt.Color.yellow), 0) |
java.awt.Color.black), 0) |
270 |
self.doLink.put(li, '1') |
self.doLink.put(li, '1') |
271 |
else: |
else: |
272 |
pl = self.nodes.get(li) |
pl = self.nodes.get(li) |
273 |
vs.put(vob.vobs.LineVob(xx,yy,int(pl[1]), int(pl[2]), |
vs.put(vob.vobs.LineVob(xx,yy,int(pl[1]), int(pl[2]), |
274 |
java.awt.Color.red), 0) |
java.awt.Color.black), 0) |
275 |
|
|
276 |
for link in links: |
for link in links: |
277 |
if self.doLink.get(link) != None: |
if self.doLink.get(link) != None: |
326 |
vs.coords.getSqSize(cs, box) |
vs.coords.getSqSize(cs, box) |
327 |
bx, by = box[0], box[1] |
bx, by = box[0], box[1] |
328 |
|
|
329 |
if key == mm.getAccursed(): |
# if key == mm.getAccursed(): |
330 |
color = wh = java.awt.Color.white |
# color = wh = java.awt.Color.white |
331 |
if rect: |
# if rect: |
332 |
vs.put(vob.vobs.RectBgVob(self.color(key),1,wh), cs) |
# vs.put(vob.vobs.RectBgVob(self.color(key),1,wh), cs) |
333 |
else: vs.put(vob.vobs.OvalBgVob(self.color(key),1,wh), cs) |
# else: vs.put(vob.vobs.OvalBgVob(self.color(key),1,wh), cs) |
334 |
else: |
# else: |
335 |
color = java.awt.Color.black |
# color = java.awt.Color.black |
336 |
if rect: |
# if rect: |
337 |
vs.put(vob.vobs.RectBgVob(self.color(key)), cs) |
# vs.put(vob.vobs.RectBgVob(self.color(key)), cs) |
338 |
else: vs.put(vob.vobs.OvalBgVob(self.color(key)), cs) |
# else: vs.put(vob.vobs.OvalBgVob(self.color(key)), cs) |
339 |
vs.activate(cs) |
vs.activate(cs) |
340 |
|
|
341 |
# put the text |
# put the text |
342 |
cs = vs.translateCS(cs, "TR", 0, by*0.3 ) |
cs = vs.translateCS(cs, "TR", 0, by*0.3 ) |
343 |
|
|
344 |
text = vob.vobs.TextVob(textstyle, alphContent |
p = nodeview.f(fen.graph, key) |
345 |
.getText(fen.graph,key), 0, |
|
346 |
color) |
# text = vob.vobs.TextVob(textstyle, alphContent |
347 |
cs = vs.scaleCS(cs, "SC", bx/4, by/2) |
# .getText(fen.graph,key), 0, |
348 |
vs.put(text, cs) |
# color) |
349 |
|
|
350 |
|
# cs = vs.scaleCS(cs, "SC", bx/4, by/2) |
351 |
|
p.place(vs, cs) |
352 |
|
|
353 |
def color(self, key): |
def color(self, key): |
354 |
r = java.util.Random(java.lang.String(key).hashCode()) |
return java.awt.Color.white |
355 |
return java.awt.Color(r.nextFloat(), r.nextFloat(), r.nextFloat() ) |
# r = java.util.Random(java.lang.String(key).hashCode()) |
356 |
|
# return java.awt.Color(r.nextFloat(), r.nextFloat(), r.nextFloat() ) |
357 |
|
|
358 |
class MindNet: |
class MindNet: |
359 |
def __init__(self): |
def __init__(self): |