KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > awt > geom > AffineTransform

java.awt.geom
Class AffineTransform

java.lang.Object
  extended by java.awt.geom.AffineTransform
All Implemented Interfaces:
Serializable, Cloneable
See Also:
Top Examples, Source Code

public AffineTransform()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1476]Transform coordinates of a Graphics2D
By Andy on 2005/07/10 07:42:56  Rate
Instances of the class java.awt.geom.AffineTransform represent the transformation from one coordinate system to another. AffineTransform was used to save and restore the transform state of a Graphics2D. AffineTransform can also be useful when you need to compute and store transformed coordinates before you draw. 
  
  
 public class AffineTest extends JComponent  {  
   
  public void paintComponent ( Graphics g )   {  
     
   Graphics2D g2D =  ( Graphics2D )  g; 
  
  
                 AffineTransform origTransform = g2D.getTransform (  ) ; //save original transform  
   g2D.translate ( getWidth (  )  / 2, getHeight (  )  / 2 ) ; //transform the original coordinate 
                                                                 //from  ( 0,0 )  to  ( getWidth (  ) /2,getHeight (  ) /2 )  
    
   g2D.rotate  (  30.0 * Math.PI / 180.0  ) ; 
   g2D.setFont ( new Font ( "Sans", Font.BOLD, 24 )  ) ; 
          g2D.drawString ( "M",  ( float ) 0.0,  ( float ) 0.0 ) ; //draw a M, to  ( getWidth (  ) /2,getHeight (  ) /2 )  
     
          g2D.setTransform  (  origTransform  ) ; //restore to original coordinate 
      
          g2D.setFont ( new Font ( "Sans", Font.BOLD, 24 )  ) ; 
          g2D.drawString ( "M",  ( float ) 10.0,  ( float ) 30.0 ) ; //draw a M, to  ( 0,0 )  
        
   }  
  } 


public AffineTransform(double m00,
                       double m10,
                       double m01,
                       double m11,
                       double m02,
                       double m12)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public AffineTransform(double[] flatmatrix)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public AffineTransform(float m00,
                       float m10,
                       float m01,
                       float m11,
                       float m02,
                       float m12)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public AffineTransform(float[] flatmatrix)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public AffineTransform(AffineTransform Tx)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Object clone()
See Also:
Cloneable
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void concatenate(AffineTransform Tx)
See Also:
preConcatenate(java.awt.geom.AffineTransform)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public AffineTransform createInverse()
                              throws NoninvertibleTransformException
See Also:
getDeterminant()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Shape createTransformedShape(Shape pSrc)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void deltaTransform(double[] srcPts,
                           int srcOff,
                           double[] dstPts,
                           int dstOff,
                           int numPts)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Point2D deltaTransform(Point2D ptSrc,
                              Point2D ptDst)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean equals(Object obj)
See Also:
Hashtable, Object.hashCode()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public double getDeterminant()
See Also:
TYPE_UNIFORM_SCALE, inverseTransform(java.awt.geom.Point2D, java.awt.geom.Point2D), createInverse(), getType(), NoninvertibleTransformException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void getMatrix(double[] flatmatrix)
See Also:
getTranslateY(), getTranslateX(), getShearY(), getShearX(), getScaleY(), getScaleX()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static AffineTransform getRotateInstance(double theta)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[490]Roate image 90 degrees in either direction
By Scott Plante on 2003/11/04 15:26:30  Rate
/* Here's a little test class that will take a file orig.jpg  
 * and create a left.jpg and right.jpg that contain the image  
 * rotated 90 degrees in either direction. I used the code to  
 * allow photos in a web slide show to be rotated after they were 
 * uploaded and thought it took longer than it should have to figure 
 * out how to make it work. 
 */
 
  
  
  
 import java.awt.*; 
 import java.awt.geom.*; 
 import java.awt.image.*; 
 import java.io.*; 
  
  
 import javax.imageio.*; 
 import javax.swing.*; 
  
  
 public class X 
  {  
   public static void main ( String args [  ]  )  
       throws Exception 
    {  
     File f = new File ( "orig.jpg" ) ; 
  
  
     BufferedImage bi = ImageIO.read ( f ) ; 
  
  
     BufferedImage left = rotateLeft ( bi ) ; 
  
  
     ImageIO.write ( left, "jpg", new File ( "left.jpg" )  ) ; 
  
  
     BufferedImage right = rotateRight ( bi ) ; 
  
  
     ImageIO.write ( right, "jpg", new File ( "right.jpg" )  ) ; 
  
  
    }  
  
  
   public static BufferedImage rotateLeft ( BufferedImage bi )  
    {  
     AffineTransform afLeft = AffineTransform.getRotateInstance (  
         Math.toRadians ( 270 )  ) ; 
     afLeft.translate ( bi.getWidth (  )  * -1,0 ) ; 
     AffineTransformOp lOp = new AffineTransformOp ( afLeft,null ) ; 
  
  
     BufferedImage dstbi = lOp.filter ( bi, null ) ; 
  
  
     return dstbi; 
    }  
  
  
   public static BufferedImage rotateRight ( BufferedImage bi )  
    {  
     AffineTransform afRight = AffineTransform.getRotateInstance (  
         Math.toRadians ( 90 )  ) ; 
     afRight.translate ( 0,bi.getHeight (  )  * -1 ) ; 
     AffineTransformOp rOp = new AffineTransformOp ( afRight,null ) ; 
  
  
     BufferedImage dstbi = rOp.filter ( bi, null ) ; 
  
  
     return dstbi; 
    }  
  
  
  
  }  
 


public static AffineTransform getRotateInstance(double theta,
                                                double x,
                                                double y)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static AffineTransform getScaleInstance(double sx,
                                               double sy)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public double getScaleX()
See Also:
getMatrix(double[])
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public double getScaleY()
See Also:
getMatrix(double[])
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static AffineTransform getShearInstance(double shx,
                                               double shy)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public double getShearX()
See Also:
getMatrix(double[])
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public double getShearY()
See Also:
getMatrix(double[])
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static AffineTransform getTranslateInstance(double tx,
                                                   double ty)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public double getTranslateX()
See Also:
getMatrix(double[])
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public double getTranslateY()
See Also:
getMatrix(double[])
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getType()
See Also:
TYPE_GENERAL_TRANSFORM, TYPE_GENERAL_ROTATION, TYPE_QUADRANT_ROTATION, TYPE_GENERAL_SCALE, TYPE_UNIFORM_SCALE, TYPE_TRANSLATION, TYPE_IDENTITY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int hashCode()
See Also:
Hashtable, Object.equals(java.lang.Object)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void inverseTransform(double[] srcPts,
                             int srcOff,
                             double[] dstPts,
                             int dstOff,
                             int numPts)
                      throws NoninvertibleTransformException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Point2D inverseTransform(Point2D ptSrc,
                                Point2D ptDst)
                         throws NoninvertibleTransformException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isIdentity()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void preConcatenate(AffineTransform Tx)
See Also:
concatenate(java.awt.geom.AffineTransform)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void rotate(double theta)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void rotate(double theta,
                   double x,
                   double y)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void scale(double sx,
                  double sy)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setToIdentity()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setToRotation(double theta)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setToRotation(double theta,
                          double x,
                          double y)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setToScale(double sx,
                       double sy)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setToShear(double shx,
                       double shy)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setToTranslation(double tx,
                             double ty)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setTransform(double m00,
                         double m10,
                         double m01,
                         double m11,
                         double m02,
                         double m12)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setTransform(AffineTransform Tx)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void shear(double shx,
                  double shy)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String toString()
See Also:
Object
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void transform(double[] srcPts,
                      int srcOff,
                      double[] dstPts,
                      int dstOff,
                      int numPts)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void transform(double[] srcPts,
                      int srcOff,
                      float[] dstPts,
                      int dstOff,
                      int numPts)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void transform(float[] srcPts,
                      int srcOff,
                      double[] dstPts,
                      int dstOff,
                      int numPts)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void transform(float[] srcPts,
                      int srcOff,
                      float[] dstPts,
                      int dstOff,
                      int numPts)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Point2D transform(Point2D ptSrc,
                         Point2D ptDst)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void transform(Point2D[] ptSrc,
                      int srcOff,
                      Point2D[] ptDst,
                      int dstOff,
                      int numPts)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void translate(double tx,
                      double ty)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int TYPE_FLIP
See Also:
getType(), TYPE_GENERAL_TRANSFORM, TYPE_GENERAL_ROTATION, TYPE_QUADRANT_ROTATION, TYPE_GENERAL_SCALE, TYPE_UNIFORM_SCALE, TYPE_TRANSLATION, TYPE_IDENTITY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int TYPE_GENERAL_ROTATION
See Also:
getType(), TYPE_GENERAL_TRANSFORM, TYPE_QUADRANT_ROTATION, TYPE_FLIP, TYPE_GENERAL_SCALE, TYPE_UNIFORM_SCALE, TYPE_TRANSLATION, TYPE_IDENTITY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int TYPE_GENERAL_SCALE
See Also:
getType(), TYPE_GENERAL_TRANSFORM, TYPE_GENERAL_ROTATION, TYPE_QUADRANT_ROTATION, TYPE_FLIP, TYPE_UNIFORM_SCALE, TYPE_TRANSLATION, TYPE_IDENTITY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int TYPE_GENERAL_TRANSFORM
See Also:
getType(), TYPE_GENERAL_ROTATION, TYPE_QUADRANT_ROTATION, TYPE_FLIP, TYPE_GENERAL_SCALE, TYPE_UNIFORM_SCALE, TYPE_TRANSLATION, TYPE_IDENTITY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int TYPE_IDENTITY
See Also:
getType(), TYPE_GENERAL_TRANSFORM, TYPE_GENERAL_ROTATION, TYPE_QUADRANT_ROTATION, TYPE_FLIP, TYPE_GENERAL_SCALE, TYPE_UNIFORM_SCALE, TYPE_TRANSLATION
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int TYPE_MASK_ROTATION
See Also:
TYPE_GENERAL_ROTATION, TYPE_QUADRANT_ROTATION
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int TYPE_MASK_SCALE
See Also:
TYPE_GENERAL_SCALE, TYPE_UNIFORM_SCALE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int TYPE_QUADRANT_ROTATION
See Also:
getType(), TYPE_GENERAL_TRANSFORM, TYPE_GENERAL_ROTATION, TYPE_FLIP, TYPE_GENERAL_SCALE, TYPE_UNIFORM_SCALE, TYPE_TRANSLATION, TYPE_IDENTITY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int TYPE_TRANSLATION
See Also:
getType(), TYPE_GENERAL_TRANSFORM, TYPE_GENERAL_ROTATION, TYPE_QUADRANT_ROTATION, TYPE_FLIP, TYPE_GENERAL_SCALE, TYPE_UNIFORM_SCALE, TYPE_IDENTITY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int TYPE_UNIFORM_SCALE
See Also:
getType(), TYPE_GENERAL_TRANSFORM, TYPE_GENERAL_ROTATION, TYPE_QUADRANT_ROTATION, TYPE_FLIP, TYPE_GENERAL_SCALE, TYPE_TRANSLATION, TYPE_IDENTITY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1947]sdddddddddddddddddddddddddddddddddddddd
By dsffffffffffffffffffffffffsssssssssssssssssddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd on 2007/12/10 03:10:55  Rate
dsssssssss
Popular Tags