Class edu.cornell.lassp.mck10.HysteresisApplet.LoopView
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class edu.cornell.lassp.mck10.HysteresisApplet.LoopView

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----edu.cornell.lassp.mck10.HysteresisApplet.LoopView

public class LoopView
extends Canvas
implements XYConsumer, Observer
The LoopView class is an extension of Canvas which displays Hysteresis loops generated by the HysteresisLattice class. It also provides some user interface functionality. If the user clicks on the loop, the external field in the model is set to the value of the external field at the point the user clicked on. If the user drags a box on the loop, the view zooms to the box which the user dragged. Zooming is also possible through a public method call.

Source Code is available.

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

Constructor Index

 o LoopView(HysteresisLattice, ConfigurableCollection)
The LoopView(model,containerMenu) constructor creates a new LoopView, attatches it to the model, and attatches it to the applet menu system.

Method Index

 o clear()
clear() is used to clear the display for a new hysteresis loop.
 o drawRect(int, int, int, int)
 o mouseDown(Event, int, int)
mouseDown(evt,y) is used to detect user mouse clicks.
 o mouseDrag(Event, int, int)
mouseDrag(evt,y) is called when the user drags the mouse with the mouse down.
 o mouseUp(Event, int, int)
mouseUp(evt,x,y) is called when the user lifts the mouse button.
 o notify(XYPair, XYProducer)
notify(XY,prod) is called when a new avalanche has happened in the model.
 o paint(Graphics)
paing(g) does a number of things, depending on the situation.
 o redraw()
redraw() is used to redraw the hysteresis loop from the hystory when the user has zoomed in.
 o resize(int, int)
resize(x,y) is overridden to make sure that the display responds to the resizing of the canvas.
 o resize(Dimension)
resize(d) is overridden to make sure that the display responds to the resizing of the canvas.
 o resizeView()
resizeView() is used to respond to the fact that the size of the canvas has changed.
 o update(Graphics)
update(g) is overridden so that the display is not cleared before repaints.
 o update(Observable, Object)
update(obs,obj) is called when the Configurable parameters of the model are changed.
 o zoomIn()
zoomIn() is used to zoom in to the coordinates the user has dragged a box around.
 o zoomIn(XYPair, XYPair)
zoomIn(min,max) zooms the display to the coordinates given in the variables min and max.
 o zoomOut()
zoomOut() is used to zoom out by a factor of two.

Constructors

 o LoopView
  public LoopView(HysteresisLattice model,
                  ConfigurableCollection containerMenu)
The LoopView(model,containerMenu) constructor creates a new LoopView, attatches it to the model, and attatches it to the applet menu system.
Parameters:
model - The model producing the hysteresis loop.
containerMenu - The menu system provided by the view's container.

Methods

 o update
  public void update(Graphics g)
update(g) is overridden so that the display is not cleared before repaints.
Parameters:
g - The graphics context for the area to be updated.
Overrides:
update in class Component
 o paint
  public void paint(Graphics g)
paing(g) does a number of things, depending on the situation. If the window has been resized, it resizes the window. if the display has not been set up, it sets things up. If it is just a repaint, it draws the buffered image to restore the display to its proper state.
Parameters:
g - The graphics context for the area to be painted.
Overrides:
paint in class Canvas
 o notify
  public void notify(XYPair XY,
                     XYProducer prod)
notify(XY,prod) is called when a new avalanche has happened in the model. The new point is added to the history, and, if it is far enough from the last displayed point to affect the display, it is plotted.
Parameters:
XY - The magnetic field and magnetization from the model.
prod - The model which produced the data.
 o clear
  public void clear()
clear() is used to clear the display for a new hysteresis loop.
 o redraw
  public void redraw()
redraw() is used to redraw the hysteresis loop from the hystory when the user has zoomed in.
 o update
  public void update(Observable obs,
                     Object obj)
update(obs,obj) is called when the Configurable parameters of the model are changed. When this happens, we usually need to clear the LoopView and start over. This method is also called when the model stops, in which case we need to display the cross.
Parameters:
obs - The observable variable which has changed.
obj - An unused parameter.
 o mouseDown
  public boolean mouseDown(Event evt,
                           int x,
                           int y)
mouseDown(evt,y) is used to detect user mouse clicks. This code just records the location of the user's mouse click.
Parameters:
evt - The event which occurred.
x - The x coordinate of the user click.
y - The y coordinate of the user click.
Overrides:
mouseDown in class Component
 o drawRect
  protected void drawRect(int cornerX,
                          int cornerY,
                          int dragX,
                          int dragY)
 o mouseDrag
  public boolean mouseDrag(Event evt,
                           int x,
                           int y)
mouseDrag(evt,y) is called when the user drags the mouse with the mouse down. The coordinates that have been dragged to are stored, and the zoom rectangle is resized.
Parameters:
evt - The event which has occurred.
x - The x coordinate the user has dragged to.
y - The y coordinate the user has dragged to.
Overrides:
mouseDrag in class Component
 o mouseUp
  public boolean mouseUp(Event evt,
                         int x,
                         int y)
mouseUp(evt,x,y) is called when the user lifts the mouse button. If the user didn't drag the mouse, then they meant to change the magnetic field, and we will do this. If they did drag the mouse, then they wanted to zoom in, and we will do this.
Parameters:
evt - The event which has occurred.
x - The x coordinate of the mouseUp event.
y - The y coordinate of the mouseUp event.
Overrides:
mouseUp in class Component
 o zoomIn
  public void zoomIn()
zoomIn() is used to zoom in to the coordinates the user has dragged a box around.
 o zoomOut
  public void zoomOut()
zoomOut() is used to zoom out by a factor of two.
 o resizeView
  public void resizeView()
resizeView() is used to respond to the fact that the size of the canvas has changed.
 o resize
  public void resize(int x,
                     int y)
resize(x,y) is overridden to make sure that the display responds to the resizing of the canvas.
Parameters:
x - The new width of the canvas.
y - The new height of the canvas.
Overrides:
resize in class Component
 o resize
  public void resize(Dimension d)
resize(d) is overridden to make sure that the display responds to the resizing of the canvas.
Parameters:
d - The new dimensions of the canvas.
Overrides:
resize in class Component
 o zoomIn
  public void zoomIn(XYPair min,
                     XYPair max)
zoomIn(min,max) zooms the display to the coordinates given in the variables min and max.
Parameters:
min - The coordinates of the lower left corner.
max - The coordinates of the upper right corner.

All Packages  Class Hierarchy  This Package  Previous  Next  Index