Class HoleLattice

java.lang.Object
  |
  +--HoleLattice

class HoleLattice
extends java.lang.Object

A simple model to describe the motion of holes through a lattice.


Inner Class Summary
protected  class HoleLattice.Basis
          Represents a basis in the lattice, consisting of four holes/electrons around an atom.
protected  class HoleLattice.Hole
          Represents a hole/electron in motion.
 
Field Summary
protected  double advanceRate
          The rate at which holes move across the lattice
protected  int atomH
           
protected  int atomW
           
static int BOTTOM
           
protected  int holeH
           
protected  java.util.Vector holes
          A list of all the holes currently in the lattice
protected  int holeW
           
protected  int insetX
           
protected  int insetY
           
protected  HoleLattice.Basis[][] lattice
          The lattice itself, represented as an array of bases
static int LEFT
           
protected  int lh
          The height (in bases) of the lattice
protected  int lw
          The width (in bases) of the lattice
static int RIGHT
           
protected  double slideRate
          The rate at which holes "slide" diagonally instead of straight ahead
protected  boolean smooth
          Set to false if electrons move instantly, true if electrons move slowly.
protected  double spawnRate
          The rate at which new holes are created
static int TOP
           
 
Constructor Summary
HoleLattice(int w, int h)
          Creates a new lattice.
 
Method Summary
 void advanceHoles()
          Executes one step for the model; each (stationary) hole will have a random chance to move to a nearby state.
 int getKeyHeight(java.awt.FontMetrics fm)
          Calculates the height (in pixels) of the key.
 void paint(java.awt.Graphics g, int w, int h)
          Paints the lattice (and associated displays) onto the specified Graphics surface.
 void paintHoles(java.awt.Graphics g, int w, int h)
          Paints any holes/electrons currently in motion.
 void paintKey(java.awt.Graphics g, int w, int h)
          Paints the key onto the specified Graphics surface.
 void setSmooth(boolean b)
          Turns animation on or off.
 void spawnHoles()
          Creates more holes at the far right-hand side of the lattice.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

smooth

protected boolean smooth
Set to false if electrons move instantly, true if electrons move slowly.

holes

protected java.util.Vector holes
A list of all the holes currently in the lattice

lattice

protected HoleLattice.Basis[][] lattice
The lattice itself, represented as an array of bases

lw

protected int lw
The width (in bases) of the lattice

lh

protected int lh
The height (in bases) of the lattice

spawnRate

protected double spawnRate
The rate at which new holes are created

advanceRate

protected double advanceRate
The rate at which holes move across the lattice

slideRate

protected double slideRate
The rate at which holes "slide" diagonally instead of straight ahead

atomW

protected int atomW

atomH

protected int atomH

holeW

protected int holeW

holeH

protected int holeH

insetX

protected int insetX

insetY

protected int insetY

TOP

public static final int TOP

BOTTOM

public static final int BOTTOM

LEFT

public static final int LEFT

RIGHT

public static final int RIGHT
Constructor Detail

HoleLattice

public HoleLattice(int w,
                   int h)
Creates a new lattice.
Parameters:
w - The width of the lattice (number of bases across)
h - The width of the lattice (number of bases down)
Method Detail

paint

public void paint(java.awt.Graphics g,
                  int w,
                  int h)
Paints the lattice (and associated displays) onto the specified Graphics surface.
Parameters:
w - The width to scale the display to
h - The height to scale the display to

advanceHoles

public void advanceHoles()
Executes one step for the model; each (stationary) hole will have a random chance to move to a nearby state.

spawnHoles

public void spawnHoles()
Creates more holes at the far right-hand side of the lattice.

paintKey

public void paintKey(java.awt.Graphics g,
                     int w,
                     int h)
Paints the key onto the specified Graphics surface.
Parameters:
w - The width to scale the display to
h - The height to scale the display to

getKeyHeight

public int getKeyHeight(java.awt.FontMetrics fm)
Calculates the height (in pixels) of the key.
Parameters:
fm - The FontMetrics with which the key will be rendered

paintHoles

public void paintHoles(java.awt.Graphics g,
                       int w,
                       int h)
Paints any holes/electrons currently in motion.
Parameters:
w - The width to scale the display to
h - The height to scale the display to

setSmooth

public void setSmooth(boolean b)
Turns animation on or off.
Parameters:
b - true if animation should be on, otherwise false