com.flagstone.transform.fillstyle
Class MorphGradientFill

java.lang.Object
  extended by com.flagstone.transform.fillstyle.MorphGradientFill
All Implemented Interfaces:
Copyable<FillStyle>, SWFEncodeable, FillStyle

public final class MorphGradientFill
extends Object
implements FillStyle

MorphGradientFill defines how a colour gradient changes across an area filled in a shape as it is morphed. GradientFill has a description of colour gradients.

See Also:
MorphGradient, GradientFill

Constructor Summary
MorphGradientFill(GradientType gradientType, CoordTransform start, CoordTransform end, List<MorphGradient> grads)
          Creates a MorphGradientFill object specifying the type of fill, starting and ending coordinate transforms and the list of gradient records.
MorphGradientFill(int fillType, SWFDecoder coder, Context context)
          Creates and initialises an MorphGradientFill fill style using values encoded in the Flash binary format.
MorphGradientFill(MorphGradientFill object)
          Creates and initialises a MorphGradientFill fill style using the values copied from another MorphGradientFill object.
 
Method Summary
 MorphGradientFill add(MorphGradient aGradient)
          Add a MorphGradient object to the list of gradient objects.
 MorphGradientFill copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 CoordTransform getEndTransform()
          Get the coordinate transform mapping the gradient square onto physical coordinates at the end of the morphing process.
 List<MorphGradient> getGradients()
          Get the list of MorphGradients defining the control points for the gradient.
 CoordTransform getStartTransform()
          Get the coordinate transform mapping the gradient square onto physical coordinates at the start of the morphing process.
 GradientType getType()
          Get the type indicating whether the gradient is linear or radial.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setEndTransform(CoordTransform matrix)
          Sets the coordinate transform mapping the gradient square onto physical coordinates at the end of the morphing process.
 void setGradients(List<MorphGradient> list)
          Sets the list of control points that define the gradient.
 void setStartTransform(CoordTransform matrix)
          Sets the coordinate transform mapping the gradient square onto physical coordinates at the start of the morphing process.
 void setType(GradientType gradientType)
          Set the type indicating whether the gradient is linear or radial.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MorphGradientFill

public MorphGradientFill(int fillType,
                         SWFDecoder coder,
                         Context context)
                  throws IOException
Creates and initialises an MorphGradientFill fill style using values encoded in the Flash binary format.

Parameters:
fillType - the value used to identify the fill style when it is encoded.
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.

MorphGradientFill

public MorphGradientFill(GradientType gradientType,
                         CoordTransform start,
                         CoordTransform end,
                         List<MorphGradient> grads)
Creates a MorphGradientFill object specifying the type of fill, starting and ending coordinate transforms and the list of gradient records.

Parameters:
gradientType - identifies whether the gradient is rendered linearly or radially.
start - the coordinate transform mapping the gradient square onto physical coordinates at the start of the morphing process.
end - the coordinate transform mapping the gradient square onto physical coordinates at the end of the morphing process.
grads - a list of MorphGradient objects defining the control points for the gradient.

MorphGradientFill

public MorphGradientFill(MorphGradientFill object)
Creates and initialises a MorphGradientFill fill style using the values copied from another MorphGradientFill object.

Parameters:
object - a MorphGradientFill fill style from which the values will be copied.
Method Detail

add

public MorphGradientFill add(MorphGradient aGradient)
Add a MorphGradient object to the list of gradient objects.

Parameters:
aGradient - an MorphGradient object. Must not be null.
Returns:
this object.

getType

public GradientType getType()
Get the type indicating whether the gradient is linear or radial.

Returns:
the gradient type, either LINEAR or RADIAL.

setType

public void setType(GradientType gradientType)
Set the type indicating whether the gradient is linear or radial.

Parameters:
gradientType - either LINEAR or RADIAL.

getStartTransform

public CoordTransform getStartTransform()
Get the coordinate transform mapping the gradient square onto physical coordinates at the start of the morphing process.

Returns:
the starting transform for the gradient.

getEndTransform

public CoordTransform getEndTransform()
Get the coordinate transform mapping the gradient square onto physical coordinates at the end of the morphing process.

Returns:
the final transform for the gradient.

getGradients

public List<MorphGradient> getGradients()
Get the list of MorphGradients defining the control points for the gradient.

Returns:
the list of points that define the gradient.

setStartTransform

public void setStartTransform(CoordTransform matrix)
Sets the coordinate transform mapping the gradient square onto physical coordinates at the start of the morphing process.

Parameters:
matrix - the starting coordinate transform. Must not be null.

setEndTransform

public void setEndTransform(CoordTransform matrix)
Sets the coordinate transform mapping the gradient square onto physical coordinates at the end of the morphing process.

Parameters:
matrix - the ending coordinate transform. Must not be null.

setGradients

public void setGradients(List<MorphGradient> list)
Sets the list of control points that define the gradient. The final list should contain at least two control points. Up to Flash 7 the list can contain up to 8 control points. For Flash 8 onwards this limit was increased to 15.

Parameters:
list - a list of MorphGradient objects. Must not be null.

copy

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

Specified by:
copy in interface Copyable<FillStyle>
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.