[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ff-cvs] fenfire docs/Functional.rst org/fenfire/fenpdf/...
From: |
Tuomas J. Lukka |
Subject: |
[ff-cvs] fenfire docs/Functional.rst org/fenfire/fenpdf/... |
Date: |
Mon, 01 Sep 2003 06:21:00 -0400 |
CVSROOT: /cvsroot/fenfire
Module name: fenfire
Branch:
Changes by: Tuomas J. Lukka <address@hidden> 03/09/01 06:20:58
Modified files:
docs : Functional.rst
org/fenfire/fenpdf: fenpdf.py
org/fenfire/fenpdf/appearance: papers.py views.py
org/fenfire/fenpdf/events: eventhandler.py
org/fenfire/impl: SimpleNodeContent.java
org/fenfire/swamp: CachedNodeFunction.java
CachedPureNodeFunction.java
MultiplexerNodeFunction.java
SuperLazyPureNodeFunction.java
observablegraphtest.py
org/fenfire/view: CanvasView2D.java DispatchingNodeView.java
PageNodeView.java PageScrollView2D.java
VobWrapperFunction.java
org/fenfire/view/buoy: TransclusionConnector.java
doublegeometer.py
Added files:
org/fenfire : ObjObs.java
org/fenfire/util: DummyPlaceable.java Function.java
FunctionCacheEntry.java PureFunction.java
SuperLazyPureFunction.java
org/fenfire/view: PageScroll2LayoutPureFunction.java
Removed files:
org/fenfire/swamp: NodeFunctionCacheEntry.java
Log message:
patch-88
twid
patch-89
Extract Function
patch-90
naming
patch-91
Naming: don't put flush without 'Set' static
patch-92
Cleaning, preparing for uncaching recalculated nodes selectively
patch-93
Rearranging, prior to introduction of the super-lazy caches
patch-94
CacheEntry is suited for non-node functions
patch-95
Superlazy pure function cache
patch-96
Remove unused getLayout function
patch-97
Multiplexernodefunction doesn't need pure args as it isn't pure itself
patch-98
Lots of work to make pdfs load lazily.
patch-99
prioritizing
patch-100
mudycs_fix_invalidind
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/docs/Functional.rst.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/ObjObs.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/fenpdf.py.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/appearance/papers.py.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/appearance/views.py.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/events/eventhandler.py.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/impl/SimpleNodeContent.java.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/swamp/CachedNodeFunction.java.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/swamp/CachedPureNodeFunction.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/swamp/MultiplexerNodeFunction.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/swamp/SuperLazyPureNodeFunction.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/swamp/observablegraphtest.py.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/util/DummyPlaceable.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/util/Function.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/util/FunctionCacheEntry.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/util/PureFunction.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/util/SuperLazyPureFunction.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/PageScroll2LayoutPureFunction.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/CanvasView2D.java.diff?tr1=1.28&tr2=1.29&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/DispatchingNodeView.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/PageNodeView.java.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/PageScrollView2D.java.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/VobWrapperFunction.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/buoy/TransclusionConnector.java.diff?tr1=1.24&tr2=1.25&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/buoy/doublegeometer.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: fenfire/docs/Functional.rst
diff -u fenfire/docs/Functional.rst:1.1 fenfire/docs/Functional.rst:1.2
--- fenfire/docs/Functional.rst:1.1 Sun Aug 31 08:29:30 2003
+++ fenfire/docs/Functional.rst Mon Sep 1 06:20:57 2003
@@ -4,6 +4,15 @@
Some design & implementation notes
+Issues
+======
+
+- How do we calculate a pure function of a superlazy function and
+ cache the result?
+
+ SIMPLE RESOLUTION: We don't. We put the superlazy part at the outermost
+ edge of the pure function chain.
+
Introduction
============
@@ -35,7 +44,6 @@
- any pure functions **shall** have the word ``Pure`` in their name.
- - impure functions **shall** take an ``Obs`` to inform of their changes.
Node functions
==============
@@ -74,13 +82,20 @@
the user.
+Mixing functions
+================
+
+-
+
Functions used in FenPDF
========================
``SpanImageFactory`` is a mapping from ``ImageSpan``s to ``SpanImageVob``s.
-In PageScrollView2D, we need to extract the function that maps
-PageScrolls to PageSpanLayouts.
+``PageScroll2LayoutPureFunction`` maps ``PageScroll``s to ``PageSpanLayout``s.
+
+
+
Foo ::
Index: fenfire/org/fenfire/fenpdf/appearance/papers.py
diff -u fenfire/org/fenfire/fenpdf/appearance/papers.py:1.9
fenfire/org/fenfire/fenpdf/appearance/papers.py:1.10
--- fenfire/org/fenfire/fenpdf/appearance/papers.py:1.9 Thu Aug 28 02:41:47 2003
+++ fenfire/org/fenfire/fenpdf/appearance/papers.py Mon Sep 1 06:20:57 2003
@@ -117,9 +117,13 @@
def decorateWithPaperView(self, view2d):
paperView = ff.view.PaperView2D(view2d)
+ paperView.paperScaling = .1
p("decorateWithPaperView", self.useBg)
if not self.useBg:
paperView.paperMill = \
ConstantPaperMill(vob.gl.SpecialPapers.solidPaper(
java.awt.Color.white))
return paperView
+
+
+
Index: fenfire/org/fenfire/fenpdf/appearance/views.py
diff -u fenfire/org/fenfire/fenpdf/appearance/views.py:1.21
fenfire/org/fenfire/fenpdf/appearance/views.py:1.22
--- fenfire/org/fenfire/fenpdf/appearance/views.py:1.21 Wed Aug 27 08:47:56 2003
+++ fenfire/org/fenfire/fenpdf/appearance/views.py Mon Sep 1 06:20:57 2003
@@ -11,7 +11,7 @@
def p(*s):
print 'appearance.views.py:: ',s
-class Views:
+class Views(ff.ObjObs):
"""Encapsulate the creation of the immutable views and connectors used in
FenPDF.
STRICT ENCAPSULATION: NO MEMBERS SHOULD BE ACCESSED
@@ -41,6 +41,14 @@
def update(self):
self.papers.update()
# XXX Figure out get & create stuffs
+ # We are essentially creating a DAG of objects and want to allow
+ # extensibility anywhere
+
+ self.pageFunc = self.createPageNodeFunction()
+
+ self.normalNodeContentFunction = self.createNormalNodeContentFunction()
+ self.accursedNodeContentFunction =
self.createAccursedNodeContentFunction()
+
self.multiplexerNodeFunction =
self.createMultiplexerNodeContentFunction()
@@ -189,16 +197,8 @@
def getCanvasView2D(self):
return self.canvasview2d
- def getPageNodeView(self, color):
- pageFunc = ff.view.PageNodeView(self.fen.txtfunc,
- self.papers.getSpanImageFactory())
- return ff.view.VobWrapperFunction(pageFunc,
- vob.vobs.ContinuousLineVob(2,
- [0,0,0 , 1,0,0 , 1,1,0 , 0,1,0], 1, 100, color))
-
-
- def getAccursedNodeContentFunction(self):
+ def createAccursedNodeContentFunction(self):
# accursed text
accursed_text = ff.view.TextNodeView(
@@ -206,11 +206,11 @@
self.getTextStyle(), java.awt.Color.red)
accursed_dispatcher = ff.view.DispatchingNodeView(
self.fen.txtfunc, accursed_text,
- self.getPageNodeView(java.awt.Color.red))
- return ff.swamp.CachedPureNodeFunction(
+ self.createPageNodeView(java.awt.Color.red))
+ return ff.swamp.CachedNodeFunction(
10, self.fen.constgraph, accursed_dispatcher)
- def getNormalNodeContentFunction(self):
+ def createNormalNodeContentFunction(self):
# normal text
normal_text = ff.view.TextNodeView(
@@ -218,14 +218,14 @@
java.awt.Color.black)
normal_dispatcher = ff.view.DispatchingNodeView(
self.fen.txtfunc, normal_text,
- self.getPageNodeView(java.awt.Color.black))
- return ff.swamp.CachedPureNodeFunction(
- 500, self.fen.constgraph, normal_dispatcher)
+ self.createPageNodeView(java.awt.Color.black))
+ return ff.swamp.CachedNodeFunction(
+ 5000, self.fen.constgraph, normal_dispatcher)
def createMultiplexerNodeContentFunction(self):
return ff.swamp.MultiplexerNodeFunction(
- self.getNormalNodeContentFunction(),
- self.getAccursedNodeContentFunction())
+ self.normalNodeContentFunction,
+ self.accursedNodeContentFunction)
def createCanvasView2D(self):
canvasview2d = ff.view.CanvasView2D(
@@ -241,9 +241,61 @@
irregu.debugFlags ^= ff.view.IrregularViewportView2D.DEBUG_CHILD
return irregu
+ def createPageNodeView(self, color):
+
+ return ff.view.VobWrapperFunction(self.pageFunc,
+ vob.vobs.ContinuousLineVob(2,
+ [0,0,0 , 1,0,0 , 1,1,0 , 0,1,0], 1, 100, color))
+
+
+ def chg(self, object):
+ """Implement ObjObs for PageNodeFunction.
+ We clear Accursed and NodeContent caches for the given entry.
+ """
+ self.normalNodeContentFunction.flush(object)
+ self.accursedNodeContentFunction.flush(object)
+ self.fenPDF.animation.regenerateVS(0)
+ vob.AbstractUpdateManager.chgAfter(400)
+ vob.AbstractUpdateManager.setNoAnimation()
+
+
+ def createPageNodeFunction(self):
+
+ placeholder = ff.util.DummyPlaceable(
+ vob.vobs.RectBgVob(java.awt.Color.red), 200, 200)
+ priorityOffset = 10
+
+ pview = ff.view.PageNodeView.Pure(self.fen.txtfunc,
+ self.papers.getSpanImageFactory())
+ pview = ff.swamp.SuperLazyPureNodeFunction(
+ 400, self.fen.constgraph, pview,
+ placeholder,
+ vob.util.PrioritizeBackground(
+ vob.AbstractUpdateManager.getInstance(),
+ priorityOffset),
+ self)
+
+ # XXX super-lazy cache
+ return pview
+
def createPageScrollView2D(self):
- pagescrollview2d = ff.view.PageScrollView2D(
+ priorityOffset = 11
+ function = ff.view.PageScroll2LayoutPureFunction(
self.papers.getSpanImageFactory())
+ # super-lazy cache
+ function = ff.util.SuperLazyPureFunction(
+ 200, function,
+ None,
+ vob.util.PrioritizeBackground(
+ vob.AbstractUpdateManager.getInstance(),
+ priorityOffset),
+ self) # Wrong obj but doesn't matter
+
+ pagescrollview2d = ff.view.PageScrollView2D(function)
return ff.view.AreaSelectingView2D(pagescrollview2d)
+
+
+
+
Index: fenfire/org/fenfire/fenpdf/events/eventhandler.py
diff -u fenfire/org/fenfire/fenpdf/events/eventhandler.py:1.11
fenfire/org/fenfire/fenpdf/events/eventhandler.py:1.12
--- fenfire/org/fenfire/fenpdf/events/eventhandler.py:1.11 Wed Aug 27
07:16:21 2003
+++ fenfire/org/fenfire/fenpdf/events/eventhandler.py Mon Sep 1 06:20:57 2003
@@ -55,15 +55,15 @@
# this is rather ugly
if ev.getType() == ev.MOUSE_DRAGGED:
- if buoymanager.singles[buoymanager.lastIndex].mainNode.mouse(ev,
buoymanager.vs):
- buoymanager.replaceScene = buoymanager.vs
+ if buoymanager.singles[buoymanager.lastIndex].mainNode.mouse(ev,
oldvs):
+ buoymanager.replaceScene = oldvs
vob.AbstractUpdateManager.setNoAnimation()
vob.AbstractUpdateManager.chg()
return
if dbg: p("4")
- buoyhit = buoymanager.findIfBuoyHit(buoymanager.vs, ev.getX(),
ev.getY())
+ buoyhit = buoymanager.findIfBuoyHit(oldvs, ev.getX(), ev.getY())
if buoyhit != None:
single, link = buoyhit
# pa("IN CS: ",cs, link)
@@ -73,12 +73,12 @@
if dbg: p("5")
- topmostMainNode = buoymanager.findTopmostMainNode(buoymanager.vs,
ev.getX(), ev.getY())
+ topmostMainNode = buoymanager.findTopmostMainNode(oldvs, ev.getX(),
ev.getY())
# If the most upper main node is available use it.
if topmostMainNode != None:
- if topmostMainNode.mouse(ev, buoymanager.vs):
- buoymanager.replaceScene = buoymanager.vs
+ if topmostMainNode.mouse(ev, oldvs):
+ buoymanager.replaceScene = oldvs
vob.AbstractUpdateManager.setNoAnimation()
vob.AbstractUpdateManager.chg()
Index: fenfire/org/fenfire/fenpdf/fenpdf.py
diff -u fenfire/org/fenfire/fenpdf/fenpdf.py:1.11
fenfire/org/fenfire/fenpdf/fenpdf.py:1.12
--- fenfire/org/fenfire/fenpdf/fenpdf.py:1.11 Tue Aug 26 15:13:53 2003
+++ fenfire/org/fenfire/fenpdf/fenpdf.py Mon Sep 1 06:20:57 2003
@@ -26,7 +26,7 @@
self.lastVs = None
self.animate = 0
- def regenerateVS(self):
+ def regenerateVS(self, callChg = 1):
self.reuseVs = 0
vob.AbstractUpdateManager.chg()
Index: fenfire/org/fenfire/impl/SimpleNodeContent.java
diff -u fenfire/org/fenfire/impl/SimpleNodeContent.java:1.12
fenfire/org/fenfire/impl/SimpleNodeContent.java:1.13
--- fenfire/org/fenfire/impl/SimpleNodeContent.java:1.12 Fri Jun 27
07:45:21 2003
+++ fenfire/org/fenfire/impl/SimpleNodeContent.java Mon Sep 1 06:20:57 2003
@@ -48,7 +48,7 @@
*/
public class SimpleNodeContent implements NodeContent {
-public static final String rcsid = "$Id: SimpleNodeContent.java,v 1.12
2003/06/27 11:45:21 mudyc Exp $";
+public static final String rcsid = "$Id: SimpleNodeContent.java,v 1.13
2003/09/01 10:20:57 tjl Exp $";
public static boolean dbg = false;
private static void pa(String s) { System.out.println("SimpleContent::
"+s); }
SpanReader spanReader;
@@ -76,7 +76,7 @@
this.fen = fen;
}
- private class Func implements org.fenfire.swamp.NodeFunction {
+ private class Func implements org.fenfire.swamp.PureNodeFunction {
public Object f(org.fenfire.swamp.ConstGraph graph, Object node) {
Object c = graph.find1_11X(node, FF.content);
if(dbg) pa("Getting content: "+node+" "+c);
Index: fenfire/org/fenfire/swamp/CachedNodeFunction.java
diff -u fenfire/org/fenfire/swamp/CachedNodeFunction.java:1.10
fenfire/org/fenfire/swamp/CachedNodeFunction.java:1.11
--- fenfire/org/fenfire/swamp/CachedNodeFunction.java:1.10 Sun Aug 31
08:36:15 2003
+++ fenfire/org/fenfire/swamp/CachedNodeFunction.java Mon Sep 1 06:20:58 2003
@@ -38,6 +38,7 @@
* subtle caching bugs - using it is slightly deprecated,
* PureNodeFunctions
* and CachedPureNodeFunction should be used whenever possible.
+ * <p>
*/
public class CachedNodeFunction implements NodeFunction {
@@ -74,9 +75,9 @@
throw new IllegalArgumentException("Called with wrong graph");
}
- NodeFunctionCacheEntry cac = (NodeFunctionCacheEntry)cache.get(node);
+ FunctionCacheEntry cac = (FunctionCacheEntry)cache.get(node);
if(cac == null) {
- cac = new NodeFunctionCacheEntry(node);
+ cac = new FunctionCacheEntry(node);
cache.put(node, cac);
}
if(cac.value == cac.DIRTY) {
@@ -98,25 +99,34 @@
l.add(func);
}
+ /** Flush all information related to node.
+ * This function is needed because we cache impure functions.
+ */
+ public void flush(Object node) {
+ FunctionCacheEntry entry = (FunctionCacheEntry)cache.get(node);
+ if(entry == null) return;
+ entry.value = entry.DIRTY;
+ }
+
/** Flush all different sets.
*/
- static public void flushAll() {
+ static public void flushAllSets() {
for (Iterator it = funcsMap.keySet().iterator(); it.hasNext(); ) {
Object set = it.next();
- flush(set);
+ flushSet(set);
}
}
/** Flush the default set.
*/
- static public void flush() {
- flush(DEFAULT);
+ static public void flushDefaultSet() {
+ flushSet(DEFAULT);
}
/** Flush the set which is given.
* Throws an error if set doesn't exist.
*/
- static public void flush(Object set) {
+ static public void flushSet(Object set) {
if (funcsMap.get(set) == null)
throw new Error("No flush set found: '"+set+"'");
Index: fenfire/org/fenfire/swamp/CachedPureNodeFunction.java
diff -u fenfire/org/fenfire/swamp/CachedPureNodeFunction.java:1.2
fenfire/org/fenfire/swamp/CachedPureNodeFunction.java:1.3
--- fenfire/org/fenfire/swamp/CachedPureNodeFunction.java:1.2 Sun Aug 31
08:36:16 2003
+++ fenfire/org/fenfire/swamp/CachedPureNodeFunction.java Mon Sep 1
06:20:58 2003
@@ -65,9 +65,9 @@
throw new IllegalArgumentException("Called with wrong graph");
}
- NodeFunctionCacheEntry cac = (NodeFunctionCacheEntry)cache.get(node);
+ FunctionCacheEntry cac = (FunctionCacheEntry)cache.get(node);
if(cac == null) {
- cac = new NodeFunctionCacheEntry(node);
+ cac = new FunctionCacheEntry(node);
cache.put(node, cac);
}
if(cac.value == cac.DIRTY) {
Index: fenfire/org/fenfire/swamp/MultiplexerNodeFunction.java
diff -u fenfire/org/fenfire/swamp/MultiplexerNodeFunction.java:1.2
fenfire/org/fenfire/swamp/MultiplexerNodeFunction.java:1.3
--- fenfire/org/fenfire/swamp/MultiplexerNodeFunction.java:1.2 Mon Aug 18
04:25:48 2003
+++ fenfire/org/fenfire/swamp/MultiplexerNodeFunction.java Mon Sep 1
06:20:58 2003
@@ -36,17 +36,17 @@
*/
public class MultiplexerNodeFunction implements NodeFunction {
- final private PureNodeFunction unknown;
- final private PureNodeFunction known;
+ final private NodeFunction unknown;
+ final private NodeFunction known;
private Set multiplexingNodes = new HashSet();
/** All functions must be pure node functions.
- * @param unknownNodes Pure node function for nodes which are not in set
of known nodes.
- * @param knownNodes Pure node function for nodes which are in set of
known nodes.
+ * @param unknownNodes Node function for nodes which are not in set of
known nodes.
+ * @param knownNodes Node function for nodes which are in set of known
nodes.
* @see setMultiplexerNodes
*/
- public MultiplexerNodeFunction(PureNodeFunction unknownNodes,
- PureNodeFunction knownNodes) {
+ public MultiplexerNodeFunction(NodeFunction unknownNodes,
+ NodeFunction knownNodes) {
this.unknown = unknownNodes;
this.known = knownNodes;
}
Index: fenfire/org/fenfire/swamp/SuperLazyPureNodeFunction.java
diff -u fenfire/org/fenfire/swamp/SuperLazyPureNodeFunction.java:1.1
fenfire/org/fenfire/swamp/SuperLazyPureNodeFunction.java:1.2
--- fenfire/org/fenfire/swamp/SuperLazyPureNodeFunction.java:1.1 Sun Aug
31 08:29:31 2003
+++ fenfire/org/fenfire/swamp/SuperLazyPureNodeFunction.java Mon Sep 1
06:20:58 2003
@@ -21,7 +21,7 @@
PureNodeFunction f;
Object placeHolder;
Background background;
- Obs recalcObs;
+ ObjObs recalcObs;
/** Create a new SuperLazyPureNodeFunction.
* @param n The number of cache entries to use
@@ -37,7 +37,7 @@
ConstGraph g, PureNodeFunction f,
Object placeHolder,
Background background,
- Obs recalcObs
+ ObjObs recalcObs
) {
cache = new CachingMap(n);
this.ourGraph = g;
@@ -48,10 +48,10 @@
}
private class SuperLazyNodeFunctionCacheEntry
- extends NodeFunctionCacheEntry
+ extends FunctionCacheEntry
implements Runnable {
- public SuperLazyNodeFunctionCacheEntry(Object node) {
- super(node);
+ public SuperLazyNodeFunctionCacheEntry(Object input) {
+ super(input);
}
public void schedule() {
@@ -60,12 +60,13 @@
public void run() {
synchronized(this) {
- ConstGraph og = (ourGraph == null ?
- null : ourGraph.getObservedConstGraph(this));
- this.value = f.f(og, node);
- if(og != null) og.close();
+ ConstGraph og = (ourGraph == null ?
+ null : ourGraph.getObservedConstGraph(this));
+ this.value = f.f(og, this.input);
+ if(og != null) og.close();
}
- recalcObs.chg();
+ if(recalcObs != null)
+ recalcObs.chg(this.input);
}
}
Index: fenfire/org/fenfire/swamp/observablegraphtest.py
diff -u fenfire/org/fenfire/swamp/observablegraphtest.py:1.8
fenfire/org/fenfire/swamp/observablegraphtest.py:1.9
--- fenfire/org/fenfire/swamp/observablegraphtest.py:1.8 Wed Jun 11
13:40:54 2003
+++ fenfire/org/fenfire/swamp/observablegraphtest.py Mon Sep 1 06:20:58 2003
@@ -118,7 +118,7 @@
of = Func()
of.calls = 0
- cf = CachedNodeFunction(3, graph, of)
+ cf = CachedNodeFunction(10, graph, of)
def doit(f):
if dbg: print "F now:",f
@@ -160,10 +160,10 @@
assert of.calls == 18
of.calls = 0
doit(cf)
- assert of.calls < 16
+ assert of.calls < 16, of.calls
of.calls = 0
- cf = CachedNodeFunction(3, graph, of)
+ cf = CachedNodeFunction(10, graph, of)
class Func2(NodeFunction):
def __init__(self, func):
Index: fenfire/org/fenfire/view/CanvasView2D.java
diff -u fenfire/org/fenfire/view/CanvasView2D.java:1.28
fenfire/org/fenfire/view/CanvasView2D.java:1.29
--- fenfire/org/fenfire/view/CanvasView2D.java:1.28 Mon Aug 25 17:15:44 2003
+++ fenfire/org/fenfire/view/CanvasView2D.java Mon Sep 1 06:20:58 2003
@@ -45,7 +45,7 @@
/** A View2D of a CANVAS2D, with a given node function.
*/
public class CanvasView2D extends View2D implements NodedView2D,
org.fenfire.view.lava.FastView {
-public static final String rcsid = "$Id: CanvasView2D.java,v 1.28 2003/08/25
21:15:44 mudyc Exp $";
+public static final String rcsid = "$Id: CanvasView2D.java,v 1.29 2003/09/01
10:20:58 tjl Exp $";
public static boolean dbg = false;
private static void p(String s) { System.out.println("CanvasView2D:: "+s);
}
@@ -108,6 +108,10 @@
if (dbg) p("placeable object: "+n);
org.nongnu.libvob.lava.placeable.Placeable p =
(org.nongnu.libvob.lava.placeable.Placeable)nodeView.f(fen.constgraph, n);
+ // May return null if it's not placeable or
+ // if it's not yet available
+ if(p == null)
+ continue;
int cs = vs.coords.orthoBox(paper2screen, 0,1,2,3,4,5,6);
vs.matcher.add(containerCS, cs, n);
@@ -177,6 +181,9 @@
org.nongnu.libvob.lava.placeable.Placeable p =
(org.nongnu.libvob.lava.placeable.Placeable)nodeView
.f(fen.constgraph, n);
+ // May return null if it's not placeable or
+ // if it's not yet available
+ if(p == null) continue;
if(dbg) p("size: "+p.getWidth()+" "+p.getHeight());
Index: fenfire/org/fenfire/view/DispatchingNodeView.java
diff -u fenfire/org/fenfire/view/DispatchingNodeView.java:1.2
fenfire/org/fenfire/view/DispatchingNodeView.java:1.3
--- fenfire/org/fenfire/view/DispatchingNodeView.java:1.2 Mon Aug 18
05:50:50 2003
+++ fenfire/org/fenfire/view/DispatchingNodeView.java Mon Sep 1 06:20:58 2003
@@ -1,7 +1,7 @@
/*
DispatchingNodeView.java
*
- * Copyright (c) 2003, Benja Fallenstein
+ * Copyright (c) 2003, Benja Fallenstein and Tuomas J. Lukka
*
* This file is part of Fenfire.
*
@@ -23,7 +23,7 @@
*
*/
/*
- * Written by Benja Fallenstein
+ * Written by Benja Fallenstein and Tuomas J. Lukka
*/
package org.fenfire.view;
import org.fenfire.swamp.*;
@@ -34,13 +34,22 @@
/** A node view dispatching to different other
* node views depending on a node content's type.
*/
-public class DispatchingNodeView implements PureNodeFunction {
+public class DispatchingNodeView implements NodeFunction {
final NodeFunction nodeContent;
final NodeFunction textView, pageView;
+ public static class Pure extends DispatchingNodeView
+ implements PureNodeFunction {
+ public Pure(PureNodeFunction nodeContent,
+ PureNodeFunction textView,
+ PureNodeFunction pageView) {
+ super(nodeContent, textView, pageView);
+ }
+ }
+
public DispatchingNodeView(NodeFunction nodeContent,
- PureNodeFunction textView,
+ NodeFunction textView,
NodeFunction pageView) {
this.nodeContent = nodeContent;
this.textView = textView;
Index: fenfire/org/fenfire/view/PageNodeView.java
diff -u fenfire/org/fenfire/view/PageNodeView.java:1.5
fenfire/org/fenfire/view/PageNodeView.java:1.6
--- fenfire/org/fenfire/view/PageNodeView.java:1.5 Tue Aug 26 07:34:41 2003
+++ fenfire/org/fenfire/view/PageNodeView.java Mon Sep 1 06:20:58 2003
@@ -41,6 +41,13 @@
final NodeFunction nodeContent;
final SpanImageFactory spanImageFactory;
+ public static class Pure extends PageNodeView implements PureNodeFunction {
+ public Pure(PureNodeFunction nodeContent,
+ SpanImageFactory spanImageFactory) {
+ super(nodeContent, spanImageFactory);
+ }
+ }
+
public PageNodeView(NodeFunction nodeContent,
SpanImageFactory spanImageFactory) {
this.nodeContent = nodeContent;
Index: fenfire/org/fenfire/view/PageScrollView2D.java
diff -u fenfire/org/fenfire/view/PageScrollView2D.java:1.10
fenfire/org/fenfire/view/PageScrollView2D.java:1.11
--- fenfire/org/fenfire/view/PageScrollView2D.java:1.10 Wed Aug 13 12:56:28 2003
+++ fenfire/org/fenfire/view/PageScrollView2D.java Mon Sep 1 06:20:58 2003
@@ -26,6 +26,7 @@
*/
package org.fenfire.view;
import org.fenfire.spanimages.*;
+import org.fenfire.util.Function;
import org.nongnu.libvob.VobScene;
import org.nongnu.alph.*;
import org.fenfire.swamp.*;
@@ -33,49 +34,41 @@
/** A View2D showing a whole PageScrollBlock.
* The <code>plane</code> object passed to <code>render()</code>
* is the <code>PageScrollBlock</code> object.
- * XXX cache?
* <p>
- * XXX!!! NO CULLING!
+ * XXX!!! NO CULLING IMPLEMENTED YET!
*/
public class PageScrollView2D extends View2D {
- private final SpanImageFactory spanImageFactory;
- public PageScrollView2D(SpanImageFactory spanImageFactory) {
- this.spanImageFactory = spanImageFactory;
- flush();
- }
-
- NodeFunction scroll2layout = null;
+ private final Function pageScroll2layout;
- public void flush() {
- scroll2layout = new CachedNodeFunction(100, null,
- new NodeFunction() {
- public Object f(ConstGraph g, Object block0) {
- PageScrollBlock block = (PageScrollBlock)block0;
- return new PageSpanLayout(
- (PageSpan)block.getCurrent(), spanImageFactory);
- }
- }
- );
+ /** Create a PageScrollView2D.
+ * @param pageScroll2layout A function taking
+ * a PageScrollBlock and returning a PageSpanLayout.
+ */
+ public PageScrollView2D(Function pageScroll2layout) {
+ this.pageScroll2layout = pageScroll2layout;
}
- public PageSpanLayout getLayout(Object plane) {
- PageScrollBlock block = (PageScrollBlock)plane;
- return (PageSpanLayout)scroll2layout.f(null, block);
- }
public void getSize(Object plane, float[] wh) {
PageScrollBlock block = (PageScrollBlock)plane;
- PageSpanLayout layout = (PageSpanLayout)scroll2layout.f(null, block);
- wh[0] = layout.getWidth();
- wh[1] = layout.getHeight();
+ PageSpanLayout layout = (PageSpanLayout)pageScroll2layout.f(block);
+ if(layout != null) {
+ wh[0] = layout.getWidth();
+ wh[1] = layout.getHeight();
+ } else {
+ wh[0] = 100;
+ wh[1] = 100;
+ }
}
public Object getSelectedObject(Object plane, float x, float y, float w,
float h) {
PageScrollBlock block = (PageScrollBlock)plane;
- PageSpanLayout layout = (PageSpanLayout)scroll2layout.f(null, block);
+ PageSpanLayout layout = (PageSpanLayout)pageScroll2layout.f(block);
+ if(layout == null) return null;
return layout.getSelection(x, y, w, h);
+
}
public void render(VobScene vs,
@@ -84,7 +77,8 @@
int box2screen, int box2paper
) {
PageScrollBlock block = (PageScrollBlock)plane;
- PageSpanLayout layout = (PageSpanLayout)scroll2layout.f(null, block);
+ PageSpanLayout layout = (PageSpanLayout)pageScroll2layout.f(block);
+ if(layout == null) return;
int paper2box = vs.invertCS(box2paper, "PGSVinv");
int paper2screen = vs.concatCS(box2screen, "PGSVconc", paper2box);
layout.place(vs, paper2screen, -1 /*box2screen*/, matchingParent);
Index: fenfire/org/fenfire/view/VobWrapperFunction.java
diff -u fenfire/org/fenfire/view/VobWrapperFunction.java:1.4
fenfire/org/fenfire/view/VobWrapperFunction.java:1.5
--- fenfire/org/fenfire/view/VobWrapperFunction.java:1.4 Thu Aug 28
09:38:03 2003
+++ fenfire/org/fenfire/view/VobWrapperFunction.java Mon Sep 1 06:20:58 2003
@@ -29,9 +29,11 @@
/** @return A Placeable object.
*/
public Object f(final ConstGraph g, final Object node) {
+ final org.nongnu.libvob.lava.placeable.Placeable content =
+ (org.nongnu.libvob.lava.placeable.Placeable)function.f(g, node);
+ if(content == null)
+ return null;
return new org.nongnu.libvob.lava.placeable.Placeable() {
- final org.nongnu.libvob.lava.placeable.Placeable content =
- (org.nongnu.libvob.lava.placeable.Placeable)function.f(g,
node);
public void place(VobScene vs, int into) {
content.place(vs, into);
Index: fenfire/org/fenfire/view/buoy/TransclusionConnector.java
diff -u fenfire/org/fenfire/view/buoy/TransclusionConnector.java:1.24
fenfire/org/fenfire/view/buoy/TransclusionConnector.java:1.25
--- fenfire/org/fenfire/view/buoy/TransclusionConnector.java:1.24 Thu Aug
21 04:05:26 2003
+++ fenfire/org/fenfire/view/buoy/TransclusionConnector.java Mon Sep 1
06:20:58 2003
@@ -44,7 +44,7 @@
/** Hang transclusion buoys.
*/
public class TransclusionConnector implements BuoyViewConnector {
-public static final String rcsid = "$Id: TransclusionConnector.java,v 1.24
2003/08/21 08:05:26 mudyc Exp $";
+public static final String rcsid = "$Id: TransclusionConnector.java,v 1.25
2003/09/01 10:20:58 tjl Exp $";
public static boolean dbg = false;
private static void p(String s) {
System.out.println("TransclusionConnector:: "+s); }
@@ -207,8 +207,14 @@
float y = RDFUtil.getFloat(fen.graph, node, CANVAS2D.y);
org.nongnu.libvob.lava.placeable.Placeable p =
(org.nongnu.libvob.lava.placeable.Placeable)nodeView.f(fen.constgraph, node);
- float w = p.getWidth();
- float h = p.getHeight();
+ float w,h;
+ if(p != null) {
+ w = p.getWidth();
+ h = p.getHeight();
+ } else {
+ w = 0;
+ h = 0;
+ }
int bw = (int)(mx * w);
int bh = (int)(my * h);
return new View2D.Anchor(plane,
Index: fenfire/org/fenfire/view/buoy/doublegeometer.py
diff -u fenfire/org/fenfire/view/buoy/doublegeometer.py:1.1
fenfire/org/fenfire/view/buoy/doublegeometer.py:1.2
--- fenfire/org/fenfire/view/buoy/doublegeometer.py:1.1 Mon Aug 18 07:18:38 2003
+++ fenfire/org/fenfire/view/buoy/doublegeometer.py Mon Sep 1 06:20:58 2003
@@ -49,13 +49,16 @@
h1 = h - h0
+ y1 = h0 * 1.03
+ h0 *= .97
+
s0 = 1.
s1 = .8
vs.coords.setOrthoBoxParams(self.mainbox1, 1,
0, 20, s0, s0, w/s0, h0/s0);
vs.coords.setOrthoBoxParams(self.mainbox2, 1,
- 0, h0, s1, s1, w/s1, h1/s1);
+ 0, y1, s1, s1, w/s1, h1/s1);
else:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [ff-cvs] fenfire docs/Functional.rst org/fenfire/fenpdf/...,
Tuomas J. Lukka <=