|
Spirograph Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Canvas
spirograph.DotPanel
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 draws the trail.
Copyright © 1998 Massachusetts Institute of Technology.
Copyright © 2002-2003 Franklin W. Olin College of Engineering.
Coord
,
Spirograph
,
AccelHandler
,
Serialized FormNested Class Summary |
Nested classes inherited from class java.awt.Canvas |
java.awt.Canvas.AccessibleAWTCanvas |
Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, 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 | |
DotPanel(Coord x,
Coord y)
Create a new dot panel that displays a dot by poling two Coord objects. |
Method Summary | |
void |
addGrav(int x,
int y)
Place a gravity source at the coordinates specified. |
int |
curHeight()
Deprecated. This method and the associated shadow variable violate the DRY (Do not Repeat Yourself) principle. The only visible benefit is a slightly reduced typing. With modern compilers this won't even yield a performance increase because the getWidth or getHeight methods will be inlined. The Sun code for these methods in Component
is:
public int getWidth() {
return width;
}
For this reason, this method and the associated variables will be removed. |
int |
curWidth()
Deprecated. This method and the associated shadow variable violate the DRY (Do not Repeat Yourself) principle. The only visible benefit is a slightly reduced typing. With modern compilers this won't even yield a performance increase because the getWidth or getHeight methods will be inlined. The Sun code for these methods in Component
is:
public int getWidth() {
return width;
}
For this reason, this method and the associated variable will be removed. |
void |
flushGrav()
Delete all gravity sources, and repaint. |
void |
flushLines()
Delete the trail of the dot. |
boolean |
getBounce()
Query the state of bounce mode. |
boolean |
getCirc()
Query the state of circular mode. |
double |
getMaxX()
The maximum distance from the center of the drawing area that the ball can be placed in the X direction. |
double |
getMaxY()
The maximum distance from the center of the drawing area that the ball can be placed in the X direction. |
java.awt.Dimension |
getMinimumSize()
Overide the parent class to return the prefered size as the minimum size. |
java.awt.Dimension |
getPreferredSize()
Overides the superclass to return our constants. |
boolean |
getWrap()
Query the state of wrap mode. |
boolean |
inEllipse()
Convenience wrapper for SpiroUtils.inEllipse(double, double, double, double) . |
void |
paint(java.awt.Graphics out)
Overide the superclass paint method, to do our own drawing. |
void |
paintBuf()
This method paints an off-screen image to be used for the double buffering. |
void |
run()
Conducts the drawing of all objects in the DotPanel. |
void |
setBounce(boolean bounceOn)
Turn bounce mode on or off. |
void |
setCirc(boolean circMode)
Turn circular mode on or off. |
void |
setMode(int mode)
Set the operational mode for both coordinate axis. |
void |
setSize(int width,
int height)
Recalculate the foci and repaint of the elipse before calling the super.setSize(). |
void |
setWrap(boolean wrapOn)
Turn wrap mode on or off. |
Methods inherited from class java.awt.Canvas |
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, update |
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, getAlignmentX, getAlignmentY, getBackground, 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, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, 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, 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, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, 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 |
public DotPanel(Coord x, Coord y)
Coord
objects.
x
- Defines the position and movement atributes along the x axisy
- Defines the position and movement atributes along the y axisMethod Detail |
public void setMode(int mode)
mode
- AccelHandler.POSMODE
, AccelHandler.VELMODE
,
or AccelHandler.ACCELMODE
public java.awt.Dimension getPreferredSize()
Spirograph.WIDTH
,Spirograph.HEIGHT
)public java.awt.Dimension getMinimumSize()
getPreferredSize()
public double getMaxX()
public double getMaxY()
public void run()
run
in interface java.lang.Runnable
public boolean inEllipse()
SpiroUtils.inEllipse(double, double, double, double)
. 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.
public void paintBuf()
It adds the balls current position to the vector of Points, then reconstructs the balls path from the Points.
public void paint(java.awt.Graphics out)
out
- The Graphics
object for this component.public void setSize(int width, int height)
width
- The new widthheight
- The new heightpublic void flushLines()
Vector
. The position of the dot
is uneffected, and the panel is repainted.
public void flushGrav()
public void addGrav(int x, int y)
MouseListener
that has been added to the DotPanel.
x
- The horizontal coordinate for the gravity source.y
- The vertical coordinate for the gravity source.public void setCirc(boolean circMode)
circMode
- true
to turn circular mode on, false
to turn it offpublic boolean getCirc()
public int curHeight()
Component
is:
public int getWidth() {
return width;
}
For this reason, this method and the associated variables will be removed.
public int curWidth()
Component
is:
public int getWidth() {
return width;
}
For this reason, this method and the associated variable will be removed.
public boolean getBounce()
public void setBounce(boolean bounceOn)
bounceOn
- true
to turn bounce mode on, false
to turn it offpublic boolean getWrap()
public void setWrap(boolean wrapOn)
wrapOn
- true
to turn wrap mode on, false
to turn it off
|
Spirograph Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |