edu.uah.math.devices
Class RouletteWheel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by edu.uah.math.devices.RouletteWheel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class RouletteWheel
extends javax.swing.JComponent
implements java.io.Serializable

This class models the standard American roulette wheel. The wheel has 38 slots labeled 0, 00, and 1 to 36. Of the slots labeled 1-26, 18 are red and 18 are green. The roulette wheel object is supplied with an image of a real roulette wheel.

Version:
August, 2003
Author:
Kyle Siegrist, Dawn Duehring
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
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 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
RouletteWheel()
          This default constructor creates a new roulette wheel.
 
Method Summary
 java.awt.Color getBallColor()
          This method returns the ball color
 int getIndex(int s)
          This method gets the index corresponding to a given score.
 java.lang.String getLabel()
          This method returns the label of the current score.
 java.awt.Dimension getMinimumSize()
          This method specifies the minimum size.
 java.awt.Dimension getPreferredSize()
          This method returns the preferred size.
 int getScore()
          This method returns the current score.
 int getScore(int i)
          This method returns the score corresponding to a given index.
 java.awt.Color getScoreColor()
          This method returns the color of the current score.
 java.awt.Color getScoreColor(int s)
          This method returns the color of a given score.
 int getScoreIndex()
          This method returns the index of the current score.
 int getScoreX(int s)
          This method returns the x-coordinate of the upper left corner of the slot corresponding to a given score.
 int getScoreY(int s)
          This method returns the y-coordinate of the upper left corner of the slot corresponding to a given score.
 boolean isBallDrawn()
          This method returns the boolean state of the ball
 java.awt.Dimension MaximumSize()
          This method returns the preferred size.
 void paintComponent(java.awt.Graphics g)
          This method paints the roulette wheel by drawing the image and drawing the ball in the appropriate slot.
 void setBallColor(java.awt.Color c)
          This method sets the ball color.
 void setBallDrawn(boolean b)
          This method sets the boolean state of the ball.
 void setScore(int s)
          This method sets the current score of the roulette wheel (the number of the slot containing the ball).
 void setScoreIndex(int i)
          This method sets the index of the score (starting at 0 and progressing counterclockwise).
 int spin()
          This method "spins" the wheel by selecting the score at ranom.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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

RouletteWheel

public RouletteWheel()
This default constructor creates a new roulette wheel.

Method Detail

paintComponent

public void paintComponent(java.awt.Graphics g)
This method paints the roulette wheel by drawing the image and drawing the ball in the appropriate slot.

Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - the graphics context

setScore

public void setScore(int s)
This method sets the current score of the roulette wheel (the number of the slot containing the ball).

Parameters:
s - the score

spin

public int spin()
This method "spins" the wheel by selecting the score at ranom.

Returns:
the random score

getScore

public int getScore()
This method returns the current score.

Returns:
the number of the slot containing the ball

getScore

public int getScore(int i)
This method returns the score corresponding to a given index. The index starts at 0, at the top of the wheel, and progresses counterclockwise.

Parameters:
i - the index

getLabel

public java.lang.String getLabel()
This method returns the label of the current score. The label is the same as the score, except that score 37 corresponds to 00.

Returns:
the label of the score

getScoreX

public int getScoreX(int s)
This method returns the x-coordinate of the upper left corner of the slot corresponding to a given score.

Parameters:
s - the score

getScoreY

public int getScoreY(int s)
This method returns the y-coordinate of the upper left corner of the slot corresponding to a given score.

Parameters:
s - the score

getScoreColor

public java.awt.Color getScoreColor(int s)
This method returns the color of a given score.

Parameters:
s - the score
Returns:
the color

getScoreColor

public java.awt.Color getScoreColor()
This method returns the color of the current score.

Returns:
the color

setBallDrawn

public void setBallDrawn(boolean b)
This method sets the boolean state of the ball.

Parameters:
b - true if the ball is drawn

isBallDrawn

public boolean isBallDrawn()
This method returns the boolean state of the ball

Returns:
true if the ball is drawn

setBallColor

public void setBallColor(java.awt.Color c)
This method sets the ball color.

Parameters:
c - the ball color

getBallColor

public java.awt.Color getBallColor()
This method returns the ball color

Returns:
the ball color

setScoreIndex

public void setScoreIndex(int i)
This method sets the index of the score (starting at 0 and progressing counterclockwise).

Parameters:
i - the index

getIndex

public int getIndex(int s)
This method gets the index corresponding to a given score. The index starts at 0 and progresses counterclockwise.

Parameters:
s - the score

getScoreIndex

public int getScoreIndex()
This method returns the index of the current score.

Returns:
the index of the current score

getMinimumSize

public java.awt.Dimension getMinimumSize()
This method specifies the minimum size.

Overrides:
getMinimumSize in class javax.swing.JComponent
Returns:
the 220 by 220 dimension

getPreferredSize

public java.awt.Dimension getPreferredSize()
This method returns the preferred size.

Overrides:
getPreferredSize in class javax.swing.JComponent
Returns:
the 220 by 220 dimension

MaximumSize

public java.awt.Dimension MaximumSize()
This method returns the preferred size.

Returns:
the 220 by 220 dimension