|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.hdcookbook.grin.Feature com.hdcookbook.grin.features.InterpolatedModel
public class InterpolatedModel
An InterpolatedModel is a feature that controls one or more integer factors, and interpolates their values according to keyframes. This is used by other features to animate the parameters in queestion. At the end of the sequence, the InterpolatedModel can kick off a list of commands, it can repeat the animation, or it can stick at the last frame.
An InterpolatedModel with no values can function as a timer. A timer simply has a number of keyframes, and triggers a set of commands after those keyframes.
Translator
Field Summary | |
---|---|
protected int[] |
currValues
|
protected Command[] |
endCommands
|
protected int[] |
frames
|
protected int |
loopCount
|
protected int |
repeatFrame
|
static int |
SCALE_X_FACTOR_FIELD
For a scale_model, the field for the horizontal scale factor in mills (1/1000) |
static int |
SCALE_X_FIELD
For a scale_model, the field for the X value |
static int |
SCALE_Y_FACTOR_FIELD
For a scale_model, the field for the horizontal scale factor in mills (1/1000) |
static int |
SCALE_Y_FIELD
For a scale_model, the field for the Y value |
protected int[][] |
values
|
Fields inherited from class com.hdcookbook.grin.Feature |
---|
name, show |
Constructor Summary | |
---|---|
InterpolatedModel(Show show)
|
Method Summary | |
---|---|
void |
addDisplayAreas(RenderContext context)
Add all of the areas that are displayed for this feature with the current frame. |
protected Feature |
createClone(java.util.HashMap clones)
This is an implementation method that should not be called direction by applications; applications should call cloneSubgraph(). |
void |
destroy()
Free any resources held by this feature. |
Command[] |
getEndCommands()
Return the list of commands that are executed at the end of doing our translation. |
int |
getField(int fieldNum)
Give the current value for the given field |
int |
getX()
Get the upper-left hand corner of this feature as presently displayed. |
int |
getY()
Get the upper-left hand corner of this feature as presently displayed Return Integer.MAX_VALUE if this feature has no visible representation. |
void |
initialize()
Initialize this feature. |
protected void |
initializeClone(Feature original,
java.util.HashMap clones)
This is an implementation method that should not be called direction by applications; it is called from cloneSubgraph(). |
void |
markDisplayAreasChanged()
Mark the display areas of this feature as modified for the next call to addDisplayAreas. |
boolean |
needsMoreSetup()
This is where the feaure says whether or not it needs more setup. |
void |
nextFrame()
Called from Segment with the Show lock held, to advance us to the state we should be in for the next frame. |
void |
paintFrame(java.awt.Graphics2D gr)
Paint the current state of this feature to gr. |
void |
readInstanceData(GrinDataInputStream in,
int length)
Reads in this node information from the binary file format. |
boolean |
scaleBounds(int x,
int y,
int width,
int height,
java.awt.Rectangle scaledBounds)
Scale the x, y, width and heigh values according to the current values of SCALE_X_FIELD, SCALE_Y_FIELD, SCALE_X_FACTOR_FIELD and SCALE_Y_FACTOR_FIELD, storing them in scaledBounds. |
protected void |
setActivateMode(boolean mode)
Change the activated mode of this feature. |
void |
setField(int fieldNum,
int value)
Sets the value of a field to value. |
protected int |
setSetupMode(boolean mode)
Change the setup mode of this feature. |
Methods inherited from class com.hdcookbook.grin.Feature |
---|
activate, addSubgraph, cloneCommands, clonedReference, cloneSubgraph, deactivate, destroyClonedSubgraph, getName, isSetup, makeNewClone, resetFeature, sendFeatureSetup, setName, setup, toString, unsetup |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int SCALE_X_FIELD
public static final int SCALE_Y_FIELD
public static final int SCALE_X_FACTOR_FIELD
public static final int SCALE_Y_FACTOR_FIELD
protected int[] frames
protected int[] currValues
protected int[][] values
protected int repeatFrame
protected int loopCount
protected Command[] endCommands
Constructor Detail |
---|
public InterpolatedModel(Show show)
show
- The show this feature is attached to. The value
can be null, as long as it's set to a real value
before the feature is used.Method Detail |
---|
protected Feature createClone(java.util.HashMap clones)
Create a new clone of this feature. This method creates a new instance of this feature, and creates new instances of any sub-features, but it does not initialize the feature. This method is called from Feature.makeNewClone().
See the documentation of cloneSubgraph() for a list of runtime exceptions this method can throw. Subclasses that wish to support cloning must override this method.
createClone
in class Feature
clones
- A map from original feature to cloned feature. Entries
are added by Feature.makeNewClone().Feature.makeNewClone(java.util.HashMap)
,
Feature.cloneSubgraph(java.util.HashMap)
protected void initializeClone(Feature original, java.util.HashMap clones)
Initialize this cloned feature from its original. This is called after the entire subgraph has been cloned, so the HashMap containing the set of clones will be complete. See the documentation of cloneSubgraph() for a list of runtime exceptions this method can throw. Subclasses that wish to support cloning must override this method.
If this feature doesn't need initialization it's OK for a feature to not implement it; the default version of this method does nothing. Typically, you only need to implement this for features that have references to other features that aren't sub-features, or that have commands that might have references to other features.
initializeClone
in class Feature
Feature.cloneSubgraph(java.util.HashMap)
public final int getField(int fieldNum)
fieldNum
- The field number, counting from 0public final void setField(int fieldNum, int value)
SCALE_X_FIELD
,
SCALE_Y_FIELD
,
SCALE_X_FACTOR_FIELD
,
SCALE_Y_FACTOR_FIELD
,
Translator.X_FIELD
,
Translator.Y_FIELD
public int getX()
Since an InterpolatedModel is invisible, this returns a very large value (Integer.MAX_VALUE)
getX
in class Feature
public int getY()
Since an InterpolatedModel is invisible, this returns a very large (Integer.MAX_VALUE)
getY
in class Feature
public Command[] getEndCommands()
public void initialize()
initialize
in class Feature
public void destroy()
Features are deactivated before they are destroyed. For example, the last segment a show is in when the show is destroyed will probably be active, but it is deactivated and unsetup() is called in Show.destroy() before the features are destroyed.
Cloned features are handled a little differently. They have destroy() called from within Feature.destroyClonedSubgraph(). Since cloned fetures are exempt from the setup/unsetup lifecycle, the cloned feature will not be activated, but will be in a setup state when destroy() is called. Features that support cloning must therefore release any resources they acquired in createClone() or initializeClone() during the call to destroy().
Clients of the GRIN framework should never call this method directly. Custom feature extensions must implement this method.
destroy
in class Feature
protected void setActivateMode(boolean mode)
Feature
setActivateMode
in class Feature
protected int setSetupMode(boolean mode)
Feature
This method must return a guaranteed lower bound for the number of times it will send a feature setup command as a result of this call. That is, it must send at least as many feature setup commands to the segment as the number returned; sending an accurate number makes the setup process more efficient, since the time it takes to process a command scales with the number of features in a segment. When mode is false, 0 should be returned.
setSetupMode
in class Feature
public boolean needsMoreSetup()
needsMoreSetup
in class Feature
SetupClient.needsMoreSetup()
public void nextFrame()
nextFrame
in class Feature
public void markDisplayAreasChanged()
See also Issue 121
markDisplayAreasChanged
in class Feature
Feature.addDisplayAreas(com.hdcookbook.grin.animator.RenderContext)
public void addDisplayAreas(RenderContext context)
A feature that displays something needs to maintain a record of it in a DrawRecord. The animation framework uses this to track what needs to be erased and drawn from frame to frame.
Clients of the GRIN framework should not call this method directly. Feature subclasses must implement this method.
addDisplayAreas
in class Feature
context
- The context for tracking rendering stateDrawRecord
public void paintFrame(java.awt.Graphics2D gr)
paintFrame
in class Feature
gr
- The place to paint to.public void readInstanceData(GrinDataInputStream in, int length) throws java.io.IOException
Node
An implementation of this method is recommended to call in.readSuperClassData(this) as the first line of the method to read in information that is defined in the base class of this Node type.
This should only be called while initializing this object.
readInstanceData
in interface Node
in
- InputStream to read data from.length
- the number of bytes that this node's information occupies
in the InputStream. The implementation of this method is expected to
read exactly this number of bytes from the stream. This can be used
for a debugging purpose.
java.io.IOException
- if error occurs.GrinDataInputStream.readSuperClassData(Feature)
,
GrinDataInputStream.readSuperClassData(RCHandler)
,
GrinDataInputStream.readSuperClassData(Segment)
,
GrinDataInputStream.readSuperClassData(Command)
public boolean scaleBounds(int x, int y, int width, int height, java.awt.Rectangle scaledBounds)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |