|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.flagstone.transform.datatype.CoordTransform
public final class CoordTransform
CoordTransform is used to specify a two-dimensional coordinate transform which allows an object to be scaled, rotated or moved without changing the original definition of how the object is drawn.
A two-dimensional transform is defined using a 3x3 matrix and the new values for a pair of coordinates (x,y) are calculated using the following matrix multiplication:
Different transformations such as scaling, rotation, shearing and translation can be performed using the above matrix multiplication. More complex transformations can be defined by performing successive matrix multiplications in a process known as compositing. This allows a complex transformations to performed on an object. However not that compositing transforms is not commutative, the order in which transformations are applied will affect the final result.
| Field Summary | |
|---|---|
static int |
DEFAULT_COORD
The default value used for the translation terms when a scaling or shearing transform is created. |
static float |
DEFAULT_SCALE
The default value used for the scaling terms when a translation or shearing transform is created. |
static float |
DEFAULT_SHEAR
The default value used for the shearing terms when a translation or scaling transform is created. |
static float |
SCALE_FACTOR
The factor applied to real numbers used for scaling terms when storing them as fixed point values. |
static float |
SHEAR_FACTOR
The factor applied to real numbers used for shearing terms when storing them as fixed point values. |
| Constructor Summary | |
|---|---|
CoordTransform(float[][] matrix)
Creates and initialises a CoordTransform object using a 3x3 matrix. |
|
CoordTransform(float xScale,
float yScale,
float xShear,
float yShear,
int xCoord,
int yCoord)
Creates an initialises a CoordTransform with scaling, shearing and translation values. |
|
CoordTransform(SWFDecoder coder)
Creates and initialises a CoordTransform object using values encoded in the Flash binary format. |
|
| Method Summary | |
|---|---|
void |
encode(SWFEncoder coder,
Context context)
Encode an object to the Flash binary format. |
boolean |
equals(Object object)
|
float[][] |
getMatrix()
Returns a matrix that can be used to create composite transforms. |
float |
getScaleX()
Returns the scaling factor along the x-axis. |
float |
getScaleY()
Returns the scaling factor along the y-axis. |
float |
getShearX()
Returns the shearing factor along the x-axis. |
float |
getShearY()
Returns the shearing factor along the y-axis. |
int |
getTranslateX()
Returns the translation in the x direction. |
int |
getTranslateY()
Returns the translation along the y-axis. |
int |
hashCode()
|
int |
prepareToEncode(Context context)
Prepare an object for encoding, returning the expected size of an object when it is encoded. |
static float[][] |
product(float[][] left,
float[][] right)
Create a new coordinate transform by multiplying two matrices together to calculate the product. |
static CoordTransform |
rotate(int angle)
Create a CoordTransform initialised for a rotation in degrees. |
static CoordTransform |
scale(float xScale,
float yScale)
Create a scaling transform. |
static CoordTransform |
shear(float xShear,
float yShear)
Create a CoordTransform initialised for a shearing operation. |
String |
toString()
|
static CoordTransform |
translate(int xCoord,
int yCoord)
Create a translation transform. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final float DEFAULT_SCALE
public static final float DEFAULT_SHEAR
public static final int DEFAULT_COORD
public static final float SCALE_FACTOR
public static final float SHEAR_FACTOR
| Constructor Detail |
|---|
public CoordTransform(SWFDecoder coder)
throws IOException
coder - an SWFDecoder object that contains the encoded Flash data.
IOException - if an error occurs while decoding the data.public CoordTransform(float[][] matrix)
matrix - a 3x3 matrix containing the transform values.
public CoordTransform(float xScale,
float yScale,
float xShear,
float yShear,
int xCoord,
int yCoord)
xScale - the scaling factor along the x-axis.yScale - the scaling factor along the y-axisxShear - the shearing factor along the x-axis.yShear - the shearing factor along the y-axisxCoord - the x coordinate of the transformation.yCoord - the y coordinate of the transformation.| Method Detail |
|---|
public static float[][] product(float[][] left,
float[][] right)
left - a 3x3 matrixright - a 3x3 matrix
public static CoordTransform translate(int xCoord,
int yCoord)
xCoord - the x coordinate of the transformation.yCoord - the y coordinate of the transformation.
public static CoordTransform scale(float xScale,
float yScale)
xScale - the scaling factor along the x-axis.yScale - the scaling factor along the y-axis
public static CoordTransform shear(float xShear,
float yShear)
xShear - the shearing factor along the x-axis.yShear - the shearing factor along the y-axis
public static CoordTransform rotate(int angle)
angle - the of rotation in degrees.
public float getScaleX()
public float getScaleY()
public float getShearX()
public float getShearY()
public int getTranslateX()
public int getTranslateY()
public float[][] getMatrix()
public String toString()
toString in class Objectpublic boolean equals(Object object)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic int prepareToEncode(Context context)
prepareToEncode in interface SWFEncodeablecontext - an Context that allows information to be passed between
objects to control how they are initialised for encoding.
public void encode(SWFEncoder coder,
Context context)
throws IOException
encode in interface SWFEncodeablecoder - an SWFEncoder object.context - an Context that allows information to be passed between
objects to control how they are initialised for encoding.
IOException - if an error occurs while encoding the object.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||