|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Panel
java.applet.Applet
javax.swing.JApplet
ptolemy.gui.BasicJApplet
ptolemy.actor.gui.PtolemyApplet
public class PtolemyApplet
This class provides a convenient way to make applets out of Ptolemy II models. It assumes that the model is defined as a Java class that extends NamedObj, with the classname given by the modelClass applet parameter. If that model does not contain a manager, then this class will create one for it.
This class offers a number of alternatives that control the visual appearance of the applet. By default, the applet places on the screen a set of control buttons that can be used to start, stop, pause, and resume the model. Below those buttons, it places the visual elements of any actors in the model that implement the Placeable interface, such as plotters or textual output.
The applet parameters are:
To create a model in a different way, say without a modelClass applet parameter, you may extend this class and override the protected method _createModel(). If you wish to alter the way that the model is represented on the screen, you can extend this class an override the _createView() method. The rendition in this class is an instance of ModelPane.
This class provides a number of methods that might be useful even if its init() or _createModel() methods are not appropriate for a given applet. Specifically, it provides a mechanism for reporting errors and exceptions; and it provide an applet parameter for controlling the background color.
ModelPane
,
Placeable
,
Serialized Form
Yellow (johnr) |
Green (eal) |
Nested Class Summary | |
---|---|
private class |
PtolemyApplet.GoButtonListener
|
private class |
PtolemyApplet.StopButtonListener
|
Nested classes/interfaces inherited from class javax.swing.JApplet |
---|
javax.swing.JApplet.AccessibleJApplet |
Nested classes/interfaces inherited from class java.applet.Applet |
---|
java.applet.Applet.AccessibleApplet |
Nested classes/interfaces inherited from class java.awt.Panel |
---|
java.awt.Panel.AccessibleAWTPanel |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
private javax.swing.JButton |
_goButton
|
protected Manager |
_manager
The manager, created in the init() method. |
private Manager.State |
_previousState
|
protected boolean |
_setupOK
Set this to false if the setup of the model during the init() method fails. |
private javax.swing.JButton |
_stopButton
|
protected NamedObj |
_toplevel
The top-level composite actor, created in the init() method. |
protected Workspace |
_workspace
The workspace that the applet is built in. |
Fields inherited from class ptolemy.gui.BasicJApplet |
---|
_background |
Fields inherited from class javax.swing.JApplet |
---|
accessibleContext, rootPane, rootPaneCheckingEnabled |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
PtolemyApplet()
|
Method Summary | |
---|---|
protected NamedObj |
_createModel(Workspace workspace)
Create a model. |
protected javax.swing.JPanel |
_createRunControls(int numberOfButtons)
Deprecated. Use the control applet parameter. |
protected void |
_createView()
Create a ModelPane to control execution of the model and display its results. |
protected void |
_go()
Execute the model, if the manager is not currently executing. |
protected void |
_stop()
Stop the execution. |
void |
destroy()
Cleanup after execution of the model. |
void |
executionError(Manager manager,
java.lang.Throwable throwable)
Report that an execute error occurred. |
void |
executionFinished(Manager manager)
Report that execution of the model has finished. |
java.lang.String |
getAppletInfo()
Return a string describing this applet. |
java.lang.String[][] |
getParameterInfo()
Describe the applet parameters. |
void |
init()
Initialize the applet. |
void |
managerStateChanged(Manager manager)
Report that the manager state has changed. |
void |
start()
Start execution of the model. |
void |
stop()
Stop execution of the model. |
Methods inherited from class ptolemy.gui.BasicJApplet |
---|
_concatStringArrays, _getBackground, _stackTraceToString, report, report, report |
Methods inherited from class javax.swing.JApplet |
---|
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update |
Methods inherited from class java.applet.Applet |
---|
getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus |
Methods inherited from class java.awt.Panel |
---|
addNotify |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, 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, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.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, 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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Manager _manager
protected boolean _setupOK
protected NamedObj _toplevel
protected Workspace _workspace
private javax.swing.JButton _goButton
private javax.swing.JButton _stopButton
private Manager.State _previousState
Constructor Detail |
---|
public PtolemyApplet()
Method Detail |
---|
public void destroy()
destroy
in class java.applet.Applet
public void executionError(Manager manager, java.lang.Throwable throwable)
executionError
in interface ExecutionListener
manager
- The manager in charge of the execution.throwable
- The throwable that triggered the error.public void executionFinished(Manager manager)
executionFinished
in interface ExecutionListener
manager
- The manager in charge of the execution.public java.lang.String getAppletInfo()
getAppletInfo
in class BasicJApplet
public java.lang.String[][] getParameterInfo()
getParameterInfo
in class BasicJApplet
public void init()
init
in class BasicJApplet
public void managerStateChanged(Manager manager)
managerStateChanged
in interface ExecutionListener
manager
- The manager controlling the execution.Manager.getState()
public void start()
start
in class java.applet.Applet
public void stop()
stop
in class java.applet.Applet
protected NamedObj _createModel(Workspace workspace) throws java.lang.Exception
workspace
- The workspace in which to create the model.
java.lang.Exception
- If something goes wrong. This is a broad
exception to allow derived classes wide latitude as to which
exception to throw.protected javax.swing.JPanel _createRunControls(int numberOfButtons)
numberOfButtons
- How many buttons to create.
protected void _createView()
protected void _go() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.protected void _stop()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |