private void moveNode(final CheckedTreeNode toolNode, Direction dir) {
   CheckedTreeNode parentNode = (CheckedTreeNode) toolNode.getParent();
   int index = parentNode.getIndex(toolNode);
   removeNodeFromParent(toolNode);
   int newIndex = dir.newIndex(index);
   parentNode.insert(toolNode, newIndex);
   getModel().nodesWereInserted(parentNode, new int[] {newIndex});
 }
Exemplo n.º 2
0
 private void movePiecesTowards(
     Map<Position, Piece> pieceMap, Position startPos, Direction direction)
     throws InvalidMoveException {
   int delta = direction.getDeltaPos();
   try {
     movePiece(pieceMap, startPos, delta);
   } catch (Exception e) {
     throw new InvalidMoveException();
   }
 }
 private boolean isMovingAvailable(final CheckedTreeNode toolNode, Direction dir) {
   TreeNode parent = toolNode.getParent();
   int index = parent.getIndex(toolNode);
   return dir.isAvailable(index, parent.getChildCount());
 }