Class BaseApplet

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--BaseApplet
Direct Known Subclasses:
BaseApplet2, LatticeApplet

public abstract class BaseApplet
extends java.applet.Applet
implements java.awt.event.ActionListener, java.awt.event.ItemListener

Base class for this set of applets, incorporating miscellaneous helper methods.

See Also:
Serialized Form

Inner Class Summary
protected  class BaseApplet.MozillaWorkaround
          Manually adjusts selected checkbox in a CheckboxGroup, fixing a problem experienced with Mozilla.
protected  class BaseApplet.ResizeListener
          Recreates buffer and repaints when size of applet is changed.
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
protected  java.awt.Image buffer
          The image used for buffering
protected  int GRAPH_MARGIN
           
protected  boolean refresh
          true if the buffer has been invalidated, else false
protected  BaseApplet.ResizeListener resizeListener
          Instance of ResizeListener used to detect size changes
protected  boolean safetyLimit
          true if extra range checks are enabled, else false
protected  boolean useBuffer
          true if buffering is enabled, else false
 
Fields inherited from class java.applet.Applet
serialVersionUID, stub
 
Fields inherited from class java.awt.Panel
base, nameCounter, serialVersionUID
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dispatcher, layoutMgr, maxSize, ncomponents, serialVersionUID
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, assert, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, serialVersionUID, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
BaseApplet()
           
 
Method Summary
abstract  void actionPerformed(java.awt.event.ActionEvent ae)
          Subclasses should at least provide an empty implementation of this method.
protected  void changeFont()
          Used internally to read and apply font settings
protected abstract  void doPaint(java.awt.Graphics g)
          Called by forcePaint() to actually perform the painting.
 void forcePaint(java.awt.Graphics g)
          Forces the buffer to be regenerated, then painted onto the specified Graphics object.
 java.lang.String getAppletInfo()
          Unless overridden, returns (C) 2002 University of Southampton, UK"
 java.lang.String[][] getParameterInfo()
          Unless overridden, returns parameter descriptions for fontname fontsize usebuffer safety
 void init()
          Performs extra intialisation specific to this class
 void itemStateChanged(java.awt.event.ItemEvent ie)
          Default ItemListener implementation, calls actionPerformed(null)
 void paint(java.awt.Graphics g)
          Paints the applet onto the specified Graphics object.
 void refresh()
          Invalidates the buffer contents and repaints the applet
 void start()
          Applets should use this method to perform any final initialisation necessary to "activate" the applet
 void stop()
          When this method is called, the applet should cease any user interaction.
 void update(java.awt.Graphics g)
          Method overridden to save clearing the screen.
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
, addNotify, constructComponentName
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyOrientation, countComponents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getCursorTarget, getInsets, getLayout, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, initIDs, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPrint, list, list, locate, minimumSize, nextFocus, paintComponents, paramString, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printOneComponent, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, readObject, remove, remove, removeAll, removeContainerListener, removeNotify, setCursor, setFocusOwner, setFont, setLayout, transferFocus, updateCursor, validate, validateTree, writeObject
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getIntrinsicCursor, getLocation, getLocation, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

buffer

protected java.awt.Image buffer
The image used for buffering

useBuffer

protected boolean useBuffer
true if buffering is enabled, else false

refresh

protected boolean refresh
true if the buffer has been invalidated, else false

safetyLimit

protected boolean safetyLimit
true if extra range checks are enabled, else false

resizeListener

protected BaseApplet.ResizeListener resizeListener
Instance of ResizeListener used to detect size changes

GRAPH_MARGIN

protected int GRAPH_MARGIN
Constructor Detail

BaseApplet

public BaseApplet()
Method Detail

init

public void init()
Performs extra intialisation specific to this class
Overrides:
init in class java.applet.Applet

start

public void start()
Applets should use this method to perform any final initialisation necessary to "activate" the applet
Overrides:
start in class java.applet.Applet

stop

public void stop()
When this method is called, the applet should cease any user interaction. In particular, any threads explicitly started should be stopped, any external resources should be closed. This method should negate the action of start().
Overrides:
stop in class java.applet.Applet

actionPerformed

public abstract void actionPerformed(java.awt.event.ActionEvent ae)
Subclasses should at least provide an empty implementation of this method.
Specified by:
actionPerformed in interface java.awt.event.ActionListener

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent ie)
Default ItemListener implementation, calls actionPerformed(null)
Specified by:
itemStateChanged in interface java.awt.event.ItemListener

changeFont

protected void changeFont()
Used internally to read and apply font settings

getAppletInfo

public java.lang.String getAppletInfo()
Unless overridden, returns (C) 2002 University of Southampton, UK"
Overrides:
getAppletInfo in class java.applet.Applet

getParameterInfo

public java.lang.String[][] getParameterInfo()
Unless overridden, returns parameter descriptions for
Overrides:
getParameterInfo in class java.applet.Applet

refresh

public void refresh()
Invalidates the buffer contents and repaints the applet

update

public void update(java.awt.Graphics g)
Method overridden to save clearing the screen. Since we are pasting the contents of a buffer, the prior state of the display area is immaterial.
Overrides:
update in class java.awt.Container

paint

public void paint(java.awt.Graphics g)
Paints the applet onto the specified Graphics object. If buffering is enabled and the buffer has not been invalidated, then the contents of the buffer will be painted. Otherwise, forcePaint() will be called to regenerate the buffer.
Overrides:
paint in class java.awt.Container
Parameters:
g - The Graphics object on which to paint

forcePaint

public void forcePaint(java.awt.Graphics g)
Forces the buffer to be regenerated, then painted onto the specified Graphics object.
Parameters:
g - The Graphics object on which to paint

doPaint

protected abstract void doPaint(java.awt.Graphics g)
Called by forcePaint() to actually perform the painting. Subclasses should implement this method as if it were the standard paint() method; buffering will then take place transparently.
Parameters:
g - The Graphics object on which to paint