|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.flagstone.transform.FSTransformObject
com.flagstone.transform.FSMovieObject
com.flagstone.transform.FSDefineObject
com.flagstone.transform.FSDefineMorphShape
public class FSDefineMorphShape
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:
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.
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()); }
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 |
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 |
---|
public FSDefineMorphShape(FSCoder coder)
coder
- an FSCoder containing the binary data.public FSDefineMorphShape(int anIdentifier, FSBounds startBounds, FSBounds endBounds, java.util.ArrayList fillStyleArray, java.util.ArrayList lineStyleArray, FSShape startShape, FSShape endShape)
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.public FSDefineMorphShape(FSDefineMorphShape obj)
obj
- an FSDefineJPEGImage object.Method Detail |
---|
public void add(FSLineStyle aLineStyle)
aLineStyle
- and FSSolidLine object.public void add(FSFillStyle aFillStyle)
aFillStyle
- an FSFillStyle object.public FSBounds getStartBounds()
public FSBounds getEndBounds()
public java.util.ArrayList getFillStyles()
public java.util.ArrayList getLineStyles()
public FSShape getStartShape()
public FSShape getEndShape()
public void setStartBounds(FSBounds aBounds)
aBounds
- the bounding rectangle enclosing the start shape.public void setEndBounds(FSBounds aBounds)
aBounds
- the bounding rectangle enclosing the end shape.public void setFillStyles(java.util.ArrayList anArray)
anArray
- an array of FSMorphSolidFill, FSMorphBitmapFill and
FSMorphGradientFill objects.public void setLineStyles(java.util.ArrayList anArray)
anArray
- an array of FSMorphLineStyle objects.public void setStartShape(FSShape aShape)
aShape
- the shape at the start of the morphing process.public void setEndShape(FSShape aShape)
aShape
- the shape at the end of the morphing process.public java.lang.Object clone()
FSTransformObject
clone
in class FSTransformObject
public boolean equals(java.lang.Object anObject)
FSMovieObject
equals
in class FSMovieObject
public void appendDescription(java.lang.StringBuffer buffer, int depth)
FSTransformObject
appendDescription
in class FSDefineObject
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.public int length(FSCoder coder)
length
in class FSDefineObject
public void encode(FSCoder coder)
encode
in class FSDefineObject
public void decode(FSCoder coder)
decode
in class FSDefineObject
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |