CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.rubik.parser
Class ConjugationNode

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

public class ConjugationNode
extends Node

A ConjugationNode holds a conjugator A and a single child B. The side effect of a conjugation node is A B A'.

Version:
2.0 2005-01-31 Reworked.
1.1 2002-08-12 Fixed a problem where conjugator (X Y) with child B was resolved into X Y B X' Y' instead of X Y B Y' X'.
1.0 2001-07-25
Author:
Werner Randelshofer, Hausmatt 10, Immensee, CH-6405, Switzerland
See Also:
ScriptParser, 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
ConjugationNode(int layerCount)
           
ConjugationNode(int layerCount, int startpos, int endpos)
           
ConjugationNode(int layerCount, Node conjugator, Node conjugate, int startpos, int endpos)
           
 
Method Summary
 void applyTo(Cube cube, boolean inverse)
          Applies the symbol represented by this node to the cube.
 Node cloneSubtree()
          Returns a deep clone of the subtree starting at this node.
 int getBlockTurnCount()
          Gets the block turn count of the subtree starting at this node.
 Node getConjugator()
           
 int getFaceTurnCount()
          Gets the face turn count of the subtree starting at this node.
 int getLayerTurnCount()
          Gets the layer turn count of the subtree starting at this node.
 int getQuarterTurnCount()
          Gets the quarter turn count of the subtree starting at this node.
 void inverse()
          Inverses the subtree starting at this node.
 void overwritePositions(int sp, int ep)
          Overwrite start and end positions of this node and the subtree starting at this node.
 void reflect()
          Reflect the subtree starting at this node.
 java.util.Enumeration resolvedEnumeration(boolean inverse)
          Enumerate this symbol and all of its children.
 void setConjugator(Node newValue)
           
 java.util.List toResolvedList()
           
 void transform(int axis, int layerMask, int angle)
          Transformes the subtree starting at this node by the given ScriptParser.symbol constant.
 void writeTokens(java.io.PrintWriter w, Notation p, java.util.Map<java.lang.String,MacroNode> macroMap)
          Writes the token(s) represented by the subtree starting at this node.
 
Methods inherited from class ch.randelshofer.rubik.parser.Node
dumpTree, enumerateChildrenReversed, getChildAt, getChildren, getEndPosition, getStartPosition, getSymbol, setEndPosition, setStartPosition, toString, toString, toString, transform, 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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConjugationNode

public ConjugationNode(int layerCount)

ConjugationNode

public ConjugationNode(int layerCount,
                       int startpos,
                       int endpos)

ConjugationNode

public ConjugationNode(int layerCount,
                       Node conjugator,
                       Node conjugate,
                       int startpos,
                       int endpos)
Method Detail

overwritePositions

public void overwritePositions(int sp,
                               int ep)
Overwrite start and end positions of this node and the subtree starting at this node.

Overrides:
overwritePositions in class Node

getConjugator

public Node getConjugator()

setConjugator

public void setConjugator(Node newValue)

applyTo

public void applyTo(Cube cube,
                    boolean inverse)
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.

inverse

public void inverse()
Inverses the subtree starting at this node.

Overrides:
inverse in class Node

reflect

public void reflect()
Reflect the subtree starting at this node.

Overrides:
reflect in class Node

transform

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

Overrides:
transform in class Node

cloneSubtree

public Node cloneSubtree()
Returns a deep clone of the subtree starting at this node.

Overrides:
cloneSubtree in class Node

getLayerTurnCount

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

Overrides:
getLayerTurnCount in class Node

getBlockTurnCount

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

Overrides:
getBlockTurnCount in class Node

getFaceTurnCount

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

Overrides:
getFaceTurnCount in class Node

getQuarterTurnCount

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

Overrides:
getQuarterTurnCount in class Node

resolvedEnumeration

public java.util.Enumeration resolvedEnumeration(boolean inverse)
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:
inverse - Set to true if you wish to get an inverted enumeration.

writeTokens

public void writeTokens(java.io.PrintWriter w,
                        Notation p,
                        java.util.Map<java.lang.String,MacroNode> macroMap)
                 throws java.io.IOException
Description copied from class: Node
Writes the token(s) represented by the subtree starting at this node. The syntax and the string representations of the tokens are provided by the parser.

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

toResolvedList

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

(c) Werner Randelshofer.
All rights reserved.