edu.neu.ccs.gui
Class Transform1D

java.lang.Object
  extended byedu.neu.ccs.gui.Transform1D
All Implemented Interfaces:
Cloneable, Serializable

public class Transform1D
extends Object
implements Cloneable, Serializable

A 1-dimensional transform class for simple affine scaling and for working with the components of a rectilinear 2-dimensional affine transform.

The transform has the form z --> factor * z + offset.

Since:
1.0
Version:
2.2
See Also:
AffineTransform, Serialized Form

Field Summary
protected  double factor
          The scale factor for this transform.
protected  double offset
          The offset for this transform.
 
Constructor Summary
Transform1D()
          Constructs a transform object representing the identity transform.
Transform1D(double f, double o)
          Constructs a transform object with the given scale factor and offset.
Transform1D(double a1, double a2, double b1, double b2)
          Constructs a transform object mapping the interval [a1, a2] to the interval [b1, b2].
 
Method Summary
 Transform1D createInverse()
          Returns a transform representing the inverse of this transform.
 double getFactor()
          Returns the scale factor for this transform.
 double getOffset()
          Return the offset for this transform.
 boolean hasInverse()
          Returns true if an inverse transform exists for this transform, and false if an inverse transform does not exist.
 double inverseTransform(double w)
          Returns the result of applying the inverse of this transform to the given value.
 void setFactor(double f)
          Sets the scale factor for this transform to the given value.
 void setOffset(double o)
          Sets the offset for this transform to the given value.
 void setTransform(double f, double o)
          Sets the scale factor and offset for this transform to the given values.
 void setTransform(double a1, double a2, double b1, double b2)
          Sets the scale factor and offset for this transform so that it maps the interval [a1, a2] to the interval [b1, b2].
 void setTransform(Transform1D other)
          Sets the scale factor and offset for this transform to the scale factor and offset of the given transform.
 double transform(double z)
          Returns the result of applying the transform to the given value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factor

protected double factor
The scale factor for this transform.


offset

protected double offset
The offset for this transform.

Constructor Detail

Transform1D

public Transform1D()
Constructs a transform object representing the identity transform.

See Also:
Transform1D(double, double), Transform1D(double, double, double, double)

Transform1D

public Transform1D(double f,
                   double o)
Constructs a transform object with the given scale factor and offset.

Parameters:
f - the scale factor for this transform
o - the offset for this transform
See Also:
Transform1D(), Transform1D(double, double, double, double), setTransform(double, double)

Transform1D

public Transform1D(double a1,
                   double a2,
                   double b1,
                   double b2)
Constructs a transform object mapping the interval [a1, a2] to the interval [b1, b2].

Parameters:
a1 - the first endpoint of the first interval
a2 - the second endpoint of the first interval
b1 - the first endpoint of the second interval
b2 - the second endpoint of the second interval
See Also:
Transform1D(), Transform1D(double, double), setTransform(double, double, double, double)
Method Detail

setTransform

public void setTransform(double f,
                         double o)
Sets the scale factor and offset for this transform to the given values.

Parameters:
f - the new factor
o - the new offset
See Also:
Transform1D(double, double), setTransform(double, double, double, double), setTransform(Transform1D)

setTransform

public void setTransform(double a1,
                         double a2,
                         double b1,
                         double b2)
Sets the scale factor and offset for this transform so that it maps the interval [a1, a2] to the interval [b1, b2].

Parameters:
a1 - the new first endpoint of the first interval
a2 - the new second endpoint of the first interval
b1 - the new first endpoint of the second interval
b2 - the new second endpoint of the second interval
See Also:
Transform1D(double, double, double, double), setTransform(double, double), setTransform(Transform1D)

setTransform

public void setTransform(Transform1D other)
Sets the scale factor and offset for this transform to the scale factor and offset of the given transform.

See Also:
setTransform(double, double), setTransform(double, double, double, double)

setFactor

public void setFactor(double f)
Sets the scale factor for this transform to the given value.

Parameters:
f - the new factor
See Also:
setTransform(double, double), getFactor()

getFactor

public double getFactor()
Returns the scale factor for this transform.

See Also:
setFactor(double), getOffset()

setOffset

public void setOffset(double o)
Sets the offset for this transform to the given value.

Parameters:
o - the new offset
See Also:
setTransform(double, double), getOffset()

getOffset

public double getOffset()
Return the offset for this transform.

See Also:
setOffset(double), getFactor()

transform

public double transform(double z)
Returns the result of applying the transform to the given value. The operation performed is z --> factor * z + offset.

See Also:
inverseTransform(double)

hasInverse

public boolean hasInverse()
Returns true if an inverse transform exists for this transform, and false if an inverse transform does not exist.

See Also:
inverseTransform(double), createInverse()

inverseTransform

public double inverseTransform(double w)
                        throws NoninvertibleTransformException
Returns the result of applying the inverse of this transform to the given value.

Throws:
NoninvertibleTransformException - if this transform cannot be inverted
See Also:
hasInverse(), createInverse()

createInverse

public Transform1D createInverse()
                          throws NoninvertibleTransformException
Returns a transform representing the inverse of this transform.

Throws:
NoninvertibleTransformException - if this transform cannot be inverted
See Also:
hasInverse(), inverseTransform(double)