|
|||||||||
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.FSShapeStyle
public class FSShapeStyle
FSShapeStyle is used to change the drawing environment when a shape is drawn. Three operations can be performed:
An FSShapeStyle object can specify one or more of the operations rather than specifying them in separate FSShapeStyle objects - compacting the size of the binary data when the object is encoded. Conversely if an operation is not defined then the values may be omitted.
Attributes | |
---|---|
lineStyle | The index of the line style in the parent shape's line style array. Optional. May be set to the framework constant Transform.VALUE_NOT_SET if no style is selected. |
fillStyle | The index of the fill style in the parent shape's fill style array. Optional. May be set to the framework constant Transform.VALUE_NOT_SET if no style is selected. |
altFillStyle | The index of the alternate fill style in the parent shape's fill style array. Optional. May be set to the framework constant Transform.VALUE_NOT_SET if no style is selected. |
moveX | The absolute x-coordinate of the new drawing point. Optional. May be set to the framework constant Transform.VALUE_NOT_SET if the drawing point is not being moved. |
moveY | The absolute y-coordinate of the new drawing point. Optional. May be set to the framework constant Transform.VALUE_NOT_SET if the drawing point is not being moved. |
lineStyles | An array of new line styles for the parent shape. Optional. May be set to null or an empty array if no line or fill styles are being added. |
fillStyles | An array of new fill styles for the parent shape. Optional. May be set to null or an empty array if no line or fill styles are being added. |
Line and Fill styles are selected by the index position, starting at 1, of the style in an array of styles. An index of zero means that no style is selected. Using the constant Transform.VALUE_NOT_SET means that the current style is unchanged. Two types of fill style are supported: fillStyle is used where a shape does not contain overlapping areas and altFillStyle is used where areas overlap. This differs from graphics environments that only support one fill style as the overlapping area would form a hole in the shape and not be filled.
In the following example, when a shape is drawn the fillStyle defines the style to the left of the line drawing the outline while the altFillStyle defines the style applied to the right of the outline.
New fill and line styles can be added to the FSShapeStyle object to change the way shapes are drawn.
A new drawing point is specified using the absolute x and y coordinates. If an FSShapeStyle object is the first in a shape then the current drawing point is the origin of the shape (0,0).
Since the FSShapeStyle object can encode three different types of operation, the unused attributes are optional. Setting line or fill styles to the framework constant Transform.VALUE_NOT_SET omits the attribute when the object is encoded - reduced the size.
For the line and fill styles setting the respective attribute to Transform.VALUE_NOT_SET is different from setting to zero. When the attribute is set to Transform.VALUE_NOT_SET attribute is not encoded. When the attribute is set to zero then that instructs the Flash Player that no current line or fill style is selected. The latter is important when filling areas of a shape that overlap - the altFillStyle attribute will be set to the desired style while the lineStyle and fillStyle attributes are set to zero.
Similarly moveX and moveY may be set to Transform.VALUE_NOT_SET to indicate that the current drawing point will not be changed. This can also be achieved by setting moveX and moveY to zero. However using Transform.VALUE_NOT_SET means that the attributes are not encoded reducing the binary representation. For large files the savings can be significant.
The line or fill style arrays May be empty if no new styles are being specified.
Note that the values for the moveX and moveY attributes and the line and fill styles arrays are defined in pairs and are optional only if both are set to zero or NULL respectively.
The class provides a range of constructors which define different subsets of the attributes according to the type of operation that will be performed. If an attribute is not specified in a constructor then it will be assigned the default value of Transform.VALUE_NOT_SET and will be omitted when the object is encoded.
1. Select line and fill styles.
FSDefineShape shape = new FSShape(movie.newIdentifier(), ...); // Add fill styles to the shape definition shape.add(new FSSolidFill(FSColor(0, 0, 255))); shape.add(new FSBitmapFill(FSFillStyle.Tiled, imageId, transform)); // Add a line styles to the shape definition shape.add(new FSSolidLine(20, FSColor(0, 0, 0))); // Select the solid line style and the bitmap fill style. Note that the // ordinal position of the styles is used. A style index of 0 means that // style is not set. shape.add(new FSShapeStyle(1, 2, 0));
2. Move the current drawing point.
The drawing point is changed by specifying the position from the current drawing point:
FSShapeStyle style = new FSShapeStyle(x, y);
3. Specifying New Styles.
Adding a new set of styles to an FSShapeStyle object will replace the existing set of styles defined for the shape.
FSDefineShape shape = new FSDefineShape(movie.newIdentifier(), bounds, fillStyles, lineStyles, shape); // Replace the existing set of fill and line styles in the shape definition ArrayList fillStyles = new ArrayList(); ArrayList lineStyles = new ArrayList(); fillStyles.add(new FSSolidFill(FSColor(255, 0, 0))); fillStyles.add(new FSSolidFill(FSColor(0, 255, 0))); fillStyles.add(new FSSolidFill(FSColor(0, 0, 255))); lineStyles.add(new FSSolidLine(1, FSColor(0, 0, 0))); shape.add(new FSShapeStyle(lineStyles, fillStyles));
4. Creating an overlapping shape.
// Create the bounding rectangle for the shape. Two rectangles 100 x 100 pixels // are drawn. The area overlap area is 50 x 50 pixels. FSBounds bounds = new FSBounds(0, -50, 150, 100); // Define the styles for the shape. ArrayList fillStyles = new ArrayList(); ArrayList lineStyles = new ArrayList(); fillStyles.add(new FSSolidFill(new FSColor(255, 0, 0))); fillStyles.add(new FSSolidFill(new FSColor(255, 255, 0))); fillStyles.add(new FSSolidFill(new FSColor(16, 123, 255))); lineStyles.add(new FSSolidLine(20, new FSColor(0, 0, 0))); FSDefineShape shape = new FSDefineShape(movie.newIdentifier, bounds, fillStyles, lineStyles, new FSShape());
// To create the overlapping shape shown above the following styles // selections are made while the shape is drawn. shape.add(new FSShapeStyle(1, 1, 0, 0, 0)); shape.add(new FSLine(50, 0)); shape.add(new FSShapeStyle(1, 1, 3)); shape.add(new FSLine(0, 50)); shape.add(new FSLine(50, 0)); shape.add(new FSShapeStyle(1, 0, 2)); shape.add(new FSLine(50, 0)); shape.add(new FSLine(0, -100)); shape.add(new FSLine(-100, 0)); shape.add(new FSLine(0, 50)); shape.add(new FSShapeStyle(1, 3, 2)); shape.add(new FSLine(50, 0)); shape.add(new FSLine(0, 50)); shape.add(new FSShapeStyle(1, 1, 0)); shape.add(new FSLine(0, 50)); shape.add(new FSLine(-100, 0)); shape.add(new FSLine(0, -100));
The FSShapeStyle class represents the StyleChange record from the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 1.
Constructor Summary | |
---|---|
FSShapeStyle(java.util.ArrayList lineStylesArray,
java.util.ArrayList fillStylesArray)
Constructs an FSShapeStyle object, specifying the new set of line and fill styles for the parent shape. |
|
FSShapeStyle(FSCoder coder)
Construct an FSShapeStyle object, initalizing it with values decoded from an encoded object. |
|
FSShapeStyle(FSShapeStyle obj)
Constructs an FSShapeStyle object by copying values from an existing object. |
|
FSShapeStyle(int relativeX,
int relativeY)
Constructs an FSShapeStyle object, selecting the relative drawing point. |
|
FSShapeStyle(int lineStyleIndex,
int fillStyleIndex,
int altFillStyleIndex)
Constructs an FSShapeStyle object, selecting the line and fill styles. |
|
FSShapeStyle(int lineStyleIndex,
int fillStyleIndex,
int altFillStyleIndex,
java.util.ArrayList lineStylesArray,
java.util.ArrayList fillStylesArray)
Constructs an FSShapeStyle object, selecting the line and fill styles, new line and new fill styles. |
|
FSShapeStyle(int lineStyleIndex,
int fillStyleIndex,
int altFillStyleIndex,
int relativeX,
int relativeY)
Constructs an FSShapeStyle object, selecting the line and fill styles and drawing point. |
|
FSShapeStyle(int lineStyleIndex,
int fillStyleIndex,
int altFillStyleIndex,
int relativeX,
int relativeY,
java.util.ArrayList lineStylesArray,
java.util.ArrayList fillStylesArray)
Constructs an FSShapeStyle object, selecting the line and fill styles, drawing point, new line and new fill styles. |
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. |
int |
getAltFillStyle()
Gets the index of the fill style that will be applied to any overlapping area filled. |
int |
getFillStyle()
Gets the index of the fill style that will be applied to any area filled. |
java.util.ArrayList |
getFillStyles()
Gets the array of new fill styles. |
int |
getLineStyle()
Gets the index of the line style that will be applied to any line drawn. |
java.util.ArrayList |
getLineStyles()
Gets the array of new line styles. |
int |
getMoveX()
Gets the x-coordinate of any relative move specified. |
int |
getMoveY()
Gets the y-coordinate of any relative move specified. |
int |
length(FSCoder coder)
|
void |
setAltFillStyle(int anIndex)
Sets the index of the fill style that will be applied to any overlapping area filled. |
void |
setFillStyle(int anIndex)
Sets the index of the fill style that will be applied to any area filled. |
void |
setFillStyles(java.util.ArrayList anArray)
Sets the array of new fill styles. |
void |
setLineStyle(int anIndex)
Sets the index of the line style that will be applied to any line drawn. |
void |
setLineStyles(java.util.ArrayList anArray)
Sets the array of new line styles. |
void |
setMove(int x,
int y)
Sets the drawing point. |
void |
setMoveX(int aNumber)
Sets the x-coordinate of any relative move. |
void |
setMoveY(int aNumber)
Sets the y-coordinate of any relative move. |
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 FSShapeStyle(FSCoder coder)
coder
- an FSCoder containing the binary data.public FSShapeStyle(int lineStyleIndex, int fillStyleIndex, int altFillStyleIndex)
lineStyleIndex
- selects the line style at lineStyleIndex in the line styles
array of the parent FSShape object.fillStyleIndex
- selects the fill style at fillStyleIndex in the fill styles
array of the parent FSShape object.altFillStyleIndex
- selects the alternate fill style at altFillStyleIndex in the
fill styles array of the parent FSShape object.public FSShapeStyle(int relativeX, int relativeY)
relativeX
- move the current point by relativeX in the x direction.relativeY
- move the current point by relativeY in the y direction.public FSShapeStyle(java.util.ArrayList lineStylesArray, java.util.ArrayList fillStylesArray)
lineStylesArray
- an array of FSLineStyle objects.fillStylesArray
- an array of fill style objects.public FSShapeStyle(int lineStyleIndex, int fillStyleIndex, int altFillStyleIndex, int relativeX, int relativeY)
lineStyleIndex
- selects the line style at lineStyleIndex in the line styles
array of the parent FSShape object.fillStyleIndex
- selects the fill style at fillStyleIndex in the fill styles
array of the parent FSShape object.altFillStyleIndex
- selects the alternate fill style at altFillStyleIndex in the
fill styles array of the parent FSShape object.relativeX
- move the current point by relativeX in the x direction.relativeY
- move the current point by relativeY in the y direction.public FSShapeStyle(int lineStyleIndex, int fillStyleIndex, int altFillStyleIndex, java.util.ArrayList lineStylesArray, java.util.ArrayList fillStylesArray)
lineStyleIndex
- selects the line style at lineStyleIndex in the line styles
array of the parent FSShape object.fillStyleIndex
- selects the fill style at fillStyleIndex in the fill styles
array of the parent FSShape object.altFillStyleIndex
- selects the alternate fill style at altFillStyleIndex in the
fill styles array of the parent FSShape object.lineStylesArray
- an array of FSLineStyle objects.fillStylesArray
- an array of fill style objects.public FSShapeStyle(int lineStyleIndex, int fillStyleIndex, int altFillStyleIndex, int relativeX, int relativeY, java.util.ArrayList lineStylesArray, java.util.ArrayList fillStylesArray)
lineStyleIndex
- selects the line style at lineStyleIndex in the line styles
array of the parent FSShape object.fillStyleIndex
- selects the fill style at fillStyleIndex in the fill styles
array of the parent FSShape object.altFillStyleIndex
- selects the alternate fill style at altFillStyleIndex in the
fill styles array of the parent FSShape object.relativeX
- move the current point by relativeX in the x direction.relativeY
- move the current point by relativeY in the y direction.lineStylesArray
- an array of FSLineStyle objects.fillStylesArray
- an array of fill style objects.public FSShapeStyle(FSShapeStyle obj)
obj
- an FSShapeStyle object.Method Detail |
---|
public void add(FSLineStyle aLineStyle)
aLineStyle
- and FSSolidLine object.public void add(FSFillStyle aFillStyle)
aFillStyle
- and FSFillStyle object.public int getMoveX()
public int getMoveY()
public int getLineStyle()
public int getFillStyle()
public int getAltFillStyle()
public java.util.ArrayList getLineStyles()
public java.util.ArrayList getFillStyles()
public void setMoveX(int aNumber)
aNumber
- move the current point by aNumber in the x direction.public void setMoveY(int aNumber)
aNumber
- move the current point by aNumber in the y direction.public void setMove(int x, int y)
x
- the x-coordinate of the drawing point.y
- the y-coordinate of the drawing point.public void setFillStyle(int anIndex)
anIndex
- selects the fill style at anIndex in the fill styles array of
the parent FSShape object.public void setAltFillStyle(int anIndex)
anIndex
- selects the alternate fill style at anIndex in the fill styles
array of the parent FSShape object.public void setLineStyle(int anIndex)
anIndex
- selects the line style at anIndex in the line styles array of
the parent FSShape object.public void setLineStyles(java.util.ArrayList anArray)
anArray
- an array of FSLineStyle objects.public void setFillStyles(java.util.ArrayList anArray)
anArray
- an array of fill style objects.public java.lang.Object clone()
FSTransformObject
clone
in class FSTransformObject
public boolean equals(java.lang.Object anObject)
equals
in class FSTransformObject
public void appendDescription(java.lang.StringBuffer buffer, int depth)
FSTransformObject
appendDescription
in class FSTransformObject
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 FSTransformObject
public void encode(FSCoder coder)
encode
in class FSTransformObject
public void decode(FSCoder coder)
decode
in class FSTransformObject
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |