Module org.bzdev.anim2d
Package org.bzdev.anim2d
Class DirectedObject2DFactory<Obj extends DirectedObject2D>
java.lang.Object
org.bzdev.obnaming.NamedObjectFactory<F,Simulation,SimObject,OBJ>
org.bzdev.devqsim.SimObjectFactory<AnimationObject2DFactory<Obj>,Animation2D,Obj>
org.bzdev.anim2d.AnimationObject2DFactory<Obj>
org.bzdev.anim2d.PlacedObject2DFactory<Obj>
org.bzdev.anim2d.DirectedObject2DFactory<Obj>
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
AbstrGraphViewFactory
public abstract class DirectedObject2DFactory<Obj extends DirectedObject2D>
extends PlacedObject2DFactory<Obj>
Abstract DirectedObject2D factory.
This factory extends the parameters provided by its superclass
by adding new timeline subparameters. As with the timeline parameters
of its superclass, these parameters use an integer-valued key to
distinguish various timeline entries.
These subparameters are as follows (all apply at the time specified by
"timeline.time" defined in AnimationObject2DFactory):
- "timeline.path" - the path that the object should follow.
If 'animation' is the current Animation2D,
animation.nullPath()
will provide a constant path that indicates that the path should no longer be used. If no value is given, the value is not changed. - "timeline.u0" - the initial value of the path's parameter (the default is 0.0)
- "timeline.t0" - the initial time interval from the time at which the path is set to wait before the object can move.
- "timeline.velocity" - the velocity along the path
- "timeline.acceleration" - the acceleration along the path
- "timeline.angleRelative" - true if "timeline.pathAngle" gives the angle relative to a tangent of the path, false if it does not, no change if not defined.
- "timeline.pathAngle" - the angle in degrees of the object with respect to the path (unchanged if not defined).
- "timeline.angularVelocity" - the angular velocity used in determining the path angle as a function of time (if not defined, the value does not change), in units of degrees per unit animation time.
- "timeline.angularAcceleration" - the angular acceleration used in determining the path angle as a function of time (if not defined, the value does not change), in units of degrees/(unit-animation-time)2.
- "timeline.distanceFunction" - a SimFunction object associated with
this animation giving the distance along the path as a function of
time. If 'animation' is the current Animation2D,
animation.nullFunction()
will provide a function that indicates that the current function should no longer be used. If no value is given, the function is not changed. - "timeline.angleFunction" - a SimFunction object associated
with this animation giving the angle of the object as it
moves along the path as a function of time. If 'animation'
is the current Animation2D,
animation.nullFunction()
will provide a function that indicates that the current function should no longer be used. If no value is given, the function is not changed. The value returned is in radians, not degrees. If a path is currently defined, the time argument treats an argument of zero as the time indicated by the path's "timeline.t0" parameter. Otherwise the argument refers to simulation time. The argument uses double-precision time units (not ticks).
As a convenience, the parameters defined in superclasses are listed:
- "traceSets" - a set of TraceSets a SimObject will use for tracing. One should use the add and remove factory methods as this parameter refers to a set of values.
- "zorder" - the initial stacking order (objects with smaller zorder values are rendered first). The zorder is defined as a long integer. The default value is 0. If two objects have the same zorder value the rendering order is technically indeterminate, but in practice the object created first will be rendered first (valid for the first 263-1 objects created).
- "visible" - true if the object is visible; false if it is not. The default value is "true".
- "refPointMode" - the configuration mode. For each value,
there are one or two parameters that can be set. The
configuration-mode values are
-
BY_NAME
- for this value the following parameter must be used:- "refPointName" - a symbolic name for a
reference point (
UPPER_LEFT
,UPPER_CENTER
,UPPER_RIGHT
,LOWER_LEFT
,CENTER_LEFT
,CENTER
,CENTER_RIGHT
,LOWER_CENTER
, orLOWER_RIGHT
) relative to the object's bounding box.
- "refPointName" - a symbolic name for a
reference point (
-
BY_COORD
- "refPointX" - the X coordinate of the reference point in graph coordinate space (the default is 0.0, and by convention should correspond to a centered object or some distinguished feature). The object will be drawn at this point when given coordinates of (0,0, 0.0) in graph coordinate space.
- "refPointY" - the Y coordinate of the reference point in graph coordinate space (the default is 0.0, and by convention should correspond to a centered object or some distinguished feature). The object will be drawn at this point when given coordinates of (0,0, 0.0) in graph coordinate space.
-
BY_FRACTION
- "refPointFractX" - the X position of the reference point as a fractional distance between the smallest X value of the object's bounding box and the largest X value of the object's bounding box, with the smallest value indicated by 0.0 and the largest value by 1.0.
- "refPointFractY" - the Y position of the reference point as a fractional distance between the smallest Y value of the object's bounding box and the largest Y value of the object's bounding box, with the smallest value indicated by 0.0 and the largest value by 1.0.
-
- "initialX" - the initial X coordinate of the object in graph coordinate space.
- "initialY" - the initial Y coordinate of the object in graph coordinate space.
- "initialAngle" - the initial angle of the object in graph coordinate space, measured in degrees.
- "timeline" - an integer-keyed set of values that define
changes in an object's configuration.
- "timeline.time" - the time at which timeline parameters are to change (typically measured in seconds, not simulation ticks). This parameter must be provided.
- "timeline.x" - the X coordinate of the reference point at the specified time, provided in graph coordinate space units. If this parameter is not defined for the key, the previous value is not changed.
- "timeline.y" - the Y coordinate of the reference point at the specified time, provided in graph coordinate space units. If this parameter is not defined for the key, the previous value is not changed.
- "timeline.angle" - the angle about the reference point at the specified time, with 0.0 referring to a reference direction (increasing angles are in the counterclockwise direction with 0.0 being a default, typically relative to a the coordinate system or to a path the object follows). If this parameter is not defined for the key, the previous value is not changed. The angle is measured in degrees.
- "timeline.traceSetMode" - indicates how the parameter
"timeline.traceSets" is interpretted. the values are
enumeration constants of type
TraceSetMode
and are used as follows:-
KEEP
- keep the existing trace sets, adding additional ones specified by the parameter "timeline.traceSets". -
REMOVE
- remove the trace sets specified by the parameter "timeline.traceSets". -
REPLACE
- remove all existing trace sets and repalce those with the ones specified by the timeline.traceSets parameter.
-
- "timeline.traceSets" - a parameter representing a set of TraceSet objects (the three-argument 'add' method is used to add entries).
- "timeline.visible" -the visibility of the object (true if visible; false if not visible. If this parameter is not defined for the key, the previous value is not changed.
- "timeline.zorder" - the zorder for the object. If this parameter is not defined for the key, the previous value is not changed.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bzdev.anim2d.PlacedObject2DFactory
PlacedObject2DFactory.RefPointMode
Nested classes/interfaces inherited from class org.bzdev.obnaming.NamedObjectFactory
NamedObjectFactory.ConfigException, NamedObjectFactory.IndexedSetter, NamedObjectFactory.ParmNameIterator
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addToTimelineRequest
(Obj object, int key, double time) Request subclasses to add entries to the timeline.void
clear()
Clear all entries and restore to default values.protected void
setDefaultAngleRelative
(boolean value) Set the default value for the angleRelative timeline entry.Methods inherited from class org.bzdev.anim2d.PlacedObject2DFactory
initObject, mayIgnoreTimelineAngle
Methods inherited from class org.bzdev.anim2d.AnimationObject2DFactory
getAnimation, getVisibility, getZorder, setAnimationObjectDefaults
Methods inherited from class org.bzdev.devqsim.SimObjectFactory
addToTimelineResponse, getSimulation
Methods inherited from class org.bzdev.obnaming.NamedObjectFactory
add, add, add, add, add, add, add, add, addDocResourceBundle, addDocResourceBundle, addJDoc, addJDoc, addLabelResourceBundle, addLabelResourceBundle, addTipResourceBundle, addTipResourceBundle, arrayInit, canAdd3, clear, configure, configureSupported, containsParm, createObject, createObject, createObject, createObject, createObjects, createObjects, createObjects, createObjects, createObjects, createObjects, doAfterInits, endObjectCreation, getDoc, getFactoryClass, getGLB, getLabel, getLayoutResource, getListedFactories, getLUB, getNextName, getNextNameIndex, getObjectNamer, getParmKeyType, getParmPrefix, getRVMode, getTemplateKeyMap, getTemplateKeyMapForFactories, getTemplateKeyMapForFactories, getTemplateKeyMapForFactories, getTip, getType, glbInRange, initParm, initParms, initParms, isClearOnly, isNamedObject, isRandomVariable, keyType, lubInRange, mustAdd, newConfigExceptionInstance, newConfigExceptionInstance, newConfigExceptionInstance, newConfigExceptionInstance, newConfigExceptionInstance, newConfigExceptionInstance, newConfigExceptionInstance, newInstance, newInstance, newObject, parmNames, parmNameSet, parmPrefixes, remove, remove, remove, remove, remove, remove, remove, remove, removeParm, removeParms, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, setDocAPIBase, setInterned, setLayoutResource, setLayoutResource, setNameRoot, setTarget, startObjectCreation, unset, unset, unset, unset, unset, unset, willIntern
-
Constructor Details
-
DirectedObject2DFactory
Constructor.- Parameters:
a2d
- the animation
-
-
Method Details
-
setDefaultAngleRelative
protected void setDefaultAngleRelative(boolean value) Set the default value for the angleRelative timeline entry. If not called, the value will betrue
. For some subclasses (e.g., AbstractGraphViewFactory), the default should befalse
.- Parameters:
value
- the value for the default
-
clear
public void clear()Description copied from class:NamedObjectFactory
Clear all entries and restore to default values. Note: each subclass that implements this method should callsuper.clear()
. Any subclass that defines parameters should call this method in order to restore the parameters to their default values. When an annotation processor is used for some parameters, those parameters can be restored to their default value by calling the parm manager's setDefaults method with the factory as its argument.- Overrides:
clear
in classPlacedObject2DFactory<Obj extends DirectedObject2D>
-
addToTimelineRequest
Request subclasses to add entries to the timeline. Each subclass adding entries should create a Callable that performs any necessary changes, which should be returned via a call to addToTimelineResponse, and each subclass that implements addToTimelineRequest must call super.addToTimelineRequest(object, key).- Overrides:
addToTimelineRequest
in classPlacedObject2DFactory<Obj extends DirectedObject2D>
- Parameters:
object
- the object being configured.key
- the timeline keytime
- the time for with the timeline entry
-