23 |
""" |
""" |
24 |
|
|
25 |
from org import fenfire as ff |
from org import fenfire as ff |
26 |
import vob |
import vob, java |
27 |
|
from org.fenfire.vocab import TREETIME |
28 |
|
|
29 |
def p(*s): |
def p(*s): |
30 |
print 'fenpdf.py::',s |
print 'fenpdf.py::',s |
71 |
self.lastVs = vs |
self.lastVs = vs |
72 |
self.animate = 1 |
self.animate = 1 |
73 |
|
|
74 |
|
class Cursor(ff.view.lava.Cursor): |
75 |
|
""" The cursor for a node, e.g., text or pgaespan |
76 |
|
(in canvas view). Cursor is like text cursor in text editor, |
77 |
|
i.e., single instance and used to represent the accursed |
78 |
|
node and offset. |
79 |
|
""" |
80 |
|
def __init__(self, alphContent, multiplexer): |
81 |
|
ff.view.lava.Cursor.__init__(self, alphContent) |
82 |
|
self.multiplexer = multiplexer |
83 |
|
def setAccursed(self, node): |
84 |
|
ff.view.lava.Cursor.setAccursed(self, node) |
85 |
|
set = java.util.HashSet() |
86 |
|
set.add(node) |
87 |
|
self.multiplexer.setMultiplexerNodes(set) |
88 |
|
|
89 |
|
|
90 |
class UIState_Menu: |
class UIState_Menu: |
91 |
""" |
""" |
92 |
|
|
239 |
support text cloud operations |
support text cloud operations |
240 |
|
|
241 |
menu -- State of the ui context menu. |
menu -- State of the ui context menu. |
242 |
|
|
243 |
|
extensions -- extensions to fenPDF specification |
244 |
|
|
245 |
Any internal members are prefixed by underscore and should |
Any internal members are prefixed by underscore and should |
246 |
not be used by anyone else. |
not be used by anyone else. |
247 |
""" |
""" |
248 |
|
|
249 |
def __init__(self, fen, treeTime, structure_ff): |
def __init__(self, fen, treeTime, structure_ff, window, |
250 |
self.fen = fen |
filename): |
251 |
|
fenPDF = self |
252 |
self.events = _Empty() |
fenPDF.fen = fen |
253 |
self.actions = _Empty() |
fenPDF.window = window |
254 |
self.structure = _Empty() |
|
255 |
self.animation = AnimationState() |
# Default controls for main view |
256 |
self.uistate = _Empty() |
## see http://himalia.it.jyu.fi/ffdoc/fenfire/pegboard/fenpdf_v1_spec_1--tjl/peg.gen.html and 'Bindings' |
257 |
self.uistate.menu = UIState_Menu() |
fenPDF.events = _Empty() |
258 |
self.uistate.textScissors = UIState_Scissors() |
if 1: |
259 |
|
fenPDF.events.buttons = ff.fenpdf.events.buttons.ActionButtons() |
260 |
|
fenPDF.events.buttons.fenPDF = fenPDF |
261 |
self.structure.ff = structure_ff |
fenPDF.events.eventHandler = \ |
262 |
self.structure.structLink = ff.structure.StructLink.create(fen.graph) |
ff.fenpdf.events.eventhandler.EventHandler(fenPDF) |
263 |
self.structure.alphContent = ff.util.AlphContent(fen, structure_ff) |
fenPDF.events.mouse = ff.fenpdf.events.mouse.MouseMapper() |
264 |
self.structure.canvas2d = ff.structure.Canvas2D.create(fen.graph) |
fenPDF.events.key = ff.fenpdf.events.key.KeyHandler() |
265 |
self.structure.treeTime = treeTime |
fenPDF.events.mousemenu = ff.fenpdf.events.mousemenu.MouseMenu(fenPDF) |
266 |
|
|
267 |
|
fenPDF.actions = _Empty() |
268 |
|
if 1: |
269 |
|
actions = ff.fenpdf.actions |
270 |
|
fenPDF.actions.mouse = actions.mouse.MouseActions(fenPDF) |
271 |
|
fenPDF.actions.key = actions.keyboard.KeyActions(fenPDF) |
272 |
|
fenPDF.actions.menu = actions.menu.MenuActions(fenPDF) |
273 |
|
fenPDF.actions.abstract = actions.abstract.AbstractActions(fenPDF) |
274 |
|
fenPDF.actions.global = actions.globalactions.GlobalActions(fenPDF) |
275 |
|
|
276 |
|
papers = ff.fenpdf.appearance.papers.Papers(fenPDF) |
277 |
|
|
278 |
|
fenPDF.structure = _Empty() |
279 |
|
fenPDF.animation = AnimationState() |
280 |
|
|
281 |
|
fenPDF.uistate = _Empty() |
282 |
|
if 1: |
283 |
|
fenPDF.uistate.filename = filename |
284 |
|
fenPDF.uistate.menu = UIState_Menu() |
285 |
|
fenPDF.uistate.textScissors = UIState_Scissors() |
286 |
|
fenPDF.uistate.selection = ff.fenpdf.fenpdfcontext.Selection() |
287 |
|
|
288 |
|
|
289 |
|
fenPDF.structure.ff = structure_ff |
290 |
|
fenPDF.structure.structLink = ff.structure.StructLink.create(fen.graph) |
291 |
|
fenPDF.structure.alphContent = ff.util.AlphContent(fen, structure_ff) |
292 |
|
fenPDF.structure.canvas2d = ff.structure.Canvas2D.create(fen.graph) |
293 |
|
fenPDF.structure.treeTime = treeTime |
294 |
|
fenPDF.extensions = ff.fenpdf.extensions.getExtensions() |
295 |
|
|
296 |
|
# The first plane is the "firstOf" of the TREETIME follows |
297 |
|
# relation. |
298 |
|
iter = fen.constgraph.findN_X11_Iter(TREETIME.firstOf, |
299 |
|
TREETIME.follows) |
300 |
|
planeHome = iter.next() |
301 |
|
if planeHome == None: |
302 |
|
raise "Error: home plane not found" |
303 |
|
|
304 |
|
# Check the type of the home plane, just in case |
305 |
|
if not fenPDF.structure.canvas2d.isCanvas(planeHome): |
306 |
|
raise "Error: home plane not found - wrong type ", planeHome |
307 |
|
|
308 |
|
# Views must be created last - XXX |
309 |
|
fenPDF.views = \ |
310 |
|
ff.fenpdf.appearance. \ |
311 |
|
views.Views(fenPDF, papers, fenPDF.events.eventHandler, planeHome) |
312 |
|
|
313 |
|
fenPDF.views.background = \ |
314 |
|
ff.fenpdf.appearance.background.FancyBlueBackground1() |
315 |
|
|
316 |
|
fenPDF.uistate.cursor = \ |
317 |
|
ff.fenpdf.fenpdf.Cursor(fenPDF.structure.alphContent, |
318 |
|
fenPDF.views.getMultiplexerNodeContentFunction()) |
319 |
|
|
320 |
|
fenPDF.events.mouse.fenPDF = fenPDF |
321 |
|
fenPDF.events.mouse.update() |
322 |
|
|
323 |
|
fenPDF.events.key.fenPDF = fenPDF |
324 |
|
|
325 |
|
def getVersion(self): |
326 |
|
""" returns the version number of specification of fenpdf. |
327 |
|
""" |
328 |
|
return 1.0 |
329 |
def render(self, vs): |
def render(self, vs): |
330 |
pass |
pass |
331 |
|
|
332 |
|
def useExtension(self, extname): |
333 |
|
""" Return true if extension is enabled otherwise return false. |
334 |
|
""" |
335 |
|
return self.extensions.get(extname, 0) |