smithers.twisty
Class TwistyPuzzleViewer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by smithers.java3d.Panel3D
              extended by smithers.twisty.TwistyPuzzleViewer
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, java.util.EventListener, javax.accessibility.Accessible

public class TwistyPuzzleViewer
extends Panel3D
implements java.awt.event.MouseListener, java.awt.event.KeyListener, java.lang.Runnable

Displays a TwistyPuzzle and allows the user to manipulate it. If the puzzle is an AnimatedTwistyPuzzle then moves the user applies may be animated over a specified length of time.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class smithers.java3d.Panel3D
Panel3D.DrawablePolygon
 
Nested classes/interfaces inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TwistyPuzzleViewer(AnimatedTwistyPuzzle puzzle, double aniTime)
          Constructs a new TwistyPuzzleViewer with an animated puzzle.
TwistyPuzzleViewer(RubiksCube puzzle, double aniTime, java.lang.String imageName, boolean demo)
          Constructs a new TwistyPuzzleViewer with a Rubik's cube.
TwistyPuzzleViewer(TwistyPuzzle puzzle)
          Constructs a new TwistyPuzzleViewer with the specified puzzle.
 
Method Summary
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
static void main(java.lang.String[] args)
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void repaint()
           
 void run()
           
 void start()
           
 
Methods inherited from class smithers.java3d.Panel3D
add, paint, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, rotateView, setBackground, update
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TwistyPuzzleViewer

public TwistyPuzzleViewer(TwistyPuzzle puzzle)
Constructs a new TwistyPuzzleViewer with the specified puzzle. This viewer will display the given puzzle and allow the user to manipulate it.

Parameters:
puzzle - the puzzle to display and manipulate

TwistyPuzzleViewer

public TwistyPuzzleViewer(AnimatedTwistyPuzzle puzzle,
                          double aniTime)
Constructs a new TwistyPuzzleViewer with an animated puzzle. This viewer will display the given puzzle and allow the user to manipulate it. If aniTime is nonzero, then moves will be animated over the given length of time.

Parameters:
puzzle - the puzzle to display and manipulate
aniTime - the time to take to animate each move, if the puzzle can be animated

TwistyPuzzleViewer

public TwistyPuzzleViewer(RubiksCube puzzle,
                          double aniTime,
                          java.lang.String imageName,
                          boolean demo)
Constructs a new TwistyPuzzleViewer with a Rubik's cube. This viewer will display the given puzzle and allow the user to manipulate it. If aniTime is nonzero, then moves will be animated over the given length of time. If demo is true, the puzzle will manipulate itself at random.

Parameters:
puzzle - the puzzle to display and manipulate
aniTime - the time to take to animate each move, if the puzzle can be animated
imageName - the image file to load sticker images from, or null
demo - whether to demonstrate the puzzle moving on its own
Method Detail

start

public void start()

run

public void run()
Specified by:
run in interface java.lang.Runnable

repaint

public void repaint()
Overrides:
repaint in class java.awt.Component

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

main

public static void main(java.lang.String[] args)