com.hdcookbook.grin.features
Class GuaranteeFill

java.lang.Object
  extended by com.hdcookbook.grin.Feature
      extended by com.hdcookbook.grin.features.Modifier
          extended by com.hdcookbook.grin.features.GuaranteeFill
All Implemented Interfaces:
Node

public class GuaranteeFill
extends Modifier
implements Node

Guarantees that its children will completely fill a given rectangle on the screen with source-mode drawing. In other words, this node and its children guarantee that they will completely paint every pixel within a given rectangle.

This node has a feature to paint transparent pixels (in the current drawing mode) in rectangular areas. This allows an author to guarantee filling a large rectangular area composed of small rectangular items (like images drawn in Src mode) that have small gaps between them -- in this case, the GuaranteeFill node can fill in those gaps. This node paints those fill areas before it paints its children.

If this node is a child of a node that sets SrcOver drawing mode, then the guarantee will not apply. In other words, it's OK as far as correctness is concerned to put a structure including a GuaranteeFill node under a SrcOver node or a Fade node, but you won't see any increase in redraw efficiency due to the GuaranteeFill node in this case.

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

Field Summary
protected  java.awt.Rectangle[] fills
           
protected  java.awt.Rectangle guaranteed
           
 
Fields inherited from class com.hdcookbook.grin.features.Modifier
activated, part
 
Fields inherited from class com.hdcookbook.grin.Feature
name, show
 
Constructor Summary
GuaranteeFill(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 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.
protected  void setChildChanged()
          Set our child's drawing area(s) as modified, if we modify the appearance of our child node.
 
Methods inherited from class com.hdcookbook.grin.features.Modifier
addSubgraph, destroy, getPart, getX, getY, initialize, markDisplayAreasChanged, needsMoreSetup, nextFrame, setActivateMode, setSetupMode, setup
 
Methods inherited from class com.hdcookbook.grin.Feature
activate, cloneCommands, clonedReference, cloneSubgraph, 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

guaranteed

protected java.awt.Rectangle guaranteed

fills

protected java.awt.Rectangle[] fills
Constructor Detail

GuaranteeFill

public GuaranteeFill(Show show)
Method Detail

createClone

protected Feature createClone(java.util.HashMap clones)
This is an implementation method that should not be called direction by applications; applications should call cloneSubgraph(). New subclasses of Feature that wish to support cloning must override this method.

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.

Overrides:
createClone in class Feature
Parameters:
clones - A map from original feature to cloned feature. Entries are added by Feature.makeNewClone().
See Also:
Feature.makeNewClone(java.util.HashMap), Feature.cloneSubgraph(java.util.HashMap)

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.

Overrides:
setChildChanged in class Modifier
See Also:
Feature.markDisplayAreasChanged()

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.

Overrides:
addDisplayAreas in class Modifier
Parameters:
context - The context for tracking rendering state
See Also:
DrawRecord

paintFrame

public void paintFrame(java.awt.Graphics2D gr)
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.

Overrides:
paintFrame in class Modifier
Parameters:
gr - The place to paint to.

readInstanceData

public void readInstanceData(GrinDataInputStream in,
                             int length)
                      throws java.io.IOException
Description copied from interface: Node
Reads in this node information from the binary file format.

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.

Specified by:
readInstanceData in interface Node
Parameters:
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.
Throws:
java.io.IOException - if error occurs.
See Also:
GrinDataInputStream.readSuperClassData(Feature), GrinDataInputStream.readSuperClassData(RCHandler), GrinDataInputStream.readSuperClassData(Segment), GrinDataInputStream.readSuperClassData(Command)