com.flagstone.transform.fillstyle
Class MorphBitmapFill

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

public final class MorphBitmapFill
extends Object
implements FillStyle

MorphBitmapFill uses a bitmap image to fill an area of a morphing shape. Four types of bitmap fill are supported:

  1. Clipped - If the image is larger than the shape then it will be clipped. Conversely if the area to be filled is larger than the image the colour at the edge of the image is used to fill the remainder of the shape.
  2. Tiled - if the area to be filled is larger than the image then the image is tiled to fill the area, otherwise as with the Clipped style the colour at the edge of the image will be use to fill the space available.
  3. Unsmoothed Clipped - Same as Clipped but if the image is smaller than the shape the colour used to fill the space available is not smoothed. This style was added to increase performance with few visible artifacts.
  4. Unsmoothed Tiled - Same as Tiled but no smoothing is applied if the colour at the edge of the image is used to fill the space available. Again this was introduced to increase performance.

Two coordinate transforms define the appearance of the image at the start and end of the morphing process. The most common use of the coordinate transform is to scale an image so it displayed at the correct resolution. When an image is loaded its width and height default to twips rather than pixels. An image 300 x 200 pixels will be displayed as 300 x 200 twips (15 x 10 pixels). Scaling the image by 20 (20 twips = 1 pixel) using the CoordTransform object will restore it to its original size.

The coordinate transform is also used to control the image registration. An image is drawn with the top left corner placed at the origin (0, 0) of the shape being filled. The transform can be used to apply different translations to the image so its position can be adjusted relative to the origin of the enclosing shape.


Constructor Summary
MorphBitmapFill(boolean tiled, boolean smoothed, int uid, CoordTransform start, CoordTransform end)
          Creates a MorphBitmapFill specifying the type, bitmap image and coordinate transforms for the image at the start and end of the morphing process.
MorphBitmapFill(int fillType, SWFDecoder coder)
          Creates and initialises a MorphBitmapFill fill style using values encoded in the Flash binary format.
MorphBitmapFill(MorphBitmapFill object)
          Creates and initialises a MorphBitmapFill fill style using the values copied from another MorphBitmapFill object.
 
Method Summary
 MorphBitmapFill 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 defining the appearance of the image at the end of the morphing process.
 int getIdentifier()
          Get the unique identifier of the bitmap image.
 CoordTransform getStartTransform()
          Get the coordinate transform defining the appearance of the image at the start of the morphing process.
 boolean isSmoothed()
          Is the image smoothed to improve display quality.
 boolean isTiled()
          Is the image tiled across the filled area.
 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 defining the appearance of the image at the end of the morphing process.
 void setIdentifier(int uid)
          Sets the identifier of the bitmap image to be used in the morphing process.
 void setSmoothed(boolean smoothed)
          Indicate whether the image will be smoothed to improve display quality.
 void setStartTransform(CoordTransform matrix)
          Sets the coordinate transform defining the appearance of the image at the start of the morphing process.
 void setTiled(boolean tiled)
          Indicate whether the image tiled across the filled area.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MorphBitmapFill

public MorphBitmapFill(int fillType,
                       SWFDecoder coder)
                throws IOException
Creates and initialises a MorphBitmapFill 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.
Throws:
IOException - if an error occurs while decoding the data.

MorphBitmapFill

public MorphBitmapFill(boolean tiled,
                       boolean smoothed,
                       int uid,
                       CoordTransform start,
                       CoordTransform end)
Creates a MorphBitmapFill specifying the type, bitmap image and coordinate transforms for the image at the start and end of the morphing process.

Parameters:
uid - the unique identifier for the image. Must be in the range 1..65535.
tiled - indicates whether the image will be tiled across the area defined by the shape.
smoothed - whether smoothing will be applied to the image to improve its appearance.
start - the coordinate transform defining the appearance of the image at the start of the morphing process.
end - the coordinate transform defining the appearance of the image at the end of the morphing process.

MorphBitmapFill

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

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

isTiled

public boolean isTiled()
Is the image tiled across the filled area.

Returns:
true if the image is tiled to completely cover the area to be filled, false otherwise.

setTiled

public void setTiled(boolean tiled)
Indicate whether the image tiled across the filled area.

Parameters:
tiled - true if the image is tiled to completely cover the area to be filled, false otherwise.

isSmoothed

public boolean isSmoothed()
Is the image smoothed to improve display quality.

Returns:
true if the image will be smoothed, false if smoothing is not applied to increase performance.

setSmoothed

public void setSmoothed(boolean smoothed)
Indicate whether the image will be smoothed to improve display quality.

Parameters:
smoothed - true if the image will be smoothed, false if smoothing is not applied.

getIdentifier

public int getIdentifier()
Get the unique identifier of the bitmap image.

Returns:
the image identifier.

getStartTransform

public CoordTransform getStartTransform()
Get the coordinate transform defining the appearance of the image at the start of the morphing process.

Returns:
the starting coordinate transform applied to the image.

getEndTransform

public CoordTransform getEndTransform()
Get the coordinate transform defining the appearance of the image at the end of the morphing process.

Returns:
the final coordinate transform applied to the image.

setIdentifier

public void setIdentifier(int uid)
Sets the identifier of the bitmap image to be used in the morphing process.

Parameters:
uid - the unique identifier of the bitmap image. Must be in the range 1..65535.

setStartTransform

public void setStartTransform(CoordTransform matrix)
Sets the coordinate transform defining the appearance of the image 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 defining the appearance of the image at the end of the morphing process.

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

copy

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