[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/lava gzz/loom/Cursor.java gzz/loom/SimpleVi...
From: |
Benja Fallenstein |
Subject: |
[Gzz-commits] gzz/lava gzz/loom/Cursor.java gzz/loom/SimpleVi... |
Date: |
Sun, 23 Feb 2003 14:44:25 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Benja Fallenstein <address@hidden> 03/02/23 14:44:25
Modified files:
lava/gzz/loom : Cursor.java SimpleView.java
lava/test/gzz/loom: Cursor.test
Log message:
refactor
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/loom/Cursor.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/loom/SimpleView.java.diff?tr1=1.19&tr2=1.20&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/loom/Cursor.test.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
Patches:
Index: gzz/lava/gzz/loom/Cursor.java
diff -u gzz/lava/gzz/loom/Cursor.java:1.4 gzz/lava/gzz/loom/Cursor.java:1.5
--- gzz/lava/gzz/loom/Cursor.java:1.4 Sun Feb 23 11:50:27 2003
+++ gzz/lava/gzz/loom/Cursor.java Sun Feb 23 14:44:24 2003
@@ -57,31 +57,24 @@
this.rotation = rotation;
}
- /** The posward connections of <code>focus</code> to show,
- * in order. XXX refactor-- we need negward connections
- * and recursion...
+ /** The posward or negward connections of <code>focus</code> to show,
+ * in order. XXX refactor-- we need only a subset of all properties,
+ * and recursion... currently slow because we iterate though
+ * ALL triples in the graph.
*/
- 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);
- }
- }
-
- public SortedSet getNegwardConnections() {
+ public SortedSet getConnections(int dir) {
try {
SortedSet nodes = new TreeSet(order);
StmtIterator i = focus.getModel().listStatements();
for(; i.hasNext();) {
Statement stmt = i.next();
- if(stmt.getObject().equals(focus))
- nodes.add(stmt.getSubject());
+ if(dir < 0) {
+ if(stmt.getObject().equals(focus))
+ nodes.add(stmt.getSubject());
+ } else {
+ if(stmt.getSubject().equals(focus))
+ nodes.add(stmt.getObject());
+ }
}
i.close();
@@ -95,7 +88,7 @@
* This moves the rotation of the cursor one step up or down. XXX
*/
public void rotate(int dir) {
- SortedSet s = getPoswardConnections();
+ SortedSet s = getConnections(1);
if(dir < 0) {
try {
rotation = (RDFNode)s.headSet(rotation).last();
@@ -114,11 +107,11 @@
public void move(int dir) {
if(dir < 0) {
rotation = focus;
- focus = (Resource)getNegwardConnections().first();
+ focus = (Resource)getConnections(-1).first();
} else {
focus = (Resource)rotation;
try {
- rotation = (RDFNode)getPoswardConnections().first();
+ rotation = (RDFNode)getConnections(1).first();
} catch(NoSuchElementException _) {
rotation = null;
}
Index: gzz/lava/gzz/loom/SimpleView.java
diff -u gzz/lava/gzz/loom/SimpleView.java:1.19
gzz/lava/gzz/loom/SimpleView.java:1.20
--- gzz/lava/gzz/loom/SimpleView.java:1.19 Sun Feb 23 11:50:27 2003
+++ gzz/lava/gzz/loom/SimpleView.java Sun Feb 23 14:44:24 2003
@@ -59,7 +59,7 @@
int cs = sc.orthoBoxCS(into, c.focus, 0, midx-25, midy-10, 1, 1, 50,
20);
nodeView.render(sc, cs, c.focus);
- SortedSet nodes = c.getPoswardConnections();
+ SortedSet nodes = c.getConnections(1);
int before;
if(c.rotation != null)
Index: gzz/lava/test/gzz/loom/Cursor.test
diff -u gzz/lava/test/gzz/loom/Cursor.test:1.2
gzz/lava/test/gzz/loom/Cursor.test:1.3
--- gzz/lava/test/gzz/loom/Cursor.test:1.2 Sun Feb 23 11:50:27 2003
+++ gzz/lava/test/gzz/loom/Cursor.test Sun Feb 23 14:44:24 2003
@@ -44,15 +44,24 @@
return l
-def testGetPoswardConnections():
+def testGetConnections():
+ n[6].addProperty(p, n[1])
+
c.set(n[0], n[1])
- assert list(c.getPoswardConnections()) == [n[1]]
+ assert list(c.getConnections(1)) == [n[1]]
+ assert list(c.getConnections(-1)) == []
c.set(n[1], n[2])
- assert list(c.getPoswardConnections()) == [n[2]]
+ assert list(c.getConnections(1)) == [n[2]]
+ assert list(c.getConnections(-1)) == [n[0], n[6]]
c.set(n[2], n[3])
- assert list(c.getPoswardConnections()) == n[3:]
+ assert list(c.getConnections(1)) == n[3:]
+ assert list(c.getConnections(-1)) == [n[1]]
+
+ c.set(n[6], n[1])
+ assert list(c.getConnections(1)) == [n[1]]
+ assert list(c.getConnections(-1)) == [n[2]]
def testRotateMove():
- [Gzz-commits] gzz/lava gzz/loom/Cursor.java gzz/loom/SimpleVi...,
Benja Fallenstein <=