|
CubeTwister 2.0alpha142 2012-02-11 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Cube
The interface for objects which represent the state of a Rubik's Cube-like puzzle by describing the orientation and location of its parts.
A cube consists of corner parts, edge parts, side parts and a center part. Each part has an individual location and orientation. Parts can permute their location with other parts of the same type. A corner part can assume three different orientations, an edge part can assume two, a side part four, and the center part can assume 24 orientations.
The parts are arranged in layers. The layers are oriented on the X-, Y- and Z-axis. The number of layers is the same for all axes. The axes have at least two layers and can have up to 32 layers.
Method Summary | |
---|---|
void |
addCubeListener(CubeListener l)
Adds a listener for CubeEvent's. |
java.lang.Object |
clone()
Clones the cube. |
boolean |
equals(java.lang.Object o)
Compares the Cube with another Cube for equality. |
int |
getCornerAt(int location)
Gets the corner part at the specified location. |
int |
getCornerCount()
Returns the number of corner parts. |
int |
getCornerLocation(int corner)
Gets the location of the specified corner part. |
int[] |
getCornerLocations()
Returns the locations of the corner parts. |
int |
getCornerOrientation(int corner)
Gets the orientation of the specified corner part. |
int[] |
getCornerOrientations()
Returns the orientations of the corner parts. |
int |
getCubeOrientation()
Returns the orientation of the whole cube. |
int |
getEdgeAt(int location)
Gets the edge part at the specified location. |
int |
getEdgeCount()
Returns the number of edge parts. |
int |
getEdgeLocation(int edge)
Gets the location of the specified edge part. |
int[] |
getEdgeLocations()
Returns the locations of the edge parts. |
int |
getEdgeOrientation(int edge)
Gets the orientation of the specified edge part. |
int[] |
getEdgeOrientations()
Returns the orientations of the edge parts. |
int |
getLayerCount()
Returns the number of layers on the x, y and z axis. |
int |
getPartAngle(int part,
int orientation)
Returns the angle which is clockwise for the specified part orientation. |
int |
getPartAt(int location)
Returns the location of the specified part. |
int |
getPartAxis(int part,
int orientation)
Returns the current axis on which the orientation of the part lies. |
int |
getPartCount()
Returns the number of cube parts. |
int |
getPartFace(int part,
int orient)
Returns the side at which the indicated orientation of the part is located. |
int |
getPartLayerMask(int part,
int orientation)
Returns the current layer mask on which the orientation of the part lies. |
int |
getPartLocation(int part)
Returns the location of the specified part. |
int |
getPartOrientation(int part)
Returns the orientation of the specified part. |
int |
getPartSwipeAngle(int part,
int orientation,
int swipeDirection)
Returns the angle on which the orientation of the part can be swiped into the specified direction. |
int |
getPartSwipeAxis(int part,
int orientation,
int swipeDirection)
Returns the axis on which the orientation of the part can be swiped into the specified direction. |
int |
getPartSwipeLayerMask(int part,
int orientation,
int swipeDirection)
Returns the layer mask on which the orientation of the part can be swiped into the specified direction. |
int |
getPartType(int part)
Returns the type of the specified part. |
int |
getSideAt(int location)
Gets the side part at the specified location. |
int |
getSideCount()
Returns the number of side parts. |
int |
getSideLocation(int side)
Gets the location of the specified side part. |
int[] |
getSideLocations()
Returns the locations of the side parts. |
int |
getSideOrientation(int side)
Gets the orientation of the specified side part. |
int[] |
getSideOrientations()
Returns the orientations of the side parts. |
int[] |
getUnsolvedParts()
Returns an array of part ID's, for each part in this cube, which is not at its initial location or has not its initial orientation. |
int |
hashCode()
Returns the hash code for the cube. |
boolean |
isSolved()
Returns true if the cube is in its solved state. |
void |
removeCubeListener(CubeListener l)
Removes a listener for CubeEvent's. |
void |
reset()
Resets the cube to its solved state. |
void |
setCorners(int[] locations,
int[] orientations)
Sets the locations and orientations of the corner parts. |
void |
setEdges(int[] locations,
int[] orientations)
Sets the locations and orientations of the edge parts. |
void |
setQuiet(boolean b)
Turns listener notification off. |
void |
setSides(int[] locations,
int[] orientations)
Sets the locations and orientations of the side parts. |
void |
setTo(Cube tx)
Sets the orientations and locations of the parts of this Cube to the same values as in the specified Cube. |
void |
setToStickers(int[][] stickers)
Sets the cube to a state where the faces of the parts map to the provided stickers array. |
int[][] |
toStickers()
Converts the cube into a stickers array reflecting the current permutation of the cube. |
void |
transform(Cube that)
Applies the permutation of the specified cube to this cube and fires a cubeChanged event. |
void |
transform(int axis,
int layerMask,
int angle)
Transforms the cube and fires a cubeTwisted event. |
Method Detail |
---|
void reset()
If the cube was not in its solved state, this method fires a cubeChanged event.
isSolved()
boolean isSolved()
In the solved state of the cube, each part i is at location i and has orientation 0.
void setTo(Cube tx)
If this cube was different from the specified cube, this method fires a cubeChanged event.
tx
- The cube to be set to.
java.lang.IllegalArgumentException
- if the specified cube has not the same
layer count like this cube.void transform(int axis, int layerMask, int angle)
axis
- 0=x, 1=y, 2=z axis.layerMask
- A bitmask specifying the layers to be transformed.
The size of the layer mask depends on the value returned by
getLayerCount(axis)
. For a 3x3x3 cube, the layer mask has the
following meaning:
7=rotate the whole cube;angle
- positive values=clockwise rotationgetLayerCount()
void transform(Cube that)
that
- The cube to be applied to this cube object.
java.lang.IllegalArgumentException
- if the specified cube has not the same
layer count like this cube.getLayerCount()
boolean equals(java.lang.Object o)
Two Cubes are equal, if they have the same number of layers, and if all their parts have the same orientations and locations.
equals
in class java.lang.Object
hashCode()
int hashCode()
hashCode
in class java.lang.Object
equals(java.lang.Object)
void addCubeListener(CubeListener l)
void removeCubeListener(CubeListener l)
void setQuiet(boolean b)
int getLayerCount()
int getCornerCount()
int[] getCornerLocations()
int[] getCornerOrientations()
void setCorners(int[] locations, int[] orientations)
locations
- An array with a permutaton of the numbers 0 through
getCornerCount() - 1.orientations
- An array with only the values 0, 1 and 2. The length
of the array must be getCornerCount().int getCornerAt(int location)
int getCornerLocation(int corner)
int getCornerOrientation(int corner)
int getEdgeCount()
int[] getEdgeLocations()
int[] getEdgeOrientations()
void setEdges(int[] locations, int[] orientations)
locations
- An array with a permutaton of the numbers 0 through
getEdgeCount() - 1.orientations
- An array with only the values 0, and 1. The length
of the array must be getEdgeCount().int getEdgeAt(int location)
int getEdgeLocation(int edge)
int getEdgeOrientation(int edge)
int getSideCount()
int[] getSideLocations()
int[] getSideOrientations()
void setSides(int[] locations, int[] orientations)
locations
- An array with a permutaton of the numbers 0 through
getSideCount() - 1.orientations
- An array with only the values 0, 1, 2, and 3. The length
of the array must be getSideCount().int getSideAt(int location)
int getSideLocation(int side)
int getSideOrientation(int side)
int getPartFace(int part, int orient)
int getPartOrientation(int part)
int getPartLocation(int part)
int getPartAxis(int part, int orientation)
int getPartLayerMask(int part, int orientation)
int getPartAngle(int part, int orientation)
int getPartSwipeAxis(int part, int orientation, int swipeDirection)
part
- The part index.orientation
- The orientation of the part where swiping is performed.swipeDirection
- The direction of the swipe. 0=up,1=right,2=down,4=left.
int getPartSwipeLayerMask(int part, int orientation, int swipeDirection)
part
- The part index.orientation
- The orientation of the part where swiping is performed.swipeDirection
- The direction of the swipe. 0=up,1=right,2=down,4=left.
int getPartSwipeAngle(int part, int orientation, int swipeDirection)
part
- The part index.orientation
- The orientation of the part where swiping is performed.swipeDirection
- The direction of the swipe. 0=up,1=right,2=down,4=left.
int getPartType(int part)
int getPartAt(int location)
int getCubeOrientation()
java.lang.Object clone()
int getPartCount()
int[] getUnsolvedParts()
int[][] toStickers()
setToStickers(int[][])
void setToStickers(int[][] stickers)
stickers
- Sticker array to be reused. The method creates a new
array if this parameter is null.
|
(c) Werner Randelshofer. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |