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});
 }
예제 #2
0
파일: Game.java 프로젝트: FransM22/GipfGame
 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());
 }