com.flagstone.transform.fillstyle
Class MorphFocalGradientFill

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

public final class MorphFocalGradientFill
extends Object
implements FillStyle

MorphFocalGradientFill extends the functionality of MorphGradientFill by allowing the focal point for the gradient at the start and end of the morphing process to be specified rather than defaulting to the centre of the shape. The value for the focal point ranges from -1.0 to 1.0, where negative values up to -1.0 sets the focal point closer to the left border gradient circle and positive values up to 1.0 sets the focal point closer the right border. A value of zero means the focal point is in the centre.


Constructor Summary
MorphFocalGradientFill(CoordTransform startMatrix, CoordTransform endMatrix, Spread spreadType, Interpolation interpolationType, float startPoint, float endPoint, List<MorphGradient> list)
          Creates a MorphFocalGradientFill.
MorphFocalGradientFill(MorphFocalGradientFill object)
          Creates and initialises a FocalGradientFill fill style using the values copied from another FocalGradientFill object.
MorphFocalGradientFill(SWFDecoder coder, Context context)
          Creates and initialises a FocalGradientFill fill style using values encoded in the Flash binary format.
 
Method Summary
 MorphFocalGradientFill add(MorphGradient aGradient)
          Add a Gradient object to the list of gradient objects.
 MorphFocalGradientFill copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 float getEndFocalPoint()
          Get the focal point at the end of the morphing process.
 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 Gradient objects defining the points for the gradient fill.
 Interpolation getInterpolation()
          Get the method used to calculate the colour changes across the gradient.
 Spread getSpread()
          Get the Spread describing how the gradient fills the area: PAD - the last colour fills the remaining area; REPEAT - the gradient is repeated; REFLECT - the gradient is repeated but reflected (reversed) each time.
 float getStartFocalPoint()
          Get the focal point at the start of the morphing process.
 CoordTransform getStartTransform()
          Get the coordinate transform mapping the gradient square onto physical coordinates at the start of the morphing process.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setEndFocalPoint(float point)
          Set the focal point at the end of the morphing process.
 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 setInterpolation(Interpolation interp)
          Set the method used to calculate the colour changes across the gradient.
 void setSpread(Spread spreadType)
          Set the Spread describing how the gradient fills the area: either by using the last gradient colour to fill the area (PAD); repeating the gradient (REPEAT) or repeating but reversing it each time (REFLECT).
 void setStartFocalPoint(float point)
          Set the focal point at the start of the morphing process.
 void setStartTransform(CoordTransform matrix)
          Sets the coordinate transform mapping the gradient square onto physical coordinates at the start of the morphing process.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MorphFocalGradientFill

public MorphFocalGradientFill(SWFDecoder coder,
                              Context context)
                       throws IOException
Creates and initialises a FocalGradientFill fill style using values encoded in the Flash binary format.

Parameters:
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.

MorphFocalGradientFill

public MorphFocalGradientFill(CoordTransform startMatrix,
                              CoordTransform endMatrix,
                              Spread spreadType,
                              Interpolation interpolationType,
                              float startPoint,
                              float endPoint,
                              List<MorphGradient> list)
Creates a MorphFocalGradientFill.

Parameters:
startMatrix - the coordinate transform mapping the gradient square onto physical coordinates at the start of the morphing process. Must not be null.
endMatrix - the coordinate transform mapping the gradient square onto physical coordinates at the end of the morphing process. Must not be null.
spreadType - To be documented.
interpolationType - how the changes in colours across the gradient are calculated.
startPoint - the position of the focal point relative to the centre of the radial circle at the start of the morphing process. Values range from -1.0 (close to the left edge), to 1.0 (close to the right edge).
endPoint - the position of the focal point relative to the centre of the radial circle at the start of the morphing process. Values range from -1.0 (close to the left edge), to 1.0 (close to the right edge).
list - a list of Gradient objects defining the control points for the gradient. For Flash 7 and earlier versions there can be up to 8 Gradients. For Flash 8 onwards this number was increased to 15. Must not be null.

MorphFocalGradientFill

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

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

getSpread

public Spread getSpread()
Get the Spread describing how the gradient fills the area: PAD - the last colour fills the remaining area; REPEAT - the gradient is repeated; REFLECT - the gradient is repeated but reflected (reversed) each time.

Returns:
the Spread, either PAD, REFLECT or REPEAT.

setSpread

public void setSpread(Spread spreadType)
Set the Spread describing how the gradient fills the area: either by using the last gradient colour to fill the area (PAD); repeating the gradient (REPEAT) or repeating but reversing it each time (REFLECT).

Parameters:
spreadType - the Spread, either PAD, REFLECT or REPEAT.

getInterpolation

public Interpolation getInterpolation()
Get the method used to calculate the colour changes across the gradient.

Returns:
the Interpolation that describes how colours change.

setInterpolation

public void setInterpolation(Interpolation interp)
Set the method used to calculate the colour changes across the gradient.

Parameters:
interp - the Interpolation that describes how colours change.

getStartFocalPoint

public float getStartFocalPoint()
Get the focal point at the start of the morphing process.

Returns:
the focal point in the range -1.0 to 1.0.

setStartFocalPoint

public void setStartFocalPoint(float point)
Set the focal point at the start of the morphing process.

Parameters:
point - the focal point in the range -1.0 to 1.0.

getEndFocalPoint

public float getEndFocalPoint()
Get the focal point at the end of the morphing process.

Returns:
the focal point in the range -1.0 to 1.0.

setEndFocalPoint

public void setEndFocalPoint(float point)
Set the focal point at the end of the morphing process.

Parameters:
point - the focal point in the range -1.0 to 1.0.

add

public MorphFocalGradientFill add(MorphGradient aGradient)
Add a Gradient object to the list of gradient objects. For Flash 7 and earlier versions there can be up to 8 Gradients. For Flash 8 onwards this number was increased to 15.

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

getGradients

public List<MorphGradient> getGradients()
Get the list of Gradient objects defining the points for the gradient fill.

Returns:
the set of points that define the gradient.

setGradients

public void setGradients(List<MorphGradient> list)
Sets the list of control points that define the gradient. For Flash 7 and earlier this list can contain up to 8 Gradient objects. For Flash 8 onwards this limit was increased to 15.

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

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.

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.

copy

public MorphFocalGradientFill 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.