Package ptolemy.domains.gr.lib
Class ViewScreen2D
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Placeable
,Initializable
,TypedActor
,ViewScreenInterface
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class ViewScreen2D extends GRActor2D implements Placeable, ViewScreenInterface
A sink actor that renders a two-dimensional scene into a display screen. All mouse and keyboard events within the viewscreen are handled by a ViewScreen2DListener.- Since:
- Ptolemy II 4.0
- Version:
- $Id$
- Author:
- Steve Neuendorffer, Ismael M. Sarmiento
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Yellow (ismael)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ViewScreen2D.ViewScreen2DListener
Listen for Layer, LayerMotion and Key events.-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description ColorAttribute
backgroundColor
The red, green, blue, and alpha components of the background color of the viewscreen.Parameter
horizontalPixels
The horizontal resolution of the display screen.Parameter
lowerRightX
The x coordinate of the canvas point visible in the lower right corner of the display screen.Parameter
lowerRightY
The y coordinate of the canvas point visible in the lower right corner of the display screen.Parameter
rotatable
Boolean variable that determines if the user is allowed to rotate the scene.Parameter
scalable
Boolean variable that determines if the user is allowed to scale the scene.TypedIOPort
sceneGraphIn
The input scene graph.Parameter
showAxes
Boolean variable that determines if the axes crosshairs are shown This parameter should contain a BooleanToken.Parameter
translatable
Boolean variable that determines if the user is allowed to translate the scene.Parameter
upperLeftX
The x coordinate of the canvas point visible in the upper left corner of the display screen.Parameter
upperLeftY
The y coordinate of the canvas point visible in the upper left corner of the display screen.Parameter
verticalPixels
The vertical resolution of the display screen.-
Fields inherited from class ptolemy.domains.gr.kernel.GRActor2D
_viewScreen
-
Fields inherited from class ptolemy.domains.gr.kernel.GRActor
_allowAttributeChanges, _isSceneGraphInitialized
-
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 ViewScreen2D(CompositeEntity container, java.lang.String name)
Construct a ViewScreen2D in the given container with the given name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_addChild(Figure figure)
Add a figure to the figure layer and set its interactor.protected void
_createViewScreen2D()
Create the view screen component.protected int
_getHorizontalPixels()
Return the horizontal pixels by reading the horizontalPixels parameter.protected int
_getVerticalPixels()
Return the vertical pixels by reading the verticalPixels parameter.protected boolean
_isRotatable()
Return the value of the rotatable parameter.protected boolean
_isScalable()
Return the value of the scalable parameter.protected boolean
_isTranslatable()
Return the value of the translatable parameter.protected void
_makeSceneGraphConnection()
Set up the scene graph connections of this actor.void
fire()
Repaint the canvas.JCanvas
getCanvas()
Return the Diva canvas used by this view screen.BasicFigure
getCrosshairX()
Return the horizontal component of the crosshair which marks the origin.BasicFigure
getCrosshairY()
Return the vertical component of the crosshair which marks the origin.java.awt.geom.Point2D.Double
getOrigin()
Return the location of the origin of the viewscreen.Figure
getSelectedFigure()
Return the figure currently selected in the viewscreen.void
initialize()
Initialize the execution.void
place(java.awt.Container container)
Set the container that this actor should display data in.void
setSelectedFigure(Figure figure)
Update the state of this object to reflect which figure is currently selected in the viewscreen.void
wrapup()
Wrap up an execution.-
Methods inherited from class ptolemy.domains.gr.kernel.GRActor2D
_setViewScreen
-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, 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, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate
-
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, attributeChanged, 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, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
backgroundColor
public ColorAttribute backgroundColor
The red, green, blue, and alpha components of the background color of the viewscreen. This parameter must contain an array of double values. The default value is {1.0, 1.0, 1.0, 1.0}, corresponding to opaque white.
-
sceneGraphIn
public TypedIOPort sceneGraphIn
The input scene graph.
-
horizontalPixels
public Parameter horizontalPixels
The horizontal resolution of the display screen. This parameter should contain a IntToken. The default value of this parameter is the IntToken 400.
-
rotatable
public Parameter rotatable
Boolean variable that determines if the user is allowed to rotate the scene. This parameter should contain a BooleanToken. The default value of this parameter is BooleanToken true.
-
scalable
public Parameter scalable
Boolean variable that determines if the user is allowed to scale the scene. This parameter should contain a BooleanToken. The default value of this parameter is BooleanToken false.
-
showAxes
public Parameter showAxes
Boolean variable that determines if the axes crosshairs are shown This parameter should contain a BooleanToken. The default value of this parameter is BooleanToken true.
-
translatable
public Parameter translatable
Boolean variable that determines if the user is allowed to translate the scene. This parameter should contain a BooleanToken. The default value of this parameter is BooleanToken false.
-
verticalPixels
public Parameter verticalPixels
The vertical resolution of the display screen. This parameter should contain a IntToken. The default value of this parameter is IntToken 400.
-
upperLeftX
public Parameter upperLeftX
The x coordinate of the canvas point visible in the upper left corner of the display screen.
-
upperLeftY
public Parameter upperLeftY
The y coordinate of the canvas point visible in the upper left corner of the display screen.
-
lowerRightX
public Parameter lowerRightX
The x coordinate of the canvas point visible in the lower right corner of the display screen.
-
lowerRightY
public Parameter lowerRightY
The y coordinate of the canvas point visible in the lower right corner of the display screen.
-
-
Constructor Detail
-
ViewScreen2D
public ViewScreen2D(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct a ViewScreen2D in the given container with the given name. If the container argument is null, a NullPointerException will be thrown. If the name argument is null, then the name is set to the empty string. Increment the version number of the workspace.- Parameters:
container
- Container of the director.name
- Name of this ViewScreen2D.- Throws:
IllegalActionException
- If this actor is not compatible with the specified container.NameDuplicationException
- If the container not a CompositeActor and the name collides with an entity in the container.
-
-
Method Detail
-
fire
public void fire() throws IllegalActionException
Repaint the canvas.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classGRActor
- Throws:
IllegalActionException
- If an error occurs during the scene graph initialization.
-
getCanvas
public JCanvas getCanvas()
Return the Diva canvas used by this view screen.- Returns:
- The Diva canvas.
-
getCrosshairX
public BasicFigure getCrosshairX()
Return the horizontal component of the crosshair which marks the origin.- Returns:
- The horizontal component of the crosshair which marks the origin.
-
getCrosshairY
public BasicFigure getCrosshairY()
Return the vertical component of the crosshair which marks the origin.- Returns:
- The vertical component of the crosshair which marks the origin.
-
getOrigin
public java.awt.geom.Point2D.Double getOrigin()
Return the location of the origin of the viewscreen.- Returns:
- The origin of the viewscreen.
-
getSelectedFigure
public Figure getSelectedFigure()
Return the figure currently selected in the viewscreen.- Returns:
- The figure currently selected in the viewscreen.
- See Also:
setSelectedFigure(Figure figure)
-
initialize
public void initialize() throws IllegalActionException
Initialize the execution. Create the ViewScreen2D frame if it hasn't been set using the place() method.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classGRActor
- Throws:
IllegalActionException
- If the base class throws it.
-
place
public void place(java.awt.Container container)
Set the container that this actor should display data in. If place is not called, then the actor will create its own frame for display.
-
setSelectedFigure
public void setSelectedFigure(Figure figure)
Update the state of this object to reflect which figure is currently selected in the viewscreen.- Parameters:
figure
- The figure currently selected.- See Also:
getSelectedFigure()
-
wrapup
public void wrapup() throws IllegalActionException
Wrap up an execution.- Specified by:
wrapup
in interfaceInitializable
- Overrides:
wrapup
in classGRActor
- Throws:
IllegalActionException
- If the base class throws it.
-
_addChild
protected void _addChild(Figure figure) throws IllegalActionException
Add a figure to the figure layer and set its interactor.- Parameters:
figure
- The figure that is to be added.- Throws:
IllegalActionException
- Always thrown for this base class.
-
_createViewScreen2D
protected void _createViewScreen2D() throws IllegalActionException
Create the view screen component. If place() was called with a container, then use the container. Otherwise, create a new frame and use that.- Throws:
IllegalActionException
- If there is a problem reading a parameter.
-
_getHorizontalPixels
protected int _getHorizontalPixels() throws IllegalActionException
Return the horizontal pixels by reading the horizontalPixels parameter.- Returns:
- the horizontal pixels.
- Throws:
IllegalActionException
- If thrown while reading the parameter.
-
_getVerticalPixels
protected int _getVerticalPixels() throws IllegalActionException
Return the vertical pixels by reading the verticalPixels parameter.- Returns:
- the vertical pixels.
- Throws:
IllegalActionException
- If thrown while reading the parameter.
-
_isRotatable
protected boolean _isRotatable() throws IllegalActionException
Return the value of the rotatable parameter.- Returns:
- The value of the rotatable parameter.
- Throws:
IllegalActionException
- If thrown while reading the parameter.
-
_isScalable
protected boolean _isScalable() throws IllegalActionException
Return the value of the scalable parameter.- Returns:
- The value of the scalable parameter.
- Throws:
IllegalActionException
- If thrown while reading the parameter.
-
_isTranslatable
protected boolean _isTranslatable() throws IllegalActionException
Return the value of the translatable parameter.- Returns:
- The value of the tranlatable parameter.
- Throws:
IllegalActionException
- If thrown while reading the parameter.
-
_makeSceneGraphConnection
protected void _makeSceneGraphConnection() throws IllegalActionException
Set up the scene graph connections of this actor.- Specified by:
_makeSceneGraphConnection
in classGRActor
- Throws:
IllegalActionException
- Always thrown for this base class.
-
-