CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.rubik.parser
Class MoveNode

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by ch.randelshofer.rubik.parser.Node
          extended by ch.randelshofer.rubik.parser.MoveNode
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode

public class MoveNode
extends Node

A MoveNode holds one rotation of one or multiple layers in a specific direction by a specific angle. The side effect of a MoveNode on a Cube is the concatenation of all permutation cycles caused by the rotation.

Version:
6.2 2012-02-08 Fixes quarter turn count for angle values > +/-3.
6.0.1 2008-01-18 Fixed face turn countTurned for 3x3 cube.
6.0 2007-06-16 Renamed from TwistNode to MoveNode.
5.0 2005-01-31 Reworked.
Author:
werni
See Also:
Serialized Form

Field Summary
 
Fields inherited from class ch.randelshofer.rubik.parser.Node
endpos, layerCount, startpos, symbol
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
MoveNode(int layerCount)
          Creates new MoveNode
MoveNode(int layerCount, int axis, int layerMask, int angle, int startpos, int endpos)
          Creates new MoveNode
MoveNode(int layerCount, Move t)
           
 
Method Summary
 void applyTo(Cube cube, boolean inverse)
          Applies the symbol represented by this node to the cube.
 boolean equals(java.lang.Object o)
           
 int getAngle()
           
 int getAxis()
           
 int getBlockTurnCount()
          Gets the block turn countTurned of the subtree starting at this node.
 int getFaceTurnCount()
          Gets the face turn countTurned of the subtree starting at this node.
 int getLayerCount()
           
 int getLayerMask()
           
 int getLayerTurnCount()
          Gets the layer turn countTurned of the subtree starting at this node.
 int getQuarterTurnCount()
          Gets the quarter turn countTurned of the subtree starting at this node.
 int hashCode()
           
 void inverse()
          Inverses the node.
 boolean isRotation()
           
 void reflect()
          Reflects the node.
 java.util.Enumeration resolvedEnumeration(boolean isInverse)
          Enumerate this symbol and all of its children.
 void setAngle(int newValue)
           
 void setAxis(int newValue)
           
 void setLayerCount(int newValue)
           
 void setLayerMask(int newValue)
           
 void setTo(MoveNode that)
           
 java.util.List toResolvedList()
           
 java.lang.String toString()
          Returns a string representation of this node.
 void transform(int axis, int layerMask, int angle)
          Transformes the node by the given ScriptParser.symbol constant.
 void transform(MoveNode move, boolean inverse)
           
 void writeTokens(java.io.PrintWriter w, Notation notation, java.util.Map<java.lang.String,MacroNode> macroMap)
          Returns a string representation of this node using the specified notation.
 
Methods inherited from class ch.randelshofer.rubik.parser.Node
cloneSubtree, dumpTree, enumerateChildrenReversed, getChildAt, getChildren, getEndPosition, getStartPosition, getSymbol, overwritePositions, setEndPosition, setStartPosition, toString, toString, transformOrientation
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MoveNode

public MoveNode(int layerCount)
Creates new MoveNode


MoveNode

public MoveNode(int layerCount,
                Move t)

MoveNode

public MoveNode(int layerCount,
                int axis,
                int layerMask,
                int angle,
                int startpos,
                int endpos)
Creates new MoveNode

Method Detail

applyTo

public void applyTo(Cube cube,
                    boolean inverse)
Description copied from class: Node
Applies the symbol represented by this node to the cube.

Overrides:
applyTo in class Node
Parameters:
cube - A cube to be transformed by this symbol.
inverse - If true, the transform will be done in inverse order.

getAxis

public int getAxis()

getLayerMask

public int getLayerMask()

getAngle

public int getAngle()

setAxis

public void setAxis(int newValue)

setLayerMask

public void setLayerMask(int newValue)

setAngle

public void setAngle(int newValue)

getLayerCount

public int getLayerCount()

setLayerCount

public void setLayerCount(int newValue)

getLayerTurnCount

public int getLayerTurnCount()
Gets the layer turn countTurned of the subtree starting at this node.

Overrides:
getLayerTurnCount in class Node

getBlockTurnCount

public int getBlockTurnCount()
Gets the block turn countTurned of the subtree starting at this node.

Overrides:
getBlockTurnCount in class Node

getFaceTurnCount

public int getFaceTurnCount()
Gets the face turn countTurned of the subtree starting at this node.

Overrides:
getFaceTurnCount in class Node

getQuarterTurnCount

public int getQuarterTurnCount()
Gets the quarter turn countTurned of the subtree starting at this node.

Overrides:
getQuarterTurnCount in class Node

resolvedEnumeration

public java.util.Enumeration resolvedEnumeration(boolean isInverse)
Enumerate this symbol and all of its children. Special operators (i. e. repeat and inverse) are resolved before the children are returned.

Overrides:
resolvedEnumeration in class Node
Parameters:
isInverse - Set to true if you wish to get an inverted enumeration.

transform

public void transform(int axis,
                      int layerMask,
                      int angle)
Transformes the node by the given ScriptParser.symbol constant. Does nothing if the transformation can not be done.

Overrides:
transform in class Node

transform

public void transform(MoveNode move,
                      boolean inverse)
Overrides:
transform in class Node

inverse

public void inverse()
Inverses the node.

Overrides:
inverse in class Node

reflect

public void reflect()
Reflects the node.

Overrides:
reflect in class Node

setTo

public void setTo(MoveNode that)

isRotation

public boolean isRotation()

toString

public java.lang.String toString()
Description copied from class: Node
Returns a string representation of this node. Use for debugging only.

Overrides:
toString in class Node

writeTokens

public void writeTokens(java.io.PrintWriter w,
                        Notation notation,
                        java.util.Map<java.lang.String,MacroNode> macroMap)
                 throws java.io.IOException
Returns a string representation of this node using the specified notation.

Overrides:
writeTokens in class Node
Parameters:
w - This is where the tokens are written to.
notation - The notation which provides the tokens.
macroMap - Local macros which are preserved by the translation.
Throws:
java.io.IOException

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

toResolvedList

public java.util.List toResolvedList()
Overrides:
toResolvedList in class Node

(c) Werner Randelshofer.
All rights reserved.