5 |
from java.lang import Math |
from java.lang import Math |
6 |
|
|
7 |
import vob |
import vob |
|
#import vob.putil.misc |
|
8 |
import org.fenfire as ff |
import org.fenfire as ff |
9 |
import org.fenfire.vocab.STRUCTLINK as LINK |
import org.fenfire.vocab.STRUCTLINK as LINK |
10 |
from org.fenfire.vocab import * |
from org.fenfire.vocab import * |
11 |
from org.fenfire.vocab.lava import MINDSTRUCT as MIND |
from org.fenfire.vocab.lava import MINDSTRUCT as MIND |
12 |
from org.fenfire.swamp import Nodes |
from org.fenfire.swamp import Nodes |
13 |
|
|
|
# coloredquad |
|
|
from vob.putil.misc import * |
|
|
|
|
14 |
def p(*s): |
def p(*s): |
15 |
print 'mindMapView2D', s |
print 'mindMapView2D', s |
16 |
|
|
152 |
def getNodeSize(self, depth): |
def getNodeSize(self, depth): |
153 |
"""Node size is relative to depth as 1-math.log10(depth).""" |
"""Node size is relative to depth as 1-math.log10(depth).""" |
154 |
assert depth <= self.maxDepth, 'Depth is greater than maxDepth.' |
assert depth <= self.maxDepth, 'Depth is greater than maxDepth.' |
155 |
if depth < 1: depth = 1 |
if depth < 1: depth = 1 # same size for center and the first depth |
156 |
if self.maxDepth > 10: depth = depth * (10/self.maxDepth) |
if self.maxDepth > 10: depth = depth * (10/self.maxDepth) |
157 |
|
|
158 |
s =(self.box[1] * 1./self.nodeScale) * (1-math.log10(depth)) |
s =(self.box[1] * 1./self.nodeScale) * (1-math.log10(depth)) |
224 |
+ rotationAngle*float(len(links)-currentIndex) |
+ rotationAngle*float(len(links)-currentIndex) |
225 |
else: startAngle = 0 |
else: startAngle = 0 |
226 |
|
|
227 |
self.doMindMapCS(vs, paper2screen, node, links, 0,0, startAngle + self.rotation, rotationAngle, 1) |
for i in range(2, self.maxDepth+1): |
228 |
|
self.doMindMapCS(vs, paper2screen, node, None, links, 0,0, |
229 |
|
startAngle + self.rotation, rotationAngle, 1, i) |
230 |
self.current['startAngle'] = startAngle |
self.current['startAngle'] = startAngle |
231 |
self.current['rotationAngle'] = rotationAngle |
self.current['rotationAngle'] = rotationAngle |
232 |
self.drawMindMap(vs) |
self.drawMindMap(vs) |
274 |
if dbg: p('linked nodes: ', nodes) |
if dbg: p('linked nodes: ', nodes) |
275 |
return nodes |
return nodes |
276 |
|
|
277 |
def doMindMapCS(self, vs, into, centerNode, links, x, y, startAngle, rotationAngle, depth): |
def doMindMapCS(self, vs, into, centerNode, oldCenter, links, x, y, |
278 |
|
startAngle, rotationAngle, depth, maxDepth): |
279 |
""" Recursively go through all cs """ |
""" Recursively go through all cs """ |
|
|
|
280 |
fen = self.fen |
fen = self.fen |
281 |
|
|
282 |
for i in range(len(links)): |
if depth < maxDepth: |
283 |
link = links[i] |
for i in range(len(links)): |
284 |
if link == centerNode: raise 'own node!!' |
link = links[i] |
285 |
if self.net.hasBeenLinked(centerNode, link): continue |
if link == centerNode: raise 'own node!!' |
286 |
self.net.link(centerNode, link) |
if self.net.hasBeenLinked(centerNode, link): continue |
287 |
|
self.net.link(centerNode, link) |
288 |
|
|
289 |
if self.nodes.get(link) == None: |
if self.nodes.get(link) == None: |
290 |
pl = self.getPlace(vs, into, x, y, link, startAngle+rotationAngle*i, depth) |
pl = self.getPlace(vs, into, x, y, link, startAngle+rotationAngle*i, depth) |
291 |
if dbg: p('new node', pl) |
if dbg: p('new node', pl) |
292 |
self.nodes.put(link, pl) |
self.nodes.put(link, pl) |
293 |
self.doLink.put(link, '1') |
self.doLink.put(link, '1') |
294 |
else: |
else: |
295 |
pl = self.nodes.get(link) |
pl = self.nodes.get(link) |
296 |
if dbg: p('old node', pl) |
if dbg: p('old node', pl) |
297 |
|
|
298 |
# debugging.. |
# debugging.. |
299 |
if dbg: |
if dbg: |
301 |
for link in links: |
for link in links: |
302 |
p(' ',self.alphContent.getText(link),self.nodes.get(link)) |
p(' ',self.alphContent.getText(link),self.nodes.get(link)) |
303 |
|
|
304 |
if depth >= self.maxDepth: return |
if depth >= maxDepth: return |
305 |
for i in range(len(links)): |
for i in range(len(links)): |
306 |
link = links[i] |
link = links[i] |
307 |
if self.doLink.get(link) != None: |
if link == oldCenter: continue |
308 |
self.doLink.put(link, None) |
if 1: # Ask mudyc about this, how this will affect |
309 |
|
# if self.doLink.get(link) != None: |
310 |
|
# self.doLink.put(link, None) |
311 |
place = self.nodes.get(link) |
place = self.nodes.get(link) |
312 |
newLinks = self.getLinks(fen, link) |
newLinks = self.getLinks(fen, link) |
313 |
newAngle = Math.PI*2./float(len(newLinks)) |
newAngle = Math.PI*2./float(len(newLinks)) |
320 |
+ newAngle*float(len(newLinks)-fromIndex) |
+ newAngle*float(len(newLinks)-fromIndex) |
321 |
else: newStartAngle = 0 |
else: newStartAngle = 0 |
322 |
|
|
323 |
self.doMindMapCS(vs, into, link, newLinks, place[1], place[2], |
self.doMindMapCS(vs, into, link, centerNode, newLinks, place[1], place[2], |
324 |
newStartAngle, newAngle, depth + 1) |
newStartAngle, newAngle, depth + 1, maxDepth) |
325 |
|
|
326 |
def getPlace(self, vs, into, x0,y0, key, angle, depth): |
def getPlace(self, vs, into, x0,y0, key, angle, depth): |
327 |
xy = self.getXY(x0,y0, angle, depth) |
xy = self.getXY(x0,y0, angle, depth) |
349 |
vs.coords.transformPoints3(cs, [0,0,0], into) |
vs.coords.transformPoints3(cs, [0,0,0], into) |
350 |
|
|
351 |
# scaling |
# scaling |
352 |
scale = (100+into[2])+2 |
scale = (100+into[2])+4 |
353 |
if self.maxDepth > 20: scale *= 20./self.maxDepth |
if self.maxDepth > 40: scale *= 40./self.maxDepth |
354 |
scale = 1-math.log10(scale/2.) |
scale = 1-math.log10(scale/4.) |
355 |
|
|
356 |
self.nodef.setScale(scale) |
self.nodef.setScale(scale) |
357 |
p = self.nodef.f(self.fen.graph, node) |
p = self.nodef.f(self.fen.graph, node) |