Ball World Problem Set Javadocs

ballworld
Class BallWorld

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byballworld.BallWorld
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.lang.Runnable, java.io.Serializable, World

public class BallWorld
extends javax.swing.JComponent
implements World, java.lang.Runnable

Provide a canvas with a grassy backround to draw balls on.

Author:
Patrick G. Heck, gus.heck@olin.edu
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
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 javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
BallWorld()
          Creates a new instance of BallWorld
 
Method Summary
 void addBall(Ball aNewBall)
          Add a ball to the world
 void addBallRenderer(BallRenderer rend)
          Add a ball to the canvas for rendering.
 Ball getClosestBall(Ball myBall)
          returns the Ball object that is closest to myBall (not including myBall).
 double getGUIMaxX()
          Get the maximum X coordinate in GUI numbers.
 double getGUIMaxY()
          Get the maximum Y coordinate in GUI numbers.
 double getMaxX()
          return the maximum visible X value of the world
 double getMaxY()
          return the maximum visible Y value of the world
 double getMinX()
          Get minimum visible X value of the world.
 double getMinY()
          return the minimum visible Y value of the world
 void paint(java.awt.Graphics g)
          Draws the grass and all the balls.
 void removeBall(Ball toBeRemoved)
          Remove a ball from the world
 void removeBallRenderer(BallRenderer rend)
          Remove ball from the canvas.
 void run()
           
 void stop()
          Stop automatic repainting.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BallWorld

public BallWorld()
Creates a new instance of BallWorld

Method Detail

paint

public void paint(java.awt.Graphics g)
Draws the grass and all the balls.

Parameters:
g - a graphics context to draw in

addBallRenderer

public void addBallRenderer(BallRenderer rend)
Add a ball to the canvas for rendering.

Parameters:
rend - A renderer that should be added.

removeBallRenderer

public void removeBallRenderer(BallRenderer rend)
Remove ball from the canvas.

Parameters:
rend - A renderer that should be added.

addBall

public void addBall(Ball aNewBall)
Description copied from interface: World
Add a ball to the world

Specified by:
addBall in interface World
Parameters:
aNewBall - The ball to add

getClosestBall

public Ball getClosestBall(Ball myBall)
Description copied from interface: World
returns the Ball object that is closest to myBall (not including myBall). Be careful! If there is only one ball on the screen, then this method will return null

Specified by:
getClosestBall in interface World
Parameters:
myBall - The ball to find neighbors for
Returns:
The nearest ball if there is one, null otherwise

getMaxX

public double getMaxX()
Description copied from interface: World
return the maximum visible X value of the world

Specified by:
getMaxX in interface World
Returns:
The maximum x coordinate

getMaxY

public double getMaxY()
Description copied from interface: World
return the maximum visible Y value of the world

Specified by:
getMaxY in interface World
Returns:
The maximum y coordinate

getGUIMaxX

public double getGUIMaxX()
Get the maximum X coordinate in GUI numbers.

Returns:
the width of the component

getGUIMaxY

public double getGUIMaxY()
Get the maximum Y coordinate in GUI numbers.

Returns:
the height of the component

getMinX

public double getMinX()
Description copied from interface: World
Get minimum visible X value of the world.

Specified by:
getMinX in interface World
Returns:
The minimum x coordinate

getMinY

public double getMinY()
Description copied from interface: World
return the minimum visible Y value of the world

Specified by:
getMinY in interface World
Returns:
The minimum y coordinate

removeBall

public void removeBall(Ball toBeRemoved)
Description copied from interface: World
Remove a ball from the world

Specified by:
removeBall in interface World
Parameters:
toBeRemoved - The ball to remove

run

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

stop

public void stop()
Stop automatic repainting.


Ball World Problem Set Javadocs