com.hdcookbook.grin.io
Class ShowBuilder

java.lang.Object
  extended by com.hdcookbook.grin.io.ShowBuilder
Direct Known Subclasses:
GuiShowBuilder

public class ShowBuilder
extends java.lang.Object

A helper class for parsing a show. Clients of the parser can subclass this to intercept items as they are encountered.

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

Field Summary
protected  SEShow show
           
 
Constructor Summary
ShowBuilder()
           
 
Method Summary
 void addCommand(Command command, int line)
          Called when a new command is encountered.
 void addDeferredBuilder(DeferredBuilder builder)
          Called when a DeferrredBuilder is created.
 void addFeature(java.lang.String name, int line, Feature f)
          Called when a new feature is encountered.
 void addNamedCommand(java.lang.String name, int line, Command c)
          Called when a new named command is encountered
 void addRCHandler(java.lang.String name, int line, RCHandler hand)
          Called when a new remote control handler is encountered.
 void addSegment(java.lang.String name, int line, Segment s)
          Called when a new segment is encountered.
 void addSyntheticFeature(Feature f)
          Add a feature that's created programmatically during show construction, e.g.
 void finishBuilding()
          Called when the show has finished parsing and all forward references have been resolved.
 ExtensionParser getExtensionParser()
          Returns an instance of ExtensionParser that this Builder is working with, or null if it is not set.
 int getFontIndex(FontSpec spec)
           
 Command getNamedCommand(java.lang.String name)
          Look up a command in the list of all named commands.
 Feature getNamedFeature(java.lang.String name)
          Look up a feature in the list of all named features.
 RCHandler getNamedRCHandler(java.lang.String name)
          Look up an RC handler in the list of all named handlers.
 Segment getNamedSegment(java.lang.String name)
          Look up a segment in the list of all named segments.
 SEShow getShow()
           
 void init(SEShow show)
           
 void injectParent(Feature newFeature, Feature child)
          Add a feature that's created programmatically during show construction, and inject it as the parent of the child node passed in.
 InterpolatedModel makeInterpolatedModel(java.lang.String name, int[] frames, int[][] values, int repeatFrame, int loopCount, Command[] commands, java.lang.Class clazz)
           
 InterpolatedModel makeScalingModel(java.lang.String name, int[] frames, int[][] values, int repeatFrame, int loopCount, Command[] commands)
           
 InterpolatedModel makeTimer(java.lang.String name, int numFrames, boolean repeat, Command[] commands)
           
 SETranslatorModel makeTranslatorModel(java.lang.String name, int[] frames, int[][] values, boolean isRelative, int repeatFrame, int loopCount, Command[] commands)
           
 void setBinaryGrinFileName(java.lang.String fileName)
          Called when a "binary_grin_file_setting" clause is enocuntered.
 void setExported(java.lang.String[] segments, java.lang.String[] features, java.lang.String[] handlers, java.lang.String[] namedCommands)
          Called when the exported clause is encountered.
 void setExtensionParser(ExtensionParser parser)
           
 void setShowTop(java.lang.String showTopName)
          Called when a "show_top" clause is encountered.
 void setShowTopGroup(SEGroup showTopGroup)
          Called when a "showtop_group" clause is encountered.
 void setStickyImages(java.lang.String[] stickyImages)
          Called when a "sticky images" clause is enocuntered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

show

protected SEShow show
Constructor Detail

ShowBuilder

public ShowBuilder()
Method Detail

getShow

public SEShow getShow()

init

public void init(SEShow show)

setExtensionParser

public void setExtensionParser(ExtensionParser parser)

getExtensionParser

public ExtensionParser getExtensionParser()
Returns an instance of ExtensionParser that this Builder is working with, or null if it is not set.


addSyntheticFeature

public void addSyntheticFeature(Feature f)
                         throws java.io.IOException
Add a feature that's created programmatically during show construction, e.g. from SENode.postProcess().

Throws:
java.io.IOException
See Also:
SENode.postProcess(ShowBuilder)

injectParent

public void injectParent(Feature newFeature,
                         Feature child)
                  throws java.io.IOException
Add a feature that's created programmatically during show construction, and inject it as the parent of the child node passed in. The entire show tree will be visited, and references to the child will be changed to references to the parent where appropriate.

Parameters:
newFeature - The new feature being added
child - The existing feature that will be its child
Throws:
java.io.IOException - if a problem is encountered

addFeature

public void addFeature(java.lang.String name,
                       int line,
                       Feature f)
                throws java.io.IOException
Called when a new feature is encountered.

Throws:
java.io.IOException

addSegment

public void addSegment(java.lang.String name,
                       int line,
                       Segment s)
                throws java.io.IOException
Called when a new segment is encountered.

Throws:
java.io.IOException

addNamedCommand

public void addNamedCommand(java.lang.String name,
                            int line,
                            Command c)
                     throws java.io.IOException
Called when a new named command is encountered

Throws:
java.io.IOException

addCommand

public void addCommand(Command command,
                       int line)
                throws java.io.IOException
Called when a new command is encountered.

Throws:
java.io.IOException

addRCHandler

public void addRCHandler(java.lang.String name,
                         int line,
                         RCHandler hand)
                  throws java.io.IOException
Called when a new remote control handler is encountered.

Throws:
java.io.IOException

addDeferredBuilder

public void addDeferredBuilder(DeferredBuilder builder)
Called when a DeferrredBuilder is created. It will be called after the show is populated with all of its parts, in the finishBuilding method.

See Also:
finishBuilding()

setExported

public void setExported(java.lang.String[] segments,
                        java.lang.String[] features,
                        java.lang.String[] handlers,
                        java.lang.String[] namedCommands)
                 throws java.io.IOException
Called when the exported clause is encountered. This is optional; if it's not called, then everything defaults to public visibility.

The segments, features and handlers may contain the wildcard character "*", which cannot be escaped.

Throws:
java.io.IOException

setBinaryGrinFileName

public void setBinaryGrinFileName(java.lang.String fileName)
Called when a "binary_grin_file_setting" clause is enocuntered.


setStickyImages

public void setStickyImages(java.lang.String[] stickyImages)
Called when a "sticky images" clause is enocuntered.


setShowTopGroup

public void setShowTopGroup(SEGroup showTopGroup)
                     throws java.io.IOException
Called when a "showtop_group" clause is encountered.

Throws:
java.io.IOException

setShowTop

public void setShowTop(java.lang.String showTopName)
                throws java.io.IOException
Called when a "show_top" clause is encountered.

Throws:
java.io.IOException

getNamedSegment

public Segment getNamedSegment(java.lang.String name)
Look up a segment in the list of all named segments.


getNamedCommand

public Command getNamedCommand(java.lang.String name)
Look up a command in the list of all named commands.


getNamedFeature

public Feature getNamedFeature(java.lang.String name)
Look up a feature in the list of all named features.


getNamedRCHandler

public RCHandler getNamedRCHandler(java.lang.String name)
Look up an RC handler in the list of all named handlers.


finishBuilding

public void finishBuilding()
                    throws java.io.IOException
Called when the show has finished parsing and all forward references have been resolved. Any DeferredBuider instances are processed here.

Throws:
java.io.IOException

makeTimer

public InterpolatedModel makeTimer(java.lang.String name,
                                   int numFrames,
                                   boolean repeat,
                                   Command[] commands)

makeTranslatorModel

public SETranslatorModel makeTranslatorModel(java.lang.String name,
                                             int[] frames,
                                             int[][] values,
                                             boolean isRelative,
                                             int repeatFrame,
                                             int loopCount,
                                             Command[] commands)

makeScalingModel

public InterpolatedModel makeScalingModel(java.lang.String name,
                                          int[] frames,
                                          int[][] values,
                                          int repeatFrame,
                                          int loopCount,
                                          Command[] commands)

makeInterpolatedModel

public InterpolatedModel makeInterpolatedModel(java.lang.String name,
                                               int[] frames,
                                               int[][] values,
                                               int repeatFrame,
                                               int loopCount,
                                               Command[] commands,
                                               java.lang.Class clazz)

getFontIndex

public int getFontIndex(FontSpec spec)