com.hdcookbook.grin.features
Class Modifier

java.lang.Object
  extended by com.hdcookbook.grin.Feature
      extended by com.hdcookbook.grin.features.Modifier
Direct Known Subclasses:
Clipped, Fade, GuaranteeFill, SEGenericModifier, SetTarget, SrcOver, Translator

public abstract class Modifier
extends Feature

Abstract base class for features that modify a single child feature.

Author:
Bill Foote (http://jovial.com)

Field Summary
protected  boolean activated
           
protected  Feature part
           
 
Fields inherited from class com.hdcookbook.grin.Feature
name, show
 
Constructor Summary
Modifier(Show show)
           
Modifier(Show show, java.lang.String name)
           
 
Method Summary
 void addDisplayAreas(RenderContext context)
          Add all of the areas that are displayed for this feature with the current frame.
 void addSubgraph(java.util.HashSet set)
          This is an implementation method that is not intended to be called direction by applications.
 void destroy()
          Free any resources held by this feature.
 Feature getPart()
          Get our child feature
 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.
 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 g)
          Paint the current state of this feature to gr.
protected  void setActivateMode(boolean mode)
          Change the activated mode of this feature.
protected  void setChildChanged()
          Set our child's drawing area(s) as modified, if we modify the appearance of our child node.
protected  int setSetupMode(boolean mode)
          Change the setup mode of this feature.
 void setup(Feature part)
          Called from the parser.
 
Methods inherited from class com.hdcookbook.grin.Feature
activate, cloneCommands, clonedReference, cloneSubgraph, createClone, deactivate, destroyClonedSubgraph, getName, initializeClone, 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

part

protected Feature part

activated

protected boolean activated
Constructor Detail

Modifier

public Modifier(Show show,
                java.lang.String name)

Modifier

public Modifier(Show show)
Method Detail

addSubgraph

public void addSubgraph(java.util.HashSet set)
This is an implementation method that is not intended to be called direction by applications. New subclasses of Feature may override this method, and must overrride it if they have children.

Add this node and all of its descendent nodes to the given set. The superclass definition of this method adds the current node. Any node types that have children should override this method to call the superclass version, then recursively invoke this method on each child.

Overrides:
addSubgraph in class Feature

setup

public void setup(Feature part)
Called from the parser.


getPart

public Feature getPart()
Get our child feature


getX

public int getX()
Get the upper-left hand corner of this feature as presently displayed. Return Integer.MAX_VALUE if this feature has no visible representation.

Specified by:
getX in class Feature
Returns:
the x coordinate

getY

public 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.

Specified by:
getY in class Feature
Returns:
the y coordinate

initialize

public void initialize()
Initialize this feature. This is called on show initialization. A show will initialize all of its features after it initializes the segments.

Specified by:
initialize in class Feature

destroy

public void destroy()
Free any resources held by this feature. It is the opposite of setup; each call to setup() shall be balanced by a call to unsetup(), and they shall *not* be nested.

It's possible an active segment may be destroyed. For example, the last segment a show is in when the show is destroyed will probably be active (and it will probably be an empty segment too!).

Specified by:
destroy in class Feature

setActivateMode

protected void setActivateMode(boolean mode)
Change the activated mode of this feature. The new mode will always be different than the old. Clients of the GRIN framework should never call this method directly. Custom feature extensions must implement this method.

Specified by:
setActivateMode in class Feature

setChildChanged

protected void setChildChanged()
Set our child's drawing area(s) as modified, if we modify the appearance of our child node. This is done when we are deactivated, because it's possible our children aren't deactivated at the same time.

See Also:
Feature.markDisplayAreasChanged()

setSetupMode

protected int setSetupMode(boolean mode)
Change the setup mode of this feature. The new mode will always be different than the old. Clients of the GRIN framework should never call this method directly. Custom feature extensions must implement this method.

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.

Specified by:
setSetupMode in class Feature

needsMoreSetup

public boolean needsMoreSetup()
This is where the feaure says whether or not it needs more setup. Calls to this are synchronized within the init manager to avoid race conditions. The implementation of this method must not call outside code or call any animation manager methods. For a given setup cycle, this method is called only after setup(). Clients of the GRIN framework should never call this method directly. Custom feature extensions must implement this method.

Specified by:
needsMoreSetup in class Feature
See Also:
SetupClient.needsMoreSetup()

paintFrame

public void paintFrame(java.awt.Graphics2D g)
Paint the current state of this feature to gr. Clients of the GRIN framework should not call this method directly. Feature subclasses must implement this method.

Specified by:
paintFrame in class Feature
Parameters:
g - The place to paint to.

markDisplayAreasChanged

public void markDisplayAreasChanged()
Mark the display areas of this feature as modified for the next call to addDisplayAreas. This can be called by a parent node on its children, e.g. when the parent is deactivated. This is necessary because a parent node might modify the drawing of its children (e.g. by setting an alpha value), and a parent might be taken out of a render tree when its children are not.

See also Issue 121

Specified by:
markDisplayAreasChanged in class Feature
See Also:
Feature.addDisplayAreas(com.hdcookbook.grin.animator.RenderContext)

addDisplayAreas

public void addDisplayAreas(RenderContext context)
Add all of the areas that are displayed for this feature with the current frame. This will be called exactly once per frame displayed on each activated feature.

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.

Subclasses will probably want to override this to account for changes in the drawing environment they make. The version in this class simply calls this method on the modified part.

Specified by:
addDisplayAreas in class Feature
Parameters:
context - The context for tracking rendering state
See Also:
DrawRecord

nextFrame

public void nextFrame()
Called from Segment with the Show lock held, to advance us to the state we should be in for the next frame.

Specified by:
nextFrame in class Feature