ilog.views
Class IlvTransformer

java.lang.Object
  extended by ilog.views.IlvTransformer
All Implemented Interfaces:
Serializable, Cloneable

public final class IlvTransformer
extends Object
implements Cloneable, Serializable

The IlvTransformer class is a two dimensional affine transform that performs a linear mapping from 2D coordinates to other 2D coordinates.

Such a coordinate transformation can be represented by a 3-row by 3-column matrix with an implied last row of [ 0 0 1 ]. 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']   [ x11 x12 x0 ] [ x ]   [ x11*x + x12*y + x0 ]
   [ y'] = [ x21 x22 y0 ] [ y ] = [ x21*x + x22*y + y0 ]
   [ 1 ]   [  0   0   1 ] [ 1 ]   [         1          ]

See Also:
Serialized Form

Constructor Summary
IlvTransformer()
          Creates a new IlvTransformer representing the identity transformation.
IlvTransformer(AffineTransform aft)
          Creates a transformer that corresponds to the input affine transform.
IlvTransformer(double x11, double x12, double x21, double x22, double x0, double y0)
          Creates a new IlvTransformer from the 6 double precision values representing the 6 entries of the transformation matrix.
IlvTransformer(double sx, double sy, IlvPoint point)
          Creates a new IlvTransformer that corresponds to a scaling operation, meaning a transformation that applies itself without changing the definition axis of the operands.
IlvTransformer(IlvPoint delta)
          Creates a new IlvTransformer that corresponds to a translation.
IlvTransformer(IlvPoint center, double angle)
          Creates a new IlvTransformer that corresponds to a rotation around a point.
IlvTransformer(IlvTransformer orig)
          Creates a new IlvTransformer by copying the specified transformer.
 
Method Summary
 void apply(IlvPoint point)
          Applies the transformer to a point.
 void apply(IlvRect rect)
          Applies the transformer to the specified rectangle.
 void applyFloor(IlvPoint point)
          Applies the transformer to a point.
 void applyFloor(IlvRect rect)
          Applies the transformer to a rectangle.
 void boundingBox(IlvRect rect, boolean inverse)
          Computes the bounding box of the transformed edges of the rectangle.
 Object clone()
          Copies the transformer.
 void compose(IlvTransformer t)
          Computes the composition of two transformers.
 boolean computeInverse(IlvTransformer t)
          Computes the inverse transformer of this transformation and stores the result in the t parameter.
static IlvTransformer computeTransformer(IlvRect rect, IlvRect trect, IlvTransformer t)
          Computes the transformer that will transform the rectangle rect into the rectangle trect.
 void deltaApply(IlvPoint point)
          Applies the transformer to the specified point, but without the translation parameters.
 boolean equals(Object transformer)
          Tests the equality of two transformers.
 AffineTransform getAffineTransform(AffineTransform aft)
          Copies this transformation into the input affine transform.
 double getDeterminant()
          Returns the determinant of the matrix.
 double getx0()
          Returns the x0 value.
 double getx11()
          Returns the x11 value.
 double getx12()
          Returns the x12 value.
 double getx21()
          Returns the x21 value.
 double getx22()
          Returns the x22 value.
 double gety0()
          Returns the y0 value.
 int hashCode()
          Returns a hash code for this transformer.
 boolean inverse(IlvPoint p)
          Applies the inverse transformation on the specified point.
 boolean inverse(IlvRect rect)
          Applies the inverse transformation on the specified rectangle.
 boolean isBad()
          Returns true if the transformer is not reversible.
 boolean isIdentity()
          Returns true if the transformer is the Identity transformer, false otherwise.
 boolean isScale()
          Returns true if the transformer is a scaling transformer, false otherwise.
 boolean isTranslation()
          Returns true if the transformer is a translation, false otherwise.
 void postCompose(IlvTransformer t)
          Computes the composition of two transformers.
 void rotate(double cx, double cy, double angle)
          Composes the transformer with a rotation operation of angle degrees around the center point (cx, cy).
 void scale(double cx, double cy, double sx, double sy)
          Composes the transformer with a scaling operation of sx by sy leaving the point (cx, cy) fixed.
 void setAffineTransform(AffineTransform aft)
          Creates a transformation that corresponds to the input affine transform.
 void setValues(double x0, double y0)
          Changes the translation values (x0 and y0) of the transformation.
 void setValues(double x11, double x12, double x21, double x22)
          Changes the x11, x12, x21, x22 values of the transformation matrix.
 void setValues(double x11, double x12, double x21, double x22, double x0, double y0)
          Set this transformation to the matrix specified by the 6 values.
 String toString()
          Returns the transformer as a String.
 void translate(double dx, double dy)
          Composes the transformer with a (dx, dy) translation.
 double zoomFactor()
          Returns the zoom factor of the transformer.
 double zoomXFactor()
          Returns the zoom factor of the transformer in the x direction.
 double zoomYFactor()
          Returns the zoom factor of the transformer in the y direction.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlvTransformer

public IlvTransformer()
Creates a new IlvTransformer representing the identity transformation.


IlvTransformer

public IlvTransformer(IlvTransformer orig)
Creates a new IlvTransformer by copying the specified transformer. If the specified transformer is null the resulting transformer is an identity transformer.

Parameters:
orig - The original transformer.

IlvTransformer

public IlvTransformer(double x11,
                      double x12,
                      double x21,
                      double x22,
                      double x0,
                      double y0)
Creates a new IlvTransformer from the 6 double precision values representing the 6 entries of the transformation matrix.


IlvTransformer

public IlvTransformer(AffineTransform aft)
Creates a transformer that corresponds to the input affine transform.

Since:
JViews 8.0

IlvTransformer

public IlvTransformer(IlvPoint center,
                      double angle)
Creates a new IlvTransformer that corresponds to a rotation around a point.

Parameters:
center - The center point of the rotation.
angle - The rotation angle in degrees.

IlvTransformer

public IlvTransformer(double sx,
                      double sy,
                      IlvPoint point)
Creates a new IlvTransformer that corresponds to a scaling operation, meaning a transformation that applies itself without changing the definition axis of the operands. The scaling is specified by the sx and sy parameters. The point parameter is the point that will remain unchanged after the scaling.


IlvTransformer

public IlvTransformer(IlvPoint delta)
Creates a new IlvTransformer that corresponds to a translation.

Parameters:
delta - The translation parameter.
Method Detail

setValues

public final void setValues(double x0,
                            double y0)
Changes the translation values (x0 and y0) of the transformation.


setValues

public void setValues(double x11,
                      double x12,
                      double x21,
                      double x22)
Changes the x11, x12, x21, x22 values of the transformation matrix.


setValues

public void setValues(double x11,
                      double x12,
                      double x21,
                      double x22,
                      double x0,
                      double y0)
Set this transformation to the matrix specified by the 6 values.


setAffineTransform

public void setAffineTransform(AffineTransform aft)
Creates a transformation that corresponds to the input affine transform.

Since:
JViews 8.0

getAffineTransform

public AffineTransform getAffineTransform(AffineTransform aft)
Copies this transformation into the input affine transform. If the input affine transform is null, a new affine transform is created and returned. Otherwise the input transform is returned.

Since:
JViews 8.0

getx0

public double getx0()
Returns the x0 value.


gety0

public double gety0()
Returns the y0 value.


getx11

public double getx11()
Returns the x11 value.


getx12

public double getx12()
Returns the x12 value.


getx21

public double getx21()
Returns the x21 value.


getx22

public double getx22()
Returns the x22 value.


isIdentity

public boolean isIdentity()
Returns true if the transformer is the Identity transformer, false otherwise.


isTranslation

public boolean isTranslation()
Returns true if the transformer is a translation, false otherwise.


isScale

public boolean isScale()
Returns true if the transformer is a scaling transformer, false otherwise.


isBad

public boolean isBad()
Returns true if the transformer is not reversible. In this case you cannot call the inverse method.

See Also:
getDeterminant()

getDeterminant

public double getDeterminant()
Returns the determinant of the matrix. The determinant is useful to determine whether the transform can be inverted.

If the determinant is non-zero, then this transform is invertible. Mathematically, the determinant is calculated using the formula:

     |  x11  x12  x0  |
     |  x21  x22  y0  |  =  x11 * x22 - x21 * x12
     |   0    0    1  |
  
 

Returns:
the determinant of the matrix used to transform the coordinates.
See Also:
isBad(), computeInverse(ilog.views.IlvTransformer), inverse(ilog.views.IlvPoint), inverse(ilog.views.IlvRect)

apply

public void apply(IlvPoint point)
Applies the transformer to a point.

Parameters:
point - The point to transform.
See Also:
applyFloor(ilog.views.IlvPoint)

applyFloor

public void applyFloor(IlvPoint point)
Applies the transformer to a point. This method applies the transformer to the point, then the point values are transformed to mathematical integers using the Math.floor method. This method is useful when you need to apply a transformer in order to draw on a view. When drawing an object (using the IlvGraphic.draw method) you need to transform float values that define your object into integer values. In this case, once you have called applyFloor on the point, you can directly cast the values of the resulting point (x,y) into integer values to perform the drawings. Note that calling applyFloor is the same as calling apply and floor on the resulting point.

Parameters:
point - The point to transform.
See Also:
applyFloor(ilog.views.IlvRect), IlvRect.floor()

apply

public void apply(IlvRect rect)
Applies the transformer to the specified rectangle.

Note: This applies the transformer to the top-left and bottom-right corners of a rectangle, and returns a rectangle containing the resulting two points. To get a rectangle that contains all four transformed corners, use this.boundingBox(rect, false).

Parameters:
rect - The rectangle to transform.
See Also:
applyFloor(ilog.views.IlvRect), boundingBox(IlvRect, boolean)

boundingBox

public void boundingBox(IlvRect rect,
                        boolean inverse)
Computes the bounding box of the transformed edges of the rectangle.

Parameters:
rect - The rectangle to transform.
inverse - If set to true, the inverted transformer is applied to the edges, otherwise, the transformer itself is applied to the edges.
See Also:
apply(ilog.views.IlvRect)

applyFloor

public void applyFloor(IlvRect rect)
Applies the transformer to a rectangle. This method applies the transformer to the rectangle, then the rectangle values are transformed to mathematical integers using the Math.floor method. This method is useful when you need to apply a transformer in order to draw on a view. When drawing an object (using the IlvGraphic.draw method) you need to transform float values that define your object into integer values. In this case, once you have called applyFloor on the rectangle, you can directly cast the values of the rectangle (x,y,width,height) into integer values to perform the drawings. Note that calling applyFloor is different than calling apply and floor on the resulting rectangle.

Parameters:
rect - The rectangle to transform.
See Also:
applyFloor(ilog.views.IlvPoint), IlvRect.floor()

deltaApply

public void deltaApply(IlvPoint point)
Applies the transformer to the specified point, but without the translation parameters.


inverse

public boolean inverse(IlvPoint p)
Applies the inverse transformation on the specified point.

Parameters:
p - The point to invert.
Returns:
true if the transformation can be inverted, false otherwise.
See Also:
isBad(), getDeterminant()

inverse

public boolean inverse(IlvRect rect)
Applies the inverse transformation on the specified rectangle.

Parameters:
rect - The rectangle to invert.
Returns:
true if the transformation can be inverted, false otherwise.
See Also:
isBad(), getDeterminant()

compose

public void compose(IlvTransformer t)
Computes the composition of two transformers. This method computes the transformation that corresponds to the composition of this transformer and the transformer t and stores the result in this transformer.

In matrix notation, the operation is:

  [this] = [t] o [this]
Note that this operation corresponds mathematically to AffineTransform.preConcatenate(AffineTransform), that is,
 t1.compose(t2);
 
and
 AffineTransform at1 = t1.getAffineTransform(null);
 AffineTransform at2 = t2.getAffineTransform(null);
 at1.preConcatenate(at2);
 t1.setAffineTransform(at1);
 
set t1 to the same value.


postCompose

public void postCompose(IlvTransformer t)
Computes the composition of two transformers. This method computes the transformation that corresponds to the composition of this transformer and the transformer t and stores the result in this transformer.

In matrix notation, the operation is:

  [this] = [this] o [t]
Note that this operation corresponds mathematically to AffineTransform.concatenate(AffineTransform), that is,
 t1.postCompose(t2);
 
and
 AffineTransform at1 = t1.getAffineTransform(null);
 AffineTransform at2 = t2.getAffineTransform(null);
 at1.concatenate(at2);
 t1.setAffineTransform(at1);
 
set t1 to the same value.

Since:
JViews 5.0

computeInverse

public boolean computeInverse(IlvTransformer t)
Computes the inverse transformer of this transformation and stores the result in the t parameter.

Parameters:
t - The result of the inversion.
Returns:
true if the inversion is possible, false otherwise.

translate

public void translate(double dx,
                      double dy)
Composes the transformer with a (dx, dy) translation.


scale

public void scale(double cx,
                  double cy,
                  double sx,
                  double sy)
Composes the transformer with a scaling operation of sx by sy leaving the point (cx, cy) fixed.


rotate

public void rotate(double cx,
                   double cy,
                   double angle)
Composes the transformer with a rotation operation of angle degrees around the center point (cx, cy).


computeTransformer

public static IlvTransformer computeTransformer(IlvRect rect,
                                                IlvRect trect,
                                                IlvTransformer t)
Computes the transformer that will transform the rectangle rect into the rectangle trect.

Parameters:
rect - The IlvRect object before the transformation.
trect - the IlvRect object after the transformation.
t - Set this to null for a new IlvTransformer to be created containing the transformation. An IlvTransformer If set to non-null, this parameter will be changed to hold the transformation.
Returns:
An IlvTransformer containing the transformer used to transform rect into trect.

zoomFactor

public double zoomFactor()
Returns the zoom factor of the transformer. If the zoom factor is not the same along the x and y axis, it returns the minimum.


zoomXFactor

public double zoomXFactor()
Returns the zoom factor of the transformer in the x direction.

Since:
JViews 5.5

zoomYFactor

public double zoomYFactor()
Returns the zoom factor of the transformer in the y direction.

Since:
JViews 5.5

clone

public Object clone()
Copies the transformer.

Overrides:
clone in class Object

equals

public boolean equals(Object transformer)
Tests the equality of two transformers.

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns a hash code for this transformer.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.

toString

public String toString()
Returns the transformer as a String.

Overrides:
toString in class Object


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.