SimJava 2.0.1

eduni.simanim
Class Anim_applet

Object
  extended by Component
      extended by Container
          extended by Panel
              extended by Applet
                  extended by Anim_applet
All Implemented Interfaces:
Traceable, Sim_reporter, ActionListener, AdjustmentListener, ImageObserver, MenuContainer, Serializable, Runnable, EventListener, Accessible

public abstract class Anim_applet
extends Applet
implements Runnable, ActionListener, AdjustmentListener, Traceable, Sim_reporter

The superclass for all animated simulations.

Users that want to add animation to their simulations need to subclass Anim_applet. Following this they should override some or all of the following methods:

More information of how to use these methods and how to add animation to simulations can be found at the SimJava Tutorial.

Version:
1.3, 12 July 2002
Author:
Costas Simatos
See Also:
Sim_system, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class Applet
Applet.AccessibleApplet
 
Nested classes/interfaces inherited from class Panel
Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
(package private)  ScrollPane animScroll
           
(package private)  boolean do_messages
           
(package private)  boolean do_report
           
(package private)  Button layoutBut
           
(package private)  TextArea messagesArea
           
(package private)  Button pauseBut
           
(package private)  boolean paused
           
(package private)  StringBuffer report
           
(package private)  TextArea reportArea
           
(package private)  Button runBut
           
(package private)  Thread simThread
           
(package private)  int speed
           
(package private)  Label speedLabel
           
(package private)  Scrollbar speedScroll
           
(package private)  Button stopBut
           
(package private)  boolean stopped
           
protected  Sim_anim trace_out
           
 
Fields inherited from class Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface Traceable
DISPLAY, LAYOUT, PAUSE, RUN, STOP, TRACE
 
Fields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Anim_applet()
           
 
Method Summary
 void actionPerformed(ActionEvent e)
          Internal action handler.
 void add_message(String msg)
          Internal method used to generate a message.
 void adjustmentValueChanged(AdjustmentEvent e)
          Internal scrollbar event handler.
 void anim_completed()
          Define code to be execute upon simulation completion.
 void anim_init()
          Set up additional GUI components.
abstract  void anim_layout()
          Setup the simulation.
 void anim_output()
          Specify the level of reporting the animation should provide.
 void append_report(String line)
          Internal method used to add to the simulation's report.
 void close_report()
          Internal method used to close the simulation's report.
(package private)  void finished()
           
 void generate_messages(boolean do_messages)
          Generate the simulation's messages.
 void generate_report(boolean do_report)
          Generate the simulation's report.
(package private)  boolean get_paused()
           
(package private)  int get_speed()
           
(package private)  boolean get_stopped()
           
 void init()
          Internal method used to set up the default GUI components and the entities.
 void pause()
          Internal method used to pause the animation.
 void run()
          Internal method used to run the animation.
 void setup_report()
          Internal method used to setup the simulation's report.
 void sim_setup()
          Specify simulation conditions, an output analysis method and other simulation parameters.
 
Methods inherited from class Applet
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class Panel
addNotify
 
Methods inherited from class Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

simThread

Thread simThread

trace_out

protected Sim_anim trace_out

layoutBut

Button layoutBut

runBut

Button runBut

stopBut

Button stopBut

pauseBut

Button pauseBut

speedLabel

Label speedLabel

speedScroll

Scrollbar speedScroll

animScroll

ScrollPane animScroll

reportArea

TextArea reportArea

messagesArea

TextArea messagesArea

speed

int speed

paused

boolean paused

stopped

boolean stopped

do_report

boolean do_report

do_messages

boolean do_messages

report

StringBuffer report
Constructor Detail

Anim_applet

public Anim_applet()
Method Detail

anim_layout

public abstract void anim_layout()
Setup the simulation. This method must be overriden in the subclass and completed to add the simulation's entities and to link their ports.


anim_init

public void anim_init()
Set up additional GUI components. This method may be overriden to specify additional GUI components in the simulation's applet. This method is called once the applet starts up.


anim_completed

public void anim_completed()
Define code to be execute upon simulation completion. This method is called when the simulation completes.


init

public final void init()
Internal method used to set up the default GUI components and the entities. This method should not be overriden or used directly.

Overrides:
init in class Applet

sim_setup

public void sim_setup()
Specify simulation conditions, an output analysis method and other simulation parameters. If any of these are used in the simulation this method must be overriden to make the relevant Sim_system calls.


get_speed

int get_speed()

get_paused

boolean get_paused()

get_stopped

boolean get_stopped()

pause

public void pause()
Internal method used to pause the animation. Should not be used in user simulations.


actionPerformed

public void actionPerformed(ActionEvent e)
Internal action handler. Should not be used or overriden in the subclass.

Specified by:
actionPerformed in interface ActionListener
Parameters:
e - The ActionEvent

adjustmentValueChanged

public void adjustmentValueChanged(AdjustmentEvent e)
Internal scrollbar event handler. Should not be used or overriden in the subclass.

Specified by:
adjustmentValueChanged in interface AdjustmentListener
Parameters:
e - The AdjustmentEvent

run

public final void run()
Internal method used to run the animation. This method should not be used or overidden in the subclass.

Specified by:
run in interface Runnable

setup_report

public void setup_report()
Internal method used to setup the simulation's report. Should not be used or overriden in the subclass.

Specified by:
setup_report in interface Sim_reporter

close_report

public void close_report()
Internal method used to close the simulation's report. Should not be used or overriden in the subclass.

Specified by:
close_report in interface Sim_reporter

append_report

public void append_report(String line)
Internal method used to add to the simulation's report. Should not be used or overriden in the subclass.

Specified by:
append_report in interface Sim_reporter
Parameters:
line - The line of information to append to the report

anim_output

public void anim_output()
Specify the level of reporting the animation should provide. This method may be overriden to specify that the simulation's report and messages should be displayed on the applet.

The only code that should be included here are a call to generate_report and a call to generate_messages.

The default, if this method is not overriden, is to add only the simulation's messages.


generate_report

public void generate_report(boolean do_report)
Generate the simulation's report. This method should be called within the overriden anim_output method.

Parameters:
do_report - true if the report should be generated, false otherwise.

generate_messages

public void generate_messages(boolean do_messages)
Generate the simulation's messages. This method should be called within the overriden anim_output method.

Parameters:
do_messages - true if the messages should be generated, false otherwise.

finished

void finished()

add_message

public void add_message(String msg)
Internal method used to generate a message. This method should not be used or overriden in the subclass.


SimJava 2.0.1

The University of Edinburgh, 2009