org.w3c.dom.svg
Interface SVGMatrix


public interface SVGMatrix

This interface represents an "SVGMatrix" datatype, identified by an affine transform. It can be used to read and modify the values of transform attribute as per SVG specification. Note that the mTranslate, mMultiply, mScale and mRotate methods in this interface mutate the SVGMatrix object and return a reference to the SVGMatrix instance itself, after performing the necessary matrix operation.

This matrix transforms source coordinates (x, y) into destination coordinates (x', y') by considering them to be a column vector and multiplying the coordinate vector by the matrix according to the following process:

        [ x' ]    [  a  c  e  ]   [ x ]    [ a.x + c.y + e ]
        [ y' ] =  [  b  d  f  ]   [ y ] =  [ b.x + d.y + f ]
        [ 1  ]    [  0  0  1  ]   [ 1 ]    [        1      ]
 


Method Summary
 float getComponent(int index)
          Returns a component of the matrix by component's zero-based index.
 SVGMatrix inverse()
          Returns a new instance of SVGMatrix containing the inverse of the current matrix.
 SVGMatrix mMultiply(SVGMatrix secondMatrix)
          Performs matrix multiplication.
 SVGMatrix mRotate(float angle)
          Post-multiplies a rotation transformation on the current matrix and returns the resulting current matrix.
 SVGMatrix mScale(float scaleFactor)
          Post-multiplies a uniform scale transformation on the current matrix and returns the resulting current matrix.
 SVGMatrix mTranslate(float x, float y)
          Post-multiplies a translation transformation on the current matrix and returns the resulting current matrix.
 

Method Detail

getComponent

float getComponent(int index)
                   throws DOMException
Returns a component of the matrix by component's zero-based index. getComponent(0) is a, getComponent(1) is b, etc.

Parameters:
index - the index of the matrix component to retrieve.
Returns:
the component for the specified index.
Throws:
DOMException - - INDEX_SIZE_ERR if the index is invalid.

mMultiply

SVGMatrix mMultiply(SVGMatrix secondMatrix)
Performs matrix multiplication. This matrix is post-multiplied by another matrix, returning the resulting current matrix.

Parameters:
secondMatrix - the matrix to post-multiply with.
Returns:
the resulting current matrix after post-multiplication.
Throws:
java.lang.NullPointerException - - if secondMatrix is null.

inverse

SVGMatrix inverse()
                  throws SVGException
Returns a new instance of SVGMatrix containing the inverse of the current matrix.

Returns:
the inverse of the current matrix.
Throws:
SVGException - - SVG_MATRIX_NOT_INVERTABLE when determinant of this matrix is zero.

mTranslate

SVGMatrix mTranslate(float x,
                     float y)
Post-multiplies a translation transformation on the current matrix and returns the resulting current matrix. This is equivalent to calling multiply(T), where T is an SVGMatrix object represented by the following matrix:

                [   1    0    x  ]
                [   0    1    y  ]
                [   0    0    1   ]
 

Parameters:
x - the distance by which coordinates are translated in the X axis direction.
y - the distance by which coordinates are translated in the Y axis direction.
Returns:
the resulting current matrix after post-multiplication.

mScale

SVGMatrix mScale(float scaleFactor)
Post-multiplies a uniform scale transformation on the current matrix and returns the resulting current matrix. This is equivalent to calling multiply(S), where S is an SVGMatrix object represented by the following matrix:

                [   scaleFactor      0          0   ]
                [   0          scaleFactor      0   ]
                [   0                0          1   ]
 

Parameters:
scaleFactor - the factor by which coordinates are scaled along the X and Y axis.
Returns:
the resulting current matrix after post-mutiplication.

mRotate

SVGMatrix mRotate(float angle)
Post-multiplies a rotation transformation on the current matrix and returns the resulting current matrix. This is equivalent to calling multiply(R), where R is an SVGMatrix object represented by the following matrix:

        [ cos(angle) -sin(angle) 0 ]
        [ sin(angle)  cos(angle) 0 ]
        [ 0           0          1 ]
 

Parameters:
angle - the angle of rotation in degrees.
Returns:
the resulting current matrix after post-multiplication.


Copyright © 2003-2006 Nokia Corporation. See the Copyright Notice for details.