Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.flagstone.transform
Class FSBitmapFill

    java.lang.Object
      com.flagstone.transform.FSTransformObject
          com.flagstone.transform.FSFillStyle
              com.flagstone.transform.FSBitmapFill

All Implemented Interfaces:
  java.lang.Cloneable

    public class FSBitmapFill

extends FSFillStyle

The FSBitmapFill class is used to fill a shape with an image.

Two types of bitmap fill are supported:

Clipped | If the area to be filled is larger than the image then the colour at the edge of the image is used to fill the remainder of the shape.
Tiled | If the area to be filled is larger than the image then the image is tiled across the area to be filled.
Unsmoothed Clipped | If the area to be filled is larger than the image then the colour at the edge of the image is used to fill the remainder of the shape.
Unsmoothed Tiled | If the area to be filled is larger than the image then the image is tiled without smoothing to fill the area.

Attributes
type | The type of bitmap fill, either FSFillStyle.Tiled or FSFillStyle.Clipped.
identifier | The identifier, in the range 1..65535, of the object that contains the image that will be displayed.
transform | An FSCoordTransform object that defines the coordinate transformation that will be applied to the image, to change its size, location relative to the origin of the shape, orientation, etc., when it is displayed.

The type attribute may be used when iterating through an array of fill style objects to identify the type of fill style without using run-time type checking.

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 FSCoordTransform object will restore it to its original size.

The image is drawn with the top left corner placed at the origin (0, 0) of the shape being filled. Depending on how the shape is drawn the coordinate transform may also need to specify a translation to place the image at the desired location.

# When To Use

In addition to filling shapes with images that represent textures or complex fill patterns the FSBitmapFill class is required to display any image in a Flash file - image can only be displayed in Flash inside a shape definition. The classes that define images only contain the image data, not how it is displayed. To simply display an image, the selected line style of a shape may be set to zero so that the image is displayed without a border.

# Example

The following code fragment centres the image in the centre of the shape - assuming the shape is drawn with the origin at the centre. The transform constructor allows the translation and scaling transform to be specified in a single step rather than compositing the transforms.

     FSCoordTransform composite = new FSCoordTransform(-imageWidth / 2,
                                    -imageHeight / 2, 20.0, 20.0);

     fillStyles.add(new FSBitmapFill(FSFillStyle.Clipped, imageId, composite));

# History

The FSBitmapFill class represents the FillStyle structure from the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 1.

Field Summary

Fields inherited from class com.flagstone.transform.FSFillStyle
`Clipped, Linear, Radial, Solid, Tiled, type, Unsmoothed_Clipped, Unsmoothed_Tiled`

Constructor Summary
`FSBitmapFill(FSBitmapFill obj)` Construct an FSBitmapFill object by copying an existing object.
`FSBitmapFill(FSCoder coder)` Construct an FSBitmapFill object an initialize it with values decoded from an encoded FSBitmapFill object.
`FSBitmapFill(int aType, int anIdentifier, FSCoordTransform aTransform)` Constructs an FSBitmapFill object, specifying whether the image is tiled or clipped within the shape, the identifier of the object containing the image data and the coordinate transform used to change the appearance of the image and place it relative to the origin of the shape.

Method Summary
`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` | `getIdentifier()` Gets the identifier of the object containing the image to be displayed.
`FSCoordTransform` | `getTransform()` Gets the coordinate transform applied to the image.
`int` | `length(FSCoder coder)`
`void` | `setIdentifier(int anIdentifier)` Sets the identifier of the object containing the image to be displayed.
`void` | `setTransform(FSCoordTransform aTransform)` Sets the coordinate transform applied to the image to display it inside the shape.

Methods inherited from class com.flagstone.transform.FSFillStyle
`getType, setType`

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

### FSBitmapFill

    public FSBitmapFill(FSCoder coder)

  Construct an FSBitmapFill object an initialize it with values decoded from an encoded FSBitmapFill object.

  Parameters:
    `coder` - an FSCoder object containing an FSBitmapFill encoded as binary data.

### FSBitmapFill

    public FSBitmapFill(int aType,
                        int anIdentifier,
                        FSCoordTransform aTransform)

  Constructs an FSBitmapFill object, specifying whether the image is tiled or clipped within the shape, the identifier of the object containing the image data and the coordinate transform used to change the appearance of the image and place it relative to the origin of the shape.

  Parameters:
    `aType` - the type of bitmap fill, FSFillStyle.Clipped or FSFillStyle.Tiled.
    `anIdentifier` - the identifier of the object containing the image to be displayed.
    `aTransform` - an FSCoordTransform object that changes the appearance of the image.

### FSBitmapFill

    public FSBitmapFill(FSBitmapFill obj)

  Construct an FSBitmapFill object by copying an existing object.

  Parameters:
    `obj` - an FSBitmapFill object.

Method Detail

### getIdentifier

    public int getIdentifier()

  Gets the identifier of the object containing the image to be displayed.

  Returns:
    the identifier of the image object to be displayed.

### setIdentifier

    public void setIdentifier(int anIdentifier)

  Sets the identifier of the object containing the image to be displayed.

  Parameters:
    `anIdentifier` - the identifier of the object containing the image to be displayed.

### getTransform

    public FSCoordTransform getTransform()

  Gets the coordinate transform applied to the image.

  Returns:
    the transform that will be applied to the image when it is displayed.

### setTransform

    public void setTransform(FSCoordTransform aTransform)

  Sets the coordinate transform applied to the image to display it inside the shape.

  Parameters:
    `aTransform` - an FSCoordTransform object that changes the appearance and location of the image inside the shape.

### clone

    public java.lang.Object clone()

  Description copied from class: `FSTransformObject`
  Creates a deep copy of the entire object.

  Overrides:
    `clone` in class `FSTransformObject`
  Returns:
    a copy of the object.

### equals

    public boolean equals(java.lang.Object anObject)

  Description copied from class: `FSFillStyle`
  Returns true if anObject is equal to this one. Objects are considered equal if they would generate identical binary data when they are encoded to a Flash file.

  Overrides:
    `equals` in class `FSFillStyle`
  Returns:
    true if this object would be identical to anObject when encoded.

### appendDescription

    public void appendDescription(java.lang.StringBuffer buffer,
                                  int depth)

  Description copied from class: `FSTransformObject`
  AppendDescription is used to present a string description of the object including all nested objects up to a specified depth. This method provide a more controlled way of creating a string representation of an object since large objects such as font or shape definitions can contain dozens of nested objects. The representation of the object is appended to the StringBuffer, showing the name of the class and values of the attributes it contains. If the object contains any attributes that are objects then the object graph will be traversed up to the specified depth. If objects are nested at a level less than specified depth then the full string representation of the object is displayed. For objects at the specified depth only the name of the class is displayed. Any objects below this depth are not displayed.

  Specified by:
    `appendDescription` in class `FSTransformObject`
  Parameters:
    `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.

### length

    public int length(FSCoder coder)

  Overrides:
    `length` in class `FSFillStyle`

### encode

    public void encode(FSCoder coder)

  Overrides:
    `encode` in class `FSFillStyle`

### decode

    public void decode(FSCoder coder)

  Overrides:
    `decode` in class `FSFillStyle`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD