Class edu.cornell.lassp.mck10.Hysteresis.LatticeView
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class edu.cornell.lassp.mck10.Hysteresis.LatticeView

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----edu.cornell.lassp.mck10.Hysteresis.LatticeView

public class LatticeView
extends Canvas
implements AvalancheConsumer, Observer
LatticeView is a class which can be used for viewing the state of a hysteresis lattice. It can display lattices in any number of dimensions two or greater. For dimensions greater than two, the higher dimensions are shown with color. The display is as if the viewer is looking through the lattice, and the more spins are up, the closer a pixel gets to white. The more spins are down, the closer it gets to black. Colors are used to display individual avalanches. When an avalanche first flips, the previous avalanche is erased, and the new avalanche is displayed. The colors of the avalanche represent the order in which the spins flipped. Blue represents spins that flipped early, then green, yellow, orange, red, and finally purple.

Source Code is available.

Version:
1.0
Author:
Matt Kuntz (e-mail: mck10@cornell.edu)

Variable Index

 o localMenu
localMenu contains the configuration menu for the lattice view.

Constructor Index

 o LatticeView(HysteresisLattice, ConfigurableCollection)
The LatticeView(model,menu) constructor is used to create a new LatticeView displaying the model model and attaching its menu to the menu menu

Method Index

 o clearAvalanche()
clearAvalanche() is used to erase the last avalanche from the display.
 o drawAvalanche()
drawAvalanche() displays the last avalanche.
 o minimumSize()
minimumSize() returns the minimum size for the view.
 o notify(Avalanche, AvalancheProducer)
notify(avalanche,prod) is called any time an avalanche is produced.
 o paint(Graphics)
paint is called whenever the display area needs to be repainted.
 o preferredSize()
preferredSize() returns the preferred size of the view.
 o resize(Dimension)
resize(newSize) is overridden so that the display will be re-setup when the area is resized.
 o restart()
restart() is called when we want to reset the view.
 o update(Observable, Object)
update is called when one of the configurable parameters of the model has changed.
 o update(Graphics)
update(g) is overridded so that the display will not be blanked before it is redrawn.

Variables

 o localMenu
  public ConfigurableCollection localMenu
localMenu contains the configuration menu for the lattice view.

Constructors

 o LatticeView
  public LatticeView(HysteresisLattice model,
                     ConfigurableCollection menu)
The LatticeView(model,menu) constructor is used to create a new LatticeView displaying the model model and attaching its menu to the menu menu
Parameters:
model - The model to view.
menu - The menu to attach to.

Methods

 o update
  public void update(Observable obs,
                     Object obj)
update is called when one of the configurable parameters of the model has changed. When this happens, we probably need to change the way we display ourselves, or at the very least clear the display.
 o update
  public void update(Graphics g)
update(g) is overridded so that the display will not be blanked before it is redrawn.
Parameters:
g - The graphics context to be updated.
Overrides:
update in class Component
 o resize
  public void resize(Dimension newSize)
resize(newSize) is overridden so that the display will be re-setup when the area is resized.
Parameters:
newSize - The size to change to.
Overrides:
resize in class Component
 o paint
  public void paint(Graphics g)
paint is called whenever the display area needs to be repainted. This paint method sets things up properly if they haven't been set up already, and draws myImage to the screen if it has been drawn to.
Parameters:
g - The graphics context to paint to.
Overrides:
paint in class Canvas
 o notify
  public void notify(Avalanche avalanche,
                     AvalancheProducer prod)
notify(avalanche,prod) is called any time an avalanche is produced. This is where the avalanches are displayed.
Parameters:
avalanche - The avalanche to display.
prod - The model which produced the avalanche.
 o clearAvalanche
  public void clearAvalanche()
clearAvalanche() is used to erase the last avalanche from the display. Instead, we see the normal view through the lattice.
 o drawAvalanche
  public void drawAvalanche()
drawAvalanche() displays the last avalanche.
 o preferredSize
  public Dimension preferredSize()
preferredSize() returns the preferred size of the view. This should be big enough to hold a model of the current dimensions with spins displayed large enough to make the display area at least 150 pixels.
Returns:
The preferred size of the view.
Overrides:
preferredSize in class Component
 o minimumSize
  public Dimension minimumSize()
minimumSize() returns the minimum size for the view. This should be big enough to hold a model of the current dimensions with spins taking up one pixel.
Returns:
The minimum size of the view.
Overrides:
minimumSize in class Component
 o restart
  public void restart()
restart() is called when we want to reset the view.

All Packages  Class Hierarchy  This Package  Previous  Next  Index