com.flagstone.transform.shape
Class ShapeStyle

java.lang.Object
  extended by com.flagstone.transform.shape.ShapeStyle
All Implemented Interfaces:
Copyable<ShapeRecord>, SWFEncodeable, ShapeRecord

public final class ShapeStyle
extends Object
implements ShapeRecord

ShapeStyle is used to change the drawing environment when a shape is drawn. Three operations can be performed:

An ShapeStyle object can specify one or more of the operations rather than specifying them in separate ShapeStyle 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.

Line and Fill styles are selected by the index position, starting at 1, of the style in a list of styles. An index of zero means that no style is used. 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.

A new drawing point is specified using the absolute x and y coordinates. If an ShapeStyle object is the first in a shape then the current drawing point is the origin of the shape (0,0). As with the line and fill styles, specifying a move is optional.

Finally the line or fill style lists may left empty if no new styles are being specified.


Constructor Summary
ShapeStyle()
          Creates an uninitialised ShapeStyle object.
ShapeStyle(int flags, SWFDecoder coder, Context context)
          Creates and initialises a ShapeStyle object using values encoded in the Flash binary format.
ShapeStyle(ShapeStyle object)
          Creates and initialises a ShapeStyle object using the values copied from another ShapeStyle object.
 
Method Summary
 ShapeStyle add(FillStyle style)
          Add the fill style object to the list of fill styles.
 ShapeStyle add(LineStyle1 style)
          Add a LineStyle object to the list of line styles.
 ShapeStyle copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 Integer getAltFillStyle()
          Get the index of the fill style that will be applied to any overlapping area filled.
 Integer getFillStyle()
          Get the index of the fill style that will be applied to any area filled.
 List<FillStyle> getFillStyles()
          Returns the list of new fill styles.
 Integer getLineStyle()
          Get the index of the line style that will be applied to any line drawn.
 List<LineStyle1> getLineStyles()
          Get the list of new line styles.
 Integer getMoveX()
          Get the x-coordinate of any relative move or null if no move is specified.
 Integer getMoveY()
          Get the y-coordinate of any relative move or null if no move is specified.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 ShapeStyle setAltFillStyle(Integer anIndex)
          Sets the index of the fill style that will be applied to any overlapping area filled.
 ShapeStyle setFillStyle(Integer anIndex)
          Sets the index of the fill style that will be applied to any area filled.
 ShapeStyle setFillStyles(List<FillStyle> list)
          Sets the list of new fill styles.
 ShapeStyle setLineStyle(Integer anIndex)
          Sets the index of the line style that will be applied to any line drawn.
 ShapeStyle setLineStyles(List<LineStyle1> list)
          Sets the list of new line styles.
 ShapeStyle setMove(Integer xCoord, Integer yCoord)
          Sets the coordinates of any relative move.
 ShapeStyle setMoveX(Integer coord)
          Sets the x-coordinate of any relative move.
 ShapeStyle setMoveY(Integer coord)
          Sets the x-coordinate of any relative move.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ShapeStyle

public ShapeStyle(int flags,
                  SWFDecoder coder,
                  Context context)
           throws IOException
Creates and initialises a ShapeStyle object using values encoded in the Flash binary format.

Parameters:
flags - contains fields identifying which fields are optionally encoded in the data - decoded by parent object.
coder - an SWFDecoder object that contains the encoded Flash data.
context - a Context object used to manage the decoders for different type of object and to pass information on how objects are decoded.
Throws:
IOException - if an error occurs while decoding the data.

ShapeStyle

public ShapeStyle()
Creates an uninitialised ShapeStyle object.


ShapeStyle

public ShapeStyle(ShapeStyle object)
Creates and initialises a ShapeStyle object using the values copied from another ShapeStyle object.

Parameters:
object - a ShapeStyle object from which the values will be copied.
Method Detail

add

public ShapeStyle add(LineStyle1 style)
Add a LineStyle object to the list of line styles.

Parameters:
style - and LineStyle object. Must not be null.
Returns:
this object.

add

public ShapeStyle add(FillStyle style)
Add the fill style object to the list of fill styles.

Parameters:
style - and FillStyle object. Must not be null.
Returns:
this object.

getMoveX

public Integer getMoveX()
Get the x-coordinate of any relative move or null if no move is specified.

Returns:
the relative move in the x direction.

getMoveY

public Integer getMoveY()
Get the y-coordinate of any relative move or null if no move is specified.

Returns:
the relative move in the y direction.

getLineStyle

public Integer getLineStyle()
Get the index of the line style that will be applied to any line drawn. Returns null if no line style is defined.

Returns:
the selected line style.

getFillStyle

public Integer getFillStyle()
Get the index of the fill style that will be applied to any area filled. Returns null if no fill style is defined.

Returns:
the selected fill style.

getAltFillStyle

public Integer getAltFillStyle()
Get the index of the fill style that will be applied to any overlapping area filled. Returns null if no alternate fill style is defined.

Returns:
the selected alternate fill style.

getLineStyles

public List<LineStyle1> getLineStyles()
Get the list of new line styles.

Returns:
the list of line styles.

getFillStyles

public List<FillStyle> getFillStyles()
Returns the list of new fill styles.

Returns:
the list of fill styles.

setMoveX

public ShapeStyle setMoveX(Integer coord)
Sets the x-coordinate of any relative move.

Parameters:
coord - move the current point by aNumber in the x direction. Must be in the range -65535..65535.
Returns:
this object.

setMoveY

public ShapeStyle setMoveY(Integer coord)
Sets the x-coordinate of any relative move.

Parameters:
coord - move the current point by aNumber in the x direction. Must be in the range -65535..65535.
Returns:
this object.

setMove

public ShapeStyle setMove(Integer xCoord,
                          Integer yCoord)
Sets the coordinates of any relative move.

Parameters:
xCoord - move the current point by aNumber in the x direction. Must be in the range -65535..65535.
yCoord - move the current point by aNumber in the y direction. Must be in the range -65535..65535.
Returns:
this object.

setFillStyle

public ShapeStyle setFillStyle(Integer anIndex)
Sets the index of the fill style that will be applied to any area filled. May be set to zero if no style is selected or null if the line style remains unchanged.

Parameters:
anIndex - selects the fill style at anIndex in the fill styles list of the parent Shape object.
Returns:
this object.

setAltFillStyle

public ShapeStyle setAltFillStyle(Integer anIndex)
Sets the index of the fill style that will be applied to any overlapping area filled. May be set to zero if no style is selected or null if the ~ line style remains unchanged.

Parameters:
anIndex - selects the alternate fill style at anIndex in the fill styles list of the parent Shape object.
Returns:
this object.

setLineStyle

public ShapeStyle setLineStyle(Integer anIndex)
Sets the index of the line style that will be applied to any line drawn. May be set to zero if no style is selected or null if the line style remains unchanged.

Parameters:
anIndex - selects the line style at anIndex in the line styles list of the parent Shape object.
Returns:
this object.

setLineStyles

public ShapeStyle setLineStyles(List<LineStyle1> list)
Sets the list of new line styles. May be set to null if no styles are being defined.

Parameters:
list - a list of LineStyle objects. Must not be null.
Returns:
this object.

setFillStyles

public ShapeStyle setFillStyles(List<FillStyle> list)
Sets the list of new fill styles. May be set to null if no styles are being defined.

Parameters:
list - a list of fill style objects. Must not be null.
Returns:
this object.

copy

public ShapeStyle copy()
Creates a complete copy of this object.

Specified by:
copy in interface Copyable<ShapeRecord>
Returns:
a deep-copy of this object. New instances of mutable objects are copied and immutable instances are shared.

toString

public String toString()
Overrides:
toString in class Object

prepareToEncode

public int prepareToEncode(Context context)
Prepare an object for encoding, returning the expected size of an object when it is encoded. This method also used to initialise variables, such as offsets and flags that will be used when the object is encoded. Generally the method returns the size in bytes, however when called on objects that use bit fields such as shapes the methods will return the size in bits.

Specified by:
prepareToEncode in interface SWFEncodeable
Parameters:
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Returns:
the size of the object when it is encoded.

encode

public void encode(SWFEncoder coder,
                   Context context)
            throws IOException
Encode an object to the Flash binary format.

Specified by:
encode in interface SWFEncodeable
Parameters:
coder - an SWFEncoder object.
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Throws:
IOException - if an error occurs while encoding the object.


Copyright © 2002-2010 Flagstone Software Ltd.. All Rights Reserved.