Package ptolemy.actor.lib.gui
Class SliderSource
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,java.util.EventListener
,javax.swing.event.ChangeListener
,Actor
,Executable
,FiringsRecordable
,Placeable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
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$
- Author:
- Xiaojun Liu, Gang Zhou
- Pt.AcceptedRating:
- Red (liuxj)
- Pt.ProposedRating:
- Red (liuxj)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SliderSource.SliderFrame
The frame for the slider.-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description Parameter
majorTickSpacing
The major tick spacing of the slider.Parameter
maximum
The maximum value of the slider.Parameter
minimum
The minimum value of the slider.Parameter
minorTickSpacing
The minor tick spacing 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
_triggered, output, trigger
-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description SliderSource(CompositeEntity container, java.lang.String name)
Construct an actor with an input multiport of type GENERAL.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 of the panel that contains the slider.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.lib.Source
_customTypeConstraints
-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, stop, stopFire, terminate, wrapup
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, postfire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
slider
public javax.swing.JSlider slider
The slider that controls the output of this actor.
-
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.
-
majorTickSpacing
public Parameter majorTickSpacing
The major tick spacing of the slider. The value must be an integer. The default value is 10.
-
minorTickSpacing
public Parameter minorTickSpacing
The minor tick spacing of the slider. The value must be an integer. The default value is 1.
-
title
public StringAttribute title
The title to put on top.
-
-
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 classNamedObj
- 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 classTypedAtomicActor
- 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.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
fire
public void fire() throws IllegalActionException
Output the value of the slider recorded when prefire() is last called.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classSource
- Throws:
IllegalActionException
- Not thrown in this base class.
-
getBackground
public java.awt.Color getBackground()
Return the background.- Returns:
- The background color.
- See Also:
setBackground(Color)
-
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 interfaceInitializable
- Overrides:
initialize
in classAtomicActor<TypedIOPort>
- 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).
-
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 interfaceExecutable
- Overrides:
prefire
in classSource
- Returns:
- True, unless the trigger input is connected and has no input.
- Throws:
IllegalActionException
- If checking the trigger for a token throws it or if the super class throws it.
-
setBackground
public void setBackground(java.awt.Color background)
Set the background color of the panel that contains the slider.- Parameters:
background
- The background color.- See Also:
getBackground()
-
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 classAtomicActor<TypedIOPort>
- Parameters:
container
- The proposed container.- Throws:
IllegalActionException
- If the base class throws it.NameDuplicationException
- If the base class throws it.- See Also:
ComponentEntity.getContainer()
-
stateChanged
public void stateChanged(javax.swing.event.ChangeEvent e)
The value of the slider changed, record the new value.- Specified by:
stateChanged
in interfacejavax.swing.event.ChangeListener
-
-