/[fenfire]/fenfire/org/fenfire/loom/Cursor.java
ViewVC logotype

Diff of /fenfire/org/fenfire/loom/Cursor.java

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

revision 1.6 by benja, Fri Mar 7 20:48:08 2003 UTC revision 1.7 by benja, Fri Mar 7 21:03:43 2003 UTC
# Line 161  public class Cursor { Line 161  public class Cursor {
161          return s;          return s;
162      }      }
163    
164        public int getConnectionCount() {
165            int negn = getConnections(-1).size();
166            int posn = getConnections(1).size();
167    
168            return (negn>posn) ? negn : posn;
169        }
170    
171      /** Rotate the view up or down.      /** Rotate the view up or down.
172       *  This moves the rotation of the cursor up or down.       *  This moves the rotation of the cursor up or down.
173       */       */
174      public void rotate(int dir) {            public void rotate(int dir) {      
175          SortedSet          int n = getConnectionCount();
             neg = getConnections(-1),  
             pos = getConnections(1);  
   
         int negn = neg.size();  
         int posn = pos.size();  
   
         int n = (negn>posn) ? negn : posn;  
   
176          int abs = (n-1)/2 + rotation + dir;          int abs = (n-1)/2 + rotation + dir;
177    
178          if(abs<0 || abs>=n)          if(abs<0 || abs>=n)
# Line 192  public class Cursor { Line 191  public class Cursor {
191       */       */
192      public int getRotationIndex(int dir) {      public int getRotationIndex(int dir) {
193          int n = getConnections(dir).size();          int n = getConnections(dir).size();
194          int abs = (n-1)/2 + rotation;          return getMiddle(n) + rotation;
         return abs;  
195      }      }
196    
197      protected Statement getRotationStmt(int dir) {      protected Statement getRotationStmt(int dir) {
198          Iterator iter = getConnections(dir).iterator();          List l = new ArrayList(getConnections(dir));
199          int n = getRotationIndex(dir);          try {
200          if(n < 0)              return (Statement)l.get(getRotationIndex(dir));
201              // nothing there          } catch(IndexOutOfBoundsException _) {
202              return null;              return null;
203          for(int i=0; i<n; i++) if(iter.hasNext()) iter.next();          }
         if(!iter.hasNext())  
             // nothing there  
             return null;  
   
         return (Statement)iter.next();  
204      }      }
205    
206      /** Get the selected node in the given direction.      /** Get the selected node in the given direction.
# Line 239  public class Cursor { Line 232  public class Cursor {
232                                           stmt.getPredicate(), 1);                                           stmt.getPredicate(), 1);
233      }      }
234    
235      /** Move left/right. XXX      /** Move left/right. Focuses the node currently selected
236         *  in the given direction. The rotation is set so that
237         *  the old focus becomes selected.
238       */       */
239      public void move(int dir) {      public void move(int dir) {
240          RDFNode node = getRotationNode(dir);          RDFNode node = getRotationNode(dir);

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

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