ptolemy.actor.lib.gui
Class SliderSource

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.InstantiableNamedObj
          extended byptolemy.kernel.Entity
              extended byptolemy.kernel.ComponentEntity
                  extended byptolemy.actor.AtomicActor
                      extended byptolemy.actor.TypedAtomicActor
                          extended byptolemy.actor.lib.Source
                              extended byptolemy.actor.lib.gui.SliderSource
All Implemented Interfaces:
Actor, Changeable, javax.swing.event.ChangeListener, java.lang.Cloneable, Debuggable, DebugListener, Derivable, java.util.EventListener, Executable, Instantiable, ModelErrorHandler, MoMLExportable, Nameable, Placeable, java.io.Serializable, TypedActor

public class SliderSource
extends Source
implements javax.swing.event.ChangeListener, Placeable

The output of this actor is controlled by a slider in the run window. The range of the output is specified by two parameters, minimum and maximum. The type of these parameters and the output is integer.

Since:
Ptolemy II 2.0
Version:
$Id: SliderSource.java,v 1.18 2004/04/13 05:12:32 cxh Exp $
Author:
Xiaojun Liu
See Also:
Serialized Form
Accepted Rating:
Red (liuxj)
Proposed Rating:
Red (liuxj)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
protected  javax.swing.JPanel _panel
           
 Parameter maximum
          The maximum value of the slider.
 Parameter minimum
          The minimum value of the slider.
 javax.swing.JSlider slider
          The slider that controls the output of this actor.
 StringAttribute title
          The title to put on top.
 
Fields inherited from class ptolemy.actor.lib.Source
output, trigger
 
Fields inherited from class ptolemy.actor.AtomicActor
_stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
SliderSource(CompositeEntity container, java.lang.String name)
          Construct an actor with an input multiport of type GENERAL.
 
Method Summary
 void attributeChanged(Attribute attribute)
          If the specified attribute is minimum or maximum, then set the range of the slider.
 java.lang.Object clone(Workspace workspace)
          Clone the actor into the specified workspace.
 void fire()
          Output the value of the slider recorded when prefire() is last called.
 java.awt.Color getBackground()
          Return the background.
 void initialize()
          Create a slider on the screen, if necessary.
 void place(java.awt.Container container)
          Specify the container in which the slider should be displayed.
 boolean prefire()
          Record the current value of the slider.
 void setBackground(java.awt.Color background)
          Set the background color.
 void setContainer(CompositeEntity container)
          Override the base class to remove the display from its graphical container if the argument is null.
 void stateChanged(javax.swing.event.ChangeEvent e)
          The value of the slider changed, record the new value.
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, attributeTypeChanged, clone, newPort, typeConstraintList
 
Methods inherited from class ptolemy.actor.AtomicActor
_createReceivers, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, postfire, preinitialize, pruneDependencies, removeDependency, stop, stopFire, terminate, wrapup
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_description, _exportMoMLContents, _removePort, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName, validateSettables
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.actor.Actor
getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
iterate, postfire, preinitialize, stop, stopFire, terminate, wrapup
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getFullName, getName, getName
 

Field Detail

minimum

public Parameter minimum
The minimum value of the slider. The value must be an integer. The default value is -10.


maximum

public Parameter maximum
The maximum value of the slider. The value must be an integer. The default value is 10.


slider

public javax.swing.JSlider slider
The slider that controls the output of this actor.


title

public StringAttribute title
The title to put on top.


_panel

protected javax.swing.JPanel _panel
Constructor Detail

SliderSource

public SliderSource(CompositeEntity container,
                    java.lang.String name)
             throws IllegalActionException,
                    NameDuplicationException
Construct an actor with an input multiport of type GENERAL.

Parameters:
container - The container.
name - The name of this actor.
Throws:
IllegalActionException - If the actor cannot be contained by the proposed container.
NameDuplicationException - If the container already has an entity with this name.
Method Detail

attributeChanged

public void attributeChanged(Attribute attribute)
                      throws IllegalActionException
If the specified attribute is minimum or maximum, then set the range of the slider.

Overrides:
attributeChanged in class NamedObj
Parameters:
attribute - The attribute that has changed.
Throws:
IllegalActionException - If the specified range for the slider is invalid.

clone

public java.lang.Object clone(Workspace workspace)
                       throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace. This calls the base class and then sets the slider public variable to null.

Overrides:
clone in class AtomicActor
Parameters:
workspace - The workspace for the new object.
Returns:
A new actor.
Throws:
java.lang.CloneNotSupportedException - If a derived class contains an attribute that cannot be cloned.

getBackground

public java.awt.Color getBackground()
Return the background.


fire

public void fire()
          throws IllegalActionException
Output the value of the slider recorded when prefire() is last called.

Specified by:
fire in interface Executable
Overrides:
fire in class Source
Throws:
IllegalActionException - Not thrown in this base class.

initialize

public void initialize()
                throws IllegalActionException
Create a slider on the screen, if necessary. If a graphical container has not been specified, place the slider into its own frame. Otherwise, place it in the specified container.

Specified by:
initialize in interface Executable
Overrides:
initialize in class AtomicActor
Throws:
IllegalActionException - If the parent class throws it.

place

public void place(java.awt.Container container)
Specify the container in which the slider should be displayed. An instance of JSlider will be added to that container. This method needs to be called before the first call to initialize(). Otherwise, an instance of JSlider will be placed in its own frame. The slider is also placed in its own frame if this method is called with a null argument. The background of the slider is set equal to that of the container (unless it is null).

Specified by:
place in interface Placeable
Parameters:
container - The container into which to place the slider.

prefire

public boolean prefire()
                throws IllegalActionException
Record the current value of the slider. This value is output in the subsequent firings of this actor.

Specified by:
prefire in interface Executable
Overrides:
prefire in class AtomicActor
Returns:
True if this actor is ready for firing, false otherwise.
Throws:
IllegalActionException - Not thrown in this base class.

setBackground

public void setBackground(java.awt.Color background)
Set the background color.


setContainer

public void setContainer(CompositeEntity container)
                  throws IllegalActionException,
                         NameDuplicationException
Override the base class to remove the display from its graphical container if the argument is null.

Overrides:
setContainer in class AtomicActor
Parameters:
container - The proposed container.
Throws:
IllegalActionException - If the base class throws it.
NameDuplicationException - If the base class throws it.

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
The value of the slider changed, record the new value.

Specified by:
stateChanged in interface javax.swing.event.ChangeListener