/[gzz]/gzz/lava/gzz/loom/Cursor.java
ViewVC logotype

Diff of /gzz/lava/gzz/loom/Cursor.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by benja, Sun Feb 23 16:50:27 2003 UTC revision 1.5 by benja, Sun Feb 23 19:44:24 2003 UTC
# Line 57  public class Cursor { Line 57  public class Cursor {
57          this.rotation = rotation;          this.rotation = rotation;
58      }      }
59    
60      /** The posward connections of <code>focus</code> to show,      /** The posward or negward connections of <code>focus</code> to show,
61       *  in order. XXX refactor-- we need negward connections       *  in order. XXX refactor-- we need only a subset of all properties,
62       *  and recursion...       *  and recursion... currently slow because we iterate though
63         *  ALL triples in the graph.
64       */       */
65      public SortedSet getPoswardConnections() {      public SortedSet getConnections(int dir) {
         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() {  
66          try {          try {
67              SortedSet nodes = new TreeSet(order);              SortedSet nodes = new TreeSet(order);
68              StmtIterator i = focus.getModel().listStatements();              StmtIterator i = focus.getModel().listStatements();
69              for(; i.hasNext();) {              for(; i.hasNext();) {
70                  Statement stmt = i.next();                  Statement stmt = i.next();
71                  if(stmt.getObject().equals(focus))                  if(dir < 0) {
72                      nodes.add(stmt.getSubject());                                        if(stmt.getObject().equals(focus))
73                            nodes.add(stmt.getSubject());
74                    } else {
75                        if(stmt.getSubject().equals(focus))
76                            nodes.add(stmt.getObject());
77                    }
78              }              }
79              i.close();              i.close();
80    
# Line 95  public class Cursor { Line 88  public class Cursor {
88       *  This moves the rotation of the cursor one step up or down. XXX       *  This moves the rotation of the cursor one step up or down. XXX
89       */       */
90      public void rotate(int dir) {      public void rotate(int dir) {
91          SortedSet s = getPoswardConnections();          SortedSet s = getConnections(1);
92          if(dir < 0) {          if(dir < 0) {
93              try {              try {
94                  rotation = (RDFNode)s.headSet(rotation).last();                  rotation = (RDFNode)s.headSet(rotation).last();
# Line 114  public class Cursor { Line 107  public class Cursor {
107      public void move(int dir) {      public void move(int dir) {
108          if(dir < 0) {          if(dir < 0) {
109              rotation = focus;              rotation = focus;
110              focus = (Resource)getNegwardConnections().first();              focus = (Resource)getConnections(-1).first();
111          } else {          } else {
112              focus = (Resource)rotation;              focus = (Resource)rotation;
113              try {              try {
114                  rotation = (RDFNode)getPoswardConnections().first();                  rotation = (RDFNode)getConnections(1).first();
115              } catch(NoSuchElementException _) {              } catch(NoSuchElementException _) {
116                  rotation = null;                  rotation = null;
117              }              }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26