Spirograph
Class DotPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--Spirograph.DotPanel

public class DotPanel
extends java.awt.Canvas
implements java.lang.Runnable

This class keeps track of the coordinates of the Dot. It has a seperate Thread to update the "state" of the two coordinates and to repaint itself. It also handles the dot bouncing off either the walls of the square or the circle. It also keeps track of all of the gravity points and all of the places where the dot has been before and draw them in.

Copyright (C) 1998 Massachusetts Institute of Technology.

See Also:
Coord, Spirograph, AccelHandler, Serialized Form

Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
DotPanel(Coord x, Coord y)
           
 
Method Summary
 void addGrav(int x, int y)
           
 int curHeight()
           
 int curWidth()
           
 void flushGrav()
           
 void flushLines()
           
 boolean getBounce()
           
 boolean getCirc()
           
 double getMaxX()
           
 double getMaxY()
           
 java.awt.Dimension getMinimumSize()
           
 java.awt.Dimension getPreferredSize()
           
 boolean getWrap()
           
 boolean inEllipse()
          This is called by the AdvArg to see whether or not the ball is in the circle.
 void paint(java.awt.Graphics out)
           
 void paintBuf()
          This method paints an off-screen image to be used for the double buffering. It adds the balls current position to the vector of Points, then reconstructs the balls path from the Points.
 void run()
           
 void setBounce(boolean bounceOn)
           
 void setCirc(boolean circMode)
           
 void setMode(int mode)
           
 void setSize(int width, int height)
          Called by the DotFrame whenever the DotFrame is resized
 void setWrap(boolean wrapOn)
           
 
Methods inherited from class java.awt.Canvas
addNotify
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, 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, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DotPanel

public DotPanel(Coord x,
                Coord y)
Method Detail

setMode

public void setMode(int mode)

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class java.awt.Component

getMinimumSize

public java.awt.Dimension getMinimumSize()
Overrides:
getMinimumSize in class java.awt.Component

getMaxX

public double getMaxX()

getMaxY

public double getMaxY()

run

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

inEllipse

public boolean inEllipse()
This is called by the AdvArg to see whether or not the ball is in the circle. If the ball isn't inside the circle, AdvArg won't turn on circle mode.

paintBuf

public void paintBuf()
This method paints an off-screen image to be used for the double buffering.

It adds the balls current position to the vector of Points, then reconstructs the balls path from the Points.


paint

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

setSize

public void setSize(int width,
                    int height)
Called by the DotFrame whenever the DotFrame is resized
Overrides:
setSize in class java.awt.Component

flushLines

public void flushLines()

flushGrav

public void flushGrav()

addGrav

public void addGrav(int x,
                    int y)

setCirc

public void setCirc(boolean circMode)

getCirc

public boolean getCirc()

curHeight

public int curHeight()

curWidth

public int curWidth()

getBounce

public boolean getBounce()

setBounce

public void setBounce(boolean bounceOn)

getWrap

public boolean getWrap()

setWrap

public void setWrap(boolean wrapOn)