[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ff-cvs] fenfire/org/fenfire bin/fenpdf10.py fenpdf/demo...
From: |
Tuomas J. Lukka |
Subject: |
[ff-cvs] fenfire/org/fenfire bin/fenpdf10.py fenpdf/demo... |
Date: |
Wed, 05 Nov 2003 05:25:56 -0500 |
CVSROOT: /cvsroot/fenfire
Module name: fenfire
Branch:
Changes by: Tuomas J. Lukka <address@hidden> 03/11/05 05:25:54
Modified files:
org/fenfire/bin: fenpdf10.py
org/fenfire/fenpdf: demospace.py fenpdf.py fenpdfcontext.py
org/fenfire/fenpdf/actions: eventgrabs.py keyboard.py mouse.py
org/fenfire/fenpdf/appearance: papers.py views.py
org/fenfire/fenpdf/events: buttons.py eventhandler.py key.py
mouse.py mousemenu.py
org/fenfire/spanimages: SpanImageFactory.java
org/fenfire/spanimages/gl: CachingSpanImageFactory.java
DefaultSpanImageFactory.java
MuxSpanImageFactory.java
PageScrollBlockImager.java
PoolManager.java
ScrollBlockImager.java
SingleImage.java benchpapers.py
papermakers.py spanimages.test
org/fenfire/structure: Ff.java
org/fenfire/view: AreaSelectingView2D.java CanvasView2D.java
IrregularViewportView2D.java NodedView2D.java
PageNodeView.java
PageScroll2LayoutPureFunction.java
PageSpanLayout.java PaperView2D.java
View2D.java pagespanlayout.test
papercanvas2d.test
org/fenfire/view/buoy: AbstractMainNode2D.java
AbstractNodeType2D.java
org/fenfire/view/lava: FastView.java
Added files:
org/fenfire/fenpdf: fenpdftestutil.py init.test
Log message:
sync
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/bin/fenpdf10.py.diff?tr1=1.82&tr2=1.83&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/fenpdftestutil.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/init.test?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/demospace.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/fenpdf.py.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/fenpdfcontext.py.diff?tr1=1.36&tr2=1.37&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/actions/eventgrabs.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/actions/keyboard.py.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/actions/mouse.py.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/appearance/papers.py.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/appearance/views.py.diff?tr1=1.28&tr2=1.29&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/events/buttons.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/events/eventhandler.py.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/events/key.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/events/mouse.py.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/events/mousemenu.py.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/spanimages/SpanImageFactory.java.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/spanimages/gl/CachingSpanImageFactory.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/spanimages/gl/DefaultSpanImageFactory.java.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/spanimages/gl/MuxSpanImageFactory.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/spanimages/gl/PageScrollBlockImager.java.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/spanimages/gl/PoolManager.java.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/spanimages/gl/ScrollBlockImager.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/spanimages/gl/SingleImage.java.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/spanimages/gl/benchpapers.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/spanimages/gl/papermakers.py.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/spanimages/gl/spanimages.test.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/structure/Ff.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/AreaSelectingView2D.java.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/CanvasView2D.java.diff?tr1=1.33&tr2=1.34&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/IrregularViewportView2D.java.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/NodedView2D.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/PageNodeView.java.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/PageScroll2LayoutPureFunction.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/PageSpanLayout.java.diff?tr1=1.24&tr2=1.25&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/PaperView2D.java.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/View2D.java.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/pagespanlayout.test.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/papercanvas2d.test.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java.diff?tr1=1.52&tr2=1.53&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/buoy/AbstractNodeType2D.java.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/lava/FastView.java.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
Patches:
Index: fenfire/org/fenfire/bin/fenpdf10.py
diff -u fenfire/org/fenfire/bin/fenpdf10.py:1.82
fenfire/org/fenfire/bin/fenpdf10.py:1.83
--- fenfire/org/fenfire/bin/fenpdf10.py:1.82 Thu Sep 11 10:52:07 2003
+++ fenfire/org/fenfire/bin/fenpdf10.py Wed Nov 5 05:25:49 2003
@@ -88,43 +88,52 @@
from org.fenfire.fenpdf import actions
-from org.fenfire.fenpdf.fenpdfcontext import Context
# save and load
from com.hp.hpl.mesa.rdf.jena.mem import ModelMem
import os.path
import vob
-w.setCursor('wait')
+# Read the user-settable properties.
+DIR = 'myFenfire/'
+FILE = java.lang.System.getProperty("fenpdf.file", DIR+"mygraph.rdf")
+POOLDIR = java.lang.System.getProperty("fenpdf.pool", DIR)
-vob.putil.demo.usingNormalBindings = 0
-### debugs
-#ff.view.AreaSelectingView2D.dbg = 1
-
-# Java system property "fenpdf.file" can be used to set the file name -
-# the default is "myFenfire/mygraph.rdf"
+# We're using the demo framework here (should eventually move
+# out of it) but for now; set the flag to show that
+# we don't want 'r' to reload; make the demo framework
+# use Ctrl-R instead
+vob.putil.demo.usingNormalBindings = 0
+# Starting up takes a few seconds; show to the user the friendly
+# wait cursor
+w.setCursor('wait')
-DIR = 'myFenfire/'
+# Now, before reading the xu stuff, render something
+# to try to prevent NV driver
+# fallback to software rendering.
+# Might be that it only reserves screen memory when starting to render
+# and if we reserve it all for textures, ... splat ...
+vs = w.createVobScene()
+vs.put(background((.8, .4, .9)))
+w.renderStill(vs, 0)
-FILE = java.lang.System.getProperty("fenpdf.file", DIR+"mygraph.rdf")
-POOLDIR = java.lang.System.getProperty("fenpdf.pool", DIR)
+### debugs
+#ff.view.AreaSelectingView2D.dbg = 1
+# Create the pool directory if necessary
+# (XXX NOT PORTABLE)
os.system('mkdir -p '+POOLDIR)
+# Create the storm and alph instances
pool = storm.impl.DirPool(java.io.File(POOLDIR), java.util.HashSet())
myalph = alph.impl.StormAlph(pool)
-# manual system to toggle the load point ;)
-# first time put 0 in here,
-# then Qtrl-Q for quit and save
-# then put load_toggle to 1 and rerun.
-do_load_graph = 0
-
-# automatic system for previous
+# If the file does exist, load it; otherwise, create
+# a new, empty graph, to be saved into that file.
if os.path.isfile(FILE):
print 'Loading the RDF graph from the file %s.'% FILE
do_load_graph = 1
@@ -133,134 +142,59 @@
do_load_graph = 0
-# Create fen with swamps.
+# Create the fen with swamps.
fen = ff.Fen()
+fen.alph = myalph
if do_load_graph:
m = ModelMem()
m.read(java.io.FileReader(FILE), None)
fen.constgraph = fen.graph = ff.swamp.Graphs.toGraph(m)
else:
- fen.graph = fen.constgraph = ff.swamp.impl.HashGraph()
+ fen.constgraph = fen.graph = ff.swamp.impl.HashGraph()
-structure_ff = ff.structure.Ff.create(fen.graph, myalph)
+# Create the enfilade/nodecontent structure
+structure_ff = ff.structure.Ff.create(fen.graph, fen.alph)
+treetime = ff.structure.TreeTime(TREETIME.follows)
fen.enfiladeOverlap = structure_ff.getTransclusionIndex()
-fen.alph = myalph
-ppActions = ff.modules.pp.PPActionsImpl(fen, structure_ff)
-treetime = ff.structure.TreeTime(TREETIME.follows)
-ppActions.treeTime = treetime
-
-# Now, before reading the xu stuff, render something
-# to try to prevent NV driver
-# fallback to software rendering.
-# Might be that it only reserves screen memory when starting to render
-# and if we reserve it all for textures, ... splat ...
-vs = w.createVobScene()
-vs.put(background((.8, .4, .9)))
-w.renderStill(vs, 0)
# If we want a new space, create a demo space.
if not do_load_graph:
val = java.lang.System.getProperty("fenpdf.demo")
if val != None and java.lang.Integer.parseInt(val) != 0:
- ff.fenpdf.demospace.createDemoSpace(fen, myalph, treetime, ppActions,
+ ff.fenpdf.demospace.createDemoSpace(fen, myalph, treetime,
structure_ff)
else:
- ff.fenpdf.demospace.createEmptySpace(fen, myalph, treetime, ppActions,
+ ff.fenpdf.demospace.createEmptySpace(fen, myalph, treetime,
structure_ff)
-# Default controls for main view
-## see
http://himalia.it.jyu.fi/ffdoc/fenfire/pegboard/fenpdf_v1_spec_1--tjl/peg.gen.html
and 'Bindings'
-
-
-
-# print "APP",dir(ff.fenpdf.appearance)
-# import org.fenfire.fenpdf.appearance.papers
-
-
-
-
-#
-# The first plane is the "firstOf" of the TREETIME follows
-# relation.
-# XXX Should also check type.
-#
-iter = fen.constgraph.findN_X11_Iter(TREETIME.firstOf, TREETIME.follows)
-planeHome = iter.next()
-if planeHome == None:
- print "Error: home plane not found"
- exit(42)
-if not ppActions.isPaper(planeHome):
- print "Error: home plane not found - wrong type ", planeHome
- exit(42)
-
-
-
-fenPDF = ff.fenpdf.fenpdf.FenPDF(fen, treetime, structure_ff)
-fenPDF.window = w
-fenPDF.events.buttons = ff.fenpdf.events.buttons.ActionButtons()
-fenPDF.events.buttons.fenPDF = fenPDF
-
-
-papers = ff.fenpdf.appearance.papers.Papers(fenPDF)
-
-eventHandler = ff.fenpdf.events.eventhandler.EventHandler(fenPDF)
-fenPDF.events.eventHandler = eventHandler
-
-
-context = Context(w, fen, ppActions, FILE)
-context.states.selection = \
- fenPDF.uistate.selection = ff.fenpdf.fenpdfcontext.Selection()
-context.fenPDF = fenPDF
-context.mousemenu = ff.fenpdf.events.mousemenu.MouseMenu(fenPDF,
context.states)
-fenPDF.events.mousemenu = context.mousemenu
-fenPDF.events.mouse = ff.fenpdf.events.mouse.MouseMapper(context)
-fenPDF.events.key = ff.fenpdf.events.key.KeyHandler(context.states)
-views = ff.fenpdf.appearance.views.Views(fenPDF, papers,
- eventHandler,
- planeHome)
-fenPDF.views = views
-fenPDF.views.background =
ff.fenpdf.appearance.background.FancyBlueBackground1()
+fenPDF = ff.fenpdf.fenpdf.FenPDF(fen, treetime, structure_ff, w, FILE)
-context.states.cursor =
ff.fenpdf.fenpdfcontext.Cursor(fenPDF.structure.alphContent,
- views.getMultiplexerNodeContentFunction())
-context.states.fenPDF = fenPDF
-fenPDF.uistate.cursor = context.states.cursor
-eventHandler.context = context
-ff.view.buoy.MainNode2D.fen = fen
-ff.view.buoy.AbstractMainNode2D.context = context
+# XXX THIS IS REALLY BAD ARCHITECTURALLY!
+cursorRenderer = ff.fenpdf.fenpdfcontext.CursorRenderer(fenPDF)
+ff.view.buoy.AbstractMainNode2D.context = cursorRenderer
-fenPDF.actions.mouse = ff.fenpdf.actions.mouse.MouseActions(fenPDF,context)
-fenPDF.actions.key = ff.fenpdf.actions.keyboard.KeyActions(context)
-fenPDF.actions.menu = ff.fenpdf.actions.menu.MenuActions(fenPDF)
-fenPDF.actions.abstract = ff.fenpdf.actions.abstract.AbstractActions(fenPDF)
-fenPDF.events.mouse.fenPDF = fenPDF
-fenPDF.events.mouse.update()
-fenPDF.events.key.fenPDF = fenPDF
-fenPDF.actions.key.fenPDF = fenPDF
class Scene:
def __init__(self):
- global context
w.setCursor('default')
- self.context = context
def scene(self, vs):
scene = fenPDF.views.scene(vs)
Index: fenfire/org/fenfire/fenpdf/actions/eventgrabs.py
diff -u fenfire/org/fenfire/fenpdf/actions/eventgrabs.py:1.2
fenfire/org/fenfire/fenpdf/actions/eventgrabs.py:1.3
--- fenfire/org/fenfire/fenpdf/actions/eventgrabs.py:1.2 Fri Oct 31
02:21:15 2003
+++ fenfire/org/fenfire/fenpdf/actions/eventgrabs.py Wed Nov 5 05:25:51 2003
@@ -44,6 +44,17 @@
def isCanvas(self, mainNode, fenPDF):
return mainNode != None and
fenPDF.structure.canvas2d.isCanvas(mainNode.getPlane())
+ def getNodeCSbyNode(self, mainNode, fenPDF, vs, node):
+ box2screen = mainNode.getBox2Screen()
+ plane = mainNode.getPlane()
+ if mainNode.getView2D().getContentView2D() == None:
+ return None
+ return mainNode.getView2D()(). \
+ getContentView2D().getNodeCS(vs,\
+ node, plane, box2screen, box2screen, 0)
+
+
+
class NodeMoverActionGrabber(Grabber):
def __init__(self, fenpdf, x,y,node, canvas):
self.fenPDF = fenpdf
@@ -109,6 +120,10 @@
self.node = node
self.x, self.y = x,y
+ """ tipNode has content for a tip, i.e., dragged text
+ cloud inserted into the underlying node's text.
+ 'Final content if you drop the text now'
+ """
self.tipNode = ff.swamp.Nodes.N()
self.tipOffset = None
@@ -116,17 +131,18 @@
self.drewMainNode = None
-## def getNodeCS(self, vs, ev, ignoreNode):
-## mainNode = self.mainNodeOfEvent(vs, ev, self.fenPDF)
-## if self.isCanvas(mainNode, self.fenPDF):
-## canvasCS = ff.view.CanvasView2D.getContainerCS(vs,
mainNode.getBox2Screen())
-## canvasCS = mainNode.getBox2Screen()
-## p('canvasCS', canvasCS)
-## ints = vs.coords.getAllCSAt(canvasCS, ev.getX(), ev.getY())
-## #p(vs.coords.getCSAt(
-## p('ints:', ints)
-## else:
-## raise 'not on canvas'
+ def getNodeOnPlane(self, vs, ev, ignoreNode):
+ mainNode = self.mainNodeOfEvent(vs, ev, self.fenPDF)
+ if self.isCanvas(mainNode, self.fenPDF):
+ cs = mainNode.getBox2Screen()
+ ints = vs.coords.getAllCSAt(cs, ev.getX(), ev.getY())
+ #p('ints:', ints)
+ for i in ints:
+ node = vs.matcher.getKey(i)
+ if node != ignoreNode:
+ return node
+ else:
+ raise 'not on canvas'
def draw(self, vs):
if self.ev == None: return
@@ -136,6 +152,12 @@
self.createFlyingNode(vs, self.node, self.ev, self.fenPDF)
self.drewMainNode = mainNode
+ viewFunction = self.fenPDF.views.getMultiplexerNodeContentFunction()
+ placeable = viewFunction.f(self.fenPDF.fen.graph, self.tipNode)
+ cs = vs.orthoBoxCS(0, 'TipNode', -1000,50,50, 1,1,
+ placeable.getWidth(), placeable.getHeight())
+ placeable.place(vs, cs)
+
def eventGrabber(self, ev, vs):
self.ev = ev
@@ -148,6 +170,7 @@
if self.isCanvas(mainNode, self.fenPDF):
canvas = mainNode.getPlane()
self.fenPDF.structure.canvas2d.placeOnCanvas(canvas,
self.node, self.x, self.y)
+ p('regenerate')
self.fenPDF.animation.regenerateVS()
else:
if self.isCanvas(mainNode, self.fenPDF):
@@ -161,56 +184,49 @@
self.fenPDF.animation.reuseVS = 1
self.fenPDF.animation.animate = 0
- if ev.getType() != ev.MOUSE_DRAGGED:
- if not self.isCanvas(mainNode, self.fenPDF):
- self.fenPDF.structure.canvas2d.removeNode(self.node)
- # XXX others also
- self.fenPDF.structure.canvas2d.placeOnCanvas(self.canvas,
self.node, self.x, self.y)
- p('placed on fen, using default')
- # temporarily solution, flush drags away...
- self.fenPDF.events.mouse.mainMouse.flush()
- self.fenPDF.events.eventHandler.eventGrabber = None
- self.fenPDF.animation.regenerateVS()
-
- vob.AbstractUpdateManager.chg()
-
- if 1: return
-
+ # if there are a change by offset!
+ if self.isCanvas(mainNode, self.fenPDF):
+ node = self.getNodeOnPlane(vs, ev, self.node)
+ if node != None:
+ #p('there\'s a node')
+ viewFunction =
self.fenPDF.views.getMultiplexerNodeContentFunction()
+ placeable = viewFunction.f(self.fenPDF.fen.graph, node)
+ if isinstance(placeable, vob.lava.placeable.TextPlaceable):
+ #p('textplaceable')
+ cs = self.getNodeCSbyNode(mainNode, self.fenPDF, vs, node)
+ ptsIn = jarray.array([ev.getX(),ev.getY(),0], 'f')
+ ptsOut = jarray.zeros(3, 'f')
+ vs.coords.inverseTransformPoints3(cs, ptsIn, ptsOut)
+ offset = placeable.getCursorPos(ptsOut[0], ptsOut[1])
+ if self.tipOffset != offset:
+ p('regenerate')
+ self.fenPDF.animation.regenerateVS()
+ self.tipOffset = offset
+
+ self.fenPDF.structure.ff.setContent(self.tipNode, \
+ self.fenPDF.structure.ff.getContent(node))
+ self.fenPDF.structure.ff.insert(self.tipNode, offset, \
+ self.fenPDF.structure.ff.getContent(self.node))
+ else: self.hideTipNode(vs)
+ else: self.hideTipNode(vs)
- self.getNodeCS(vs, ev, None)
- cs = vs.matcher.getCS('NODE_CS')
- if cs < 2:
- self.createFlyingNode(vs, self.node, ev, self.fenPDF)
- return
- self.transCS = cs
-
- if ev.getType() == ev.MOUSE_DRAGGED:
- # tip panel activism
- self.showTipPanel(vs, ev)
-
- vs.coords.setTranslateParams(self.transCS, ev.getX(), ev.getY())
- self.setFlyingNodeZoom(vs, self.node, self.fenPDF, ev)
- self.fenPDF.animation.reuseVS = 1
- self.fenPDF.animation.animate = 0
- else:
- self.hideTipPanel(vs)
- buoymanager = self.fenPDF.views.getBuoyManager()
- mainNode = buoymanager.findTopmostMainNode(vs, ev.getX(),
ev.getY())
- # if no focus or not canvas view
- if mainNode == None or not
self.fenPDF.structure.canvas2d.isCanvas(mainNode.getPlane()):
+ if ev.getType() != ev.MOUSE_DRAGGED:
+ # XXX others also ?
+ self.fenPDF.structure.canvas2d.removeNode(self.node)
+ if not self.isCanvas(mainNode, self.fenPDF):
self.fenPDF.structure.ff.insert(self.originalNode,
self.originalOffset,
-
self.fenPDF.structure.ff.getContent(self.node))
+
self.fenPDF.structure.ff.getContent(self.node))
else:
-
- node = mainNode.getNodeOnPlane(vs, ev.getX(), ev.getY())
+ node = self.getNodeOnPlane(vs, ev, self.node)
viewFunction =
self.fenPDF.views.getMultiplexerNodeContentFunction()
placeable = viewFunction.f(self.fenPDF.fen.graph, node)
# check if there are text under the mouse cursor
if node != None and isinstance(placeable,
vob.lava.placeable.TextPlaceable):
- cs = mainNode.getNodeCS(vs, node)
+ self.fenPDF.structure.canvas2d.removeNode(self.node)
+ cs = self.getNodeCSbyNode(mainNode, self.fenPDF, vs, node)
ptsIn = jarray.array([ev.getX(),ev.getY(),0], 'f')
ptsOut = jarray.zeros(3, 'f')
vs.coords.inverseTransformPoints3(cs, ptsIn, ptsOut)
@@ -222,54 +238,17 @@
else:
xy = mainNode.getXYHit(vs, ev.getX(), ev.getY())
self.fenPDF.structure.canvas2d.placeOnCanvas(mainNode.getPlane(), self.node,
xy[0], xy[1])
-
+
+
# temporarily solution, flush drags away...
self.fenPDF.events.mouse.mainMouse.flush()
self.fenPDF.events.eventHandler.eventGrabber = None
self.fenPDF.animation.regenerateVS()
+
vob.AbstractUpdateManager.chg()
-
- def hideTipPanel(self, vs):
- cs = vs.matcher.getCS('TipPanel')
- if cs < 2:
- cs = vs.orthoBoxCS(0, 'TipPanel', 0,0,0, 1,1, 0,0)
+ def hideTipNode(self, vs):
+ cs = vs.matcher.getCS('TipNode')
+ if cs < 2: return
vs.coords.setOrthoBoxParams(cs, 0, 0,0,0,0,0,0)
- def showTipPanel(self, vs, ev):
- self.hideTipPanel(vs)
-
- buoymanager = self.fenPDF.views.getBuoyManager()
- mainNode = buoymanager.findTopmostMainNode(vs, ev.getX(), ev.getY())
- if mainNode == None: return
- node = mainNode.getNodeOnPlane(vs, ev.getX(), ev.getY())
- if node == None: return
- viewFunction = self.fenPDF.views.getMultiplexerNodeContentFunction()
- placeable = viewFunction.f(self.fenPDF.fen.graph, node)
- if not isinstance(placeable, vob.lava.placeable.TextPlaceable): return
-
- cs = mainNode.getNodeCS(vs, node)
- ptsIn = jarray.array([ev.getX(),ev.getY(),0], 'f')
- ptsOut = jarray.zeros(3, 'f')
- vs.coords.inverseTransformPoints3(cs, ptsIn, ptsOut)
- offset = placeable.getCursorPos(ptsOut[0], ptsOut[1])
- if self.tipOffset != offset:
- self.fenPDF.animation.regenerateVS()
- self.tipOffset = offset
-
- self.fenPDF.structure.ff.setContent(self.tipNode, \
- self.fenPDF.structure.ff.getContent(node))
- self.fenPDF.structure.ff.insert(self.tipNode, offset, \
- self.fenPDF.structure.ff.getContent(self.node))
-
- viewFunction = self.fenPDF.views.getMultiplexerNodeContentFunction()
- placeable = viewFunction.f(self.fenPDF.fen.graph, self.tipNode)
- cs = vs.matcher.getCS('TipPanel')
- vs.coords.setOrthoBoxParams(cs, -1000,50,50, 1,1,
- placeable.getWidth(),
placeable.getHeight())
- placeable.place(vs, cs)
- vob.AbstractUpdateManager.setNoAnimation()
- vob.AbstractUpdateManager.chg()
-
-
-
Index: fenfire/org/fenfire/fenpdf/actions/keyboard.py
diff -u fenfire/org/fenfire/fenpdf/actions/keyboard.py:1.15
fenfire/org/fenfire/fenpdf/actions/keyboard.py:1.16
--- fenfire/org/fenfire/fenpdf/actions/keyboard.py:1.15 Sat Oct 18 02:06:29 2003
+++ fenfire/org/fenfire/fenpdf/actions/keyboard.py Wed Nov 5 05:25:51 2003
@@ -42,14 +42,14 @@
# that by fenPDF.animation.regenerateVs()
class KeyActions:
- def __init__(self, context):
- self.context = context
+ def __init__(self, fenpdf):
+ self.fenPDF = fenpdf
def insertChar(self, main, char):
"""Insert a character to the accursed node - no creation.
If no node is accursed, will do nothing.
"""
- cur = self.context.states.cursor
+ cur = self.fenPDF.uistate.cursor
acc = cur.getAccursed()
@@ -67,7 +67,7 @@
If no node is accursed, create a new node at cursor.
"""
- cur = self.context.states.cursor
+ cur = self.fenPDF.uistate.cursor
if cur.getAccursed() == None:
node = self.fenPDF.actions.abstract.createNewNode(
@@ -87,7 +87,7 @@
The number n may be positive or negative.
If no node is accursed, will do nothing.
"""
- cur = self.context.states.cursor
+ cur = self.fenPDF.uistate.cursor
acc = cur.getAccursed()
if acc == None: return
@@ -102,8 +102,7 @@
self.fenPDF.animation.regenerateVS()
def backspace(self, main):
- cur = self.context.states.cursor
-
+ cur = self.fenPDF.uistate.cursor
node = cur.getAccursed()
if node == None: return
@@ -139,12 +138,12 @@
# Graa - this certainly doesn't work XXX
# **AND** breaks encapsulation. Was moved
# here from fenpdf10.py, and needs fixing XXX
- self.context.states.buoymanager.singles[1].mainNode =
ff.view.buoy.MainNode2D(planeHome, irregu, ctrl)
+ self.fenPDF.views.buoymanager.singles[1].mainNode =
ff.view.buoy.MainNode2D(planeHome, irregu, ctrl)
self.fenPDF.animation.regenerateVS()
def save(self):
- self.context.save()
+ self.fenPDF.actions.global.save()
self.fenPDF.animation.regenerateVS()
def exit(self):
Index: fenfire/org/fenfire/fenpdf/actions/mouse.py
diff -u fenfire/org/fenfire/fenpdf/actions/mouse.py:1.12
fenfire/org/fenfire/fenpdf/actions/mouse.py:1.13
--- fenfire/org/fenfire/fenpdf/actions/mouse.py:1.12 Fri Oct 31 02:21:15 2003
+++ fenfire/org/fenfire/fenpdf/actions/mouse.py Wed Nov 5 05:25:51 2003
@@ -38,11 +38,40 @@
# Define the actions.
-def defineActions(fenPDF, context):
+def defineActions(fenPDF):
def getMainNode():
return fenPDF.views.getBuoyManager().getLastMain()
def getOldVS():
return fenPDF.animation.lastVs
+ def getNodeCS(x,y):
+ """ Return node's coordinate system by given coordinates
+ found from underlying main node.
+ """
+ box2screen = getMainNode().getBox2Screen()
+ plane = getMainNode().getPlane()
+ if getMainNode().getView2D().getContentView2D() == None:
+ return -1
+ return getMainNode().getView2D(). \
+ getContentView2D().getNodeCS(getOldVS(),\
+ x,y, plane, box2screen, box2screen, 0, None)
+ def getNodeOnPlane(x,y):
+ """ Return node from underlying main node
+ found by given coordinates. Node may be null.
+ """
+ cs = getNodeCS(x,y)
+ if dbg: p('cs', cs)
+ if cs < 1: return None
+ return getOldVS().matcher.getKey(cs)
+ def getNodeCSbyNode(node):
+ """ Return given node's coordinate system from underlying main node.
+ """
+ box2screen = getMainNode().getBox2Screen()
+ plane = getMainNode().getPlane()
+ if getMainNode().getView2D().getContentView2D() == None:
+ return None
+ return getMainNode().getView2D(). \
+ getContentView2D().getNodeCS(getOldVS(),\
+ node, plane, box2screen, box2screen, 0)
def getOffset(node, x,y):
""" Get the text offset in screen coordinates if placeable
@@ -51,7 +80,7 @@
viewFunction = fenPDF.views.getMultiplexerNodeContentFunction()
placeable = viewFunction.f(fenPDF.fen.graph, node)
if isinstance(placeable, vob.lava.placeable.TextPlaceable):
- cs = getMainNode().getNodeCS(getOldVS(), node)
+ cs = getNodeCSbyNode(node)
ptsIn = jarray.array([x,y,0], 'f')
ptsOut = jarray.zeros(3, 'f')
getOldVS().coords.inverseTransformPoints3(cs, ptsIn, ptsOut)
@@ -66,7 +95,7 @@
placeable = viewFunction.f(fenPDF.fen.graph, node)
retArray = []
if isinstance(placeable, vob.lava.placeable.TextPlaceable):
- cs = getMainNode().getNodeCS(getOldVS(), node)
+ cs = getNodeCSbyNode(node)
xyy = jarray.zeros(3, 'f')
placeable.getCursorXYY(offset, xyy)
ptsIn = jarray.array([xyy[0],xyy[1],0], 'f')
@@ -91,7 +120,7 @@
placeable = viewFunction.f(fenPDF.fen.graph, node)
retArray = []
if isinstance(placeable, vob.lava.placeable.TextPlaceable):
- cs = getMainNode().getNodeCS(getOldVS(), node)
+ cs = getNodeCSbyNode(node)
ptsOut = jarray.zeros(3, 'f')
ptsIn = jarray.array([0,0,0], 'f')
getOldVS().coords.transformPoints3(cs, ptsIn, ptsOut)
@@ -119,10 +148,11 @@
class ScrollWheelPan(vob.input.RelativeAxisListener):
"""Scroll vertically using the scroll wheel.
"""
+ def __init__(self): self.mul = 13
def changedRelative(self, d):
f = getMainNode().getFocus()
fX, fY = f.getPanX(), f.getPanY()
- f.setPan(fX, fY-d/f.zoom)
+ f.setPan(fX, fY - d*self.mul/f.zoom)
getMainNode().setZoomPan(getOldVS())
class Pan_Fastest(vob.mouse.RelativeAdapter):
@@ -167,15 +197,19 @@
class BrowseClick(vob.mouse.MouseClickListener):
def clicked(self, x, y):
if dbg: p('move pan slow')
- obj = getMainNode().getNodeOnPlane(getOldVS(), x,y)
- context.states.cursor.setAccursed(obj)
+ obj = getNodeOnPlane(x,y)
+ if dbg: p('node', obj)
+ fenPDF.uistate.cursor.setAccursed(obj)
getMainNode().moveToPoint(int(x),int(y), getOldVS())
+ # clear selection
+ fenPDF.views.getAreaSelectView2D().clear()
+
viewFunction = fenPDF.views.getMultiplexerNodeContentFunction()
placeable = viewFunction.f(fenPDF.fen.graph, obj)
if dbg: p(placeable)
if obj != None and isinstance(placeable,
vob.lava.placeable.TextPlaceable):
- cs = getMainNode().getNodeCS(getOldVS(), x,y)
+ cs = getNodeCS(x,y)
ptsIn = jarray.array([x,y,0], 'f')
ptsOut = jarray.zeros(3, 'f')
getOldVS().coords.inverseTransformPoints3(cs, ptsIn, ptsOut)
@@ -196,13 +230,13 @@
class IfSelectNodeOnPlane(vob.mouse.MouseClickListener):
def clicked(self, x, y):
- obj = getMainNode().getNodeOnPlane(getOldVS(), x,y)
- context.states.cursor.setAccursed(obj)
+ obj = getNodeOnPlane(x,y)
+ fenPDF.uistate.cursor.setAccursed(obj)
fenPDF.animation.regenerateVS()
class MouseMenu(vob.mouse.MouseClickListener):
def clicked(self, x, y):
- obj = getMainNode().getNodeOnPlane(getOldVS(), x,y)
+ obj = getNodeOnPlane(x,y)
#if obj != None:
# context.states.objectOnPlane = obj
#context.mousemenu.link = 1
@@ -213,7 +247,7 @@
if dbg: p(placeable)
offs = None
if obj != None and isinstance(placeable,
vob.lava.placeable.TextPlaceable):
- cs = getMainNode().getNodeCS(getOldVS(), x,y)
+ cs = getNodeCS(x,y)
ptsIn = jarray.array([x,y,0], 'f')
ptsOut = jarray.zeros(3, 'f')
getOldVS().coords.inverseTransformPoints3(cs, ptsIn, ptsOut)
@@ -222,7 +256,7 @@
fenPDF.uistate.menu.originateFromMainNode(getMainNode(), obj, offs)
- context.mousemenu.showList(x,y,'mainmenu')
+ fenPDF.events.mousemenu.showList(x,y,'mainmenu')
fenPDF.animation.regenerateVS()
vob.AbstractUpdateManager.setNoAnimation()
@@ -231,7 +265,7 @@
class NodeMover(vob.mouse.RelativeAdapter,
vob.mouse.MousePressListener):
def pressed(self, x,y):
- self.set(getMainNode().getNodeOnPlane(getOldVS(), x,y),x,y)
+ self.set(getNodeOnPlane(x,y),x,y)
return self
def set(self, node, x,y):
self.evX, self.evY = x, y
@@ -253,15 +287,13 @@
viewFunction = fenPDF.views.getMultiplexerNodeContentFunction()
placeable = viewFunction.f(fenPDF.fen.graph, self.node)
if isinstance(placeable, vob.lava.placeable.TextPlaceable):
- cs = getMainNode().getNodeCS(getOldVS(), self.evX,self.evY)
+ cs = getNodeCS(self.evX,self.evY)
ptsIn = jarray.array([self.evX,self.evY,0], 'f')
ptsOut = jarray.zeros(3, 'f')
getOldVS().coords.inverseTransformPoints3(cs, ptsIn, ptsOut)
offs = placeable.getCursorPos(ptsOut[0], ptsOut[1])
- # optional textcloud
- textcloud = 0
- if textcloud and
fenPDF.uistate.textScissors.isScissored(self.node, offs):
+ if fenPDF.useExtension('TextCloud') and
fenPDF.uistate.textScissors.isScissored(self.node, offs):
fenPDF.uistate.textScissors.fixOffset()
node = ff.swamp.Nodes.N()
enf = fenPDF.structure.ff \
@@ -299,10 +331,11 @@
return self
def startDrag(self, x,y):
self.oldxy = getMainNode().getXYHit(getOldVS(), x, y)
- self.node = getMainNode().getNodeOnPlane(getOldVS(), x,y)
- offs = getOffset(self.node, x,y)
- if dbg: p('old', self.oldxy, self.node, offs)
- fenPDF.uistate.textScissors.setBegin(self.node, offs)
+ self.node = getNodeOnPlane(x,y)
+ if self.node != None:
+ offs = getOffset(self.node, x,y)
+ if dbg: p('old', self.oldxy, self.node, offs)
+ fenPDF.uistate.textScissors.setBegin(self.node, offs)
def drag(self, x, y):
if self.node != None:
offs = getOffset(self.node, x,y)
@@ -312,11 +345,12 @@
canvasCS =
getOldVS().matcher.getCS(getMainNode().getBox2Screen(),
'AreaSelectingView_concat')
if dbg: p(getOffsetXYY(self.node, canvasCS, offs))
- v = ff.util.lava.view.getView(getMainNode(),
ff.view.AreaSelectingView2D)
- v.setCurrentPlane(getMainNode().getPlane())
+ select = fenPDF.views.getAreaSelectView2D()
+ select.setCurrentPlane(getMainNode().getPlane())
+ select.clear()
xy = getMainNode().getXYHit(getOldVS(), x,y)
if not fenPDF.uistate.textScissors.isScissored(self.node):
- v.setArea(self.oldxy[0], self.oldxy[1], xy[0], xy[1])
+ select.setArea(self.oldxy[0], self.oldxy[1], xy[0], xy[1])
else:
if dbg: p('begin',fenPDF.uistate.textScissors.begin.offset,
'end', fenPDF.uistate.textScissors.end.offset)
@@ -325,13 +359,13 @@
end = getOffsetXYY(self.node, canvasCS,
fenPDF.uistate.textScissors.end.offset)
edge = getTextWidthEdges(self.node, canvasCS)
- v.setTextArea(begin[0], begin[1], begin[2],
+ select.setTextArea(begin[0], begin[1], begin[2],
end[0], end[1], end[2],
edge[0], edge[1])
- context.states.selection.setArea(
- (self.oldxy[0], self.oldxy[1], xy[0], xy[1]),
- getMainNode())
+ fenPDF.uistate.selection.setArea(
+ (self.oldxy[0], self.oldxy[1], xy[0], xy[1]),
+ getMainNode())
getMainNode().chgFast(getOldVS(), -1)
def endDrag(self, x,y):
@@ -348,9 +382,9 @@
self.panMover = panMover
def pressed(self, x, y):
if dbg: p("OldVS: ", getOldVS())
- obj = getMainNode().getNodeOnPlane(getOldVS(), x,y)
+ obj = getNodeOnPlane(x,y)
- if obj != None and obj == context.states.cursor.getAccursed():
+ if obj != None and obj == fenPDF.uistate.cursor.getAccursed():
if dbg: p('accursed!')
self.nodeMover.set(obj, x,y)
return self.nodeMover
@@ -376,7 +410,7 @@
buoymanager = fenPDF.views.getBuoyManager()
p('hit',buoymanager.buoyHit)
fenPDF.uistate.menu.originateFromBuoy(buoymanager.buoyHit)
- context.mousemenu.showList(x,y, 'buoymenu')
+ fenPDF.events.mousemenu.showList(x,y, 'buoymenu')
fenPDF.animation.regenerateVS()
vob.AbstractUpdateManager.setNoAnimation()
@@ -395,8 +429,8 @@
return res
class MouseActions:
- def __init__(self, fenPDF, context):
- actions = defineActions(fenPDF,context)
+ def __init__(self, fenPDF):
+ actions = defineActions(fenPDF)
for sym in actions.keys():
setattr(self, sym, actions[sym])
Index: fenfire/org/fenfire/fenpdf/appearance/papers.py
diff -u fenfire/org/fenfire/fenpdf/appearance/papers.py:1.13
fenfire/org/fenfire/fenpdf/appearance/papers.py:1.14
--- fenfire/org/fenfire/fenpdf/appearance/papers.py:1.13 Sat Oct 18
02:06:30 2003
+++ fenfire/org/fenfire/fenpdf/appearance/papers.py Wed Nov 5 05:25:51 2003
@@ -55,7 +55,6 @@
# keep them here.
self.scrollBlockImager = ff.spanimages.gl.PageScrollBlockImager()
- self.update()
def toggleBg(self, useBg = -1):
"""Toggle (or set) whether to use background textures.
@@ -103,10 +102,12 @@
if not self.booting:
self.fenPDF.views.update()
- def update(self):
- self.spanImageFactory = \
- ff.spanimages.gl.DefaultSpanImageFactory(
- self.scrollBlockImager)
+ def update(self, functional):
+ """Update the objects inside this class.
+
+ For functioninstances, use the given functional
+ object.
+ """
# self.spanImageFactory.poolManager.DICELENGTH = 10
makerEntry = None
if self.useBg:
@@ -125,7 +126,12 @@
if dbg: print "Maker:", paperMaker
else:
raise 'FIX ME! Got None makeEntry.'
- self.spanImageFactory.paperMaker = paperMaker
+ self.spanImageFactory = \
+ functional.createFunctionInstance(
+ "SpanImageFactory",
+ ff.spanimages.gl.DefaultSpanImageFactory,
+ [self.scrollBlockImager,
+ paperMaker])
# # Then, make it cache stuff
# self.spanImageFactory = \
Index: fenfire/org/fenfire/fenpdf/appearance/views.py
diff -u fenfire/org/fenfire/fenpdf/appearance/views.py:1.28
fenfire/org/fenfire/fenpdf/appearance/views.py:1.29
--- fenfire/org/fenfire/fenpdf/appearance/views.py:1.28 Fri Oct 31 02:21:15 2003
+++ fenfire/org/fenfire/fenpdf/appearance/views.py Wed Nov 5 05:25:51 2003
@@ -81,6 +81,7 @@
# "PageScroll2Layout", 200, 10); # superlazy cache as it *is* slow.
"PageScroll2Layout", 100, 1, 5.5); # superlazy cache as it *is*
slow.
+ self.papers.update(self.functional)
self.textFunction = self.functional.createFunctionInstance(
"ContentFunction",
@@ -88,7 +89,6 @@
[ self.fenPDF.structure.ff ])
- self.papers.update()
# XXX Figure out get & create stuffs
# We are essentially creating a DAG of objects and want to allow
# extensibility anywhere
@@ -102,13 +102,13 @@
self.multiplexerNodeFunction =
self.createMultiplexerNodeContentFunction()
########## The two View2D objects we will use:
+ # select view also
+ self.areaSelectView2d = ff.view.AreaSelectingView2D(None)
# Canvas
-
self.canvasview2d = self.createCanvasView2D()
# PageScroll
-
self.pagescrollview2d = self.createPageScrollView2D()
########## The corresponding node types
@@ -193,6 +193,9 @@
def getDoubleGeometer(self):
return self.doubleGeometer
+ def getAreaSelectView2D(self):
+ return self.areaSelectView2d
+
def setFocus(self, index, plane):
self.buoyManager.replaceManager(index,
self.createMainNode(plane))
@@ -200,13 +203,13 @@
def createMainNode(self, plane):
if isinstance(plane, alph.PageScrollBlock):
return ff.view.buoy.FisheyeMainNode2D(plane,
- self.pagescrollview2d,
- ff.view.buoy.AbstractMainNode2D.SimpleFocus(0,0),
- self.fenPDF.events.mouse.getMainMouseMultiplexer())
+ self.pagescrollview2d,
+ ff.view.buoy.AbstractMainNode2D.SimpleFocus(0,0),
+ self.fenPDF.events.mouse.getMainMouseMultiplexer())
else:
return ff.view.buoy.MainNode2D(plane, self.canvasview2d,
- self.fenPDF.events.mouse.getMainMouseMultiplexer())
-
+ self.fenPDF.events.mouse.getMainMouseMultiplexer())
+
def scene(self, vs):
"""Render the scene, and return the vobScene.
BuoyManager may decide
@@ -260,7 +263,7 @@
ff.view.TextNodeView,
[
self.textFunction,
- self.getTextStyle(), java.awt.Color.red
+ self.getTextStyle(), java.awt.Color(0.6, 0, 0)
])
accursed_page = self.functional.createFunctionInstance(
@@ -321,14 +324,10 @@
canvasview2d = ff.view.CanvasView2D(
self.fen,
self.multiplexerNodeFunction)
+ self.contentView2d = canvasview2d
canvasview2d = self.papers.decorateWithPaperView(canvasview2d)
- canvasview2d = ff.view.AreaSelectingView2D(canvasview2d)
+ canvasview2d = ff.view.View2DList([canvasview2d,
self.areaSelectView2d])
irregu = ff.view.IrregularViewportView2D(canvasview2d)
- if 0:
- #irregu.debugFlags ^= ff.view.IrregularViewportView2D.DEBUG_CONTENT
- #irregu.debugFlags ^= ff.view.IrregularViewportView2D.DEBUG_FRAME
- #irregu.debugFlags ^= ff.view.IrregularViewportView2D.DEBUG_BLANK
- irregu.debugFlags ^= ff.view.IrregularViewportView2D.DEBUG_CHILD
return irregu
@@ -370,8 +369,8 @@
pagescrollview2d =
ff.view.PageScrollView2D(function.getCallableFunction())
- return ff.view.AreaSelectingView2D(pagescrollview2d)
-
+ return ff.view.View2DList([pagescrollview2d, self.areaSelectView2d])
+
Index: fenfire/org/fenfire/fenpdf/demospace.py
diff -u fenfire/org/fenfire/fenpdf/demospace.py:1.5
fenfire/org/fenfire/fenpdf/demospace.py:1.6
--- fenfire/org/fenfire/fenpdf/demospace.py:1.5 Sat Oct 18 02:06:29 2003
+++ fenfire/org/fenfire/fenpdf/demospace.py Wed Nov 5 05:25:50 2003
@@ -18,6 +18,7 @@
# MA 02111-1307 USA
#
+from __future__ import nested_scopes
import java
from org import fenfire as ff
@@ -25,64 +26,75 @@
from org.fenfire.vocab import RDF, CANVAS2D
-def createDemoSpace(fen, myAlph, treetime, ppActions, structure_ff):
+def createDemoSpace(fen, myAlph, treetime, structure_ff):
"""Create a small space using a transclusion and structlinks.
"""
- paperA = "urn:urn-5:P7OMBN+yp3-m-AkulZN-NeaJV9Sl:_1"
- paperHome = "urn:urn-5:COz-fSvNBZRieCdefRTKO2Mgcjmz:_1"
+ paperA = Nodes.get("urn:urn-5:P7OMBN+yp3-m-AkulZN-NeaJV9Sl:_1")
+ paperHome = Nodes.get("urn:urn-5:COz-fSvNBZRieCdefRTKO2Mgcjmz:_1")
sc = myAlph.addFile(java.io.File('../alph/testdata/test1.pdf'),
'application/pdf')
- paperB = "urn:urn-5:P7OMBN+yp3-m-AkulZN-NeaJV9Sl:_2"
- paperC = "urn:urn-5:P7OMBN+yp3-m-AkulZN-NeaJV9Sl:_5"
- fen.graph.add(Nodes.get(paperHome), RDF.type, CANVAS2D.Canvas);
- fen.graph.add(Nodes.get(paperA), RDF.type, CANVAS2D.Canvas);
- fen.graph.add(Nodes.get(paperB), RDF.type, CANVAS2D.Canvas);
- fen.graph.add(Nodes.get(paperC), RDF.type, CANVAS2D.Canvas);
+ paperB = Nodes.get("urn:urn-5:P7OMBN+yp3-m-AkulZN-NeaJV9Sl:_2")
+ paperC = Nodes.get("urn:urn-5:P7OMBN+yp3-m-AkulZN-NeaJV9Sl:_5")
+ fen.graph.add(paperHome, RDF.type, CANVAS2D.Canvas);
+ fen.graph.add(paperA, RDF.type, CANVAS2D.Canvas);
+ fen.graph.add(paperB, RDF.type, CANVAS2D.Canvas);
+ fen.graph.add(paperC, RDF.type, CANVAS2D.Canvas);
if treetime != None:
- treetime.addLatest(fen.graph, Nodes.get(paperHome))
+ treetime.addLatest(fen.graph, paperHome)
treetime.addLatest(fen.graph, Nodes.get(sc.getID()))
- treetime.addLatest(fen.graph, Nodes.get(paperA))
- treetime.addLatest(fen.graph, Nodes.get(paperB))
- treetime.addLatest(fen.graph, Nodes.get(paperC))
-
- noteA1 = Nodes.get(ppActions.newNote(paperA, -30,-30, 'This is a test!'))
- noteA2 = Nodes.get(ppActions.newNote(paperA, -60,-70, 'This is a test2!'))
- noteA2 = Nodes.get(ppActions.newNote(paperA, -60,-100,
'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789'))
- noteA3 = Nodes.get(ppActions.newNote(paperA, 100, 100, ''))
- noteA4 = Nodes.get(ppActions.newNote(paperA, -60,70, 'This is a very long
test which is used to see if '))
+ treetime.addLatest(fen.graph, paperA)
+ treetime.addLatest(fen.graph, paperB)
+ treetime.addLatest(fen.graph, paperC)
+
+ canvas2d = ff.structure.Canvas2D.create(fen.graph)
+ alphContent = ff.util.AlphContent(fen, structure_ff)
+ structLink = ff.structure.StructLink.create(fen.graph)
+
+ def newNote(pap, x, y, str):
+ node = Nodes.N()
+ canvas2d.placeOnCanvas(pap, node, x, y)
+ alphContent.setText(node, str, 1)
+ return node
+
+
+ noteA1 = newNote(paperA, -30,-30, 'This is a test!')
+ noteA2 = newNote(paperA, -60,-70, 'This is a test2!')
+ noteA2 = newNote(paperA, -60,-100, 'abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789')
+ noteA3 = newNote(paperA, 100, 100, '')
+ noteA4 = newNote(paperA, -60,70, 'This is a very long test which is used
to see if ')
fen.graph.add(noteA2, RDF.type, ff.vocab.lava.MINDSTRUCT.Data)
- ppActions.assocNotes(noteA1, 1, noteA2);
+ structLink.link(noteA1, noteA2);
span = sc.getCurrent().getPage(0).subArea(100, 100, 300, 200);
structure_ff.setContent(noteA3, fen.enfMaker.makeEnfilade(span))
- noteB1 = Nodes.get(ppActions.newNote(paperB, 1000,500, 'This is an another
test!'))
- noteA2 = Nodes.get(ppActions.newNote(paperB, 1000,600,
'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789'))
+ noteB1 = newNote(paperB, 1000,500, 'This is an another test!')
+ noteA2 = newNote(paperB, 1000,600, 'abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789')
- ppActions.assocNotes(noteA1, 1, noteB1)
+ structLink.link(noteA1, noteB1)
- noteHome = Nodes.get(ppActions.newNote(paperHome, 0, 0, 'HOME'))
- noteA2 = Nodes.get(ppActions.newNote(paperHome, 0,100,
'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789'))
+ noteHome = newNote(paperHome, 0, 0, 'HOME')
+ noteA2 = newNote(paperHome, 0,100, 'abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789')
- ppActions.assocNotes(noteHome, 1, noteA1)
+ structLink.link(noteHome, 1, noteA1)
- noteH2 = Nodes.get(ppActions.newNote(paperHome, -400, 0, 'foobar'))
- noteB2 = Nodes.get(ppActions.newNote(paperB, 1200, 300, 'This is yet
another test!'))
- ppActions.assocNotes(noteB2, 1, noteH2)
+ noteH2 = newNote(paperHome, -400, 0, 'foobar')
+ noteB2 = newNote(paperB, 1200, 300, 'This is yet another test!')
+ structLink.link(noteB2, 1, noteH2)
- noteC1 = Nodes.get(ppActions.newNote(paperC, 0, 0, 'baz'))
- noteC2 = Nodes.get(ppActions.newNote(paperC, -200, 50, 'bar'))
- noteB3 = Nodes.get(ppActions.newNote(paperB, 1150, 600, 'foo'))
- noteA4 = Nodes.get(ppActions.newNote(paperA, -100, -200, 'Lorem ipsum
dolor'))
+ noteC1 = newNote(paperC, 0, 0, 'baz')
+ noteC2 = newNote(paperC, -200, 50, 'bar')
+ noteB3 = newNote(paperB, 1150, 600, 'foo')
+ noteA4 = newNote(paperA, -100, -200, 'Lorem ipsum dolor')
- ppActions.assocNotes(noteC1, 1, noteB3)
- ppActions.assocNotes(noteA4, 1, noteC2)
+ structLink.link(noteC1, 1, noteB3)
+ structLink.link(noteA4, 1, noteC2)
def createEmptySpace(fen, myAlph, treetime, ppActions, structure_ff):
Index: fenfire/org/fenfire/fenpdf/events/buttons.py
diff -u fenfire/org/fenfire/fenpdf/events/buttons.py:1.3
fenfire/org/fenfire/fenpdf/events/buttons.py:1.4
--- fenfire/org/fenfire/fenpdf/events/buttons.py:1.3 Sat Oct 18 02:06:30 2003
+++ fenfire/org/fenfire/fenpdf/events/buttons.py Wed Nov 5 05:25:51 2003
@@ -44,7 +44,7 @@
self.fenPDF.actions.key.newCanvas()
return 1
elif key == "SAVE":
- self.fenPDF.actions.key.save()
+ self.fenPDF.actions.global.save()
return 1
else:
p('key', key)
Index: fenfire/org/fenfire/fenpdf/events/eventhandler.py
diff -u fenfire/org/fenfire/fenpdf/events/eventhandler.py:1.15
fenfire/org/fenfire/fenpdf/events/eventhandler.py:1.16
--- fenfire/org/fenfire/fenpdf/events/eventhandler.py:1.15 Fri Oct 31
02:21:15 2003
+++ fenfire/org/fenfire/fenpdf/events/eventhandler.py Wed Nov 5 05:25:52 2003
@@ -34,7 +34,7 @@
""" *THE* event handler - if you want to grab the event - grab
it in the beginning.
"""
- self.context.states.lastEvent = ev
+ self.fenPDF.uistate.lastEvent = ev
if dbg: p(ev)
Index: fenfire/org/fenfire/fenpdf/events/key.py
diff -u fenfire/org/fenfire/fenpdf/events/key.py:1.5
fenfire/org/fenfire/fenpdf/events/key.py:1.6
--- fenfire/org/fenfire/fenpdf/events/key.py:1.5 Sat Oct 18 02:06:30 2003
+++ fenfire/org/fenfire/fenpdf/events/key.py Wed Nov 5 05:25:52 2003
@@ -38,8 +38,6 @@
print 'ff.fenpdf.events.key::', s
class KeyHandler:
- def __init__(self, states):
- self.states = states
def key(self, key, main):
if dbg: p('KEY', key,', v:',main)
Index: fenfire/org/fenfire/fenpdf/events/mouse.py
diff -u fenfire/org/fenfire/fenpdf/events/mouse.py:1.6
fenfire/org/fenfire/fenpdf/events/mouse.py:1.7
--- fenfire/org/fenfire/fenpdf/events/mouse.py:1.6 Sat Oct 18 02:06:30 2003
+++ fenfire/org/fenfire/fenpdf/events/mouse.py Wed Nov 5 05:25:52 2003
@@ -30,8 +30,7 @@
"""
class MouseMapper:
- def __init__(self, context):
- self.context = context
+ def __init__(self):
self.mainMouse = vob.mouse.MouseMultiplexer()
self.buoyMouse = vob.mouse.MouseMultiplexer()
@@ -79,8 +78,6 @@
# With wheel
self.mainMouse.setWheelListener(0, 'Scrolling', \
actions.mouse.ScrollWheelPan())
-
- self.context.states.mainMouse = self.mainMouse
# Default controls for buoys
Index: fenfire/org/fenfire/fenpdf/events/mousemenu.py
diff -u fenfire/org/fenfire/fenpdf/events/mousemenu.py:1.14
fenfire/org/fenfire/fenpdf/events/mousemenu.py:1.15
--- fenfire/org/fenfire/fenpdf/events/mousemenu.py:1.14 Fri Oct 31 02:21:15 2003
+++ fenfire/org/fenfire/fenpdf/events/mousemenu.py Wed Nov 5 05:25:52 2003
@@ -33,16 +33,15 @@
dbg = 0
class MouseMenu(ff.fenpdf.actions.eventgrabs.Grabber):
- def __init__(self, fenPDF, states):
+ def __init__(self, fenPDF):
self.fenPDF = fenPDF
- self.states = states
- self.style = vob.GraphicsAPI.getInstance().getTextStyle('sans', 0, 12)
- self.makeMainList()
- self.hideList()
+ self.selectListVob = None
+ self.x, self.y = 0 ,0
+ self.w, self.h = .0, .0
def makeMainList(self):
list = []
- if self.states.selection.hasSelection():
+ if self.fenPDF.uistate.selection.hasSelection():
list.append(Item('Transclude selection (PDF to canvas only)',
lambda: self.fenPDF.actions.menu.transclude()))
if self.fenPDF.uistate.menu.originatingNode:
@@ -65,9 +64,10 @@
self.selectListVob = vob.vobs.SelectListVob(list)
def render(self, vs):
- cs = vs.orthoBoxCS(0, 'MOUSE_MENU',-100, self.x, self.y-self.h/2,
- 1,1, self.w, self.h)
- vs.put(self.selectListVob, cs)
+ if self.selectListVob:
+ cs = vs.orthoBoxCS(0, 'MOUSE_MENU',-100, self.x, self.y-self.h/2,
+ 1,1, self.w, self.h)
+ vs.put(self.selectListVob, cs)
def showList(self, x, y, who):
self.fenPDF.events.eventHandler.eventGrabber = self
@@ -91,8 +91,8 @@
def hideList(self):
self.fenPDF.events.eventHandler.eventGrabber = None
p("Hidelist")
- if hasattr(self.states, 'lastEvent'):
- self.x, self.y = self.states.lastEvent.getX(),
self.states.lastEvent.getY()
+ if hasattr(self.fenPDF.uistate, 'lastEvent'):
+ self.x, self.y = self.fenPDF.uistate.lastEvent.getX(),
self.fenPDF.uistate.lastEvent.getY()
else: self.x, self.y = 0,0
self.w, self.h = .0, .0
Index: fenfire/org/fenfire/fenpdf/fenpdf.py
diff -u fenfire/org/fenfire/fenpdf/fenpdf.py:1.17
fenfire/org/fenfire/fenpdf/fenpdf.py:1.18
--- fenfire/org/fenfire/fenpdf/fenpdf.py:1.17 Thu Oct 23 15:09:56 2003
+++ fenfire/org/fenfire/fenpdf/fenpdf.py Wed Nov 5 05:25:50 2003
@@ -23,7 +23,8 @@
"""
from org import fenfire as ff
-import vob
+import vob, java
+from org.fenfire.vocab import TREETIME
def p(*s):
print 'fenpdf.py::',s
@@ -70,6 +71,22 @@
self.lastVs = vs
self.animate = 1
+class Cursor(ff.view.lava.Cursor):
+ """ The cursor for a node, e.g., text or pgaespan
+ (in canvas view). Cursor is like text cursor in text editor,
+ i.e., single instance and used to represent the accursed
+ node and offset.
+ """
+ def __init__(self, alphContent, multiplexer):
+ ff.view.lava.Cursor.__init__(self, alphContent)
+ self.multiplexer = multiplexer
+ def setAccursed(self, node):
+ ff.view.lava.Cursor.setAccursed(self, node)
+ set = java.util.HashSet()
+ set.add(node)
+ self.multiplexer.setMultiplexerNodes(set)
+
+
class UIState_Menu:
"""
@@ -222,30 +239,97 @@
support text cloud operations
menu -- State of the ui context menu.
-
+
+ extensions -- extensions to fenPDF specification
Any internal members are prefixed by underscore and should
not be used by anyone else.
"""
- def __init__(self, fen, treeTime, structure_ff):
- self.fen = fen
-
- self.events = _Empty()
- self.actions = _Empty()
- self.structure = _Empty()
- self.animation = AnimationState()
- self.uistate = _Empty()
- self.uistate.menu = UIState_Menu()
- self.uistate.textScissors = UIState_Scissors()
-
-
- self.structure.ff = structure_ff
- self.structure.structLink = ff.structure.StructLink.create(fen.graph)
- self.structure.alphContent = ff.util.AlphContent(fen, structure_ff)
- self.structure.canvas2d = ff.structure.Canvas2D.create(fen.graph)
- self.structure.treeTime = treeTime
-
+ def __init__(self, fen, treeTime, structure_ff, window,
+ filename):
+ fenPDF = self
+ fenPDF.fen = fen
+ fenPDF.window = window
+
+ # Default controls for main view
+ ## see
http://himalia.it.jyu.fi/ffdoc/fenfire/pegboard/fenpdf_v1_spec_1--tjl/peg.gen.html
and 'Bindings'
+ fenPDF.events = _Empty()
+ if 1:
+ fenPDF.events.buttons = ff.fenpdf.events.buttons.ActionButtons()
+ fenPDF.events.buttons.fenPDF = fenPDF
+ fenPDF.events.eventHandler = \
+ ff.fenpdf.events.eventhandler.EventHandler(fenPDF)
+ fenPDF.events.mouse = ff.fenpdf.events.mouse.MouseMapper()
+ fenPDF.events.key = ff.fenpdf.events.key.KeyHandler()
+ fenPDF.events.mousemenu =
ff.fenpdf.events.mousemenu.MouseMenu(fenPDF)
+
+ fenPDF.actions = _Empty()
+ if 1:
+ actions = ff.fenpdf.actions
+ fenPDF.actions.mouse = actions.mouse.MouseActions(fenPDF)
+ fenPDF.actions.key = actions.keyboard.KeyActions(fenPDF)
+ fenPDF.actions.menu = actions.menu.MenuActions(fenPDF)
+ fenPDF.actions.abstract = actions.abstract.AbstractActions(fenPDF)
+ fenPDF.actions.global = actions.globalactions.GlobalActions(fenPDF)
+
+ papers = ff.fenpdf.appearance.papers.Papers(fenPDF)
+
+ fenPDF.structure = _Empty()
+ fenPDF.animation = AnimationState()
+
+ fenPDF.uistate = _Empty()
+ if 1:
+ fenPDF.uistate.filename = filename
+ fenPDF.uistate.menu = UIState_Menu()
+ fenPDF.uistate.textScissors = UIState_Scissors()
+ fenPDF.uistate.selection = ff.fenpdf.fenpdfcontext.Selection()
+
+
+ fenPDF.structure.ff = structure_ff
+ fenPDF.structure.structLink = ff.structure.StructLink.create(fen.graph)
+ fenPDF.structure.alphContent = ff.util.AlphContent(fen, structure_ff)
+ fenPDF.structure.canvas2d = ff.structure.Canvas2D.create(fen.graph)
+ fenPDF.structure.treeTime = treeTime
+ fenPDF.extensions = ff.fenpdf.extensions.getExtensions()
+
+ # The first plane is the "firstOf" of the TREETIME follows
+ # relation.
+ iter = fen.constgraph.findN_X11_Iter(TREETIME.firstOf,
+ TREETIME.follows)
+ planeHome = iter.next()
+ if planeHome == None:
+ raise "Error: home plane not found"
+
+ # Check the type of the home plane, just in case
+ if not fenPDF.structure.canvas2d.isCanvas(planeHome):
+ raise "Error: home plane not found - wrong type ", planeHome
+
+ # Views must be created last - XXX
+ fenPDF.views = \
+ ff.fenpdf.appearance. \
+ views.Views(fenPDF, papers, fenPDF.events.eventHandler, planeHome)
+
+ fenPDF.views.background = \
+ ff.fenpdf.appearance.background.FancyBlueBackground1()
+
+ fenPDF.uistate.cursor = \
+ ff.fenpdf.fenpdf.Cursor(fenPDF.structure.alphContent,
+ fenPDF.views.getMultiplexerNodeContentFunction())
+
+ fenPDF.events.mouse.fenPDF = fenPDF
+ fenPDF.events.mouse.update()
+
+ fenPDF.events.key.fenPDF = fenPDF
+
+ def getVersion(self):
+ """ returns the version number of specification of fenpdf.
+ """
+ return 1.0
def render(self, vs):
pass
+ def useExtension(self, extname):
+ """ Return true if extension is enabled otherwise return false.
+ """
+ return self.extensions.get(extname, 0)
Index: fenfire/org/fenfire/fenpdf/fenpdfcontext.py
diff -u fenfire/org/fenfire/fenpdf/fenpdfcontext.py:1.36
fenfire/org/fenfire/fenpdf/fenpdfcontext.py:1.37
--- fenfire/org/fenfire/fenpdf/fenpdfcontext.py:1.36 Thu Oct 23 15:09:56 2003
+++ fenfire/org/fenfire/fenpdf/fenpdfcontext.py Wed Nov 5 05:25:50 2003
@@ -31,15 +31,6 @@
global w
-class Cursor(ff.view.lava.Cursor):
- def __init__(self, alphContent, multiplexer):
- ff.view.lava.Cursor.__init__(self, alphContent)
- self.multiplexer = multiplexer
- def setAccursed(self, node):
- ff.view.lava.Cursor.setAccursed(self, node)
- set = java.util.HashSet()
- set.add(node)
- self.multiplexer.setMultiplexerNodes(set)
class Selection:
"""A selected area
@@ -75,124 +66,65 @@
h = a[1]-a[3]
return (x, y, w, h)
-class ContextStates:
- def __init__(self, fen, ppAction):
- self.clean()
- self.ppActions = ppAction
- self.fen = fen
- self.pageview = None
-
-
- # main view mouse multiplexer
- self.mainMouse = None
+class CursorRenderer(ff.view.buoy.AbstractMainNode2D.Context):
+ """The class responsible for rendering a text cursor
+ into a main view.
+ """
+ def __init__(self, fenpdf):
+ self.fenPDF = fenpdf
+
# kludge to keep flag how BuoyViewMainNode.mouse() should return.
# see AbstractMainNode2D.mouse()
- self.fastChg = 0
+ self.fenPDF.uistate.fastChg = 0
- class Views:
- def __init__(self):
- self.irregu = None
- self.pageview = None
- self.view2d = Views()
-
- self.fenPDF = None
-
- def clean(self):
- pass
-
-class Context(#ff.view.lava.ContextNodeView.Context,
- ff.view.buoy.AbstractMainNode2D.Context):
- def __init__(self, win, fen, pp, filename):
- global w
- w = win
- self.states = ContextStates(fen, pp)
- self.fen = fen
- self.filename = filename
-
-
+ self.cursorVob = vob.vobs.ContinuousLineVob(5, [0,0,0 , 0,1,0])
# call back from AbstractMainNode2D
+ # XXX SHouldn't be done like this
def changeFastAfterMouseEvent(self):
- return self.states.fastChg
+ return self.fenPDF.uistate.fastChg
# call back from AbstractMainNode2D
+ # chgFast isn't called!!! XXX
def mainNodeToBeRender(self, vs, into, mainNode):
- self.selection = ff.util.lava.view.getView(mainNode,
ff.view.AreaSelectingView2D)
+
+ if dbg:
+ print "MAINNODETOBERENDER",self,vs,into,mainNode
- buoymanager = self.states.fenPDF.views.getBuoyManager()
+ self.selection = self.fenPDF.views.getAreaSelectView2D()
+
+ buoymanager = self.fenPDF.views.getBuoyManager()
if mainNode != buoymanager.getLastMain(): return
mainNode = buoymanager.getLastMain()
- canvas = ff.util.lava.view.getView(mainNode, ff.view.CanvasView2D)
- if not isinstance(canvas, ff.view.CanvasView2D): return
-
+ contentView = mainNode.getView2D().getContentView2D()
+ if not isinstance(contentView, ff.view.CanvasView2D): return
+ canvas = contentView
+
xy = jarray.zeros(3, 'f')
- # XXX ugly
- height = 23
+ height = self.fenPDF.views.textStyle.getHeight(1)
-
- # draw scissors points
- node = self.states.fenPDF.uistate.textScissors.begin.node
- if node != None:
- containerCS = canvas.getContainerCS(vs, into)
- cs = vs.matcher.getCS(containerCS, node)
- if cs < 2: return
-
- viewFunction =
self.states.fenPDF.views.getMultiplexerNodeContentFunction()
- placeable = viewFunction.f(self.states.fen.graph, node)
- p('offset:',self.states.fenPDF.uistate.textScissors.begin.offset)
- if isinstance(placeable, vob.lava.placeable.TextPlaceable):
-
placeable.getCursorXYY(self.states.fenPDF.uistate.textScissors.begin.offset, xy)
-
- cs = vs.coords.ortho(cs, 0,xy[0],xy[1], height, xy[1]-xy[2])
- vs.put(vob.vobs.ContinuousLineVob(5, [.3,-.3,0 , 0,0,0 , 0,1,0
, .3,1.3,0], 0, 100, java.awt.Color.blue), cs)
-
- node = self.states.fenPDF.uistate.textScissors.end.node
- if node != None:
- containerCS = canvas.getContainerCS(vs, into)
- cs = vs.matcher.getCS(containerCS, node)
- if cs < 2: return
-
- viewFunction =
self.states.fenPDF.views.getMultiplexerNodeContentFunction()
- placeable = viewFunction.f(self.states.fen.graph, node)
- if isinstance(placeable, vob.lava.placeable.TextPlaceable):
-
placeable.getCursorXYY(self.states.fenPDF.uistate.textScissors.end.offset, xy)
-
- cs = vs.coords.ortho(cs, 0,xy[0],xy[1], height, xy[1]-xy[2])
- vs.put(vob.vobs.ContinuousLineVob(5, [-.3,-.3,0 , 0,0,0 ,
0,1,0 , -.3,1.3,0], 0, 100, java.awt.Color.blue), cs)
-
-
-
-
# draw cursor
- if not self.states.cursor.hasAccursed():
+ if not self.fenPDF.uistate.cursor.hasAccursed():
focus = mainNode.getFocus()
cs = vs.matcher.getCS(into, 'canvasview_conc')
cs = vs.coords.orthoBox(cs,0, focus.getPanX(), focus.getPanY(),
1,1, 1,1)
else:
# draw the cursor in somewhere where node is.
containerCS = canvas.getContainerCS(vs, into)
- cs = vs.matcher.getCS(containerCS,
self.states.cursor.getAccursed())
+ cs = vs.matcher.getCS(containerCS,
self.fenPDF.uistate.cursor.getAccursed())
if cs < 0: return
- viewFunction =
self.states.fenPDF.views.getMultiplexerNodeContentFunction()
- pl = viewFunction.f(self.states.fen.graph,
self.states.cursor.getAccursed())
+ viewFunction =
self.fenPDF.views.getMultiplexerNodeContentFunction()
+ pl = viewFunction.f(self.fenPDF.fen.graph,
self.fenPDF.uistate.cursor.getAccursed())
if isinstance(pl, vob.lava.placeable.TextPlaceable):
- pl.getCursorXYY(self.states.cursor.getCursorOffset(), xy)
+ pl.getCursorXYY(self.fenPDF.uistate.cursor.getCursorOffset(),
xy)
+ height = xy[1] - xy[2]
else: return
- cs = vs.coords.ortho(cs, 0,xy[0],xy[2], 1, -height)
- vs.put(vob.vobs.ContinuousLineVob(5, [0,0,0 , 0,1,0]), cs)
+ cs = vs.coords.ortho(cs, 0,xy[0],xy[2], 1, height)
+ vs.put(self.cursorVob, cs)
- def save(self):
- print "SAVING..."
- ff.swamp.writer.write(self.fen.graph, self.filename);
- print "DONE"
-
- def clean(self):
- self.mousemenu.hideList()
- self.states.clean()
-
Index: fenfire/org/fenfire/spanimages/SpanImageFactory.java
diff -u fenfire/org/fenfire/spanimages/SpanImageFactory.java:1.6
fenfire/org/fenfire/spanimages/SpanImageFactory.java:1.7
--- fenfire/org/fenfire/spanimages/SpanImageFactory.java:1.6 Tue Jun 24
08:09:33 2003
+++ fenfire/org/fenfire/spanimages/SpanImageFactory.java Wed Nov 5
05:25:52 2003
@@ -27,9 +27,11 @@
package org.fenfire.spanimages;
import org.fenfire.spanimages.gl.*;
import org.nongnu.alph.*;
+import org.fenfire.functional.Function;
/** The central interface for creating vobs that contain
* images of ImageSpans.
+ * Input: ImageSpan; Output: SpanImageVob
* The backend of this interface takes care of all caching and other
* operations necessary.
* <p>
@@ -37,19 +39,23 @@
* if the imagespan contains raster data, or 75 pixels per inch, if
* the imagespan contains vector data.
*/
-public abstract class SpanImageFactory {
+public abstract class SpanImageFactory implements Function {
private static SpanImageFactory instance;
+ /** (For tests, mostly) Get a reasonable instance
+ * of SpanImageFactory.
+ */
public static SpanImageFactory getDefaultInstance() {
// XXX This is wrong - need a mux to handle images!
if(instance == null)
instance = new CachingSpanImageFactory(
new DefaultSpanImageFactory(
- new PageScrollBlockImager()));
+ new PageScrollBlockImager(),
+ new PlainPaperMaker()
+ ));
return instance;
}
- abstract public SpanImageVob getSpanImageVob(ImageSpan s);
}
Index: fenfire/org/fenfire/spanimages/gl/CachingSpanImageFactory.java
diff -u fenfire/org/fenfire/spanimages/gl/CachingSpanImageFactory.java:1.4
fenfire/org/fenfire/spanimages/gl/CachingSpanImageFactory.java:1.5
--- fenfire/org/fenfire/spanimages/gl/CachingSpanImageFactory.java:1.4 Thu Aug
28 10:23:19 2003
+++ fenfire/org/fenfire/spanimages/gl/CachingSpanImageFactory.java Wed Nov
5 05:25:52 2003
@@ -54,11 +54,11 @@
cache.clear();
}
- public SpanImageVob getSpanImageVob(ImageSpan s) {
+ public Object f(Object s) {
SpanImageVob ret = (SpanImageVob)cache.get(s);
if(ret == null) {
listener.startMiss(s);
- ret = factory.getSpanImageVob(s);
+ ret = (SpanImageVob)factory.f(s);
cache.put(s, ret);
listener.endMiss(s);
} else
Index: fenfire/org/fenfire/spanimages/gl/DefaultSpanImageFactory.java
diff -u fenfire/org/fenfire/spanimages/gl/DefaultSpanImageFactory.java:1.12
fenfire/org/fenfire/spanimages/gl/DefaultSpanImageFactory.java:1.13
--- fenfire/org/fenfire/spanimages/gl/DefaultSpanImageFactory.java:1.12 Sun Nov
2 14:20:51 2003
+++ fenfire/org/fenfire/spanimages/gl/DefaultSpanImageFactory.java Wed Nov
5 05:25:52 2003
@@ -35,17 +35,20 @@
import java.awt.Dimension;
import java.awt.Point;
+/** A class that converts ImageSpans to SpanImageVobs.
+ */
public class DefaultSpanImageFactory extends SpanImageFactory {
public static boolean dbg = false;
private static void p(String s) {
System.out.println("DefaultSpanImageFactory: "+s); }
- public PoolManager poolManager = PoolManager.getInstance();
- public PaperMaker paperMaker = new PlainPaperMaker();
+ public PaperMaker paperMaker ;
public ScrollBlockImager scrollBlockImager;
- public DefaultSpanImageFactory(ScrollBlockImager imager) {
+ public DefaultSpanImageFactory(ScrollBlockImager imager,
+ PaperMaker paperMaker) {
this.scrollBlockImager = imager;
+ this.paperMaker = paperMaker;
}
/** Get the whole contiguous 2D image that this span is a part of.
@@ -62,12 +65,13 @@
}
}
- public SpanImageVob getSpanImageVob(ImageSpan s) {
+ public Object f(Object imageSpan0) {
+ ImageSpan imageSpan = (ImageSpan)imageSpan0;
- ImageSpan superImage = getSuperImageSpan(s);
+ ImageSpan superImage = getSuperImageSpan(imageSpan);
SingleImage singleImage = scrollBlockImager.getSingleImage(
- s, poolManager);
+ imageSpan.getSuperImageSpan());
// x,y texcoords of (1,1) inside texture
float x1 = singleImage.virtualTexture.mipzipFile.getOrigWidth();
@@ -94,8 +98,8 @@
float xscale = 1f / largest.width / xpixReso;
float yscale = 1f / largest.height / ypixReso;
- Point p =s.getLocation();
- Dimension ps =s.getSize();
+ Point p =imageSpan.getLocation();
+ Dimension ps =imageSpan.getSize();
float xoffs = p.x / (float)d.width * x1;
float yoffs = p.y / (float)d.height * y1;
@@ -112,7 +116,7 @@
Paper paper = paperMaker.makePaper(singleImage, texgen);
- return poolManager.makeVob(
+ return PoolManager.getInstance().makeVob(
singleImage,
paper,
texgen,
Index: fenfire/org/fenfire/spanimages/gl/MuxSpanImageFactory.java
diff -u fenfire/org/fenfire/spanimages/gl/MuxSpanImageFactory.java:1.4
fenfire/org/fenfire/spanimages/gl/MuxSpanImageFactory.java:1.5
--- fenfire/org/fenfire/spanimages/gl/MuxSpanImageFactory.java:1.4 Thu Jun
12 07:07:45 2003
+++ fenfire/org/fenfire/spanimages/gl/MuxSpanImageFactory.java Wed Nov 5
05:25:52 2003
@@ -41,11 +41,11 @@
this.pageImageFactory = pageImageFactory;
}
- public SpanImageVob getSpanImageVob(ImageSpan s) {
+ public Object f(Object s) {
if(s instanceof PageImageSpan)
- return pageImageFactory.getSpanImageVob(s);
+ return pageImageFactory.f(s);
else
- return imageFactory.getSpanImageVob(s);
+ return imageFactory.f(s);
}
}
Index: fenfire/org/fenfire/spanimages/gl/PageScrollBlockImager.java
diff -u fenfire/org/fenfire/spanimages/gl/PageScrollBlockImager.java:1.15
fenfire/org/fenfire/spanimages/gl/PageScrollBlockImager.java:1.16
--- fenfire/org/fenfire/spanimages/gl/PageScrollBlockImager.java:1.15 Fri Oct
17 05:25:33 2003
+++ fenfire/org/fenfire/spanimages/gl/PageScrollBlockImager.java Wed Nov
5 05:25:52 2003
@@ -37,6 +37,8 @@
import java.io.*;
import java.util.*;
+/** A class that converts PageImageSpans to SingleImages.
+ */
public class PageScrollBlockImager extends ScrollBlockImager {
public static boolean dbg = true;
private static void p(String s) {
@@ -85,7 +87,7 @@
String[] filenames;
}
- public SingleImage getSingleImage(ImageSpan img, PoolManager poolManager) {
+ public SingleImage getSingleImage(ImageSpan img) {
PageImageSpan span = (PageImageSpan)img;
int page = span.getPageIndex();
@@ -105,8 +107,7 @@
page,
pageFiles.filenames[page],
pageFiles.xreso,
- pageFiles.yreso,
- poolManager
+ pageFiles.yreso
);
} catch(Exception e) {
e.printStackTrace();
Index: fenfire/org/fenfire/spanimages/gl/PoolManager.java
diff -u fenfire/org/fenfire/spanimages/gl/PoolManager.java:1.17
fenfire/org/fenfire/spanimages/gl/PoolManager.java:1.18
--- fenfire/org/fenfire/spanimages/gl/PoolManager.java:1.17 Sun Nov 2
14:20:51 2003
+++ fenfire/org/fenfire/spanimages/gl/PoolManager.java Wed Nov 5 05:25:52 2003
@@ -209,13 +209,38 @@
};
- /** A set of singleimages that are to be locked at
+ /** (For tests): A set of singleimages that are to be locked at
* maximum resolution.
*/
- public Set locked = Collections.synchronizedSet(new HashSet());
+ public List locked = null;
+
+ synchronized public void lock(SingleImage image) throws
java.io.IOException {
+ if(locked == null)
+ locked = new ArrayList();
+
+ locked.add(image);
+ if(locked.size() > slotContents[0].length)
+ throw new Error("Locking too many");
+ for(int level=0; level<slotContents.length; level++) {
+ for(int i=0; i<slotContents[level].length; i++)
+ slotContents[level][i] = null;
+ }
+ for(int i=0; i<locked.size(); i++)
+ slotContents[0][i] = ((SingleImage)locked.get(i)).virtualTexture;
+
+ indirectMipzipManager.setSlotContents_synchronously(slotContents);
+ }
+
+ synchronized public void unlock() {
+ locked = null;
+ }
+
SingleImage[] templ = new SingleImage[0];
- public void updateAllocs() {
+ synchronized public void updateAllocs() {
+
+ if(locked != null) return;
+
SingleImage[] actives = (SingleImage[])activeSet.toArray(templ);
if(dbg) p("UpdateAllocs start "+actives.length+" "+this);
Arrays.sort(actives, sortPriority);
Index: fenfire/org/fenfire/spanimages/gl/ScrollBlockImager.java
diff -u fenfire/org/fenfire/spanimages/gl/ScrollBlockImager.java:1.4
fenfire/org/fenfire/spanimages/gl/ScrollBlockImager.java:1.5
--- fenfire/org/fenfire/spanimages/gl/ScrollBlockImager.java:1.4 Mon Jun
23 10:00:36 2003
+++ fenfire/org/fenfire/spanimages/gl/ScrollBlockImager.java Wed Nov 5
05:25:52 2003
@@ -30,10 +30,17 @@
/** Base class for the classes holding scrollblock images.
* Contains some necessary trappings.
+ * The getSingleImage method should only be called with
+ * entire image spans, i.e. objects obtained
+ * from imageSpan.getSuperImageSpan(), to allow proper caching.
*/
public abstract class ScrollBlockImager {
- static File __tmp = new File("./tmpimg");
+ /** The directory to store the cached images in (in mipzip format).
+ */
+ static private File __tmp = new File("./tmpimg");
+ /** Get the directory to store the cached images in (in mipzip format).
+ */
static File tmp() {
if(!__tmp.exists())
__tmp.mkdir();
@@ -55,6 +62,6 @@
return res.toString();
}
- public abstract SingleImage getSingleImage(ImageSpan img, PoolManager
poolManager) ;
+ public abstract SingleImage getSingleImage(ImageSpan img) ;
}
Index: fenfire/org/fenfire/spanimages/gl/SingleImage.java
diff -u fenfire/org/fenfire/spanimages/gl/SingleImage.java:1.15
fenfire/org/fenfire/spanimages/gl/SingleImage.java:1.16
--- fenfire/org/fenfire/spanimages/gl/SingleImage.java:1.15 Fri Oct 31
02:21:15 2003
+++ fenfire/org/fenfire/spanimages/gl/SingleImage.java Wed Nov 5 05:25:52 2003
@@ -85,8 +85,7 @@
String scrollBlock, int page,
String filename,
float xresolution,
- float yresolution,
- GL.StatsCallback statsCallback
+ float yresolution
) throws java.io.IOException {
this.scrollBlock = scrollBlock;
this.page = page;
@@ -96,13 +95,10 @@
this.virtualTexture = new VirtualTexture(
new MipzipFile(new File(filename)));
- if(statsCallback != null)
- this.accum = GL.createTexAccum(statsCallback, this);
- else
- this.accum = GL.createTexAccum();
+ this.accum = GL.createTexAccum(PoolManager.getInstance(), this);
if(dbg) p("Create single image: "+scrollBlock+" "+page+" "+filename
- +" "+xresolution+" "+yresolution+" "+statsCallback);
+ +" "+xresolution+" "+yresolution);
this.missingPixels = new double[
this.virtualTexture.mipzipFile.getNLevels()];
Index: fenfire/org/fenfire/spanimages/gl/benchpapers.py
diff -u fenfire/org/fenfire/spanimages/gl/benchpapers.py:1.3
fenfire/org/fenfire/spanimages/gl/benchpapers.py:1.4
--- fenfire/org/fenfire/spanimages/gl/benchpapers.py:1.3 Fri Oct 31
07:30:34 2003
+++ fenfire/org/fenfire/spanimages/gl/benchpapers.py Wed Nov 5 05:25:52 2003
@@ -34,40 +34,43 @@
nquads = 100
):
span = sc.getPage(0)
- poolManager = spi.PoolManager()
+ poolManager = spi.PoolManager.getInstance()
scrollimager = spi.PageScrollBlockImager()
-
img = scrollimager.getSingleImage(span, poolManager)
- poolManager.locked.add(img)
- # XXX Doesn't work!
- img.loader.loadToBaseLevelSynch(0)
-
- spanImageFactory = spi.DefaultSpanImageFactory(scrollimager)
-
- w = vob.putil.demowindow.w
- if paper == 0:
- spanImageFactory.paperMaker = papermakers.white(w)
- elif paper == 1:
- spanImageFactory.paperMaker = papermakers.fancyBlend(w)
- elif paper == 2:
- spanImageFactory.paperMaker = papermakers.fancyHalo(w)
- elif paper == 3:
- spanImageFactory.paperMaker = papermakers.fancyBlur(w)
- elif paper == 4:
- spanImageFactory.paperMaker = papermakers.nvFancyBlur(w)
- else: assert 0==1, paper
-
- layout = ff.view.PageSpanLayout(
- sc.getPage(0),
- spanImageFactory)
-
- vs.map.put(vob.vobs.SolidBackdropVob(java.awt.Color.yellow))
-
- for i in range(0, nquads):
- cs = vs.orthoCS(0,"A", 50-i, 1, 1, 1, 1)
- layout.place(vs, cs)
+ try:
+ poolManager.lock(img)
+
+ spanImageFactory = spi.DefaultSpanImageFactory(scrollimager)
+
+ w = vob.putil.demowindow.w
+ if paper == 0:
+ spanImageFactory.paperMaker = papermakers.white()
+ elif paper == 1:
+ spanImageFactory.paperMaker = papermakers.fancyBlend()
+ elif paper == 2:
+ spanImageFactory.paperMaker = papermakers.fancyHalo()
+ elif paper == 3:
+ spanImageFactory.paperMaker = papermakers.fancyBlur()
+ elif paper == 4:
+ spanImageFactory.paperMaker = papermakers.nvFancyBlur()
+ else: assert 0==1, paper
+
+ layout = ff.view.PageSpanLayout(
+ sc.getPage(0),
+ spanImageFactory)
+
+ vs.map.put(vob.vobs.SolidBackdropVob(java.awt.Color.yellow))
+
+ for i in range(0, nquads):
+ cs = vs.orthoCS(0,"A", 50-i, 1, 1, 1, 1)
+ layout.place(vs, cs)
+ finally:
+ poolManager.unlock()
+
+ return (paper, nquads)
args = {
- "nquads" : (10, 100),
- "paper" : (0, 4)
+ "nquads" : (1, 2, 4, 8, 16),
+ # "paper" : (0, 1, 2, 3, 4)
+ "paper" : (3, 4)
}
Index: fenfire/org/fenfire/spanimages/gl/papermakers.py
diff -u fenfire/org/fenfire/spanimages/gl/papermakers.py:1.15
fenfire/org/fenfire/spanimages/gl/papermakers.py:1.16
--- fenfire/org/fenfire/spanimages/gl/papermakers.py:1.15 Fri Oct 17
05:25:34 2003
+++ fenfire/org/fenfire/spanimages/gl/papermakers.py Wed Nov 5 05:25:52 2003
@@ -91,6 +91,9 @@
# Texture unit 2 is blurred
TEX H2, f[TEX1], TEX2, 2D;
+ # Get the sharp value of the text texture
+ TEX H3, f[TEX1], TEX1, 2D;
+
# Map blurred 'text' texture intensity to background blur
# as follows:
# 1 -> no bias
@@ -98,22 +101,19 @@
DP4H H2, {-10,-10,-10,31}, H2;
# The derivatives of the paper texture
- DDXH H0, f[TEX0];
- DDYH H1, f[TEX0];
+ DDXH H0.xy, f[TEX0].xyxy;
+ DDYH H0.zw, f[TEX0].xyxy;
# Scale with the DP
MULH H0, H2, H0;
- MULH H1, H2, H1;
# Get the blurred value of the background texture
- TXD H0, f[TEX0], H0, H1, TEX0, 2D;
+ TXD H0, f[TEX0], H0.xyxy, H0.zwzw, TEX0, 2D;
- # Get the sharp value of the text texture
- TEX H1, f[TEX1], TEX1, 2D;
# Compute the final color
- MULX o[COLR], H0, H1;
+ MULX o[COLR], H0, H3;
END
""")
Index: fenfire/org/fenfire/spanimages/gl/spanimages.test
diff -u fenfire/org/fenfire/spanimages/gl/spanimages.test:1.7
fenfire/org/fenfire/spanimages/gl/spanimages.test:1.8
--- fenfire/org/fenfire/spanimages/gl/spanimages.test:1.7 Fri Oct 17
05:25:34 2003
+++ fenfire/org/fenfire/spanimages/gl/spanimages.test Wed Nov 5 05:25:52 2003
@@ -86,7 +86,7 @@
def checkPaper(spanImageFactory, blank):
- spanImageVob = spanImageFactory.getSpanImageVob(
+ spanImageVob = spanImageFactory.f(
sc.getCurrent().getPage(0))
assert 615 < spanImageVob.getWidth() < 625
@@ -162,7 +162,8 @@
"""
# The defaults are such that
spanImageFactory = spim.DefaultSpanImageFactory(
- spim.PageScrollBlockImager()
+ spim.PageScrollBlockImager(),
+ spim.PlainPaperMaker()
)
checkPaper(spanImageFactory, 1)
Index: fenfire/org/fenfire/structure/Ff.java
diff -u fenfire/org/fenfire/structure/Ff.java:1.3
fenfire/org/fenfire/structure/Ff.java:1.4
--- fenfire/org/fenfire/structure/Ff.java:1.3 Thu Oct 23 15:09:57 2003
+++ fenfire/org/fenfire/structure/Ff.java Wed Nov 5 05:25:52 2003
@@ -61,6 +61,8 @@
private ContentFunction contentFunction = new ContentFunction(this);
private Ff(ConstGraph g, Alph alph) {
+ if(g == null) throw new NullPointerException("Graph");
+ if(alph == null) throw new NullPointerException("Alph");
this.constGraph = g;
this.alph = alph;
Index: fenfire/org/fenfire/view/AreaSelectingView2D.java
diff -u fenfire/org/fenfire/view/AreaSelectingView2D.java:1.15
fenfire/org/fenfire/view/AreaSelectingView2D.java:1.16
--- fenfire/org/fenfire/view/AreaSelectingView2D.java:1.15 Thu Oct 23
15:09:57 2003
+++ fenfire/org/fenfire/view/AreaSelectingView2D.java Wed Nov 5 05:25:52 2003
@@ -26,14 +26,14 @@
package org.fenfire.view;
import org.nongnu.libvob.*;
+import org.nongnu.libvob.impl.*;
import org.nongnu.libvob.gl.*;
import java.util.*;
/** View2D to draw the selecting area
*/
-public class AreaSelectingView2D extends View2D
- implements org.fenfire.view.lava.FastView {
+public class AreaSelectingView2D extends View2D {
public static boolean dbg = false;
private static void p(String s) {
System.out.println("AreaSelectingView2D:: "+s); }
@@ -42,8 +42,29 @@
private TextSelectionPainter text = new TextSelectionPainter();
private SelectionPainter currentPainter = rect;
- private interface SelectionPainter extends org.fenfire.view.lava.FastView {
+
+ /** An interface for selection shape painter.
+ */
+ private interface SelectionPainter {
+
+ /** Render the selection into VobScene.
+ * @param plane The object of View2D plane where
+ * this selection is rendered.
+ */
void render(VobScene vs, int into);
+
+ /** Set coordinate system parameters for the selection.
+ * @param plane The plane where this selection is rendered.
+ * @param currentPlane
+ * The current accursed plane object.
+ * Selection should be shown if currentPlane
+ * is same as the plane object.
+ */
+ void chgFast(VobScene old, int into, Object plane,
+ Object currentPlane);
+
+ /** Clears the selection.
+ */
void clear();
}
@@ -62,7 +83,8 @@
for (int i=0; i<pts.length; i++)
renderImpl(vs, into, i);
}
- private int renderImpl(VobScene vs, int into, int index) {
+ private int renderImpl(VobScene vs, int into, int index)
+ {
int cs = -1;
switch(index) {
case 0: cs = vs.orthoCS(into, SELECT_BEGIN, 0, 1,2,3,4); break;
@@ -75,7 +97,8 @@
return cs;
}
- public void chgFast(VobScene oldVS, int concatCs) {
+ public void chgFast(VobScene oldVS, int concatCs,
+ Object plane, Object current) {
int [] cs = new int[3];
cs[0] = oldVS.matcher.getCS(concatCs, SELECT_BEGIN);
cs[1] = oldVS.matcher.getCS(concatCs, SELECT_OTHER);
@@ -87,8 +110,12 @@
cs[i] = renderImpl(oldVS, concatCs, i);
}
- for(int i=0; i<pts.length; i++)
- oldVS.coords.setOrthoParams(cs[i], 0, pts[i][0], pts[i][1],
pts[i][2]-pts[i][0], pts[i][3]-pts[i][1]);
+ for(int i=0; i<pts.length; i++) {
+ if (plane == current)
+ oldVS.coords.setOrthoParams(cs[i], 0, pts[i][0],
pts[i][1], pts[i][2]-pts[i][0], pts[i][3]-pts[i][1]);
+ else
+ oldVS.coords.setOrthoParams(cs[i], 0, 0,0,0,0);
+ }
}
public void clear() {
@@ -145,10 +172,15 @@
setArea(0,0,0,0);
}
- public void chgFast(VobScene oldVS, int concatCs) {
+ public void chgFast(VobScene oldVS, int concatCs,
+ Object plane, Object current) {
int cs = oldVS.matcher.getCS(concatCs, SELECT);
if (cs < 1) throw new Error(cs+" is not possible!");
- oldVS.coords.setOrthoParams(cs, 0, x0, y0, x1-x0, y1-y0);
+
+ if (plane == current)
+ oldVS.coords.setOrthoParams(cs, 0, x0, y0, x1-x0, y1-y0);
+ else
+ oldVS.coords.setOrthoParams(cs, 0, 0,0,0,0);
}
private float x0,y0,x1,y1;
@@ -171,10 +203,12 @@
float ex, float eyTop, float eyBot,
float edgeL, float edgeR) {
currentPainter = text;
+ rect.clear();
text.set(bx,byTop, byBot, ex,eyTop,eyBot,edgeL, edgeR);
}
public void setArea(float x0, float y0, float x1, float y1) {
currentPainter = rect;
+ text.clear();
rect.setArea(x0,y0,x1,y1);
}
@@ -211,18 +245,21 @@
paper2box);
currentPainter.render(vs, paper2screen);
- if (current != plane) currentPainter.clear();
- chgFast(vs, box2screen);
+ chgFast(vs, plane, matchingParent, box2screen, box2paper);
}
- public void chgFast(VobScene oldVS, int parent) {
- if (dbg) p("NEW: parent: "+parent+" to make chgFast:
"+oldVS.matcher.getKey(parent)
- + " foo: "+
oldVS.matcher.getCS(oldVS.matcher.getKey(parent)));
+ public void clear() {
+ text.clear();
+ rect.clear();
+ }
- if (dbg) p("parent cs: "+parent);
- int concatCs = oldVS.matcher.getCS(parent, CONCAT);
+ public void chgFast(VobScene oldVS, Object plane,
+ int matchingParent, int box2screen, int box2plane) {
+ if (dbg) p("box2screen: "+box2screen);
+ int concatCs = oldVS.matcher.getCS(box2screen, CONCAT);
if (dbg) p("conc: "+concatCs);
- currentPainter.chgFast(oldVS, concatCs);
+ text.chgFast(oldVS, concatCs, plane, current);
+ currentPainter.chgFast(oldVS, concatCs, plane, current);
}
public Object getSelectedObject(Object plane, float x, float y, float w,
float h) {
Index: fenfire/org/fenfire/view/CanvasView2D.java
diff -u fenfire/org/fenfire/view/CanvasView2D.java:1.33
fenfire/org/fenfire/view/CanvasView2D.java:1.34
--- fenfire/org/fenfire/view/CanvasView2D.java:1.33 Thu Oct 23 15:09:57 2003
+++ fenfire/org/fenfire/view/CanvasView2D.java Wed Nov 5 05:25:53 2003
@@ -45,7 +45,8 @@
/** A View2D of a CANVAS2D, with a given node function.
*/
-public class CanvasView2D extends View2D implements
org.fenfire.view.lava.FastView {// NodedView2D,{
+public class CanvasView2D extends View2D
+ implements NodedView2D {
public static boolean dbg = false;
private static void p(String s) { System.out.println("CanvasView2D:: "+s);
}
@@ -72,6 +73,7 @@
return null;
}
+ public View2D getContentView2D() { return this; }
public void render(VobScene vs, Object container,
int matchingParent, int box2screen, int box2plane)
@@ -122,7 +124,7 @@
}
p.place(vs, cs);
}
- chgFast(vs, box2screen);
+ chgFast(vs, container, matchingParent, box2screen, box2plane);
// [mudyc] thinks that something which knows
@@ -168,8 +170,9 @@
return containerCS;
}
- public void chgFast(VobScene oldVS, int parent) {
- int containerCS = getContainerCS(oldVS, parent);
+ public void chgFast(VobScene oldVS, Object container,
+ int matchingParent, int box2screen, int box2plane) {
+ int containerCS = getContainerCS(oldVS, box2screen);
DefaultVobMatcher m = (DefaultVobMatcher)oldVS.matcher;
for(Iterator i=m.getKeys(containerCS).iterator(); i.hasNext();) {
@@ -197,24 +200,27 @@
}
public int getNodeCS(VobScene oldvs,
- int x, int y,
- Object plane, int matchingParent,
- int box2screen, int box2plane,
- float[] xyout) {
+ int x, int y,
+ Object plane, int matchingParent,
+ int box2screen, int box2plane,
+ float[] xyout) {
return oldvs.getCSAt(box2screen, x, y, xyout);
}
public int getNodeCS(VobScene oldVS,
Object node,
Object plane, int matchingParent,
- int box2screen, int box2plane,
- float[] xyout) {
+ int box2screen, int box2plane) {
int containerCS = getContainerCS(oldVS, box2screen);
int cs = oldVS.matcher.getCS(containerCS, node);
if (cs < 1) throw new Error(cs+" is not possible!");
return cs;
}
+ public Object getNode(VobScene oldVS, int cs) {
+ if (cs < 1) throw new Error(cs+" is not possible!");
+ return oldVS.matcher.getKey(cs);
+ }
static public boolean hasCanvas(ConstGraph g, Object node) {
Index: fenfire/org/fenfire/view/IrregularViewportView2D.java
diff -u fenfire/org/fenfire/view/IrregularViewportView2D.java:1.9
fenfire/org/fenfire/view/IrregularViewportView2D.java:1.10
--- fenfire/org/fenfire/view/IrregularViewportView2D.java:1.9 Wed Aug 13
12:56:28 2003
+++ fenfire/org/fenfire/view/IrregularViewportView2D.java Wed Nov 5
05:25:53 2003
@@ -48,7 +48,17 @@
*/
public int debugFlags = 0;
- public View2D getChildView2D() { return child; }
+ public View2D getContentView2D() {
+ if (child != null) return child.getContentView2D();
+ return null;
+ }
+ public void chgFast(VobScene vs,
+ Object plane,
+ int matchingParent,
+ int box2screen, int box2plane) {
+ if (child != null)
+ child.chgFast(vs, plane, matchingParent, box2screen, box2plane);
+ }
public View2D child;
public IrregularViewportView2D(View2D child) {
Index: fenfire/org/fenfire/view/NodedView2D.java
diff -u fenfire/org/fenfire/view/NodedView2D.java:1.4
fenfire/org/fenfire/view/NodedView2D.java:1.5
--- fenfire/org/fenfire/view/NodedView2D.java:1.4 Wed Jun 11 13:00:24 2003
+++ fenfire/org/fenfire/view/NodedView2D.java Wed Nov 5 05:25:53 2003
@@ -30,12 +30,25 @@
/** An interface which a View2D may implement.
*/
public interface NodedView2D {
- /** Return the node (or null) pointed to by a mouse click.
+ /** Return the node coordinate system that is at the given
+ * coordinates, or -1 if none.
*/
- Object getNode(VobScene oldvs,
- int x, int y,
- Object plane, int matchingParent,
- int box2screen, int box2plane,
- float[] xyout);
+ int getNodeCS(VobScene oldvs,
+ int x, int y,
+ Object plane, int matchingParent,
+ int box2screen, int box2plane,
+ float[] xyout);
+
+ /** Return the given node's coordinate system or throw an error.
+ */
+ int getNodeCS(VobScene oldvs,
+ Object node,
+ Object plane, int matchingParent,
+ int box2screen, int box2plane);
+
+ /** Return the node matched with coordinate system or null.
+ */
+ Object getNode(VobScene oldvs, int nodeCS);
+
}
Index: fenfire/org/fenfire/view/PageNodeView.java
diff -u fenfire/org/fenfire/view/PageNodeView.java:1.7
fenfire/org/fenfire/view/PageNodeView.java:1.8
--- fenfire/org/fenfire/view/PageNodeView.java:1.7 Wed Sep 10 09:00:48 2003
+++ fenfire/org/fenfire/view/PageNodeView.java Wed Nov 5 05:25:53 2003
@@ -40,10 +40,10 @@
public class PageNodeView implements PureNodeFunction {
final NodeFunction nodeContent;
- final SpanImageFactory spanImageFactory;
+ final Function spanImageFactory;
public PageNodeView(NodeFunction nodeContent,
- SpanImageFactory spanImageFactory) {
+ Function spanImageFactory) {
this.nodeContent = nodeContent;
this.spanImageFactory = spanImageFactory;
}
Index: fenfire/org/fenfire/view/PageScroll2LayoutPureFunction.java
diff -u fenfire/org/fenfire/view/PageScroll2LayoutPureFunction.java:1.3
fenfire/org/fenfire/view/PageScroll2LayoutPureFunction.java:1.4
--- fenfire/org/fenfire/view/PageScroll2LayoutPureFunction.java:1.3 Sat Oct
18 02:06:31 2003
+++ fenfire/org/fenfire/view/PageScroll2LayoutPureFunction.java Wed Nov 5
05:25:53 2003
@@ -28,6 +28,7 @@
import org.nongnu.alph.*;
import org.fenfire.spanimages.*;
import org.fenfire.functional.PureFunction;
+import org.fenfire.functional.Function;
/** A (non-node)function which takes a PageScrollBlock and returns
* a PageSpanLayout.
@@ -38,8 +39,8 @@
public class PageScroll2LayoutPureFunction implements PureFunction {
- private final SpanImageFactory spanImageFactory;
- public PageScroll2LayoutPureFunction(SpanImageFactory spanImageFactory) {
+ private final Function spanImageFactory;
+ public PageScroll2LayoutPureFunction(Function spanImageFactory) {
this.spanImageFactory = spanImageFactory;
}
Index: fenfire/org/fenfire/view/PageSpanLayout.java
diff -u fenfire/org/fenfire/view/PageSpanLayout.java:1.24
fenfire/org/fenfire/view/PageSpanLayout.java:1.25
--- fenfire/org/fenfire/view/PageSpanLayout.java:1.24 Mon Aug 18 03:49:25 2003
+++ fenfire/org/fenfire/view/PageSpanLayout.java Wed Nov 5 05:25:53 2003
@@ -35,6 +35,7 @@
import org.nongnu.libvob.gl.*;
import org.nongnu.alph.*;
import org.fenfire.spanimages.*;
+import org.fenfire.functional.Function;
/** A single pagespan enfilade laid out on the plane.
*/
@@ -44,9 +45,6 @@
public static boolean dbg = false;
private void p(String s) { System.out.println("PageSpanLayout:: "+s); }
- public static SpanImageFactory spanImageFactory =
- SpanImageFactory.getDefaultInstance();
-
public static Enfilade1D.Maker enfilade1DMaker =
org.nongnu.alph.impl.Enfilade1DImpl.theMaker;
@@ -75,10 +73,10 @@
/** (To be called with increasing p): add a page.
*/
private void page(int p, PageImageSpan sp,
- SpanImageFactory spanImageFactory) {
+ Function spanImageFactory) {
pages[p] = sp;
- spivs[p] = spanImageFactory.getSpanImageVob(sp);
+ spivs[p] = (SpanImageVob)spanImageFactory.f(sp);
xywh[4*p + 0] = 0;
xywh[4*p + 1] = 0;
@@ -97,11 +95,8 @@
h = xywh[4*p + 3];
}
- public PageSpanLayout(Enfilade1D enf) {
- this(enf, spanImageFactory);
- }
public PageSpanLayout(Enfilade1D enf,
- SpanImageFactory spanImageFactory) {
+ Function spanImageFactory) {
alloc(enf.length());
for(int p = 0; p < npages; p++) {
@@ -118,12 +113,8 @@
}
- public PageSpanLayout(PageSpan sp) {
- this(sp, spanImageFactory);
- }
-
public PageSpanLayout(PageSpan sp,
- SpanImageFactory spanImageFactory) {
+ Function spanImageFactory) {
alloc(sp.length());
for(int p = 0; p < npages; p++) {
@@ -131,12 +122,8 @@
}
}
- public PageSpanLayout(PageImageSpan sp) {
- this(sp, spanImageFactory);
- }
-
public PageSpanLayout(PageImageSpan sp,
- SpanImageFactory spanImageFactory) {
+ Function spanImageFactory) {
alloc(1);
page(0, sp, spanImageFactory);
}
Index: fenfire/org/fenfire/view/PaperView2D.java
diff -u fenfire/org/fenfire/view/PaperView2D.java:1.21
fenfire/org/fenfire/view/PaperView2D.java:1.22
--- fenfire/org/fenfire/view/PaperView2D.java:1.21 Wed Sep 10 09:28:24 2003
+++ fenfire/org/fenfire/view/PaperView2D.java Wed Nov 5 05:25:53 2003
@@ -45,7 +45,19 @@
public float paperScaling = .5f;
- public View2D getChildView2D() { return child; }
+ // implement
+ public void chgFast(VobScene vs,
+ Object plane,
+ int matchingParent,
+ int box2screen, int box2plane) {
+ if (child != null)
+ child.chgFast(vs, plane, matchingParent, box2screen, box2plane);
+ }
+ // implement
+ public View2D getContentView2D() {
+ if (child != null) return child.getContentView2D();
+ return null;
+ }
protected View2D child;
public PaperView2D() {
@@ -58,6 +70,7 @@
private float[] tmp = new float[2];
private float[] tmp2 = new float[2];
+ // implement
public Object getSelectedObject(Object plane, float x, float y, float w,
float h) {
return child.getSelectedObject(plane, x, y, w, h);
}
Index: fenfire/org/fenfire/view/View2D.java
diff -u fenfire/org/fenfire/view/View2D.java:1.10
fenfire/org/fenfire/view/View2D.java:1.11
--- fenfire/org/fenfire/view/View2D.java:1.10 Fri Aug 15 03:46:07 2003
+++ fenfire/org/fenfire/view/View2D.java Wed Nov 5 05:25:53 2003
@@ -119,10 +119,22 @@
wh[1] = -1;
}
- /** Get the child View2D of this view if any.
- * @return null if none.
+ /** Return the View2D which can handle the content.
*/
- public View2D getChildView2D() { return null; }
+ public View2D getContentView2D() { return null; }
+
+ /** A method to push a View2D to set it's coordinate system parameters.
+ * While dragging with mouse, for example, should this method be used
+ * instead of creating new scenes.
+ *<p>
+ * Programming note: using one scene wherever it's possible is faster
+ * than creating a new one.
+ */
+ public void chgFast(VobScene currentVisibleVobScene,
+ Object plane,
+ int matchingParent,
+ int box2screen, int box2plane)
+ { ; }
/** Get an object describing (as a selection) what
* is inside a rectangular region.
Index: fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java
diff -u fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java:1.52
fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java:1.53
--- fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java:1.52 Fri Oct 31
11:59:41 2003
+++ fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java Wed Nov 5
05:25:53 2003
@@ -244,68 +244,6 @@
clipPan();
setZoomPan(oldVobScene);
- View2D view = getView2D();
- while (view != null) {
- if (view instanceof org.fenfire.view.lava.FastView)
- ((org.fenfire.view.lava.FastView)view)
- .chgFast(oldVobScene, box2screen);
- view = view.getChildView2D();
- }
- }
-
- public int getNodeCS(VobScene oldVobScene, Object node) {
-
- // XXX refactor me!
-
- View2D view = getView2D();
- while (view.getChildView2D() != null)
- view = view.getChildView2D();
-
- // XXX should this be in View2D?
- if (view instanceof CanvasView2D) {
-
- int cs = ((CanvasView2D)view)
- .getNodeCS(oldVobScene, node,
- plane, box2screen, box2screen,
- box2paper, null);
-
- if(dbg) p("CS is: "+cs);
- return cs;
- }
- return -1;
- }
-
- public int getNodeCS(VobScene oldVobScene, float x, float y) {
-
- // XXX refactor me!
-
- View2D view = getView2D();
- while (view.getChildView2D() != null)
- view = view.getChildView2D();
-
- // XXX should this be in View2D?
- if (view instanceof CanvasView2D) {
-
- int cs = ((CanvasView2D)view)
- .getNodeCS(oldVobScene, (int)x, (int)y,
- plane, box2screen, box2screen,
- box2paper, null);
-
- if(dbg) p("CS is: "+cs);
- return cs;
- }
- return -1;
- }
-
- public Object getNodeOnPlane(VobScene oldVobScene, float x, float y) {
-
- // XXX refactor me!
- // I should be in CanvasView2D
-
- int cs = getNodeCS(oldVobScene, x, y);
- if(cs <= 1) return null;
- Object obj = oldVobScene.matcher.getKey(cs);
- if (dbg) p("Object is: "+ (obj != null ? obj.toString() : obj));
- return obj;
+ getView2D().chgFast(oldVobScene, plane, box2screen, box2screen, -1);
}
}
Index: fenfire/org/fenfire/view/buoy/AbstractNodeType2D.java
diff -u fenfire/org/fenfire/view/buoy/AbstractNodeType2D.java:1.8
fenfire/org/fenfire/view/buoy/AbstractNodeType2D.java:1.9
--- fenfire/org/fenfire/view/buoy/AbstractNodeType2D.java:1.8 Wed Aug 20
12:34:33 2003
+++ fenfire/org/fenfire/view/buoy/AbstractNodeType2D.java Wed Nov 5
05:25:53 2003
@@ -32,10 +32,6 @@
import org.nongnu.libvob.impl.DefaultVobMatcher;
import org.nongnu.libvob.buoy.*;
-import java.awt.Rectangle;
-import java.awt.Color;
-import java.awt.event.MouseEvent;
-
public abstract class AbstractNodeType2D implements BuoyViewNodeType {
protected View2D view2d;
protected AbstractMainNode2D.Factory mainNodeFactory;
Index: fenfire/org/fenfire/view/lava/FastView.java
diff -u fenfire/org/fenfire/view/lava/FastView.java:1.5
fenfire/org/fenfire/view/lava/FastView.java:1.6
--- fenfire/org/fenfire/view/lava/FastView.java:1.5 Sun Aug 17 15:55:02 2003
+++ fenfire/org/fenfire/view/lava/FastView.java Wed Nov 5 05:25:53 2003
@@ -27,21 +27,19 @@
package org.fenfire.view.lava;
import org.nongnu.libvob.VobScene;
-/** An interface for a view which change is done through setOrthoParams.
+/** An interface for a view which can change by setting coordinate system
parameters.
* If animation/interpolation is not needed and changing of
* scene must be fast, the libvob platform provides a technique
- * to not regenerate but change parameters of VobScene.coords.
+ * to not regenerate VobScene but set parameters of existing coordinate
systems.
*
* @see VobCoorder
- * @see VobScene setOrthoBoxParams
*/
public interface FastView {
- /* Method to give the old scene to view.
- * @param oldVobScene is the VobScene which is used in previous
+ /* A method to push a view to set it's coordinate system parameters.
+ * @param oldVobScene is the VobScene which is used in current visible
* scene. The view must not try to rerender into this scene
- * but use parametrisation of old coordinate system through
- * setOrthoParams.
+ * but use parametrisation of old coordinate system instead.
* @see VobCoorder
*/
void chgFast(VobScene oldVobScene, int parent);
Index: fenfire/org/fenfire/view/pagespanlayout.test
diff -u fenfire/org/fenfire/view/pagespanlayout.test:1.13
fenfire/org/fenfire/view/pagespanlayout.test:1.14
--- fenfire/org/fenfire/view/pagespanlayout.test:1.13 Mon Aug 18 03:50:22 2003
+++ fenfire/org/fenfire/view/pagespanlayout.test Wed Nov 5 05:25:53 2003
@@ -29,12 +29,12 @@
import java, org
-from org import fenfire
+from org import fenfire as ff
import vob
from org.nongnu import alph
from org.nongnu import storm
-fenfire.test.gfx.needGL()
+ff.test.gfx.needGL()
from org.nongnu.libvob.gl import GL, GLRen, GLCache
@@ -101,7 +101,9 @@
z = jarray.zeros(2, "f")
- l = fenfire.view.PageSpanLayout(enfMaker.makeEnfilade(sc.getCurrent()))
+ l = ff.view.PageSpanLayout(
+ enfMaker.makeEnfilade(sc.getCurrent()),
+ ff.spanimages.SpanImageFactory.getDefaultInstance())
assertApprox(1, l.getWidth(), 2 * 595 * 75 / 72.)
assertApprox(1, l.getHeight(), 842 * 75 / 72.)
@@ -127,7 +129,9 @@
scaled = vs.orthoCS(0, "X", 0, 150, 150, scale, scale)
- layout =
fenfire.view.PageSpanLayout(enfMaker.makeEnfilade(sc.getCurrent()))
+ layout = ff.view.PageSpanLayout(
+ enfMaker.makeEnfilade(sc.getCurrent()),
+ ff.spanimages.SpanImageFactory.getDefaultInstance())
layout.place(vs, scaled)
gfx.render(vs)
@@ -156,7 +160,9 @@
def testSelection():
"""Test that getting selection returns a good enf.
"""
- pageSpanLayout =
fenfire.view.PageSpanLayout(enfMaker.makeEnfilade(sc.getCurrent()))
+ pageSpanLayout = ff.view.PageSpanLayout(
+ enfMaker.makeEnfilade(sc.getCurrent()),
+ ff.spanimages.SpanImageFactory.getDefaultInstance())
w = pageSpanLayout.getWidth()
h = pageSpanLayout.getHeight()
Index: fenfire/org/fenfire/view/papercanvas2d.test
diff -u fenfire/org/fenfire/view/papercanvas2d.test:1.16
fenfire/org/fenfire/view/papercanvas2d.test:1.17
--- fenfire/org/fenfire/view/papercanvas2d.test:1.16 Fri Sep 12 04:38:21 2003
+++ fenfire/org/fenfire/view/papercanvas2d.test Wed Nov 5 05:25:53 2003
@@ -49,23 +49,17 @@
(fen, ff_structure, contentFunction) = ff.test.fen.newFen()
con = ff.util.AlphContent(fen, ff_structure)
+ canvas2d = ff.structure.Canvas2D.create(fen.graph)
nodec = ff.util.RDFUtil.N(fen.graph, CANVAS2D.Canvas)
+ canvas2d.makeIntoCanvas(nodec)
+
node1 = ff.swamp.Nodes.N()
node2 = ff.swamp.Nodes.N()
-
- fen.graph.add(nodec, CANVAS2D.contains, node1)
- fen.graph.add(nodec, CANVAS2D.contains, node2)
-
con.setText(node1, "XXX", 0)
con.setText(node2, "YYY", 0)
-
- ff.util.RDFUtil.setInt(fen.graph, node1, CANVAS2D.x, 200)
- ff.util.RDFUtil.setInt(fen.graph, node1, CANVAS2D.y, 100)
-
- ff.util.RDFUtil.setInt(fen.graph, node2, CANVAS2D.x, 200)
- ff.util.RDFUtil.setInt(fen.graph, node2, CANVAS2D.y, 500)
-
+ canvas2d.placeOnCanvas(nodec, node1, 200,100)
+ canvas2d.placeOnCanvas(nodec, node2, 200,500)
################ Create the view structure
vs = getvs()
@@ -113,7 +107,8 @@
############## Check mouse clicks
- assert None == canvasView2D.getNode(vs, 120, 120, nodec,
- box2screen, box2screen, box2plane, None)
- assert node1 == canvasView2D.getNode(vs, 100+105, 100+55, nodec,
- box2screen, box2screen, box2plane, None)
+ assert -1 == canvasView2D.getNodeCS(vs, 120, 120, nodec,
+ box2screen, box2screen, box2plane,
None)
+ assert node1 == canvasView2D.getNode(vs,
+ canvasView2D.getNodeCS(vs, 100+105, 100+55, nodec,
+ box2screen, box2screen, box2plane, None))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [ff-cvs] fenfire/org/fenfire bin/fenpdf10.py fenpdf/demo...,
Tuomas J. Lukka <=