com.hdcookbook.grin
Class SEShow

java.lang.Object
  extended by com.hdcookbook.grin.Show
      extended by com.hdcookbook.grin.SEShow
All Implemented Interfaces:
AnimationClient

public class SEShow
extends Show

Represents a show, with extra data that's useful for tools that run on SE (big JDK), including a record of things like the names of private features, and a list of all of the features and segments.

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

Field Summary
 
Fields inherited from class com.hdcookbook.grin.Show
component, features, fontName, fontStyleSize, initializer, publicFeatures, publicNamedCommands, publicRCHandlers, publicSegments, rcHandlers, segments, setupManager, showTop, showTopGroup, stickyImages
 
Constructor Summary
SEShow(Director director)
          Create a new SEShow.
 
Method Summary
 void accept(SEShowVisitor visitor)
          Visit a SEShow with a SEShowVisitor.
static void acceptCommand(SEShowVisitor visitor, Command command)
          Accept a command from a show.
static void acceptCommands(SEShowVisitor visitor, Command[] commands)
          Visit a list of commands with a SEShowVisitor.
static void acceptFeature(SEShowVisitor visitor, Feature feature)
          Accept a feature of a show.
static void acceptFeatures(SEShowVisitor visitor, Feature[] features)
          Visit a list of features with a SEShowVisitor.
static void acceptRCHandler(SEShowVisitor visitor, RCHandler handler)
          Accept an RC handler from a show.
static void acceptRCHandlers(SEShowVisitor visitor, RCHandler[] rcHandlers)
          Visit a list of RC handlers with a SEShowVisitor.
static void acceptSegments(SEShowVisitor visitor, Segment[] segments)
          Visit a list of segments with a SEShowVisitor.
 void appendCommandClassCode(java.lang.String s)
          Append a declaration that will be emitted with the command class.
 void buildShow(Segment[] segments, Feature[] features, RCHandler[] rcHandlers, java.lang.String[] stickyImages, Segment showTop, Group showTopGroup, java.util.Hashtable publicSegments, java.util.Hashtable publicFeatures, java.util.Hashtable publicRCHandlers, java.util.Hashtable publicNamedCommands, java.lang.String[] fontName, int[] fontStyleSize)
          This is called to build the show.
 java.lang.String getBinaryGrinFileName()
          Gets the name of the file that the GRIN compiler should generate.
 java.lang.String getCommandClassCode()
          Get the extra code that goes in the command class
 Feature[] getFeatures()
          Get all of the features in the show
 java.lang.String[] getFontName()
          Get the font name array
 int[] getFontStyleSize()
          Get they StyleSize information for the show's fonts
 BackgroundSpec[] getGrinviewBackgrounds()
           
 MosaicSpec[] getMosaicSpecs()
          Returns an array of MosaicSpec instances associated with this show, or an zero-length array if none is found.
 boolean getNoShowFile()
          Get a flag to indicate that no binary show file should be generated.
 Segment getPrivateSegment(java.lang.String name)
          Look up a private segment.
 java.util.Hashtable getPublicNamedCommands()
           
 RCHandler[] getRCHandlers()
          Get all of the remote control handlers in the show
 Segment[] getSegments()
          Get all of the segments in the show
 SEShowCommands getShowCommands()
          Get the object that represents the commands defined for this show.
 Group getShowTopGroup()
          Get the group for active features of a show's currently activated segment.
 Segment getShowTopSegment()
          Get the Show's top Segment, which represents the top of a rendering tree.
 java.lang.String[] getStickyImages()
          Get the list of sticky images as a string array of the image file names.
 boolean isPublic(Feature f)
          Determine if the given Feature is public
 boolean isPublic(RCHandler hand)
          Determine if the given RCHandler is public
 boolean isPublic(Segment seg)
          Determine if the given Segment is public
 boolean isPublic(SENode node)
          Returns true if the node passed in is recorded as an public element in this show, false otherwise.
 MosaicSpec newMosaicSpec(java.lang.String name)
          Called by the ShowParser when a new mosaic or mosaic_hint is found.
 void printContent(java.io.PrintStream out)
           
 void scaleBy(int xScale, int yScale, int xOffset, int yOffset)
          Scale this show by the given scale factor, and apply the given offset.
 void setBinaryGrinFileName(java.lang.String name)
          Sets the name of the file that the GRIN compiler should generate, if you want to override the default.
 void setGrinviewBackgrounds(java.util.ArrayList<BackgroundSpec> value)
          Sets the list of background images for grinview.
 void setIsBinary(boolean isBinary)
          Set a flag to indicate that this show file was read from a binary file.
 void setNamedCommands(Command[] namedCommands)
           
 void setNoShowFile(boolean val)
          Set a flag to indicate that no binary show file should be generated.
 
Methods inherited from class com.hdcookbook.grin.Show
activateSegment, activateSegment, addDisplayAreas, deferNextCommands, destroy, doActivateSegment, doSegmentDone, getCurrentSegment, getDirector, getDrawTargets, getFeature, getFont, getNamedCommand, getRCHandler, getSegment, getSegmentStackDepth, getXOffset, getXScale, getYOffset, getYScale, handleKeyPressed, handleKeyReleased, handleKeyTyped, handleMouseClicked, handleMouseMoved, initialize, internalHandleKeyPressed, internalHandleKeyReleased, internalHandleKeyTyped, mapDrawTargets, nextFrame, paintDone, paintFrame, popSegmentStack, pushCurrentSegment, runCommand, runCommands, scale, segmentDone, setCaughtUp, setDrawTargets, setScale, setSegmentStackDepth, syncDisplay
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SEShow

public SEShow(Director director)
Create a new SEShow.

Parameters:
director - A Director helper class that can be used to control the show.
Method Detail

setIsBinary

public void setIsBinary(boolean isBinary)
Set a flag to indicate that this show file was read from a binary file. The double-use checker won't be run on such a show file.


setNoShowFile

public void setNoShowFile(boolean val)
Set a flag to indicate that no binary show file should be generated. This is used for the synthetic show file that is used to collect mosaic definitions.


getNoShowFile

public boolean getNoShowFile()
Get a flag to indicate that no binary show file should be generated. This is used for the synthetic show file that is used to collect mosaic definitions.


getStickyImages

public java.lang.String[] getStickyImages()
Get the list of sticky images as a string array of the image file names.


getShowTopSegment

public Segment getShowTopSegment()
Get the Show's top Segment, which represents the top of a rendering tree. This segment's active feature list includes all the active features of this show's activated segment.

See Also:
getShowTopGroup()

getShowTopGroup

public Group getShowTopGroup()
Get the group for active features of a show's currently activated segment. When the show moves from one segment to another, then this showTopGroup's part is swapped using Group.resetVisibleParts().

See Also:
getShowTopSegment()

getShowCommands

public SEShowCommands getShowCommands()
Get the object that represents the commands defined for this show. If no show commands class has been defined, this will return an unpopulated SEShowCommands object.


getSegments

public Segment[] getSegments()
Get all of the segments in the show


getPublicNamedCommands

public java.util.Hashtable getPublicNamedCommands()

getFeatures

public Feature[] getFeatures()
Get all of the features in the show


getRCHandlers

public RCHandler[] getRCHandlers()
Get all of the remote control handlers in the show


getPrivateSegment

public Segment getPrivateSegment(java.lang.String name)
Look up a private segment. This only works if the show had names for the private segments, of course, but for debugging reasons we expect even binary files will do this.


getFontName

public java.lang.String[] getFontName()
Get the font name array


getFontStyleSize

public int[] getFontStyleSize()
Get they StyleSize information for the show's fonts


isPublic

public boolean isPublic(Segment seg)
Determine if the given Segment is public


isPublic

public boolean isPublic(Feature f)
Determine if the given Feature is public


isPublic

public boolean isPublic(RCHandler hand)
Determine if the given RCHandler is public


setNamedCommands

public void setNamedCommands(Command[] namedCommands)

buildShow

public void buildShow(Segment[] segments,
                      Feature[] features,
                      RCHandler[] rcHandlers,
                      java.lang.String[] stickyImages,
                      Segment showTop,
                      Group showTopGroup,
                      java.util.Hashtable publicSegments,
                      java.util.Hashtable publicFeatures,
                      java.util.Hashtable publicRCHandlers,
                      java.util.Hashtable publicNamedCommands,
                      java.lang.String[] fontName,
                      int[] fontStyleSize)
               throws java.io.IOException
This is called to build the show. This needs to be done before initialize is called. Normally, clients of the GRIN framework shouldn't call this.

This adds internal structure checking to the superclass version of this method.

Overrides:
buildShow in class Show
Throws:
java.io.IOException - if anything goes wrong.

setBinaryGrinFileName

public void setBinaryGrinFileName(java.lang.String name)
Sets the name of the file that the GRIN compiler should generate, if you want to override the default.

Parameters:
name - The file name, including any extension

setGrinviewBackgrounds

public void setGrinviewBackgrounds(java.util.ArrayList<BackgroundSpec> value)
Sets the list of background images for grinview. See grinview_background_setting in the show's BNF for the format and semantics.


getGrinviewBackgrounds

public BackgroundSpec[] getGrinviewBackgrounds()

getBinaryGrinFileName

public java.lang.String getBinaryGrinFileName()
Gets the name of the file that the GRIN compiler should generate. Gives null if the default file name should be used.


newMosaicSpec

public MosaicSpec newMosaicSpec(java.lang.String name)
                         throws java.io.IOException
Called by the ShowParser when a new mosaic or mosaic_hint is found.

Throws:
java.io.IOException - if name is a duplicate

getMosaicSpecs

public MosaicSpec[] getMosaicSpecs()
Returns an array of MosaicSpec instances associated with this show, or an zero-length array if none is found.


accept

public void accept(SEShowVisitor visitor)
Visit a SEShow with a SEShowVisitor. This will call visitShow on the given visitor; it's up to the visitor to call SEShow.accept(xxx) for any children it wants to visit.


acceptSegments

public static void acceptSegments(SEShowVisitor visitor,
                                  Segment[] segments)
Visit a list of segments with a SEShowVisitor. This will call visitSegment on each segment.


acceptFeatures

public static void acceptFeatures(SEShowVisitor visitor,
                                  Feature[] features)
Visit a list of features with a SEShowVisitor. This will call acceptFeature() on each of the features.


acceptRCHandlers

public static void acceptRCHandlers(SEShowVisitor visitor,
                                    RCHandler[] rcHandlers)
Visit a list of RC handlers with a SEShowVisitor. This will call acceptRCHandler() on each of the handlers.


acceptFeature

public static void acceptFeature(SEShowVisitor visitor,
                                 Feature feature)
Accept a feature of a show. This will call the appropriate visitXXX method on the visitor, according to the subtype of feature passed in.


acceptRCHandler

public static void acceptRCHandler(SEShowVisitor visitor,
                                   RCHandler handler)
Accept an RC handler from a show. This will call the appropriate visitXXX method on the visitor, according to the subtype of the handler passed in.


acceptCommands

public static void acceptCommands(SEShowVisitor visitor,
                                  Command[] commands)
Visit a list of commands with a SEShowVisitor. This will call acceptCommand() on each of the commands.


acceptCommand

public static void acceptCommand(SEShowVisitor visitor,
                                 Command command)
Accept a command from a show. This will call the appropriate visitXXX method on the visitor, according to the subtype of the command passed in.


isPublic

public boolean isPublic(SENode node)
Returns true if the node passed in is recorded as an public element in this show, false otherwise.

Throws:
java.lang.RuntimeException - if node is neither an instance of Feature, RCHandler, nor Segment.

printContent

public void printContent(java.io.PrintStream out)

scaleBy

public void scaleBy(int xScale,
                    int yScale,
                    int xOffset,
                    int yOffset)
             throws java.io.IOException
Scale this show by the given scale factor, and apply the given offset. This will change the size of the features and RC handlers within the show at compile time, so no special scaling action is required at runtime.

Parameters:
xScale - x scale factor in mills
yScale - y scale factor in mills
xOffset - x offset in pixels
yOffset - y offset in pixels
Throws:
java.io.IOException

appendCommandClassCode

public void appendCommandClassCode(java.lang.String s)
Append a declaration that will be emitted with the command class. This can be used, for example, to add a public final static int constant.


getCommandClassCode

public java.lang.String getCommandClassCode()
Get the extra code that goes in the command class