com.oxfordmathcenter.breadboards
Class AbstractBreadboard

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by javax.swing.JApplet
                      extended by acm.program.Program
                          extended by acm.program.GraphicsProgram
                              extended by com.oxfordmathcenter.breadboards.AbstractBreadboard
All Implemented Interfaces:
acm.io.IOModel, java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer
Direct Known Subclasses:
ComboBoxWithButtonsBreadboard, NoButtonsBreadboard, OneButtonBreadboard, TwoButtonBreadboard

public abstract class AbstractBreadboard
extends acm.program.GraphicsProgram

This class provides some of the common functionality to all breadboard classes -- such as keeping track of a timer, updating any GObjects that implement the TimerAware interface, providing methods to be overloaded to handle reacting to mouse events, etc...

Author:
oser
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
 
Fields inherited from class acm.program.Program
CENTER, EAST, NORTH, SOUTH, WEST
 
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
AbstractBreadboard()
          Constructs the breadboard and its related timer and timerListener
 
Method Summary
 javax.swing.Timer getTimer()
          Gets the timer associated with this breadboard
 int getTimerDelay()
          Get the time between timer ticks for this breadboard
 void onMouseClick(java.awt.event.MouseEvent e)
          Override this method for the breadboard to react to this type of mouse event
 void onMouseDragged(java.awt.event.MouseEvent e)
          Override this method for the breadboard to react to this type of mouse event
 void onMouseEntered(java.awt.event.MouseEvent e)
          Override this method for the breadboard to react to this type of mouse event
 void onMouseExited(java.awt.event.MouseEvent e)
          Override this method for the breadboard to react to this type of mouse event
 void onMouseMoved(java.awt.event.MouseEvent e)
          Override this method for the breadboard to react to this type of mouse event
 void onMousePressed(java.awt.event.MouseEvent e)
          Override this method for the breadboard to react to this type of mouse event
 void onMouseReleased(java.awt.event.MouseEvent e)
          Override this method for the breadboard to react to this type of mouse event
 void onTimerTick()
          Override this method for the breadboard to react to timer ticks
 void paintBreadboardCanvas()
          This method forces the repainting of the breadboard's canvas.
 
Methods inherited from class acm.program.GraphicsProgram
add, add, add, add, add, addKeyListeners, addKeyListeners, addMouseListeners, addMouseListeners, getElement, getElementAt, getElementAt, getElementCount, getGCanvas, init, iterator, iterator, remove, removeAll, removeAllComponents, repaint, run, setBackground, startGraphicsProgram, waitForClick
 
Methods inherited from class acm.program.Program
actionPerformed, add, addActionListeners, addActionListeners, addExitHook, destroy, exit, getCentralRegionSize, getConsole, getDialog, getHeight, getInputModel, getLayout, getMainThread, getMenuBar, getOutputModel, getParameter, getPreferredSize, getReader, getRegionPanel, getTitle, getWidth, getWriter, isAppletMode, keyPressed, keyReleased, keyTyped, main, menuAction, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, pause, print, print, print, print, print, print, print, print, println, println, println, println, println, println, println, println, println, readBoolean, readBoolean, readBoolean, readDouble, readDouble, readDouble, readDouble, readInt, readInt, readInt, readInt, readLine, readLine, remove, remove, setConsole, setDialog, setInputModel, setLayout, setOutputModel, setParameter, setTitle, showErrorMessage, start, start, validate
 
Methods inherited from class javax.swing.JApplet
getAccessibleContext, getContentPane, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, repaint, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setTransferHandler, update
 
Methods inherited from class java.applet.Applet
getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getListeners, getMaximumSize, getMinimumSize, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, requestFocus, requestFocusInWindow, reshape, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractBreadboard

public AbstractBreadboard()
Constructs the breadboard and its related timer and timerListener

Method Detail

getTimerDelay

public int getTimerDelay()
Get the time between timer ticks for this breadboard

Returns:
an int representing the delay between timer ticks for this breadboard in milliseconds

getTimer

public javax.swing.Timer getTimer()
Gets the timer associated with this breadboard

Returns:
the timer associated with this breadboard

onTimerTick

public void onTimerTick()
Override this method for the breadboard to react to timer ticks


onMouseClick

public void onMouseClick(java.awt.event.MouseEvent e)
Override this method for the breadboard to react to this type of mouse event

Parameters:
e - the MouseEvent in question

onMouseEntered

public void onMouseEntered(java.awt.event.MouseEvent e)
Override this method for the breadboard to react to this type of mouse event

Parameters:
e - the MouseEvent in question

onMouseExited

public void onMouseExited(java.awt.event.MouseEvent e)
Override this method for the breadboard to react to this type of mouse event

Parameters:
e - the MouseEvent in question

onMousePressed

public void onMousePressed(java.awt.event.MouseEvent e)
Override this method for the breadboard to react to this type of mouse event

Parameters:
e - the MouseEvent in question

onMouseReleased

public void onMouseReleased(java.awt.event.MouseEvent e)
Override this method for the breadboard to react to this type of mouse event

Parameters:
e - the MouseEvent in question

onMouseDragged

public void onMouseDragged(java.awt.event.MouseEvent e)
Override this method for the breadboard to react to this type of mouse event

Parameters:
e - the MouseEvent in question

onMouseMoved

public void onMouseMoved(java.awt.event.MouseEvent e)
Override this method for the breadboard to react to this type of mouse event

Parameters:
e - the MouseEvent in question

paintBreadboardCanvas

public void paintBreadboardCanvas()
This method forces the repainting of the breadboard's canvas. This is particularly useful to call when the screen should be updated frequently, like when showing something moving in an animated way. Without calls to this method, you may only see the final position of the objects in question - even if you had intended them to be moving or updating continuously.