Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.flagstone.transform
Class FSDefineMorphShape

    java.lang.Object
      com.flagstone.transform.FSTransformObject
          com.flagstone.transform.FSMovieObject
              com.flagstone.transform.FSDefineObject
                  com.flagstone.transform.FSDefineMorphShape

All Implemented Interfaces:
  java.lang.Cloneable

    public class FSDefineMorphShape

extends FSDefineObject

FSDefineMorphShape defines a shape that will morph from one form into another.

Only the start and end shapes are defined the Flash Player will perform the interpolation that transforms the shape at each staging in the morphing process.

Morphing can be applied to any shape, however there are a few restrictions:

- The start and end shapes must have the same number of edges (FSLine and FSCurve objects).
- The fill style (Solid, Bitmap or Gradient) must be the same in the start and end shape.
- If a bitmap fill style is used then the same image must be used in the start and end shapes.
- If a gradient fill style is used then the gradient must contain the same number of points in the start and end shape.
- The start and end shape must contain the same set of FSShapeStyle objects.

To perform the morphing of a shape the shape is placed in the display list using a FSPlaceObject2 object. The ratio attribute in the FSPlaceObject2 object defines the progress of the morphing process. The ratio ranges between 0.0 and 1.0 where 0 represents the start of the morphing process and 1.0, the end.

Attributes
type | Identifies the data structure when it is encoded. The type attribute is read-only and may be used when iterating through the objects in an FSMovie object to identify the object class without using run-time type checking.
identifier | An unique identifier for this object in the range 1..65535.
startBounds | A rectangle (FSBounds) defining the bounding area in which the shape is drawn at the start of the morph process.
endBounds | A rectangle (FSBounds) defining the bounding area in which the shape is drawn at the end of the morph process.
fillStyles | An array of fill styles.
lineStyles | An array of line styles.
startShape | An FSShape object containing the shape records (FSLine, FSCurve and FSShapeStyle objects) that describe the shape at the start of the morphing process.
endShape | The shape at the end of the morphing process containing the FSLine and FSCurve objects that define the edges of the shape.FSShapeStyle objects may only be included if they are used to move the current point and may not change the style being used to draw the shape.

The edges may change their type when a shape is morphed. Straight edges can become curves and vice versa.

# Examples

This simple example morphs a rectangle into a square. While this example is trivial it illustrates how the FSDefineMorphShape class is used.

This rectangle is 200 twips wide and 100 twips high, drawing using a black outline 1 twip wide and filled with a transparent red colour. The square is 150 x 150 twips. The origin of the shape is at the bottom left corner of the rectangle.

      // Create the bounding rectangle for the start shape (rectangle).
      FSBounds startBounds = new FSBounds(0, 0, 200, 100);

      // Create the bounding rectangle for the end shape (square).
      FSBounds endBounds = new FSBounds(0, 0, 150, 150);

      // Define the styles for the shape.

      ArrayList fillStyles = new ArrayList();
      ArrayList lineStyles = new ArrayList();

      fillStyles.push_back(new FSSolidFill(new FSColor((FSColorTable.red)));

      lineStyles.push_back(new FSSolidLine(1, FColor.black()));

      // Draw the rectangle.

      FSShape rectangle = new FSShape();

      rectangle.add(new FSShapeStyle(1, 1, 0, 0, 0));
      rectangle.add(new FSLine(200,0));
      rectangle.add(new FSLine(0,100));
      rectangle.add(new FSLine(-200,0));
      rectangle.add(new FSLine(0,-100));

      // Draw the square.

      FSShape square = new FSShape();

      square.add(new FSLine(150,0));
      square.add(new FSLine(0,150));
      square.add(new FSLine(-150,0));
      square.add(new FSLine(0,-150));

      FSDefineMorphShape shape = FSDefineMorphShape(movie.newIdentifier(), startBounds, endBounds, fillStyles, lineStyles, rectangle, square);

      // The morphing process is controlled by the FSPlaceObject2 class using the ratio attribute.
      // Place the shape on layer 1 of the display list at coordinates (0,0).

      movie.add(new FSPlaceObject2(shape.getIdentifier(), 1, 0.0, 0,0));
      movie.add(new FSShowFrame());

      // Morph the shape over 5 steps without changing its location.

      for (float i=0.2; i<1.0; i+= 0.2)
      {
      movie.add(new FSPlaceObject2(1, i, 0,0));
      movie.add(new FSShowFrame());
      }

# History

The FSDefineMorphShape class represents the DefineMorphShape tag from the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 3.

Field Summary

Fields inherited from class com.flagstone.transform.FSDefineObject
`identifier`

Fields inherited from class com.flagstone.transform.FSMovieObject
`ButtonColorTransform, ButtonSound, DefineBitsPtr, DefineButton, DefineButton2, DefineFont, DefineFont2, DefineImage, DefineImage2, DefineJPEGImage, DefineJPEGImage2, DefineJPEGImage3, DefineMorphShape, DefineMovieClip, DefineShape, DefineShape2, DefineShape3, DefineSound, DefineText, DefineText2, DefineTextField, DefineVideo, DoAction, EnableDebugger, EnableDebugger2, Export, extendLength, FontInfo, FontInfo2, FrameLabel, Free, Import, Initialize, JPEGTables, length, LimitScript, PathsArePostscript, PlaceObject, PlaceObject2, Protect, QuicktimeMovie, RemoveObject, RemoveObject2, SerialNumber, SetBackgroundColor, ShowFrame, SoundStreamBlock, SoundStreamHead, SoundStreamHead2, StartSound, TabOrder, type, VideoFrame`

Constructor Summary
`FSDefineMorphShape(FSCoder coder)` Construct an FSDefineJPEGImage object, initialising it with values decoded from an encoded object.
`FSDefineMorphShape(FSDefineMorphShape obj)` Constructs an FSDefineJPEGImage object by copying values from an existing object.
`FSDefineMorphShape(int anIdentifier, FSBounds startBounds, FSBounds endBounds, java.util.ArrayList fillStyleArray, java.util.ArrayList lineStyleArray, FSShape startShape, FSShape endShape)` Constructs an FSDefineMorphShape object.

Method Summary
`void` | `add(FSFillStyle aFillStyle)` Add the fill style object to the array of fill styles.
`void` | `add(FSLineStyle aLineStyle)` Add a FSSolidLine object to the array of line styles.
`void` | `appendDescription(java.lang.StringBuffer buffer, int depth)` AppendDescription is used to present a string description of the object including all nested objects up to a specified depth.
`java.lang.Object` | `clone()` Creates a deep copy of the entire object.
`void` | `decode(FSCoder coder)`
`void` | `encode(FSCoder coder)`
`boolean` | `equals(java.lang.Object anObject)` Returns true if anObject is equal to this one.
`FSBounds` | `getEndBounds()` Gets the FSBounds object that defines the bounding rectangle enclosing the end shape.
`FSShape` | `getEndShape()` Gets the ending shape.
`java.util.ArrayList` | `getFillStyles()` Gets the array of FSMorphSolidFill, FSMorphBitmapFill and FSMorphGradientFill objects that define the fill styles for the shapes.
`java.util.ArrayList` | `getLineStyles()` Gets the array of FSMorphLineStyle objects that define the line styles for the shapes.
`FSBounds` | `getStartBounds()` Gets the FSBounds object that defines the bounding rectangle enclosing the start shape.
`FSShape` | `getStartShape()` Gets the starting shape.
`int` | `length(FSCoder coder)`
`void` | `setEndBounds(FSBounds aBounds)` Sets the ending bounds of the shape.
`void` | `setEndShape(FSShape aShape)` Sets the ending shape.
`void` | `setFillStyles(java.util.ArrayList anArray)` Sets the array of morph fill styles.
`void` | `setLineStyles(java.util.ArrayList anArray)` Sets the array of morph line styles.
`void` | `setStartBounds(FSBounds aBounds)` Sets the starting bounds of the shape.
`void` | `setStartShape(FSShape aShape)` Sets the starting shape.

Methods inherited from class com.flagstone.transform.FSDefineObject
`getIdentifier, setIdentifier`

Methods inherited from class com.flagstone.transform.FSMovieObject
`getType`

Methods inherited from class com.flagstone.transform.FSTransformObject
`name, toString`

Methods inherited from class java.lang.Object
`finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### FSDefineMorphShape

    public FSDefineMorphShape(FSCoder coder)

  Construct an FSDefineJPEGImage object, initialising it with values decoded from an encoded object.

  Parameters:
    `coder` - an FSCoder containing the binary data.

### FSDefineMorphShape

    public FSDefineMorphShape(int anIdentifier,
                              FSBounds startBounds,
                              FSBounds endBounds,
                              java.util.ArrayList fillStyleArray,
                              java.util.ArrayList lineStyleArray,
                              FSShape startShape,
                              FSShape endShape)

  Constructs an FSDefineMorphShape object.

  Parameters:
    `anIdentifier` - an unique identifier for this object.
    `startBounds` - the bounding rectangle enclosing the start shape.
    `endBounds` - the bounding rectangle enclosing the end shape.
    `fillStyleArray` - an array of FSMorphSolidFill, FSMorphBitmapFill and FSMorphGradientFill objects.
    `lineStyleArray` - an array of FSMorphLineStyle objects.
    `startShape` - the shape at the start of the morphing process.
    `endShape` - the shape at the end of the morphing process.

### FSDefineMorphShape

    public FSDefineMorphShape(FSDefineMorphShape obj)

  Constructs an FSDefineJPEGImage object by copying values from an existing object.

  Parameters:
    `obj` - an FSDefineJPEGImage object.

Method Detail

### add

    public void add(FSLineStyle aLineStyle)

  Add a FSSolidLine object to the array of line styles.

  Parameters:
    `aLineStyle` - and FSSolidLine object.

### add

    public void add(FSFillStyle aFillStyle)

  Add the fill style object to the array of fill styles.

  Parameters:
    `aFillStyle` - an FSFillStyle object.

### getStartBounds

    public FSBounds getStartBounds()

  Gets the FSBounds object that defines the bounding rectangle enclosing the start shape.

  Returns:
    the bounds of the start shape.

### getEndBounds

    public FSBounds getEndBounds()

  Gets the FSBounds object that defines the bounding rectangle enclosing the end shape.

  Returns:
    the bounds of the end shape.

### getFillStyles

    public java.util.ArrayList getFillStyles()

  Gets the array of FSMorphSolidFill, FSMorphBitmapFill and FSMorphGradientFill objects that define the fill styles for the shapes.

  Returns:
    the array morph fill styles.

### getLineStyles

    public java.util.ArrayList getLineStyles()

  Gets the array of FSMorphLineStyle objects that define the line styles for the shapes.

  Returns:
    the array morph line styles.

### getStartShape

    public FSShape getStartShape()

  Gets the starting shape.

  Returns:
    the start shape.

### getEndShape

    public FSShape getEndShape()

  Gets the ending shape.

  Returns:
    the end shape.

### setStartBounds

    public void setStartBounds(FSBounds aBounds)

  Sets the starting bounds of the shape.

  Parameters:
    `aBounds` - the bounding rectangle enclosing the start shape.

### setEndBounds

    public void setEndBounds(FSBounds aBounds)

  Sets the ending bounds of the shape.

  Parameters:
    `aBounds` - the bounding rectangle enclosing the end shape.

### setFillStyles

    public void setFillStyles(java.util.ArrayList anArray)

  Sets the array of morph fill styles.

  Parameters:
    `anArray` - an array of FSMorphSolidFill, FSMorphBitmapFill and FSMorphGradientFill objects.

### setLineStyles

    public void setLineStyles(java.util.ArrayList anArray)

  Sets the array of morph line styles.

  Parameters:
    `anArray` - an array of FSMorphLineStyle objects.

### setStartShape

    public void setStartShape(FSShape aShape)

  Sets the starting shape.

  Parameters:
    `aShape` - the shape at the start of the morphing process.

### setEndShape

    public void setEndShape(FSShape aShape)

  Sets the ending shape.

  Parameters:
    `aShape` - the shape at the end of the morphing process.

### clone

    public java.lang.Object clone()

  Description copied from class: `FSTransformObject`
  Creates a deep copy of the entire object.

  Overrides:
    `clone` in class `FSTransformObject`
  Returns:
    a copy of the object.

### equals

    public boolean equals(java.lang.Object anObject)

  Description copied from class: `FSMovieObject`
  Returns true if anObject is equal to this one. Objects are considered equal if they would generate identical binary data when they are encoded to a Flash file.

  Overrides:
    `equals` in class `FSMovieObject`
  Returns:
    true if this object would be identical to anObject when encoded.

### appendDescription

    public void appendDescription(java.lang.StringBuffer buffer,
                                  int depth)

  Description copied from class: `FSTransformObject`
  AppendDescription is used to present a string description of the object including all nested objects up to a specified depth. This method provide a more controlled way of creating a string representation of an object since large objects such as font or shape definitions can contain dozens of nested objects. The representation of the object is appended to the StringBuffer, showing the name of the class and values of the attributes it contains. If the object contains any attributes that are objects then the object graph will be traversed up to the specified depth. If objects are nested at a level less than specified depth then the full string representation of the object is displayed. For objects at the specified depth only the name of the class is displayed. Any objects below this depth are not displayed.

  Overrides:
    `appendDescription` in class `FSDefineObject`
  Parameters:
    `buffer` - a StringBuffer to which the description of each object is appended.
    `depth` - the maximum level of nesting up to which objects will be displayed.

### length

    public int length(FSCoder coder)

  Overrides:
    `length` in class `FSDefineObject`

### encode

    public void encode(FSCoder coder)

  Overrides:
    `encode` in class `FSDefineObject`

### decode

    public void decode(FSCoder coder)

  Overrides:
    `decode` in class `FSDefineObject`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD