com.flagstone.transform
Class FSBounds

java.lang.Object
  extended by com.flagstone.transform.FSTransformObject
      extended by com.flagstone.transform.FSBounds
All Implemented Interfaces:
java.lang.Cloneable

public class FSBounds
extends FSTransformObject

The FSBounds class is used to define the area inside which shapes, text fields and characters are drawn.

In Flash the axes are specified relative to the top left corner of the screen and the bounding area is defined by two pairs of coordinates that identify the top left and bottom right corners of a rectangle.

Attributes
minX The x-coordinate of the upper left corner of the rectangle.
minY The y-coordinate of the upper left corner of the rectangle.
maxX The x-coordinate of the lower right corner of the rectangle.
maxY The y-coordinate of the lower right corner of the rectangle.

The coordinates for each corner also specify the coordinate range so specifying a bounding rectangle with the points (-100,-100) and (100,100) defines a rectangle 200 twips by 200 twips with the point (0,0) located in the centre. Specifying the points (0,0) and (200,200) defines a rectangle with the same size however the centre is now located at (100,100).

The bounding rectangle does not clip the object when it is drawn. Lines and curves drawn outside of the rectangle will still be displayed. However when the bounding rectangle is defined for an FSMovie object then this defines the size of the Flash Player screen and shapes drawn outside of the bounding rectangle will not be displayed.

Examples

To create an FSBounds object simply specify the coordinates of the corners of the rectangle in the following order: top left x, top left y, bottom right x, bottom right y.

 FSBounds bounds = new FSBounds(0, 0, 100, 200);
 

Creates a bounding rectangle for an object which is 100 twips wide and 200 twips high. The coordinate range for the object is from 0..100 along the x-axis and 0..200 along the y-axis. The origin (0,0) will be at the top left corner of the object as it is displayed on the screen.

 FSBounds bounds = new FSBounds(-100, -200, 100, 200);
 

Creates a bounding rectangle for an object which is 200 twips wide and 400 twips high. The coordinate range for the object is from -100..100 along the x-axis and -200..200 along the y-axis. The origin (0,0) will be in the middle of the object as it is displayed on the screen.

History

The FSBounds class corresponds to the RECT data type, in the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 1.


Constructor Summary
FSBounds(FSBounds obj)
          Construct an FSBounds object and initialise it with value from another FSBounds object.
FSBounds(FSCoder coder)
          Construct an FSBounds object an initialise it with values decoded from a binary encoded FSBounds object.
FSBounds(int xl, int yl, int xr, int yr)
          Constructs an FSBounds object representing a rectangle with the top left corner at (xl,yl) and bottom right corner at (xr,yr).
 
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.
 void decode(FSCoder coder)
           
 void encode(FSCoder coder)
           
 boolean equals(java.lang.Object anObject)
          Returns true if anObject is equal to this one.
 int getHeight()
          Gets the height of the rectangle.
 int getMaxX()
          Gets the x-coordinate of the bottom right corner of the bounding rectangle.
 int getMaxY()
          Gets the y-coordinate of the bottom right corner of the bounding rectangle.
 int getMinX()
          Gets the x-coordinate of the top left corner of the bounding rectangle.
 int getMinY()
          Gets the y-coordinate of the top left corner of the bounding rectangle.
 int getWidth()
          Gets the width of the rectangle.
 int length(FSCoder coder)
           
 void setMax(int xr, int yr)
          Sets the x and y coordinates of the upper corner.
 void setMaxX(int aNumber)
          Sets the x-coordinate of the bottom right corner of the bounding rectangle.
 void setMaxY(int aNumber)
          Sets the y-coordinate of the bottom right corner of the bounding rectangle.
 void setMin(int xl, int yl)
          Sets the x and y coordinates of the lower corner.
 void setMinX(int aNumber)
          Sets the x-coordinate of the top left corner of the bounding rectangle.
 void setMinY(int aNumber)
          Sets the y-coordinate of the upper left corner of the bounding rectangle.
 void setPoints(int xl, int yl, int xr, int yr)
          Sets the x and y coordinates of the lower and upper corner point.
 
Methods inherited from class com.flagstone.transform.FSTransformObject
clone, name, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FSBounds

public FSBounds(FSCoder coder)
Construct an FSBounds object an initialise it with values decoded from a binary encoded FSBounds object.

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

FSBounds

public FSBounds(int xl,
                int yl,
                int xr,
                int yr)
Constructs an FSBounds object representing a rectangle with the top left corner at (xl,yl) and bottom right corner at (xr,yr).

Parameters:
xl - x-coordinate of the top left corner.
yl - y-coordinate of the top left corner.
xr - x-coordinate of bottom right corner.
yr - y-coordinate of bottom right corner.

FSBounds

public FSBounds(FSBounds obj)
Construct an FSBounds object and initialise it with value from another FSBounds object.

Parameters:
obj - an FSBounds object.
Method Detail

getMinX

public int getMinX()
Gets the x-coordinate of the top left corner of the bounding rectangle.

Returns:
the x-coordinate of the lower left corner of the bounding rectangle.

getMaxX

public int getMaxX()
Gets the x-coordinate of the bottom right corner of the bounding rectangle.

Returns:
the x-coordinate of the bottom right corner of the bounding rectangle.

getMinY

public int getMinY()
Gets the y-coordinate of the top left corner of the bounding rectangle.

Returns:
the y-coordinate of the top left corner of the bounding rectangle.

getMaxY

public int getMaxY()
Gets the y-coordinate of the bottom right corner of the bounding rectangle.

Returns:
the y-coordinate of the bottom right corner of the bounding rectangle.

setMinX

public void setMinX(int aNumber)
Sets the x-coordinate of the top left corner of the bounding rectangle.

Parameters:
aNumber - x-coordinate of the lower left corner of the bounding rectangle.

setMaxX

public void setMaxX(int aNumber)
Sets the x-coordinate of the bottom right corner of the bounding rectangle.

Parameters:
aNumber - x-coordinate of the bottom right corner of the bounding rectangle.

setMinY

public void setMinY(int aNumber)
Sets the y-coordinate of the upper left corner of the bounding rectangle.

Parameters:
aNumber - y-coordinate of the lower left corner of the bounding rectangle.

setMaxY

public void setMaxY(int aNumber)
Sets the y-coordinate of the bottom right corner of the bounding rectangle.

Parameters:
aNumber - x-coordinate of the bottom right corner of the bounding rectangle.

getWidth

public int getWidth()
Gets the width of the rectangle.

Returns:
the width of the rectangle.

getHeight

public int getHeight()
Gets the height of the rectangle.

Returns:
the height of the rectangle.

setMin

public void setMin(int xl,
                   int yl)
Sets the x and y coordinates of the lower corner.

Parameters:
xl - the x-coordinate of the top left corner point.
yl - the y-coordinate of the top left corner point.

setMax

public void setMax(int xr,
                   int yr)
Sets the x and y coordinates of the upper corner.

Parameters:
xr - the x-coordinate of the bottom right corner point.
yr - the y-coordinate of the bottom right corner point.

setPoints

public void setPoints(int xl,
                      int yl,
                      int xr,
                      int yr)
Sets the x and y coordinates of the lower and upper corner point.

Parameters:
xl - the x-coordinate of the top left corner point.
yl - the y-coordinate of the top left corner point.
xr - the x-coordinate of the bottom right corner point.
yr - the y-coordinate of the bottom right corner point.

equals

public boolean equals(java.lang.Object anObject)
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 FSTransformObject
Parameters:
anObject - the reference object with which to compare.
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)
Specified by:
length in class FSTransformObject

encode

public void encode(FSCoder coder)
Specified by:
encode in class FSTransformObject

decode

public void decode(FSCoder coder)
Specified by:
decode in class FSTransformObject