gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] fenfire/org/fenfire/view CanvasView2D.java buoy...


From: Matti Katila
Subject: [Gzz-commits] fenfire/org/fenfire/view CanvasView2D.java buoy...
Date: Thu, 31 Jul 2003 06:08:05 -0400

CVSROOT:        /cvsroot/fenfire
Module name:    fenfire
Branch:         
Changes by:     Matti Katila <address@hidden>   03/07/31 06:08:05

Modified files:
        org/fenfire/view: CanvasView2D.java 
        org/fenfire/view/buoy: NodeType2D.java PPConnector.java 

Log message:
        fix pair problem. transclusionconnector still missing.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/CanvasView2D.java.diff?tr1=1.22&tr2=1.23&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/buoy/NodeType2D.java.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/buoy/PPConnector.java.diff?tr1=1.19&tr2=1.20&r1=text&r2=text

Patches:
Index: fenfire/org/fenfire/view/CanvasView2D.java
diff -u fenfire/org/fenfire/view/CanvasView2D.java:1.22 
fenfire/org/fenfire/view/CanvasView2D.java:1.23
--- fenfire/org/fenfire/view/CanvasView2D.java:1.22     Wed Jul 30 06:32:10 2003
+++ fenfire/org/fenfire/view/CanvasView2D.java  Thu Jul 31 06:08:04 2003
@@ -34,6 +34,7 @@
 import org.fenfire.util.*;
 import org.nongnu.libvob.*;
 import org.nongnu.libvob.gl.*;
+import org.nongnu.libvob.impl.DefaultVobMatcher;
 import org.nongnu.libvob.impl.gl.*;
 import org.nongnu.libvob.buoy.*;
 import org.nongnu.libvob.vobs.SimpleConnection;
@@ -44,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.22 2003/07/30 
10:32:10 mudyc Exp $";
+public static final String rcsid = "$Id: CanvasView2D.java,v 1.23 2003/07/31 
10:08:04 mudyc Exp $";
     public static boolean dbg = false;
     private static void p(String s) { System.out.println("CanvasView2D:: "+s); 
}
     
@@ -86,6 +87,19 @@
            p("box2screen: "+box2screen);
            p("matchingparent: "+matchingParent);
        }
+
+       /* The code adds two dummy cs:
+        * 1) cs with "CANVAS" as a key.
+        * 2) cs into the previous one with container as a key.
+        * All nodes are matched into latter dummy cs and connectors etc.
+        * must know this and follow that specification to work correctly.
+        * [specification specified in irc at 2003-07-31T9:50/10:35Z]
+        */
+       int canvasCS = vs.coords.translate(matchingParent, 0,0);
+       vs.matcher.add(matchingParent, canvasCS, "CANVAS");
+       int containerCS = vs.coords.translate(canvasCS, 0,0);
+       vs.matcher.add(canvasCS, containerCS, container);
+
        Iterator iter = fen.constgraph.findN_11X_Iter(container, 
                                                      CANVAS2D.contains);
        if (dbg) p("Canvas begin");
@@ -96,7 +110,7 @@
                    
(org.nongnu.libvob.lava.placeable.Placeable)nodeView.f(fen.constgraph, n);
 
            int cs = vs.coords.orthoBox(paper2screen, 0,1,2,3,4,5,6);
-           vs.matcher.add(matchingParent, cs, new Pair(container, n));
+           vs.matcher.add(containerCS, cs, n);
            vs.activate(cs);
 
            if(cull) {
@@ -106,14 +120,16 @@
         }
         chgFast(vs, box2screen);
 
+       
+       // [mudyc] thinks that something which knows
+       // about STRUCTLINK should be an adaptor.
 
        // show connections
        Iterator iter1 = fen.constgraph.findN_11X_Iter(container, 
                                                      CANVAS2D.contains);
        while (iter1.hasNext()) {
            Object node1 = iter1.next();
-           Pair key1 = new Pair(container, node1);
-           int cs1 = vs.matcher.getCS(matchingParent, key1);
+           int cs1 = vs.matcher.getCS(containerCS, node1);
 
            Iterator iter2 = fen.constgraph.findN_11X_Iter(node1, 
                    STRUCTLINK.linkedTo);
@@ -122,22 +138,38 @@
                Object container2 = fen.constgraph.find1_X11(CANVAS2D.contains, 
node2);
                if(container2 != container)
                    continue;
-               Pair key2 = new Pair(container, node2);
-               int cs2 = vs.matcher.getCS(matchingParent, key2);
+               int cs2 = vs.matcher.getCS(containerCS, node2);
                
                vs.map.put(lineconn, cs1, cs2);
            }
         }
     }
 
+    static public Object getContainerKey(VobScene vs, int from) {
+       DefaultVobMatcher m = (DefaultVobMatcher)vs.matcher;
+       int canvasCS = m.getCS(from, "CANVAS");
+
+       Object container = null;
+       for(Iterator i=m.getKeys(canvasCS).iterator(); i.hasNext();) {
+           container = i.next();
+           if (dbg) p("container object is: " +container);
+       }
+       return container;
+    }
+    static public int getContainerCS(VobScene vs, int from) {
+       Object container = getContainerKey(vs, from);
+       int canvasCS = vs.matcher.getCS(from, "CANVAS");
+       int containerCS = vs.matcher.getCS(canvasCS, container);
+       if (containerCS < 0) throw new Error("Impossible!");
+       return containerCS;
+    }
+
     public void chgFast(VobScene oldVS, int parent) {
+       int containerCS = getContainerCS(oldVS, parent);
 
-       Object container = containers.get(""+parent);
-       if (dbg) p("chgFast container: " + container);
-       Iterator iter = fen.constgraph.findN_11X_Iter(container, 
-                                                     CANVAS2D.contains);
-        while (iter.hasNext()) {
-            Object n = iter.next();
+       DefaultVobMatcher m = (DefaultVobMatcher)oldVS.matcher;
+       for(Iterator i=m.getKeys(containerCS).iterator(); i.hasNext();) {
+           Object n = i.next();
            if (dbg) p("Object is: "+n);
            float x = RDFUtil.getFloat(fen.graph, n, CANVAS2D.x);
            float y = RDFUtil.getFloat(fen.graph, n, CANVAS2D.y);
@@ -148,7 +180,7 @@
            
            if(dbg) p("size: "+p.getWidth()+" "+p.getHeight());
 
-           int cs = oldVS.matcher.getCS(parent, new Pair(container, n));
+           int cs = oldVS.matcher.getCS(containerCS, n);
            if (cs < 1) throw new Error(cs+" is not possible!");
 
             oldVS.coords.setOrthoBoxParams(cs, 0, 
@@ -164,7 +196,6 @@
                    float[] xyout) {
        int cs = oldvs.getCSAt(box2screen, x, y, xyout);
        if(cs <= 1) return null;
-       Pair p = (Pair)oldvs.matcher.getKey(cs);
-       return p.second;
+       return oldvs.matcher.getKey(cs);
     }
 }
Index: fenfire/org/fenfire/view/buoy/NodeType2D.java
diff -u fenfire/org/fenfire/view/buoy/NodeType2D.java:1.14 
fenfire/org/fenfire/view/buoy/NodeType2D.java:1.15
--- fenfire/org/fenfire/view/buoy/NodeType2D.java:1.14  Wed Jul 30 08:52:33 2003
+++ fenfire/org/fenfire/view/buoy/NodeType2D.java       Thu Jul 31 06:08:05 2003
@@ -26,6 +26,7 @@
  */
 package org.fenfire.view.buoy;
 import org.fenfire.view.View2D;
+import org.fenfire.view.CanvasView2D;
 import org.fenfire.view.NodedView2D;
 import org.fenfire.util.Pair;
 import org.fenfire.util.Triple;
@@ -42,7 +43,7 @@
  */
 public class NodeType2D extends AbstractNodeType2D {
     public static boolean dbg = false;
-    private static void pa(String s) { System.out.println("NodeType2D:: "+s); }
+    private static void p(String s) { System.out.println("NodeType2D:: "+s); }
 
     public static int effigy = 0;
     
@@ -61,7 +62,7 @@
 
     public int renderBuoy(VobScene vs, int into, Object linkId,
                          Object a, Object cachedSize) {
-       if (dbg) pa("start renderBuoy");
+       if (dbg) p("start renderBuoy");
        if(effigy != 0) {
            Vob eff = org.nongnu.libvob.gl.GLRen.createQuad(effigy-1, 0,0);
            vs.map.put( eff, into);
@@ -72,7 +73,7 @@
        float[] tmp = new float[2];
        vs.coords.getSqSize(into, tmp);
        float w = tmp[0], h = tmp[1];
-       if (dbg) pa("rect "+anchor+" coords "+w+","+h);
+       if (dbg) p("rect "+anchor+" coords "+w+","+h);
 
        float scale = w / anchor.w;
        if(scale < h / anchor.h) scale = h / anchor.h;
@@ -87,15 +88,21 @@
 
        view2d.render(vs, anchor.plane, into, into, box2paper);
 
-       if (dbg) pa("start renderBuoy..DONE");
+       if (dbg) p("start renderBuoy..DONE");
 
        // anchor.node may be null if this
        // is not a noded View2D
        
-       int box = anchor.node==null 
-                   ?  into 
-                   : vs.matcher.getCS(into, 
-                           new Pair(anchor.plane, anchor.node));
+       int box = into;
+       if (anchor.node != null ) {
+           int containerCS = CanvasView2D.getContainerCS(vs, into);
+           box = vs.matcher.getCS(containerCS, anchor.node);
+           if (dbg) p("box is: "+box);
+       }
+       if (box < 0) {
+           box = into;
+           throw new Error("Heyhey boys!! this doesn't work!");
+       }
        return vs.coords.unitSq(box);
     }
 }
Index: fenfire/org/fenfire/view/buoy/PPConnector.java
diff -u fenfire/org/fenfire/view/buoy/PPConnector.java:1.19 
fenfire/org/fenfire/view/buoy/PPConnector.java:1.20
--- fenfire/org/fenfire/view/buoy/PPConnector.java:1.19 Wed Jul 30 08:38:32 2003
+++ fenfire/org/fenfire/view/buoy/PPConnector.java      Thu Jul 31 06:08:05 2003
@@ -40,9 +40,9 @@
 /** Make the kinds of links familiar from PP structure.
  */
 public class PPConnector implements BuoyViewConnector {
-public static final String rcsid = "$Id: PPConnector.java,v 1.19 2003/07/30 
12:38:32 tjl Exp $";
+public static final String rcsid = "$Id: PPConnector.java,v 1.20 2003/07/31 
10:08:05 mudyc Exp $";
     public static boolean dbg = false;
-    private static void pa(String s) { System.out.println("PPConnector::"+s); }
+    private static void p(String s) { System.out.println("PPConnector:: "+s); }
 
     public static boolean hackForTesting = false;
 
@@ -72,18 +72,23 @@
        MainNode2D mn2d = (MainNode2D)mainNode;
        if(mn2d.getView2D() != view2d && !hackForTesting) return;
 
+       Object container = CanvasView2D.getContainerKey(vs, parentCs);
+       int containerCS = CanvasView2D.getContainerCS(vs, parentCs);
+       if (dbg) p("containerCS: "+containerCS);
+
        DefaultVobMatcher m = (DefaultVobMatcher)vs.matcher;
-       for(Iterator i=m.getKeys(parentCs).iterator(); i.hasNext();) {
-           Object next = i.next();
-           if(!(next instanceof Pair)) continue;
-           Pair pair = (Pair)next;
-           int cs = m.getCS(parentCs, pair);
+       for(Iterator i=m.getKeys(containerCS).iterator(); i.hasNext();) {
+           Object node = i.next();
+           int cs = m.getCS(containerCS, node);
            int culledCS = m.getCS(cs, "CULL");
+           if (dbg) p("node: "+node+", cs: "+cs+", cull: "+culledCS);
            if(culledCS > 0) cs = culledCS;
 
-           Object container = pair.first;
-           Object node = pair.second;
-           
+           if (cs < 0) {
+               p("Error with node: "+node+", too low cs: "+cs);
+               continue;
+           }
+
            /* check all associations */
 
            // Right links!
@@ -95,7 +100,7 @@
                Object plane = fen.constgraph.find1_X11(CANVAS2D.contains, obj);
                if (container == plane) continue;
                Object anchor = getAnchor(plane, obj);
-               if (dbg) pa("rect:"+anchor);
+               if (dbg) p("anchor:"+anchor);
                l.link(1, cs, nodeType, new Pair(node, obj), anchor, shift);
                 shift++;
            }
@@ -108,7 +113,7 @@
                Object plane = fen.constgraph.find1_X11(CANVAS2D.contains, obj);
                if (container == plane) continue;
                Object anchor = getAnchor(plane, obj);
-               if (dbg) pa("rect:"+anchor);
+               if (dbg) p("anchor:"+anchor);
                l.link(-1, cs, nodeType, new Pair(obj, node), anchor, shift);
                 shift++;
            }




reply via email to

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