org.vectomatic.dom.svg
Class OMSVGMatrix

java.lang.Object
  extended by com.google.gwt.core.client.JavaScriptObject
      extended by org.vectomatic.dom.svg.OMSVGMatrix

public class OMSVGMatrix
extends com.google.gwt.core.client.JavaScriptObject

Many of SVG's graphics operations utilize 2x3 matrices of the form:

 [a c e]
 [b d f]

which, when expanded into a 3x3 matrix for the purposes of matrix arithmetic, become:

 [a c e]
 [b d f]
 [0 0 1]


Constructor Summary
protected OMSVGMatrix()
           
 
Method Summary
 OMSVGMatrix flipX()
          Post-multiplies the transformation [-1 0 0 1 0 0] and returns the resulting matrix.
 OMSVGMatrix flipY()
          Post-multiplies the transformation [1 0 0 -1 0 0] and returns the resulting matrix.
 float getA()
          The a component of the matrix.
 float getB()
          The b component of the matrix.
 float getC()
          The c component of the matrix.
 float getD()
          The d component of the matrix.
 String getDescription()
          Returns a textual description of the matrix for debugging purposes.
 float getE()
          The e component of the matrix.
 float getF()
          The f component of the matrix.
 OMSVGMatrix inverse()
          Returns the inverse matrix.
 boolean isIdentity()
          Returns true if this matrix is the identity matrix
 OMSVGMatrix multiply(OMSVGMatrix secondMatrix)
          Performs matrix multiplication.
 OMSVGMatrix rotate(float angle)
          Post-multiplies a rotation transformation on the current matrix and returns the resulting matrix.
 OMSVGMatrix rotateFromVector(float x, float y)
          Post-multiplies a rotation transformation on the current matrix and returns the resulting matrix.
 OMSVGMatrix scale(float scaleFactor)
          Post-multiplies a uniform scale transformation on the current matrix and returns the resulting matrix.
 OMSVGMatrix scaleNonUniform(float scaleFactorX, float scaleFactorY)
          Post-multiplies a non-uniform scale transformation on the current matrix and returns the resulting matrix.
 void setA(float value)
          The a component of the matrix.
 void setB(float value)
          The b component of the matrix.
 void setC(float value)
          The c component of the matrix.
 void setD(float value)
          The d component of the matrix.
 void setE(float value)
          The e component of the matrix.
 void setF(float value)
          The f component of the matrix.
 OMSVGMatrix skewX(float angle)
          Post-multiplies a skewX transformation on the current matrix and returns the resulting matrix.
 OMSVGMatrix skewY(float angle)
          Post-multiplies a skewY transformation on the current matrix and returns the resulting matrix.
 OMSVGMatrix translate(float x, float y)
          Post-multiplies a translation transformation on the current matrix and returns the resulting matrix.
 
Methods inherited from class com.google.gwt.core.client.JavaScriptObject
cast, createArray, createFunction, createObject, equals, hashCode, toSource, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OMSVGMatrix

protected OMSVGMatrix()
Method Detail

getA

public final float getA()
The a component of the matrix.


setA

public final void setA(float value)
                throws com.google.gwt.core.client.JavaScriptException
The a component of the matrix.

Throws:
DOMException(NO_MODIFICATION_ALLOWED_ERR) - Raised on an attempt to change the value of a read only attribute.
com.google.gwt.core.client.JavaScriptException

getB

public final float getB()
The b component of the matrix.


setB

public final void setB(float value)
                throws com.google.gwt.core.client.JavaScriptException
The b component of the matrix.

Throws:
DOMException(NO_MODIFICATION_ALLOWED_ERR) - Raised on an attempt to change the value of a read only attribute.
com.google.gwt.core.client.JavaScriptException

getC

public final float getC()
The c component of the matrix.


setC

public final void setC(float value)
                throws com.google.gwt.core.client.JavaScriptException
The c component of the matrix.

Throws:
DOMException(NO_MODIFICATION_ALLOWED_ERR) - Raised on an attempt to change the value of a read only attribute.
com.google.gwt.core.client.JavaScriptException

getD

public final float getD()
The d component of the matrix.


setD

public final void setD(float value)
                throws com.google.gwt.core.client.JavaScriptException
The d component of the matrix.

Throws:
DOMException(NO_MODIFICATION_ALLOWED_ERR) - Raised on an attempt to change the value of a read only attribute.
com.google.gwt.core.client.JavaScriptException

getE

public final float getE()
The e component of the matrix.


setE

public final void setE(float value)
                throws com.google.gwt.core.client.JavaScriptException
The e component of the matrix.

Throws:
DOMException(NO_MODIFICATION_ALLOWED_ERR) - Raised on an attempt to change the value of a read only attribute.
com.google.gwt.core.client.JavaScriptException

getF

public final float getF()
The f component of the matrix.


setF

public final void setF(float value)
                throws com.google.gwt.core.client.JavaScriptException
The f component of the matrix.

Throws:
DOMException(NO_MODIFICATION_ALLOWED_ERR) - Raised on an attempt to change the value of a read only attribute.
com.google.gwt.core.client.JavaScriptException

multiply

public final OMSVGMatrix multiply(OMSVGMatrix secondMatrix)
Performs matrix multiplication. This matrix is post-multiplied by another matrix, returning the resulting new matrix.

Parameters:
secondMatrix - The matrix which is post-multiplied to this matrix.
Returns:
The resulting matrix.

inverse

public final OMSVGMatrix inverse()
                          throws com.google.gwt.core.client.JavaScriptException
Returns the inverse matrix.

Returns:
The inverse matrix.
Throws:
SVGException(SVG_MATRIX_NOT_INVERTABLE) - Raised if this matrix is not invertable.
com.google.gwt.core.client.JavaScriptException

translate

public final OMSVGMatrix translate(float x,
                                   float y)
Post-multiplies a translation transformation on the current matrix and returns the resulting matrix.

Parameters:
x - The distance to translate along the x-axis.
y - The distance to translate along the y-axis.
Returns:
The resulting matrix.

scale

public final OMSVGMatrix scale(float scaleFactor)
Post-multiplies a uniform scale transformation on the current matrix and returns the resulting matrix.

Parameters:
scaleFactor - Scale factor in both X and Y.
Returns:
The resulting matrix.

scaleNonUniform

public final OMSVGMatrix scaleNonUniform(float scaleFactorX,
                                         float scaleFactorY)
Post-multiplies a non-uniform scale transformation on the current matrix and returns the resulting matrix.

Parameters:
scaleFactorX - Scale factor in X.
scaleFactorY - Scale factor in Y.
Returns:
The resulting matrix.

rotate

public final OMSVGMatrix rotate(float angle)
Post-multiplies a rotation transformation on the current matrix and returns the resulting matrix.

Parameters:
angle - Rotation angle.
Returns:
The resulting matrix.

rotateFromVector

public final OMSVGMatrix rotateFromVector(float x,
                                          float y)
                                   throws com.google.gwt.core.client.JavaScriptException
Post-multiplies a rotation transformation on the current matrix and returns the resulting matrix. The rotation angle is determined by taking (+/-) atan(y/x). The direction of the vector (x, y) determines whether the positive or negative angle value is used.

Parameters:
x - The X coordinate of the vector (x,y). Must not be zero.
y - The Y coordinate of the vector (x,y). Must not be zero.
Returns:
The resulting matrix.
Throws:
SVGException(SVG_INVALID_VALUE_ERR) - Raised if one of the parameters has an invalid value.
com.google.gwt.core.client.JavaScriptException

flipX

public final OMSVGMatrix flipX()
Post-multiplies the transformation [-1 0 0 1 0 0] and returns the resulting matrix.

Returns:
The resulting matrix.

flipY

public final OMSVGMatrix flipY()
Post-multiplies the transformation [1 0 0 -1 0 0] and returns the resulting matrix.

Returns:
The resulting matrix.

skewX

public final OMSVGMatrix skewX(float angle)
Post-multiplies a skewX transformation on the current matrix and returns the resulting matrix.

Parameters:
angle - Skew angle.
Returns:
The resulting matrix.

skewY

public final OMSVGMatrix skewY(float angle)
Post-multiplies a skewY transformation on the current matrix and returns the resulting matrix.

Parameters:
angle - Skew angle.
Returns:
The resulting matrix.

getDescription

public final String getDescription()
Returns a textual description of the matrix for debugging purposes.

Returns:
a textual description of the matrix.

isIdentity

public final boolean isIdentity()
Returns true if this matrix is the identity matrix

Returns:
true if this matrix is the identity matrix


Copyright © 2012. All Rights Reserved.