fenfire-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ff-cvs] fenfire ./Makefile org/fenfire/demo/mm.py org/f...


From: Tuomas J. Lukka
Subject: [ff-cvs] fenfire ./Makefile org/fenfire/demo/mm.py org/f...
Date: Mon, 06 Oct 2003 02:26:14 -0400

CVSROOT:        /cvsroot/fenfire
Module name:    fenfire
Branch:         
Changes by:     Tuomas J. Lukka <address@hidden>        03/10/06 02:26:13

Modified files:
        .              : Makefile 
        org/fenfire/demo: mm.py 
        org/fenfire/fenmm: WhiteNodeView.java 
        org/fenfire/functional: Functional.java FunctionalTest.java 
                                functionaltest.py 
        org/fenfire/view/lava: mindMapView2D.py 
Added files:
        org/fenfire    : mm.test 

Log message:
        CVS sync

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/Makefile.diff?tr1=1.46&tr2=1.47&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/mm.test?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/demo/mm.py.diff?tr1=1.62&tr2=1.63&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenmm/WhiteNodeView.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/functional/Functional.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/functional/FunctionalTest.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/functional/functionaltest.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/lava/mindMapView2D.py.diff?tr1=1.56&tr2=1.57&r1=text&r2=text

Patches:
Index: fenfire/Makefile
diff -u fenfire/Makefile:1.46 fenfire/Makefile:1.47
--- fenfire/Makefile:1.46       Mon Sep 29 10:49:21 2003
+++ fenfire/Makefile    Mon Oct  6 02:26:12 2003
@@ -53,7 +53,7 @@
        $(LDLIB) java -cp $(CLASSPATH) $(PYTHONPATH) org.python.util.jython 
../libvob/rundemo.py -Dfenpdf.file=$(FILE) -Dfenpdf.demo=1 $(DBG) 
org/fenfire/bin/$(BIN)
 
 run_mmdemo:
-       $(LDLIB) java -cp $(CLASSPATH) $(PYTHONPATH) org.python.util.jython 
../libvob/rundemo.py -Dfenmm.file="../spaces/mmdemo.rdf" org/fenfire/demo/mm.py
+       $(LDLIB) java -cp $(CLASSPATH) $(PYTHONPATH) org.python.util.jython 
../libvob/rundemo.py -Dfenmm.file="../spaces/mmdemo.rdf" $(DBG) 
org/fenfire/demo/mm.py
 
 run_textmm:
        java -cp $(CLASSPATH) $(PYTHONPATH) -Dfenmm.file="$(FILE)" 
org.python.util.jython org/fenfire/fenmm/textmm.py
@@ -154,7 +154,7 @@
 
 tags:
        ctags -R metacode docs lava org
-       
+
 
 ##################
 # Storm pool rsync
Index: fenfire/org/fenfire/demo/mm.py
diff -u fenfire/org/fenfire/demo/mm.py:1.62 fenfire/org/fenfire/demo/mm.py:1.63
--- fenfire/org/fenfire/demo/mm.py:1.62 Mon Sep 15 14:31:15 2003
+++ fenfire/org/fenfire/demo/mm.py      Mon Oct  6 02:26:12 2003
@@ -43,7 +43,7 @@
     print 'mindMapView2D', s
 
 dbg = 0
-w = vob.putil.demowindow.w
+
 w.setCursor("wait")
 vob.putil.demo.usingNormalBindings = 1
 
@@ -124,27 +124,31 @@
     )
 
 functional.cache("ContentFunction", 1);
+functional.cache("TextNodeView", 500);
 functional.cache("NormalTextNodeView", 500);
 functional.cache("AccursedTextNodeView", 10);
 
 contentFunction = functional.createFunctionInstance(
     "ContentFunction",
     ff.structure.Ff.ContentFunction,
-    [ ff_structure ]).getCallableFunction()
+    [ ff_structure ])
+
+textnodeview = functional.createFunctionInstance(
+    "TextNodeView",
+    ff.view.TextNodeView,
+    [contentFunction, style, java.awt.Color.black, 250.])
 
 # nodeview for normal nodes
-normal_text = ff.view.TextNodeView(contentFunction, style, java.awt.Color(0., 
0., 0.), 250.)
 normalf = functional.createFunctionInstance(
     "NormalTextNodeView",
     ff.fenmm.WhiteNodeView,
-    [normal_text, java.awt.Color(.6, .6, .6)])
+    [textnodeview, java.awt.Color(.6, .6, .6)])
 
 # nodeview for accursed nodes
-accursed_text = ff.view.TextNodeView(contentFunction, style, 
java.awt.Color.black, 250.)
 accursedf = functional.createFunctionInstance(
     "AccursedTextNodeView",
     ff.fenmm.WhiteNodeView,
-    [accursed_text, java.awt.Color(.9, .9, .9)])
+    [textnodeview, java.awt.Color(.9, .9, .9)])
 
 multiplexer = ff.swamp.MultiplexerNodeFunction(
     normalf.getCallableFunction(),
@@ -185,8 +189,6 @@
         self.bgcolor = (.4, .7, 1.0)
         self.c = ff.fenmm.MMTextCursor(style)
 
-        self.alphContent = ff.util.AlphContent(self.fen, self.ff_structure)
-
     def nextRmb(self):
         rmb = self.rmb_switch
         rmb.append(rmb.pop(0)) 
@@ -349,7 +351,8 @@
             cursor.setAccursed(node)
 
             ### something easier to allow setOffset(x,y) before rendering
-            nodeview = ff.view.TextNodeView(self.context.contentFunction, 
self.context.style, 250.)
+            nodeview = 
ff.view.TextNodeView(self.context.contentFunction.getCallableFunction(), \
+                                            self.context.style, 250.)
             self.context.c.setTextPlaceable(nodeview.f(fen.graph, node))
 
             # set cursor, transitions between zoomed and normal should be 
accounted
@@ -402,9 +405,11 @@
 
 class MMScene:
     def __init__(self):
-        components, centered = self.compinit()
+        alphContent = ff.util.AlphContent(fen, ff_structure)
+        components, centered = self.compinit(alphContent)
 
         self.context = Context(fen, w, components, multiplexer, style)
+        self.context.alphContent = alphContent
 
         self.mindMouse = vob.mouse.MouseMultiplexer()
         self.mindMouse.setListener(3, 0, 'Right mouse button switching.', 
RMB(fen, self.context))
@@ -456,7 +461,7 @@
         except: pass # java.io.FileNotFoundException: pass
 #       if self.naxes >= 3: self.view.initRotation = None
 
-    def compinit(self):
+    def compinit(self, alphContent):
         """Finds mindmap components; if none, creates one.
         Returns tuple: the first element is a list of other components but
                        the second element, which is the largest component"""
@@ -471,7 +476,7 @@
         if largest == None:
             # No components, so create one for focus
             largest = ff.util.RDFUtil.N(fen.graph, MINDSTRUCT.Data)
-            self.context.alphContent.setText(largest, 'Home', 1)
+            alphContent.setText(largest, 'Home', 1)
         else:
             # convert from java.util.Set to list
             for component in comps.toArray():
@@ -515,12 +520,14 @@
 
         # draw cursor
         if accursed:
-            nodeview = ff.view.TextNodeView(self.context.contentFunction, 
style, 250.)
+            nodeview = 
ff.view.TextNodeView(self.context.contentFunction.getCallableFunction(), \
+                                            style, 250.)
             if hasattr(self.view, "zoomPanCS") \
                and (structLink.isLinked(accursed) or 
self.context.main.getPlane() == accursed):
                     self.context.c.render(vs, self.view.zoomPanCS, cs, 
nodeview.f(fen.graph, accursed))
             else:
-                self.context.c.render(vs, cs, cs, vs.matcher.getCS(cs, 
accursed), nodeview.f(fen.graph, accursed))
+                self.context.c.render(vs, cs, cs, vs.matcher.getCS(cs, 
accursed), \
+                                      nodeview.f(fen.graph, accursed))
 
         if self.startup: w.setCursor('default'); self.startup = 0
 
Index: fenfire/org/fenfire/fenmm/WhiteNodeView.java
diff -u fenfire/org/fenfire/fenmm/WhiteNodeView.java:1.4 
fenfire/org/fenfire/fenmm/WhiteNodeView.java:1.5
--- fenfire/org/fenfire/fenmm/WhiteNodeView.java:1.4    Wed Sep 10 09:00:46 2003
+++ fenfire/org/fenfire/fenmm/WhiteNodeView.java        Mon Oct  6 02:26:13 2003
@@ -3,6 +3,7 @@
 package org.fenfire.fenmm;
 
 import org.fenfire.functional.PureNodeFunction;
+import org.fenfire.functional.NodeFunction;
 import org.fenfire.swamp.ConstGraph;
 import org.nongnu.libvob.lava.placeable.TextPlaceable;
 import org.nongnu.libvob.VobScene;
@@ -20,9 +21,9 @@
 
     private Paper paper;
     private GLRen.FixedPaperQuad pq;
-    private PureNodeFunction nodef;
+    private NodeFunction nodef;
     
-    public WhiteNodeView(PureNodeFunction nodef, Color color) {
+    public WhiteNodeView(NodeFunction nodef, Color color) {
         paper = SpecialPapers.selectionPaper(color);
         pq = GLRen.createFixedPaperQuad(paper, 0, 0, 1, 1, 0, 10, 10, 10);
 
Index: fenfire/org/fenfire/functional/Functional.java
diff -u fenfire/org/fenfire/functional/Functional.java:1.2 
fenfire/org/fenfire/functional/Functional.java:1.3
--- fenfire/org/fenfire/functional/Functional.java:1.2  Wed Sep 10 09:51:31 2003
+++ fenfire/org/fenfire/functional/Functional.java      Mon Oct  6 02:26:13 2003
@@ -11,6 +11,8 @@
  * transparent run-time data-sensitive caching and super-lazy caching.
  */
 public abstract class Functional {
+    public static boolean dbg = false;
+    private void p(String s) { System.out.println(s); }
 
     /** Hints about a Function class.
      * Hints tell the Functional API about a Function: is it slow to evaluate,
@@ -120,12 +122,39 @@
                // If it's a node, allow functions and nodefunctions.
                if(FunctionInstance.class.isAssignableFrom(givenParamType)) {
                    if(ptypes[j].isAssignableFrom(Function.class) ||
-                      ptypes[j].isAssignableFrom(NodeFunction.class))
+                      ptypes[j].isAssignableFrom(NodeFunction.class)) {
+                       if (dbg) p("MATCH: "+givenParamType+", "+ptypes[j]);
                        continue PARAMETERS;
+                   }
                }
 
-               if(! ptypes[j].isAssignableFrom(givenParamType))
+               // Allow float parameter for double and integer.
+               if(ptypes[j].isAssignableFrom(java.lang.Float.TYPE)) {
+                   if (parameters[j] instanceof java.lang.Double) {
+                       parameters[j] = new 
java.lang.Float(((java.lang.Double)parameters[j]).floatValue());
+                       if (dbg) p("MATCH: "+givenParamType+", "+ptypes[j]);
+                       continue PARAMETERS;
+                   } else if (parameters[j] instanceof java.lang.Integer) {
+                       parameters[j] = new 
java.lang.Float(((java.lang.Integer)parameters[j]).floatValue());
+                       if (dbg) p("MATCH: "+givenParamType+", "+ptypes[j]);
+                       continue PARAMETERS;
+                   }
+               }
+
+               // Allow double parameter for float.
+               if(ptypes[j].isAssignableFrom(java.lang.Double.TYPE)) {
+                   if (parameters[j] instanceof java.lang.Float) {
+                       parameters[j] = new 
java.lang.Double(((java.lang.Float)parameters[j]).doubleValue());
+                       if (dbg) p("MATCH: "+givenParamType+", "+ptypes[j]);
+                       continue PARAMETERS;
+                   }
+               }
+
+               if(! ptypes[j].isAssignableFrom(givenParamType)) {
+                   if (dbg) p("DISMATCH: "+givenParamType+", "+ptypes[j]);
                    continue CONSTRUCTORS;
+               }
+               if (dbg) p("MATCH: "+givenParamType+", "+ptypes[j]);
            }
            return constructors[i];
        }
Index: fenfire/org/fenfire/functional/FunctionalTest.java
diff -u fenfire/org/fenfire/functional/FunctionalTest.java:1.2 
fenfire/org/fenfire/functional/FunctionalTest.java:1.3
--- fenfire/org/fenfire/functional/FunctionalTest.java:1.2      Mon Sep 15 
13:34:44 2003
+++ fenfire/org/fenfire/functional/FunctionalTest.java  Mon Oct  6 02:26:13 2003
@@ -117,5 +117,22 @@
            return f.f(g, o);
        }
     }
+
+ 
+    /** A class used to test mapping of integer
+     * and double parameters into float.
+     */
+    static public class floatParamClass implements Function {
+       public floatParamClass(float f) { }
+       public Object f(Object o) {  return o; }
+    }
+
+    /** A class used to test mapping of float
+     * parameters into double.
+     */
+    static public class doubleParamClass implements Function {
+       public doubleParamClass(double d) { }
+       public Object f(Object o) {  return o; }
+    }
 }
 
Index: fenfire/org/fenfire/functional/functionaltest.py
diff -u fenfire/org/fenfire/functional/functionaltest.py:1.1 
fenfire/org/fenfire/functional/functionaltest.py:1.2
--- fenfire/org/fenfire/functional/functionaltest.py:1.1        Wed Sep 10 
09:00:46 2003
+++ fenfire/org/fenfire/functional/functionaltest.py    Mon Oct  6 02:26:13 2003
@@ -53,3 +53,37 @@
     def t():
        assert f.f("AAA") == "AAAXXXYYY", f.f("AAA")
     waitEvalFunc(t)
+
+
+# map java.lang.integer and java.lang.double into float
+def test_Functional_param_integer2float():
+    """
+    A method used to test mapping of integer
+    parameters into float.
+    """
+    foobar = functional.createFunctionInstance(
+        "integer2float",
+        FunctionalTest.floatParamClass,
+        [1])
+
+def test_Functional_param_double2float():
+    """
+    A method used to test mapping of double
+    parameters into float.
+    """
+    foobar = functional.createFunctionInstance(
+        "double2float",
+        FunctionalTest.floatParamClass,
+        [1.])
+
+# map java.lang.Float into double
+def test_Functional_param_float2double():
+    """
+    A method used to test mapping of float
+    parameters into double.
+    """
+    import java
+    foobar = functional.createFunctionInstance(
+        "float2double",
+        FunctionalTest.doubleParamClass,
+        [java.lang.Float(1.)])
Index: fenfire/org/fenfire/view/lava/mindMapView2D.py
diff -u fenfire/org/fenfire/view/lava/mindMapView2D.py:1.56 
fenfire/org/fenfire/view/lava/mindMapView2D.py:1.57
--- fenfire/org/fenfire/view/lava/mindMapView2D.py:1.56 Fri Sep 12 11:36:13 2003
+++ fenfire/org/fenfire/view/lava/mindMapView2D.py      Mon Oct  6 02:26:13 2003
@@ -43,21 +43,22 @@
 
         style = self.context.style
 
+        nodeview = self.context.functional.createFunctionInstance(
+            "TextNodeView",
+            ff.view.TextNodeView,
+            [self.context.contentFunction, style, java.awt.Color.black, 250.])
+
         # nodeview for normal nodes
-        normal_text = ff.view.TextNodeView(self.context.contentFunction,
-                                           style, java.awt.Color(0., 0., 0.), 
250.)
         normalf = self.context.functional.createFunctionInstance(
             "NormalTextNodeView",
             ff.fenmm.WhiteNodeView,
-            [normal_text, java.awt.Color(.6, .6, 0)])
+            [nodeview, java.awt.Color(.6, .6, 0)])
         
         # nodeview for accursed nodes
-        accursed_text = ff.view.TextNodeView(self.context.contentFunction,
-                                             style, java.awt.Color.black, 250.)
         accursedf = self.context.functional.createFunctionInstance(
             "AccursedTextNodeView",
             ff.fenmm.WhiteNodeView,
-            [accursed_text, java.awt.Color(.9, .9, .9)])
+            [nodeview, java.awt.Color(.9, .9, .9)])
             
         self.multiplexer = ff.swamp.MultiplexerNodeFunction(
             normalf.getCallableFunction(),




reply via email to

[Prev in Thread] Current Thread [Next in Thread]