org.geotools.resources.geometry
Class XAffineTransform

java.lang.Object
  extended byjava.awt.geom.AffineTransform
      extended byorg.geotools.resources.geometry.XAffineTransform
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public abstract class XAffineTransform
extends java.awt.geom.AffineTransform

Utility methods for affine transforms. This class provides a set of public static methods working on any AffineTransform.

Class overrides all mutable methods of AffineTransform in order to check for permission before changing the transform's state. If checkPermission() is defined to always throw an exception, then is immutable.

Since:
2.0
Version:
$Id: XAffineTransform.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.awt.geom.AffineTransform
TYPE_FLIP, TYPE_GENERAL_ROTATION, TYPE_GENERAL_SCALE, TYPE_GENERAL_TRANSFORM, TYPE_IDENTITY, TYPE_MASK_ROTATION, TYPE_MASK_SCALE, TYPE_QUADRANT_ROTATION, TYPE_TRANSLATION, TYPE_UNIFORM_SCALE
 
Constructor Summary
protected XAffineTransform(java.awt.geom.AffineTransform tr)
          Constructs a new that is a copy of the specified object.
 
Method Summary
protected abstract  void checkPermission()
          Check if the caller is allowed to change this 's state.
 void concatenate(java.awt.geom.AffineTransform Tx)
          Check for permission before concatenating this transform.
static double getScale(java.awt.geom.AffineTransform zoom)
          Returns a global scale factor for the specified affine transform.
static java.awt.geom.AffineTransform getScaleInstance(double sx, double sy, double x, double y)
          Returns an affine transform representing a zoom carried out around a central point (x,y).
static double getScaleX0(java.awt.geom.AffineTransform zoom)
          Returns the scale factor x by cancelling the effect of an eventual rotation.
static double getScaleY0(java.awt.geom.AffineTransform zoom)
          Returns the scale factor y by cancelling the effect of an eventual rotation.
static java.awt.geom.Point2D inverseDeltaTransform(java.awt.geom.AffineTransform transform, java.awt.geom.Point2D source, java.awt.geom.Point2D dest)
          Calculates the inverse affine transform of a point without bearing in mind the translation.
static java.awt.geom.Rectangle2D inverseTransform(java.awt.geom.AffineTransform transform, java.awt.geom.Rectangle2D bounds, java.awt.geom.Rectangle2D dest)
          Returns a rectangle which entirely contains the inverse transform of .
 void preConcatenate(java.awt.geom.AffineTransform Tx)
          Check for permission before concatenating this transform.
 void rotate(double theta)
          Check for permission before rotating this transform.
 void rotate(double theta, double x, double y)
          Check for permission before rotating this transform.
static void round(java.awt.geom.AffineTransform zoom)
           
 void scale(double sx, double sy)
          Check for permission before scaling this transform.
 void setToIdentity()
          Check for permission before setting this transform.
 void setToRotation(double theta)
          Check for permission before setting this transform.
 void setToRotation(double theta, double x, double y)
          Check for permission before setting this transform.
 void setToScale(double sx, double sy)
          Check for permission before setting this transform.
 void setToShear(double shx, double shy)
          Check for permission before setting this transform.
 void setToTranslation(double tx, double ty)
          Check for permission before setting this transform.
 void setTransform(java.awt.geom.AffineTransform Tx)
          Check for permission before setting this transform.
 void setTransform(double m00, double m10, double m01, double m11, double m02, double m12)
          Check for permission before setting this transform.
 void shear(double shx, double shy)
          Check for permission before shearing this transform.
static java.awt.geom.Rectangle2D transform(java.awt.geom.AffineTransform transform, java.awt.geom.Rectangle2D bounds, java.awt.geom.Rectangle2D dest)
          Returns a rectangle which entirely contains the direct transform of .
 void translate(double tx, double ty)
          Check for permission before translating this transform.
 
Methods inherited from class java.awt.geom.AffineTransform
clone, createInverse, createTransformedShape, deltaTransform, deltaTransform, equals, getDeterminant, getMatrix, getRotateInstance, getRotateInstance, getScaleInstance, getScaleX, getScaleY, getShearInstance, getShearX, getShearY, getTranslateInstance, getTranslateX, getTranslateY, getType, hashCode, inverseTransform, inverseTransform, isIdentity, toString, transform, transform, transform, transform, transform, transform
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XAffineTransform

protected XAffineTransform(java.awt.geom.AffineTransform tr)
Constructs a new that is a copy of the specified object.

Method Detail

checkPermission

protected abstract void checkPermission()
Check if the caller is allowed to change this 's state.


translate

public void translate(double tx,
                      double ty)
Check for permission before translating this transform.


rotate

public void rotate(double theta)
Check for permission before rotating this transform.


rotate

public void rotate(double theta,
                   double x,
                   double y)
Check for permission before rotating this transform.


scale

public void scale(double sx,
                  double sy)
Check for permission before scaling this transform.


shear

public void shear(double shx,
                  double shy)
Check for permission before shearing this transform.


setToIdentity

public void setToIdentity()
Check for permission before setting this transform.


setToTranslation

public void setToTranslation(double tx,
                             double ty)
Check for permission before setting this transform.


setToRotation

public void setToRotation(double theta)
Check for permission before setting this transform.


setToRotation

public void setToRotation(double theta,
                          double x,
                          double y)
Check for permission before setting this transform.


setToScale

public void setToScale(double sx,
                       double sy)
Check for permission before setting this transform.


setToShear

public void setToShear(double shx,
                       double shy)
Check for permission before setting this transform.


setTransform

public void setTransform(java.awt.geom.AffineTransform Tx)
Check for permission before setting this transform.


setTransform

public void setTransform(double m00,
                         double m10,
                         double m01,
                         double m11,
                         double m02,
                         double m12)
Check for permission before setting this transform.


concatenate

public void concatenate(java.awt.geom.AffineTransform Tx)
Check for permission before concatenating this transform.


preConcatenate

public void preConcatenate(java.awt.geom.AffineTransform Tx)
Check for permission before concatenating this transform.


transform

public static java.awt.geom.Rectangle2D transform(java.awt.geom.AffineTransform transform,
                                                  java.awt.geom.Rectangle2D bounds,
                                                  java.awt.geom.Rectangle2D dest)
Returns a rectangle which entirely contains the direct transform of . This operation is equivalent to .

Parameters:
transform - Affine transform to use.
bounds - Rectangle to transform. This rectangle will not be modified.
dest - Rectangle in which to place the result. If null, a new rectangle will be created.
Returns:
The direct transform of the rectangle.

inverseTransform

public static java.awt.geom.Rectangle2D inverseTransform(java.awt.geom.AffineTransform transform,
                                                         java.awt.geom.Rectangle2D bounds,
                                                         java.awt.geom.Rectangle2D dest)
                                                  throws java.awt.geom.NoninvertibleTransformException
Returns a rectangle which entirely contains the inverse transform of . This operation is equivalent to .

Parameters:
transform - Affine transform to use.
bounds - Rectangle to transform. This rectangle will not be modified.
dest - Rectangle in which to place the result. If null, a new rectangle will be created.
Returns:
The inverse transform of the rectangle.
Throws:
java.awt.geom.NoninvertibleTransformException - if the affine transform can't be inverted.

inverseDeltaTransform

public static java.awt.geom.Point2D inverseDeltaTransform(java.awt.geom.AffineTransform transform,
                                                          java.awt.geom.Point2D source,
                                                          java.awt.geom.Point2D dest)
                                                   throws java.awt.geom.NoninvertibleTransformException
Calculates the inverse affine transform of a point without bearing in mind the translation.

Parameters:
transform - Affine transform to use.
source - Point to transform. This rectangle will not be modified.
dest - Point in which to place the result. If null, a new point will be created.
Returns:
The inverse transform of the point.
Throws:
java.awt.geom.NoninvertibleTransformException - if the affine transform can't be inverted.

getScaleX0

public static double getScaleX0(java.awt.geom.AffineTransform zoom)
Returns the scale factor x by cancelling the effect of an eventual rotation. This factor is calculated by .


getScaleY0

public static double getScaleY0(java.awt.geom.AffineTransform zoom)
Returns the scale factor y by cancelling the effect of an eventual rotation. This factor is calculated by .


getScale

public static double getScale(java.awt.geom.AffineTransform zoom)
Returns a global scale factor for the specified affine transform. This scale factor will combines getScaleX0(java.awt.geom.AffineTransform) and getScaleY0(java.awt.geom.AffineTransform). The way to compute such a "global" scale is somewhat arbitrary and may change in a future version.


getScaleInstance

public static java.awt.geom.AffineTransform getScaleInstance(double sx,
                                                             double sy,
                                                             double x,
                                                             double y)
Returns an affine transform representing a zoom carried out around a central point (x,y). The transforms will leave the specified (x,y) coordinate unchanged.

Parameters:
sx - Scale along x axis.
sy - Scale along y axis.
x - x coordinates of the central point.
y - y coordinates of the central point.
Returns:
Affine transform of a zoom which leaves the (x,y) coordinate unchanged.

round

public static void round(java.awt.geom.AffineTransform zoom)


Copyright © GeoTools. All Rights Reserved.