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) |
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. |
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); |