gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/lava gzz/loom/Cursor.java gzz/loom/Loom.jav...


From: Benja Fallenstein
Subject: [Gzz-commits] gzz/lava gzz/loom/Cursor.java gzz/loom/Loom.jav...
Date: Sun, 23 Feb 2003 09:45:14 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Benja Fallenstein <address@hidden>      03/02/23 09:45:14

Modified files:
        lava/gzz/loom  : Cursor.java Loom.java SimpleView.java 
        lava/test/gzz/loom: SimpleView.test 

Log message:
        refactor

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/loom/Cursor.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/loom/Loom.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/loom/SimpleView.java.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/loom/SimpleView.test.diff?tr1=1.11&tr2=1.12&r1=text&r2=text

Patches:
Index: gzz/lava/gzz/loom/Cursor.java
diff -u gzz/lava/gzz/loom/Cursor.java:1.1 gzz/lava/gzz/loom/Cursor.java:1.2
--- gzz/lava/gzz/loom/Cursor.java:1.1   Sun Feb 23 09:20:18 2003
+++ gzz/lava/gzz/loom/Cursor.java       Sun Feb 23 09:45:14 2003
@@ -38,9 +38,35 @@
     public Resource focus;
     public RDFNode rotation;
 
-    public Cursor() {}
-    public Cursor(Resource focus, RDFNode rotation) {
+    /** The comparator used to order the nodes in the graph.
+     *  The vertical order of nodes is determined by this Comparator.
+     */
+    public Comparator order;
+
+    public Cursor(Comparator order) {
+       this.order = order;
+    }
+
+    public Cursor(Comparator order, Resource focus, RDFNode rotation) {
+       this(order);
        this.focus = focus;
        this.rotation = rotation;
+    }
+
+    /** The posward connections of <code>focus</code> to show,
+     *  in order. XXX refactor-- we need negward connections
+     *  and recursion...
+     */
+    public SortedSet getPoswardConnections() {
+       try {
+           SortedSet nodes = new TreeSet(order);
+           StmtIterator i = focus.listProperties();
+           for(; i.hasNext();) nodes.add(i.next().getObject());
+           i.close();
+
+           return nodes;
+       } catch(RDFException e) {
+           throw new Error("RDFException: "+e);
+       }
     }
 }
Index: gzz/lava/gzz/loom/Loom.java
diff -u gzz/lava/gzz/loom/Loom.java:1.3 gzz/lava/gzz/loom/Loom.java:1.4
--- gzz/lava/gzz/loom/Loom.java:1.3     Sun Feb 23 09:15:46 2003
+++ gzz/lava/gzz/loom/Loom.java Sun Feb 23 09:45:14 2003
@@ -53,14 +53,16 @@
     public static void main(String[] args) throws RDFException, IOException {
        final Model model = load(args[0]);
        final Statement stmt = model.listStatements().next();
-       final Cursor cursor = new Cursor(stmt.getSubject(), stmt.getObject());
        final GraphicsAPI api = GraphicsAPI.getInstance();
 
-       final Comparator cmp = new Comparator() {
+       final Comparator order = new Comparator() {
                public int compare(Object o1, Object o2) {
                    return o1.hashCode() - o2.hashCode();
                }
            };
+       final Cursor cursor = 
+           new Cursor(order, stmt.getSubject(), stmt.getObject());
+
        final Vob bg = new RectBgVob();
        final TextStyle style = api.getTextStyle("Serif", 0, 12);
        final NodeView nodeView = new NodeView() {
@@ -76,7 +78,7 @@
                }
                public VobScene generate() {
                    VobScene sc = this.screen.window.createVobScene();
-                   SimpleView sv = new SimpleView(cmp, nodeView);
+                   SimpleView sv = new SimpleView(nodeView);
                    sc.map.put(new SolidBgVob(java.awt.Color.white), 0);
                    sv.render(sc, 0, cursor);
                    return sc;
Index: gzz/lava/gzz/loom/SimpleView.java
diff -u gzz/lava/gzz/loom/SimpleView.java:1.15 
gzz/lava/gzz/loom/SimpleView.java:1.16
--- gzz/lava/gzz/loom/SimpleView.java:1.15      Sun Feb 23 09:15:46 2003
+++ gzz/lava/gzz/loom/SimpleView.java   Sun Feb 23 09:45:14 2003
@@ -44,43 +44,29 @@
  */
 public class SimpleView implements View {
 
-    /** The comparator used to order the nodes in the graph.
-     *  The vertical order of nodes is determined by this Comparator.
-     */
-    protected Comparator cmp;
-    
     /** The view used to show the individual nodes.
      */
     protected NodeView nodeView;
 
-    public SimpleView(Comparator cmp, NodeView nodeView) {
-       this.cmp = cmp;
+    public SimpleView(NodeView nodeView) {
        this.nodeView = nodeView;
     }
 
     public void render(VobScene sc, int into, Cursor c) {
-       try {
-           int midx = sc.size.width/2, midy = sc.size.height/2;
-           int cs = sc.boxCS(into, c.focus, midx-25, midy-10, 50, 20);
-           nodeView.render(sc, cs, c.focus);
-
-           SortedSet nodes = new TreeSet(cmp);
-           StmtIterator i=c.focus.listProperties();
-           for(; i.hasNext();) nodes.add(i.next().getObject());
-           i.close();
-
-           int before = nodes.headSet(c.rotation).size();
-
-           int x = midx + 75, y = midy-10-before*50;
-
-           for(Iterator j=nodes.iterator(); j.hasNext();) {
-               RDFNode node = (RDFNode)j.next();
-               cs = sc.boxCS(into, node, x, y, 50, 20);
-               nodeView.render(sc, cs, node);
-               y += 50;
-           }
-       } catch(RDFException e) {
-           throw new Error("RDFException: "+e);
+       int midx = sc.size.width/2, midy = sc.size.height/2;
+       int cs = sc.boxCS(into, c.focus, midx-25, midy-10, 50, 20);
+       nodeView.render(sc, cs, c.focus);
+       
+       SortedSet nodes = c.getPoswardConnections();
+       int before = nodes.headSet(c.rotation).size();
+       
+       int x = midx + 75, y = midy-10-before*50;
+       
+       for(Iterator j=nodes.iterator(); j.hasNext();) {
+           RDFNode node = (RDFNode)j.next();
+           cs = sc.boxCS(into, node, x, y, 50, 20);
+           nodeView.render(sc, cs, node);
+           y += 50;
        }
     }
 }
Index: gzz/lava/test/gzz/loom/SimpleView.test
diff -u gzz/lava/test/gzz/loom/SimpleView.test:1.11 
gzz/lava/test/gzz/loom/SimpleView.test:1.12
--- gzz/lava/test/gzz/loom/SimpleView.test:1.11 Sun Feb 23 09:15:46 2003
+++ gzz/lava/test/gzz/loom/SimpleView.test      Sun Feb 23 09:45:14 2003
@@ -42,7 +42,7 @@
     def compare(self, r1, r2):
         return [t,r,s,v,u].index(r1) - [t,r,s,v,u].index(r2)
 
-view = gzz.loom.SimpleView(Cmp(), NodeView())
+view = gzz.loom.SimpleView(NodeView())
 
 def testSimple():
     r.addProperty(p, s)
@@ -51,7 +51,7 @@
     r.addProperty(p, v)
 
     vs = getvs()
-    cursor = gzz.loom.Cursor(r, s)
+    cursor = gzz.loom.Cursor(Cmp(), r, s)
     view.render(vs, 0, cursor)
 
     cs_r, cs_s, cs_t, cs_u, cs_v = [vs.matcher.getCS(0, x)




reply via email to

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