|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.flagstone.transform.FSTransformObject
com.flagstone.transform.FSFillStyle
com.flagstone.transform.FSBitmapFill
public class FSBitmapFill
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.
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.
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));
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 |
---|
public FSBitmapFill(FSCoder coder)
coder
- an FSCoder object containing an FSBitmapFill encoded as binary
data.public FSBitmapFill(int aType, int anIdentifier, FSCoordTransform aTransform)
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.public FSBitmapFill(FSBitmapFill obj)
obj
- an FSBitmapFill object.Method Detail |
---|
public int getIdentifier()
public void setIdentifier(int anIdentifier)
anIdentifier
- the identifier of the object containing the image to be
displayed.public FSCoordTransform getTransform()
public void setTransform(FSCoordTransform aTransform)
aTransform
- an FSCoordTransform object that changes the appearance and
location of the image inside the shape.public java.lang.Object clone()
FSTransformObject
clone
in class FSTransformObject
public boolean equals(java.lang.Object anObject)
FSFillStyle
equals
in class FSFillStyle
public void appendDescription(java.lang.StringBuffer buffer, int depth)
FSTransformObject
appendDescription
in class FSTransformObject
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.public int length(FSCoder coder)
length
in class FSFillStyle
public void encode(FSCoder coder)
encode
in class FSFillStyle
public void decode(FSCoder coder)
decode
in class FSFillStyle
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |