All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Canvas
|
+----edu.cornell.lassp.mck10.HysteresisApplet.LoopView
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.
LoopView(model,containerMenu) constructor creates a
new LoopView, attatches it to the model, and attatches
it to the applet menu system.
clear() is used to clear the display for a new
hysteresis loop.
mouseDown(evt,y) is used to detect user mouse clicks.
mouseDrag(evt,y) is called when the user drags the mouse
with the mouse down.
mouseUp(evt,x,y) is called when the user lifts the mouse
button.
notify(XY,prod) is called when a new avalanche has happened
in the model.
paing(g) does a number of things, depending on the
situation.
redraw() is used to redraw the hysteresis loop from the
hystory when the user has zoomed in.
resize(x,y) is overridden to make sure that the display
responds to the resizing of the canvas.
resize(d) is overridden to make sure that the display
responds to the resizing of the canvas.
resizeView() is used to respond to the fact that the size
of the canvas has changed.
update(g) is overridden so that the display is not cleared
before repaints.
update(obs,obj) is called when the Configurable parameters
of the model are changed.
zoomIn() is used to zoom in to the coordinates the user
has dragged a box around.
zoomIn(min,max) zooms the display to the coordinates
given in the variables min and max.
zoomOut() is used to zoom out by a factor of two.
public LoopView(HysteresisLattice model,
ConfigurableCollection containerMenu)
LoopView(model,containerMenu) constructor creates a
new LoopView, attatches it to the model, and attatches
it to the applet menu system.
public void update(Graphics g)
update(g) is overridden so that the display is not cleared
before repaints.
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.
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.
public void clear()
clear() is used to clear the display for a new
hysteresis loop.
public void redraw()
redraw() is used to redraw the hysteresis loop from the
hystory when the user has zoomed in.
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.
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.
protected void drawRect(int cornerX,
int cornerY,
int dragX,
int dragY)
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.
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.
public void zoomIn()
zoomIn() is used to zoom in to the coordinates the user
has dragged a box around.
public void zoomOut()
zoomOut() is used to zoom out by a factor of two.
public void resizeView()
resizeView() is used to respond to the fact that the size
of the canvas has changed.
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.
public void resize(Dimension d)
resize(d) is overridden to make sure that the display
responds to the resizing of the canvas.
public void zoomIn(XYPair min,
XYPair max)
zoomIn(min,max) zooms the display to the coordinates
given in the variables min and max.
All Packages Class Hierarchy This Package Previous Next Index