smithers.java3d
Class Panel3D

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by smithers.java3d.Panel3D
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
Direct Known Subclasses:
TwistyPuzzleViewer

public abstract class Panel3D
extends java.awt.Canvas

Class which draws a 3D object on an AWT Canvas. Objects of this class can have Drawable3D objects added to them, which will then be displayed, and have mouse events dispatched to their registered listeners.
The semantics of mouse events are as follows:
On a press, click or move event the current object is set to the object currently under the cursor, or null if there is no such object. Then the event is dispatched to the listeners registered with the current object if this is not null. Wheel events are always dispatched to the object under the cursor, without setting the current object. Enter and exit events are currently not dispatched to any of the objects on the panel.
If the event is not consumed, it is then dispatched to the listeners registered with the panel. This includes a listener specified by the panel itself, which rotates the view when the cursor is dragged.

See Also:
Serialized Form

Nested Class Summary
static class Panel3D.DrawablePolygon
          A simple drawable object which draws and fills a Polygon3D.
 
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
Panel3D(float size)
          Creates a new Panel3D object with the specified size.
 
Method Summary
 void add(Drawable3D d)
           
 void paint(java.awt.Graphics g)
           
protected  void processMouseEvent(java.awt.event.MouseEvent e)
           
protected  void processMouseMotionEvent(java.awt.event.MouseEvent e)
           
protected  void processMouseWheelEvent(java.awt.event.MouseWheelEvent e)
           
 void remove(Drawable3D d)
           
 void rotateView(float a, float b, float c)
           
 void setBackground(java.awt.Color c)
           
 void update(java.awt.Graphics g)
           
 
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, 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

Panel3D

public Panel3D(float size)
Creates a new Panel3D object with the specified size.

Parameters:
size - the object's size
Method Detail

add

public void add(Drawable3D d)

remove

public void remove(Drawable3D d)

setBackground

public void setBackground(java.awt.Color c)
Overrides:
setBackground in class java.awt.Component

rotateView

public void rotateView(float a,
                       float b,
                       float c)

update

public void update(java.awt.Graphics g)
Overrides:
update in class java.awt.Canvas

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class java.awt.Canvas

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent e)
Overrides:
processMouseEvent in class java.awt.Component

processMouseMotionEvent

protected void processMouseMotionEvent(java.awt.event.MouseEvent e)
Overrides:
processMouseMotionEvent in class java.awt.Component

processMouseWheelEvent

protected void processMouseWheelEvent(java.awt.event.MouseWheelEvent e)
Overrides:
processMouseWheelEvent in class java.awt.Component