edu.uah.math.devices
Class CellGrid

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

public class CellGrid
extends javax.swing.JComponent
implements java.awt.event.MouseMotionListener, java.io.Serializable

This class models the cell grid used in the Coupon Collector Experiment. The grid can show a ball in a particualr cell, or can show ball counts for each cell.

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
static int BALL
           
static int COUNTS
           
static int NONE
           
 
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
CellGrid()
          This default constructor creates a new cell grid with 20 cells.
CellGrid(int m)
          This general constructor: creates a new cell grid with a specified number of cells.
 
Method Summary
 java.awt.Color getBallColor()
          This method returns the ball color
 int getBigColumns()
          This method returns the number of big columns in the cell grid.
 int[] getCellCount()
          This method returns the counts for all of the cells.
 int getCellCount(int i)
          This method returns the cell count for an individual cell.
 int getCells()
          This method returns the number of cells.
 int getColumns()
          This method returns the number of columns in the cell grid.
 java.awt.Color getCountColor()
          This method returns the count color
 int getCurrentCell()
          This method gets the currently selected cell
 java.awt.Color getGridColor()
          This method returns the grid color
 int getRows()
          This method returns the number of rows in the cell grid.
 int getShow()
          This method gets the show parameter.
 void mouseDragged(java.awt.event.MouseEvent event)
           
 void mouseEntered(java.awt.event.MouseEvent event)
           
 void mouseExited(java.awt.event.MouseEvent event)
           
 void mouseMoved(java.awt.event.MouseEvent e)
          This method handles the mouse move event.
 void mousePressed(java.awt.event.MouseEvent event)
           
 void mouseReleased(java.awt.event.MouseEvent event)
           
 void paintComponent(java.awt.Graphics g)
          This method paints the cell grid.
 void reset()
          This method resets the cell grid.
 void setBallColor(java.awt.Color c)
          This method sets the ball color.
 void setCellCount(int[] c)
          This method sets the counts for all of the cells.
 void setCellCount(int i, int k)
          This method sets the count for an individual cell.
 void setCells(int m)
          This mtheod sets the number of cells.
 void setCountColor(java.awt.Color c)
          This method sets the count color.
 void setCurrentCell(int c)
          This method sets the currently selected cell
 void setGridColor(java.awt.Color c)
          This method sets the grid color.
 void setShow(int i)
          This method sets the show parameter.
 
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, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, 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
 

Field Detail

COUNTS

public static final int COUNTS
See Also:
Constant Field Values

BALL

public static final int BALL
See Also:
Constant Field Values

NONE

public static final int NONE
See Also:
Constant Field Values
Constructor Detail

CellGrid

public CellGrid(int m)
This general constructor: creates a new cell grid with a specified number of cells.

Parameters:
m - the number of cells.

CellGrid

public CellGrid()
This default constructor creates a new cell grid with 20 cells.

Method Detail

paintComponent

public void paintComponent(java.awt.Graphics g)
This method paints the cell grid.

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

setCellCount

public void setCellCount(int[] c)
This method sets the counts for all of the cells.

Parameters:
c - the array of cell counts.

setCellCount

public void setCellCount(int i,
                         int k)
This method sets the count for an individual cell.

Parameters:
i - the index of the cell.
k - the cell count.

getCellCount

public int[] getCellCount()
This method returns the counts for all of the cells.

Returns:
the array of cell counts.

getCellCount

public int getCellCount(int i)
This method returns the cell count for an individual cell.

Parameters:
i - the index of the cell.
Returns:
the cell count.

reset

public void reset()
This method resets the cell grid. The cell counts are all set to 0.


setCells

public void setCells(int m)
This mtheod sets the number of cells.

Parameters:
m - the number of cells.

getCells

public int getCells()
This method returns the number of cells.

Returns:
the number of cells.

setGridColor

public void setGridColor(java.awt.Color c)
This method sets the grid color.

Parameters:
c - the grid color

getGridColor

public java.awt.Color getGridColor()
This method returns the grid color

Returns:
the grid color

setCountColor

public void setCountColor(java.awt.Color c)
This method sets the count color.

Parameters:
c - the count color

getCountColor

public java.awt.Color getCountColor()
This method returns the count color

Returns:
the count color

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

setShow

public void setShow(int i)
This method sets the show parameter.

Parameters:
i - the show parameter

getShow

public int getShow()
This method gets the show parameter.

Returns:
the show parameter

setCurrentCell

public void setCurrentCell(int c)
This method sets the currently selected cell

Parameters:
c - the current cell

getCurrentCell

public int getCurrentCell()
This method gets the currently selected cell

Returns:
the current cell

getRows

public int getRows()
This method returns the number of rows in the cell grid.

Returns:
the number of rows

getColumns

public int getColumns()
This method returns the number of columns in the cell grid.

Returns:
the number of columns

getBigColumns

public int getBigColumns()
This method returns the number of big columns in the cell grid.

Returns:
the number of big columns

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
This method handles the mouse move event. The number of the cell is given in the tool tip.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
e - the mouse event

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent event)

mouseExited

public void mouseExited(java.awt.event.MouseEvent event)

mousePressed

public void mousePressed(java.awt.event.MouseEvent event)

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent event)

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent event)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener