org.placelab.util.swt
Class AffineTransform

java.lang.Object
  extended byorg.placelab.util.swt.AffineTransform

public class AffineTransform
extends java.lang.Object

Pocket PCs don't have java.awt.geom.AffineTransform so I made this


Nested Class Summary
static class AffineTransform.DoublePoint
           
static class AffineTransform.NotInvertibleException
           
 
Field Summary
protected  AffineTransform inverse
           
protected  boolean inverseValid
           
protected  double[][] matrix
           
static int NEAREST_NEIGHBOR
           
 
Constructor Summary
AffineTransform()
          Returns the AffineTransform for the identity matrix
AffineTransform(AffineTransform Tx)
           
AffineTransform(double[][] matrix)
           
AffineTransform(double m00, double m10, double m01, double m11, double m02, double m12)
           
 
Method Summary
 java.lang.Object clone()
           
 void concatenate(AffineTransform Tx)
           
static double[][] copyMatrix(double[][] a)
           
 AffineTransform createInverse()
           
 org.eclipse.swt.graphics.Rectangle getBoundingRect(org.eclipse.swt.graphics.Rectangle rect)
          Supposing we applied this AffineTransform to the passed in Rectangle, this returns the rectangle that would be necessary to just contain the translated one
 double[][] getMatrix()
           
static AffineTransform getRotateInstance(double theta)
           
static AffineTransform getRotateInstance(double theta, double anchorX, double anchorY)
           
static AffineTransform getScaleInstance(double sx, double sy)
           
 double getScaleX()
           
 double getScaleY()
           
static AffineTransform getShearInstance(double shx, double shy)
           
 double getShearX()
           
 double getShearY()
           
static AffineTransform getTranslateInstance(double tx, double ty)
           
 double getTranslateX()
           
 double getTranslateY()
           
 AffineTransform.DoublePoint inverseTransform(AffineTransform.DoublePoint src)
           
 org.eclipse.swt.graphics.Point inverseTransform(org.eclipse.swt.graphics.Point src)
           
static double[][] invert(double[][] a)
           
static double[][] multiply(double[][] a, double[][] b)
           
 void preConcatenate(AffineTransform Cx)
           
 java.lang.String toString()
           
 AffineTransform.DoublePoint transform(AffineTransform.DoublePoint src)
           
 org.eclipse.swt.graphics.Point transform(org.eclipse.swt.graphics.Point src)
           
 org.eclipse.swt.graphics.ImageData transformImage(org.eclipse.swt.graphics.ImageData original, int method)
          Transforms an image according to this AffineTransform using the specified algorithm for transformation (only NEAREST_NEIGHBOR is currently implemented) Note that the resulting image is the smallest possible image that can contain the transformed image.
 org.eclipse.swt.graphics.Point[] transformPoints(org.eclipse.swt.graphics.Point[] points)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

matrix

protected double[][] matrix

inverse

protected AffineTransform inverse

inverseValid

protected boolean inverseValid

NEAREST_NEIGHBOR

public static int NEAREST_NEIGHBOR
Constructor Detail

AffineTransform

public AffineTransform()
Returns the AffineTransform for the identity matrix


AffineTransform

public AffineTransform(AffineTransform Tx)

AffineTransform

public AffineTransform(double m00,
                       double m10,
                       double m01,
                       double m11,
                       double m02,
                       double m12)

AffineTransform

public AffineTransform(double[][] matrix)
Method Detail

getRotateInstance

public static AffineTransform getRotateInstance(double theta)

getRotateInstance

public static AffineTransform getRotateInstance(double theta,
                                                double anchorX,
                                                double anchorY)

getScaleInstance

public static AffineTransform getScaleInstance(double sx,
                                               double sy)

getShearInstance

public static AffineTransform getShearInstance(double shx,
                                               double shy)

getTranslateInstance

public static AffineTransform getTranslateInstance(double tx,
                                                   double ty)

clone

public java.lang.Object clone()

toString

public java.lang.String toString()

concatenate

public void concatenate(AffineTransform Tx)

preConcatenate

public void preConcatenate(AffineTransform Cx)

inverseTransform

public org.eclipse.swt.graphics.Point inverseTransform(org.eclipse.swt.graphics.Point src)
                                                throws AffineTransform.NotInvertibleException
Throws:
AffineTransform.NotInvertibleException

inverseTransform

public AffineTransform.DoublePoint inverseTransform(AffineTransform.DoublePoint src)
                                             throws AffineTransform.NotInvertibleException
Throws:
AffineTransform.NotInvertibleException

transform

public org.eclipse.swt.graphics.Point transform(org.eclipse.swt.graphics.Point src)

transform

public AffineTransform.DoublePoint transform(AffineTransform.DoublePoint src)

getMatrix

public double[][] getMatrix()

getScaleX

public double getScaleX()

getScaleY

public double getScaleY()

getTranslateX

public double getTranslateX()

getTranslateY

public double getTranslateY()

getShearX

public double getShearX()

getShearY

public double getShearY()

copyMatrix

public static double[][] copyMatrix(double[][] a)

createInverse

public AffineTransform createInverse()
                              throws AffineTransform.NotInvertibleException
Throws:
AffineTransform.NotInvertibleException

multiply

public static double[][] multiply(double[][] a,
                                  double[][] b)

invert

public static double[][] invert(double[][] a)
                         throws AffineTransform.NotInvertibleException
Throws:
AffineTransform.NotInvertibleException

getBoundingRect

public org.eclipse.swt.graphics.Rectangle getBoundingRect(org.eclipse.swt.graphics.Rectangle rect)
Supposing we applied this AffineTransform to the passed in Rectangle, this returns the rectangle that would be necessary to just contain the translated one


transformPoints

public org.eclipse.swt.graphics.Point[] transformPoints(org.eclipse.swt.graphics.Point[] points)

transformImage

public org.eclipse.swt.graphics.ImageData transformImage(org.eclipse.swt.graphics.ImageData original,
                                                         int method)
                                                  throws AffineTransform.NotInvertibleException
Transforms an image according to this AffineTransform using the specified algorithm for transformation (only NEAREST_NEIGHBOR is currently implemented) Note that the resulting image is the smallest possible image that can contain the transformed image. So if there is a translation associated with this transform you will need to then draw the resulting image with the appropriate x and y offsets to complete the transform onscreen.

Parameters:
original - the image to transform
method - the interpolation technique
Returns:
a transformed version of the image interpolated
Throws:
AffineTransform.NotInvertibleException