public final class IlvTransformer extends Object implements Cloneable, Serializable
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 ]
| Constructor and Description |
|---|
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. |
| Modifier and Type | Method and Description |
|---|---|
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.
|
public IlvTransformer()
IlvTransformer representing
the identity transformation.public IlvTransformer(IlvTransformer orig)
IlvTransformer by copying the specified transformer.
If the specified transformer is null the resulting
transformer is an identity transformer.orig - The original transformer.public IlvTransformer(double x11,
double x12,
double x21,
double x22,
double x0,
double y0)
IlvTransformer from the
6 double precision values representing the 6 entries
of the transformation matrix.public IlvTransformer(AffineTransform aft)
public IlvTransformer(IlvPoint center, double angle)
IlvTransformer
that corresponds to a rotation
around a point.center - The center point of the rotation.angle - The rotation angle in degrees.public IlvTransformer(double sx,
double sy,
IlvPoint point)
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.public IlvTransformer(IlvPoint delta)
IlvTransformer that corresponds to a translation.delta - The translation parameter.public final void setValues(double x0,
double y0)
x0 and y0) of the
transformation.public void setValues(double x11,
double x12,
double x21,
double x22)
x11, x12, x21,
x22 values of the transformation matrix.public void setValues(double x11,
double x12,
double x21,
double x22,
double x0,
double y0)
public void setAffineTransform(AffineTransform aft)
public AffineTransform getAffineTransform(AffineTransform aft)
null, a new affine transform
is created and returned. Otherwise the input transform is returned.public double getx0()
x0 value.public double gety0()
y0 value.public double getx11()
x11 value.public double getx12()
x12 value.public double getx21()
x21 value.public double getx22()
x22 value.public boolean isIdentity()
true
if the transformer is the identity transformer, false
otherwise.true if x11 and x22 are
1, x12 and x21 are 0,
and x0 and y0 are 0,
false otherwise.public boolean isTranslation()
true if the transformer
is a translation, false otherwise.true if x11 and x22 are
1, x12 and x21 are 0,
false otherwise.public boolean isScale()
true if the transformer
is a scaling transformer, false otherwise.true if x12 and x21 are
0, false otherwise.public boolean isBad()
true if the transformer is not reversible.
In this case you cannot call the inverse method.getDeterminant()public double getDeterminant()
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 |
isBad(),
computeInverse(ilog.views.IlvTransformer),
inverse(ilog.views.IlvPoint),
inverse(ilog.views.IlvRect)public void apply(IlvPoint point)
point - The point to transform.applyFloor(ilog.views.IlvPoint)public void applyFloor(IlvPoint point)
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 double 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.point - The point to transform.applyFloor(ilog.views.IlvRect),
IlvRect.floor()public void apply(IlvRect rect)
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).
rect - The rectangle to transform.applyFloor(ilog.views.IlvRect),
boundingBox(IlvRect, boolean)public void boundingBox(IlvRect rect, boolean inverse)
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.apply(ilog.views.IlvRect)public void applyFloor(IlvRect rect)
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 double 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.rect - The rectangle to transform.applyFloor(ilog.views.IlvPoint),
IlvRect.floor()public void deltaApply(IlvPoint point)
public boolean inverse(IlvPoint p)
p - The point to invert.true if the transformation
can be inverted, false otherwise.isBad(),
getDeterminant()public boolean inverse(IlvRect rect)
rect - The rectangle to invert.isBad(),
getDeterminant()public void compose(IlvTransformer t)
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.public void postCompose(IlvTransformer t)
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.public boolean computeInverse(IlvTransformer t)
t parameter.t - The result of the inversion.public void translate(double dx,
double dy)
public void scale(double cx,
double cy,
double sx,
double sy)
sx
by sy leaving the point (cx, cy) fixed.public void rotate(double cx,
double cy,
double angle)
angle
degrees around the center point (cx, cy).public static IlvTransformer computeTransformer(IlvRect rect, IlvRect trect, IlvTransformer t)
rect
into the rectangle trect.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.IlvTransformer containing the transformer used to
transform rect into trect.public double zoomFactor()
public double zoomXFactor()
public double zoomYFactor()
public boolean equals(Object transformer)
public int hashCode()
© Copyright Rogue Wave Software, Inc. 1997, 2017. All Rights Reserved.