Class LatticeApplet

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--BaseApplet
                                |
                                +--LatticeApplet

public class LatticeApplet
extends BaseApplet

Applet to illustrate the idea of lattice vectors. Two draggable vectors are provided, and a "grid" of bases is drawn according to these base vectors.

The basis may be chosen from a list of simple geometric figures; to add to these, override or edit makeBases() to add the basis to the list, and override or edit makeLabels() to supply a label for the basis. The position in the array of the new label should match that of the new basis.

See Also:
Serialized Form

Inner Class Summary
protected  class LatticeApplet.VectorMoveListener
          Listener to detect changes in the positions of the lattice vectors.
 
Inner classes inherited from class BaseApplet
BaseApplet.MozillaWorkaround, BaseApplet.ResizeListener
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
protected  java.awt.Label angle
           
protected  Lattice2D.Basis[] bases
          A list of all available bases
protected  java.awt.Checkbox[] boxes
          A checkbox for each basis
protected  java.awt.CheckboxGroup cbg
          Ensures that exactly one basis will be selected
protected  java.lang.String[] labels
          Names for all available bases
protected  java.awt.Point lastPos
           
protected  Lattice2D lattice
          The lattice itself
static double MIN_SPACING
          The minimum modulus (in pixels) permitted for the lattice vectors.
protected  java.awt.Label mod1
           
protected  java.awt.Label mod2
           
protected  java.awt.Label ratio
           
protected  Lattice2D reciprocal
          The lattice itself
protected  java.awt.Panel rightPanel
          Container to hold all the GUI components.
protected  LatticeApplet.VectorMoveListener vectorMoveListener
          Listener for changes in the vectors.
 
Fields inherited from class BaseApplet
buffer, GRAPH_MARGIN, refresh, resizeListener, safetyLimit, useBuffer
 
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
LatticeApplet()
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ae)
          Subclasses should at least provide an empty implementation of this method.
 void addWithLabel(java.awt.Panel root, java.awt.Component c, java.lang.String label)
          Helper method to add a component with a label.
 java.awt.Point chooseWindowPos(int w, int h, int wndW, int wndH)
           
 int displayWidth()
          Calculates the width of the area available for the lattice display
 void doPaint(java.awt.Graphics g)
          Called by forcePaint() to actually perform the painting.
 void init()
          Performs extra intialisation specific to this class
 Lattice2D.Basis[] makeBases(Lattice2D l)
          Returns an array of all available bases.
 java.lang.String[] makeLabels()
          Returns an array of labels for all available bases.
 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.
protected  java.lang.String toString(double d)
          Helper method to format a double for display in a text label.
 void updateLabels()
          Updates the numerical information displayed to the right of the applet (vector lengths, length ratio, angle between vectors).
 void updateReciprocal()
           
 
Methods inherited from class BaseApplet
changeFont, forcePaint, getAppletInfo, getParameterInfo, itemStateChanged, paint, refresh, update
 
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

lastPos

protected java.awt.Point lastPos

lattice

protected Lattice2D lattice
The lattice itself

reciprocal

protected Lattice2D reciprocal
The lattice itself

vectorMoveListener

protected LatticeApplet.VectorMoveListener vectorMoveListener
Listener for changes in the vectors.

angle

protected java.awt.Label angle

mod1

protected java.awt.Label mod1

mod2

protected java.awt.Label mod2

ratio

protected java.awt.Label ratio

labels

protected java.lang.String[] labels
Names for all available bases

bases

protected Lattice2D.Basis[] bases
A list of all available bases

boxes

protected java.awt.Checkbox[] boxes
A checkbox for each basis

cbg

protected java.awt.CheckboxGroup cbg
Ensures that exactly one basis will be selected

rightPanel

protected java.awt.Panel rightPanel
Container to hold all the GUI components. Will be positioned to the right of the applet using BorderLayout.

MIN_SPACING

public static final double MIN_SPACING
The minimum modulus (in pixels) permitted for the lattice vectors. This prevents the vectors from becoming too small to see, but does not restrict the lattices available, as the vectors may still be positioned arbitrarily close together.

(The one exception to this rule is that it is no longer to create the degnerate lattice which is collapsed onto zero dimensions. This lattice is produced if and only if v1 = v2 = 0.)

Constructor Detail

LatticeApplet

public LatticeApplet()
Method Detail

init

public void init()
Description copied from class: BaseApplet
Performs extra intialisation specific to this class
Overrides:
init in class BaseApplet

addWithLabel

public void addWithLabel(java.awt.Panel root,
                         java.awt.Component c,
                         java.lang.String label)
Helper method to add a component with a label.
Parameters:
root - The Panel to which the component and label should be added
c - The component to be added
label - The text label for the component

start

public void start()
Description copied from class: BaseApplet
Applets should use this method to perform any final initialisation necessary to "activate" the applet
Overrides:
start in class BaseApplet

stop

public void stop()
Description copied from class: BaseApplet
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 BaseApplet

displayWidth

public int displayWidth()
Calculates the width of the area available for the lattice display

doPaint

public void doPaint(java.awt.Graphics g)
Description copied from class: BaseApplet
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.
Overrides:
doPaint in class BaseApplet
Tags copied from class: BaseApplet
Parameters:
g - The Graphics object on which to paint

chooseWindowPos

public java.awt.Point chooseWindowPos(int w,
                                      int h,
                                      int wndW,
                                      int wndH)

updateLabels

public void updateLabels()
Updates the numerical information displayed to the right of the applet (vector lengths, length ratio, angle between vectors).

toString

protected java.lang.String toString(double d)
Helper method to format a double for display in a text label.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ae)
Description copied from class: BaseApplet
Subclasses should at least provide an empty implementation of this method.
Overrides:
actionPerformed in class BaseApplet

updateReciprocal

public void updateReciprocal()

makeLabels

public java.lang.String[] makeLabels()
Returns an array of labels for all available bases.

makeBases

public Lattice2D.Basis[] makeBases(Lattice2D l)
Returns an array of all available bases.